Gearman安装及使用

摘要:
tty2:#gearman-fabc'aaaa'4输出结果正确。#gearman-fabc˂/etc/php.ini当然也可以直接从文件中读入内容。

基础安装包

  1. yuminstallvimwgetgccgcc-c++makedos2unixgperflibeventlibevent-develzlib-develbzip2-developenssl-develncurses-develboostboost-develmysql-devel

安装gearman 异步队列

  1. #wgethttps://launchpad.net/gearmand/1.2/1.1.9/+download/gearmand-1.1.9.tar.gz
  2. #tar-zxvfgearmand-1.1.9.tar.gz
  3. #cdgearmand-1.1.9
  4. #./configure如果出现错误请查看下面的错误解决

成功后如下

  1. *LIBS:
  2. *LDFLAGSFlags:
  3. *Assertionsenabled:no
  4. *Debugenabled:no
  5. *Warningsasfailure:no
  6. *Buildingwithlibsqlite3no
  7. *Buildingwithlibdrizzleno
  8. *Buildingwithlibmemcachednotfound
  9. *Buildingwithlibpqno
  10. *Buildingwithtokyocabinetno
  11. *Buildingwithlibmysqlyes
  12. *SSLenabled:no
  13. *make-j:3
  14. *VCScheckout:no

  1. #make
  2. #makeinstall

安装gearman php 扩展

  1. #wgethttp://pecl.php.net/get/gearman
  2. #mvgearmangearman.tar.gz
  3. #tar-zxvfgearman.tar.gz
  4. #cdgearman-1.1.2/
  5. #phpize
  6. #./configure
  7. #make
  8. #makeinstall
  9. #cd/etc/php.d/
  10. #cpgd.inigearman.ini
  11. #vimgearman.ini
  1. ;Enablegearmanextensionmodule
  2. extension=gearman.so
  1. #servicephp-fpmrestart

错误解决
在configure过程中出现了以下错误:

  1. checkingforBoostheadersversion>=1.39.0…no
  2. configure:error:cannotfindBoostheadersversion>=1.39.0

解决办法:

  1. #yumsearchboost
  2. #yuminstallboost.x86_64
  3. #yuminstallboost-devel.x86_64

继续执行./configure出现以下错误

  1. checkingforgperf...no
  2. configure:error:couldnotfindgperf

解决办法:

  1. #yumsearchgperf
  2. #yuminstallgperf.x86_64

继续执行./configure出现以下错误

  1. checkingtestforaworkinglibevent...no
  2. configure:error:Unabletofindlibevent

解决办法:

  1. #yuminstalllibeventlibevent-devel

gearman 参数说明

  1. Clientmode:gearman[options][<data>]
  2. Workermode:gearman-w[options][<command>[<args>...]]
  3. Commonoptionstobothclientandworkermodes.
  4. -f<function>-Functionnametouseforjobs(cangivemany)
  5. -h<host>-Jobserverhost
  6. -H-Printthishelpmenu
  7. -v-Printdiagnosticinformationtostdout(false)
  8. -p<port>-Jobserverport
  9. -t<timeout>-Timeoutinmilliseconds
  10. -i<pidfile>-Createapidfilefortheprocess
  11. Clientoptions:
  12. -b-Runjobsinthebackground(false)
  13. -I-Runjobsashighpriority
  14. -L-Runjobsaslowpriority
  15. -n-Runonejobperline(false)
  16. -N-Sameas-n,butstripoffthenewline(false)
  17. -P-Prefixalloutputlineswithfunctionsnames
  18. -s-Sendjobwithoutreadingfromstandardinput
  19. -u<unique>-Uniquekeytouseforjob
  20. Workeroptions:
  21. -c<count>-Numberofjobsforworkertorunbeforeexiting
  22. -n-Senddatapacketforeachline(false)
  23. -N-Sameas-n,butstripoffthenewline(false)
  24. -w-Runinworkermode(false)

gearman异步队列使用:

下面先做个命令行测试:
首先开两个命令行窗口
tty1:

  1. #gearman-w-fabc--wc-m

表示统计用户输入了多少个字符。
tty2:

  1. #gearman-fabc'aaaa'

4
输出结果正确。

#gearman-fabc</etc/php.ini

当然也可以直接从文件中读入内容。

免责声明:文章转载自《Gearman安装及使用》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇使用 VSCode 创建 SpringBoot RESTful 增删改查接口项目并发布解决 XMLHttpRequest status = 0 问题 及 返回值为null问题下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Gearman分布式任务处理系统(一)基本介绍

Gearman介绍 Gearman是一个用来把工作委派给其他机器、分布式的调用更适合做某项工作的机器、并发的做某项工作在多个调用间做负载均衡、或用来在调用其它语言的函数的系统。 通常,多语言多系统之间的集成是个大问题,一般来说,人们多半会采用 WebService 的方式来处理此类集成问题,但不管采用何种风格的WebService,如 RPC 风格,或者...