Entries Tagged as ''

关于linux下文件/proc/kcore

这俩天在机器上搜大于2G的文件

find / -size +2000000k

居然给搜出了一个“大”文件:/proc/kcore

赶紧找文档看

我的理解大致就是:

这个文件/proc/kcore的大小就是机器的物理内存

他是系统内存的一个map

他并不真正占物理内存那么大的硬盘空间

等等

unixguide.org上讲:

 

What Is /proc/kcore?
None of the files in /proc are really there–they’re all, "pretend,"
files made up by the kernel, to give you information about the system
and don’t take up any hard disk space.

/proc/kcore is like an "alias" for the memory in your computer. Its
size is the same as the amount of RAM you have, and if you read it as
a file, the kernel does memory reads.

 

php中imagepng输出的图像掉色的问题

有个简单的程序

header("Content-type: image/png");
$im = imagecreatefrompng("test.png");
imagepng($im);
?>

发现页面上显示的图片和test.png相比掉了很多色

用imagepng($im, "haha.png");
再file test.png haha.png
发现haha.png大小比test.png小
而且haha.png的类型是8-bit colormap
而test.png就是8-bin/color RGB

而且,如果把图改成jpeg的

imagecreatefromjpeg

最后imagejpeg($im)也不会掉色

请问这是为什么呀

系统是kernel2.4.9 + php4.3.10 + gd1.8.4

后来没办法

把gd升级到2.0.33后问题解决

squid和raid

在squid的官方的faq上有这么一段话:

3.11 Is it okay to use separate drives and RAID on Squid?
RAID1 is fine, and so are separate drives.

RAID0 (striping) with Squid only gives you the drawback that if you lose one of the drives the whole stripe set is lost. There is no benefit in performance as Squid already distributes the load on the drives quite nicely.

Squid is the worst case application for RAID5, whether hardware or software, and will absolutely kill the performance of a RAID5. Once the cache has been filled Squid uses a lot of small random writes which the worst case workload for RAID5, effectively reducing write speed to only little more than that of one single drive.

Generally seek time is what you want to optimize for Squid, or more precisely the total amount of seeks/s your system can sustain. Choosing the right RAID solution generally decreases the amount of seeks/s your system can sustain significantly.

意思就是讲
squid跑在raid1上还行
raid0则没什么好处
如果跑在raid5上
则性能要降低很多

php对gif的支持

gd库在2.0.28的版本时又加入了对gif格式的支持

但我从php4.x的ChangeLog

里面却提到从php4.3.0开始

才read-only支持gif,而且还要用php自带的gd

我说怎么一直编php都不支持imagecreatefromgif函数

最后./configure –with-gd这么用自带的gd库搞定

校验文件是否被篡改的方法(md5、sha……)

以前网上放出来的东西

基本上都会同时放出一个md5码

用来校验下载东西是否正确(主要是怕被篡改)

最近md5不是出问题了吗

据说是两个不同的东西能够生成一样的md5码

(有人已经试验成功了)

所以,最近有很多已经开始采用别的校验方式

比如有的文件后缀是SHA256

里面放的是sha2校验码

那么我们可以用命令

openssl dgst sha xxx.iso

同样

校验文件的md5码也可以用命令

openssl dgst md5 xxx.iso

来得到这个文件xxx.iso的sha2的校验码

 

一个从xml文件向mysql数据库里倒数据的perl程序


#!/usr/bin/perl

use strict;
use DBI;
use XML::Parser;

# create hash to hold values for expected column names
my %row = (
"key" => undef,
"name" => undef);

# connect to database and create parser object
my $dbh = DBI->connect ("DBI:mysql:ipmap",
"root", "passwd",
{ RaiseError => 1, PrintError => 0});
my $parser = new XML::Parser (
Handlers => {
Start => \&handle_start,
End => \&handle_end,
Char => \&handle_text
}
);

# parse file and disconnect
$parser->parsefile ("example.xml");
$dbh->disconnect ();

sub handle_start
{
my ($p, $tag) = @_; # parser, tag name

if ($tag eq "row")
{
foreach my $key (keys (%row))
{
$row{$key} = undef;
}
}
}

sub handle_text
{
my ($p, $data) = @_; # parser, text

my $tag = $p->current_element ();
$row{$tag} .= $data if exists ($row{$tag});
}

sub handle_end
{
my ($p, $tag) = @_; # parser, tag name

if ($tag eq "row")
{
my $str;
# construct column assignments for INSERT statement
foreach my $key (keys (%row))
{
$str .= "," if $str;
$str .= "$key=" . $dbh->quote($row{$key});
}
$dbh->do ("INSERT INTO ipmap SET $str");
}
}

hp的机器安装redhat as4u2后,机器起不来

as4u2(advance server 4 update 2)

好象是grub安装的问题

重起进rescue模式后

装了一个lilo

然后用lilo作启动

才就OK

这个问题以前fc3(fedora core 3)也碰到过

也是强制装lilo来解决的

redhat as3下目录/var/named的权限造成的问题

这也许算是redhat as3的一个bug

当你装上他自带的dhcpd的rpm包后

再配好/etc/named.conf

/etc/rc.d/init.d/named start还是起不来的

原因是因为/etc/rc.d/init.d/named start这种起法

named是以用户named来启动的

而目录/var/named的属主为root:named

且权限为750

所以named用户要在/var/named目录下写东西是没有权限的

所以启动会失败

其实这个好解决

chown named:named /var/named就行了

这几天公司一台做ddns(动态dns)的机器

死活不能更新域名了

查来查去

原来发现可能是某次更新bind软件的时候

把目录/var/named的属主又改成root:named了

重新搞一下chown named:named /var/named就好了

linux环境下好用的字典软件:星际译神(stardict)

我的linux桌面偶尔也会查个什么单词什么的

所以我也装了个字典软件

装过几个

感觉还是星际译神(stardict)最好

fc4(Fedora Core 4)带的有这个rpm

用yum install stardict命令安装即可

但是缺省没有带字典文件

可以去这里下载字典

我下了个牛津的字典

(stardict-oxford-gb-2.4.2.tar.bz2)

mkdir /usr/share/stardict/dic

cd /usr/share/stardict/dic

tar xjvf /root/stardict-oxford-gb-2.4.2.tar.bz2

用rpm来重新为rpm文件签名

前两天

从网上下了一个apt的rpm

本想用于自己的apt respon

但apt-get安装时需要签名

我又不想import别人的签名

所以

想用自己的签名替换一下

于是

rpm –resign apt-xxxxx.rpm

搞定。

其实

从rpm4.3开始

rpm –addsign的效果跟rpm –resign是一样的

–addsign–resign这两个参数是一样的

但为什么会有两个不同的参数呢

manual上讲是由于"historical reasons"(历史原因)