http://gearman.org/
33.4.1. Getting Started with Gearman
33.4.1.1. CentOS
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm yum install gearmand -y chkconfig gearmand on service gearmand start
配置启动参数
cat >> /etc/sysconfig/gearmand <<EOF OPTIONS="--log-file=/var/log/gearman.log --threads=512" EOF
33.4.1.2. Ubuntu
$ apt-cache search gearman | grep gearman drizzle-plugin-gearman-udf - Gearman User Defined Functions for Drizzle drizzle-plugin-logging-gearman - Gearman Logging for Drizzle gearman - Distributed job queue gearman-job-server - Job server for the Gearman distributed job queue gearman-server - Gearman distributed job server and Perl interface gearman-tools - Tools for the Gearman distributed job queue libgearman-client-async-perl - asynchronous client for the Gearman distributed job system libgearman-client-perl - client for the Gearman distributed job system libgearman-dbg - Debug symbols for the Gearman Client Library libgearman-dev - Development files for the Gearman Library libgearman-doc - API Documentation for the Gearman Library libgearman6 - Library providing Gearman client and worker functions mod-gearman-doc - Documentation and examples for Mod-Gearman mod-gearman-module - Nagios/Icinga event broker module for Mod-Gearman mod-gearman-tools - Tools for mod-gearman mod-gearman-worker - Worker agent for Mod-Gearman python-gearman - Python interface to the Gearman system python-gearman.libgearman - Python wrapper of libgearman python3-gearman.libgearman - Python 3 wrapper of libgearman
33.4.1.3. 防火墙设置
查看gearman工作端口
# grep gearman /etc/services gearman 4730/tcp # Gearman Job Queue System gearman 4730/udp # Gearman Job Queue System
iptables 设置
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 4730 -j ACCEPT
33.4.2. gearman
控制台 A
gearman -w -f wc -- wc -l
控制台 B
#wc -l < /etc/passwd 30 # wc -l < /etc/passwd 30
停止 gearman 进程再试
# /etc/init.d/gearmand stop Stopping gearmand: [ OK ] [root@haproxy ~]# gearman -f wc < /etc/passwd gearman:gearman_client_run_tasks:gearman_connection_flush:could not connect
压力测试
find / -type f | awk '{ print "gearman -f wc < " $1 }' | bash
33.4.3. Gearman PHP Extension
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm yum install libgearman-devel pecl install channel://pecl.php.net/gearman-0.8.3 cat >> /srv/php/etc/conf.d/gearman.ini <<EOF extension=gearman.so EOF
测试安装
# php -r 'printf("%s \r\n", gearman_version());' 0.14
原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。