摘要:
tty2:#gearman-fabc'aaaa'4输出结果正确。#gearman-fabc˂/etc/php.ini当然也可以直接从文件中读入内容。
基础安装包
- yuminstallvimwgetgccgcc-c++makedos2unixgperflibeventlibevent-develzlib-develbzip2-developenssl-develncurses-develboostboost-develmysql-devel
安装gearman 异步队列
- #wgethttps://launchpad.net/gearmand/1.2/1.1.9/+download/gearmand-1.1.9.tar.gz
- #tar-zxvfgearmand-1.1.9.tar.gz
- #cdgearmand-1.1.9
- #./configure如果出现错误请查看下面的错误解决
成功后如下
- *LIBS:
- *LDFLAGSFlags:
- *Assertionsenabled:no
- *Debugenabled:no
- *Warningsasfailure:no
- *Buildingwithlibsqlite3no
- *Buildingwithlibdrizzleno
- *Buildingwithlibmemcachednotfound
- *Buildingwithlibpqno
- *Buildingwithtokyocabinetno
- *Buildingwithlibmysqlyes
- *SSLenabled:no
- *make-j:3
- *VCScheckout:no
- #make
- #makeinstall
安装gearman php 扩展
- #wgethttp://pecl.php.net/get/gearman
- #mvgearmangearman.tar.gz
- #tar-zxvfgearman.tar.gz
- #cdgearman-1.1.2/
- #phpize
- #./configure
- #make
- #makeinstall
- #cd/etc/php.d/
- #cpgd.inigearman.ini
- #vimgearman.ini
- ;Enablegearmanextensionmodule
- extension=gearman.so
- #servicephp-fpmrestart
错误解决
在configure过程中出现了以下错误:
- checkingforBoostheadersversion>=1.39.0…no
- configure:error:cannotfindBoostheadersversion>=1.39.0
解决办法:
- #yumsearchboost
- #yuminstallboost.x86_64
- #yuminstallboost-devel.x86_64
继续执行./configure出现以下错误
- checkingforgperf...no
- configure:error:couldnotfindgperf
解决办法:
- #yumsearchgperf
- #yuminstallgperf.x86_64
继续执行./configure出现以下错误
- checkingtestforaworkinglibevent...no
- configure:error:Unabletofindlibevent
解决办法:
- #yuminstalllibeventlibevent-devel
gearman 参数说明
- Clientmode:gearman[options][<data>]
- Workermode:gearman-w[options][<command>[<args>...]]
- Commonoptionstobothclientandworkermodes.
- -f<function>-Functionnametouseforjobs(cangivemany)
- -h<host>-Jobserverhost
- -H-Printthishelpmenu
- -v-Printdiagnosticinformationtostdout(false)
- -p<port>-Jobserverport
- -t<timeout>-Timeoutinmilliseconds
- -i<pidfile>-Createapidfilefortheprocess
- Clientoptions:
- -b-Runjobsinthebackground(false)
- -I-Runjobsashighpriority
- -L-Runjobsaslowpriority
- -n-Runonejobperline(false)
- -N-Sameas-n,butstripoffthenewline(false)
- -P-Prefixalloutputlineswithfunctionsnames
- -s-Sendjobwithoutreadingfromstandardinput
- -u<unique>-Uniquekeytouseforjob
- Workeroptions:
- -c<count>-Numberofjobsforworkertorunbeforeexiting
- -n-Senddatapacketforeachline(false)
- -N-Sameas-n,butstripoffthenewline(false)
- -w-Runinworkermode(false)
gearman异步队列使用:
下面先做个命令行测试:
首先开两个命令行窗口:
tty1:
- #gearman-w-fabc--wc-m
表示统计用户输入了多少个字符。
tty2:
- #gearman-fabc'aaaa'
4
输出结果正确。
#gearman-fabc</etc/php.ini
当然也可以直接从文件中读入内容。