寻觅生命中的那一片浅草......

每月存档 四月, 2010

Using yumdownloader To Download RPM Package Without Installing under CentOS

I would like to make a local yum Repository which only contains rpm packages I need.Copy packages from the CentOS DVD?That can’t resolve dependency problems between packages.We can use yumdownloader to download packages.

1、create directory to store packages
#mkdir /media/CentOS

2、install yum-utils which provides yumdownloader
#yum -y install yum-utils

3、download packages,–reolve option will resolve dependencies and download required packages
#cd /media/CentOS
#yumdownloader –resolve rsync telnet vixie-cron

memcached start error:event_queue_remove

I configure Nginx+MySQL+PHP+Memcached enviroment.I use my script to start memcached,then I type “netstat -tlnp” to see if memcached listens on 11211,I can see 11211,but when I type “netstat -tlnp” again,the 11211 port has disappeared.I type this command manually:

/usr/local/bin/memcached -m 128 -c 4096 -p 11211 -u www -t 10

It runs about three seconds,and then crash.the only message logged is:

[err] event_queue_remove: 0x60cfc0(fd -1) not on queue 1

I search “event_queue_remove” in Google. Some guys guess that there is something wrong with libevent.

I type LD_DEBUG=libs /usr/local/bin/memcached -m 128 -c 4096 -p 11211 -u www -t 10

The output of libevent is :
6283: calling init: /usr/lib64/libevent-1.1a.so.1

this shows that the version of libevent is “libevent-1.1a”,but the one I install from source code is “libevent-1.4.9-stable”.

rpm -qa |grep libevent
the result is :
libevent-devel-1.1a-3.2.1
libevent-1.1a-3.2.1
libevent-devel-1.1a-3.2.1
libevent-1.1a-3.2.1

Oh,my god,there is an old version libevent installed by rpm.I uninstall libevent with “yum -y remove libevent libevent-devel”,reinstall memcached,then memcached start normally.

Reference articles:http://www.serverphorums.com/read.php?9,108005

Use Parted to create partitions

I create a RAID 1 driver with six 2TB disks.The size of this driver is 6.0 TB.Fdisk which I use usually to create partitions doesn’t support this big driver.When I run fdisk -l,the output messages suggest I can use Parted to create partitions on it.

Here are the steps:

#parted /dev/sdb

###type “help” to get tips

(parted) help

(parted) mkpart

Partition name?  []?

File system type?  [ext2]? ext3

Start? 1

End? 5997GB

(parted) quit

#make ext3 file system

#mkfs.ext3 /dev/sdb1

#mount /dev/sdb1 /data

#vi /etc/fstab

#add this line

/dev/sdb1             /data                   ext3    defaults        1 2

#save and quit

用curl检测URL返回状态

#!/bin/bash
#自动检测论坛php是否挂了

while true
do
URL=” http://bbs.example.cn”
RETURN=`curl -o /dev/null -s -w “%{http_code}” “${URL}”`
if [ $RETURN != ‘200’ ];then
/data/sh/fastcgi_restart
fi
sleep 12
done

关于MCV中用C编写module然后加载进PHP中

工具 swig

教程
1, 创建example.c
$cat example.c
int example(char *s) {
printf(“%s”, s);
}
2, 创建.o
cc -c example.c
得到 example.o
3, 创建example.i
$cat example.i
%module example
extern int example(char *s);
4, 创建wrap文件
$swig -php4 example.i
得到 example_wrap.c example.php php_example.h
5, 创建wrap.o
$cc -c example_wrap.c -I/usr/local/include/glib-2.0 -I/usr/local/include/php -I/usr/local/include/php/Zend -I/usr/local/include/php/TSRM -I/usr/local/include/php/main -I/usr/local/include/php/regex
得到 example_wrap.o
6, 生成模块文件
$cc -shared -o php_example.so example.o example_wrap.o

得到的php_example.so及我们想要的lib包,可以将它放入到php.ini所指定的extension_dir中去
然后可以加上
extension=php_example.so

7, 测试文件
<?php
$s = “我的选择取决于你”;
example($s);
?>

转载自:http://blog.csdn.net/abaowu/archive/2005/07/20/429862.aspx

我的经历:

cc -shared -o php_example.so example.o example_wrap.o

报错
/usr/bin/ld: example_wrap.o: relocation R_X86_64_32S against `a local symbol’ can not be used when making a shared object; recompile with -fPIC

example_wrap.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
加-fPIC参数后,可以顺利编译通过
cc -c -fPIC example.c
cc -c example_wrap.c -fPIC -I/usr/include/glib-2.0 -I/usr/local/php/include/php -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/main -I/usr/local/php/include/php/regex

2010年四月
« 3月   5月 »
 1234
567891011
12131415161718
19202122232425
2627282930