gearman 日志分发
博客已经搬家,请访问如下地址:http://www.czhphp.com
一,安装:
wget http://www.monkey.org/~provos/libevent-1.4.12-stable.tar.gz
tar zxvf libevent-1.4.12-stable.tar.gz
cd libevent-1.4.12-stable/
./configure --prefix=/usr
make && make install
/sbin/ldconfig
cd ../
wget http://launchpad.net/gearmand/trunk/0.9/+download/gearmand-0.9.tar.gz
tar zxvf gearmand-0.9.tar.gz
cd gearmand-0.9/
./configure
make
make install
/sbin/ldconfig
cd ../
wget http://pecl.php.net/get/gearman-0.5.0.tgz
tar zxvf gearman-0.5.0.tgz
cd gearman-0.5.0
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
--with-gearman
make
make install
cd ../
二:启动服务
gearmand -L 127.0.0.1 -p 4730 -u root –d &
三:客户端脚本:
tail -F --sleep-interval=5 /home/wwwlogs/mvc_access.log > ./gearma.txt | cat gearma.txt | gearman -b -h 127.0.0.1 -f log >/dev/null &
四:work
exec("gearman -w -h 127.0.0.1 -f log >> /home/wwwroot/gearman/log.txt ");
五:设计架构:
日志汇总是从前端的任意多web服务器发送日志到汇总服务器,然后利用perl重新来统计数据,入库;