基础安装包

  1. yum install vim wget gcc gcc-c++ make dos2unix gperf libevent libevent-devel zlib-devel bzip2-devel openssl-devel ncurses-devel    boost boost-devel mysql-devel

安装gearman 异步队列

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

成功后如下

  1. * LIBS:
  2. * LDFLAGS Flags:
  3. * Assertions enabled:        no
  4. * Debug enabled:             no
  5. * Warnings as failure:       no
  6. * Building with libsqlite3   no
  7. * Building with libdrizzle   no
  8. * Building with libmemcached not found
  9. * Building with libpq        no
  10. * Building with tokyocabinet no
  11. * Building with libmysql     yes
  12. * SSL enabled:               no
  13. * make -j:                   3
  14. * VCS checkout:              no
  1. #  make
  2. #  make install

安装gearman php 扩展

  1. # wget http://pecl.php.net/get/gearman
  2. # mv gearman gearman.tar.gz
  3. # tar -zxvf gearman.tar.gz
  4. # cd gearman-1.1.2/
  5. # phpize
  6. # ./configure
  7. # make
  8. # make install
  9. # cd /etc/php.d/
  10. # cp gd.ini gearman.ini
  11. # vim gearman.ini
  1. ; Enable gearman extension module
  2. extension=gearman.so
  1. # service php-fpm restart

错误解决

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

  1. checking for Boost headers version >= 1.39.0… no
  2. configure: error: cannot find Boost headers version >= 1.39.0

解决办法:

  1. # yum search boost
  2. # yum install boost.x86_64
  3. # yum install boost-devel.x86_64

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

  1. checking for gperf... no
  2. configure: error: could not find gperf

解决办法:

  1. #yum search gperf
  2. #yum install gperf.x86_64

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

  1. checking test for a working libevent... no
  2. configure: error: Unable to find libevent

解决办法:

  1. # yum install libevent libevent-devel

gearman 参数说明

  1. Client mode: gearman [options] [<data>]
  2. Worker mode: gearman -w [options] [<command> [<args> ...]]
  3. Common options to both client and worker modes.
  4. -f <function> - Function name to use for jobs (can give many)
  5. -h <host>     - Job server host
  6. -H            - Print this help menu
  7. -v            - Print diagnostic information to stdout(false)
  8. -p <port>     - Job server port
  9. -t <timeout>  - Timeout in milliseconds
  10. -i <pidfile>  - Create a pidfile for the process
  11. Client options:
  12. -b            - Run jobs in the background(false)
  13. -I            - Run jobs as high priority
  14. -L            - Run jobs as low priority
  15. -n            - Run one job per line(false)
  16. -N            - Same as -n, but strip off the newline(false)
  17. -P            - Prefix all output lines with functions names
  18. -s            - Send job without reading from standard input
  19. -u <unique>   - Unique key to use for job
  20. Worker options:
  21. -c <count>    - Number of jobs for worker to run before exiting
  22. -n            - Send data packet for each line(false)
  23. -N            - Same as -n, but strip off the newline(false)
  24. -w            - Run in worker mode(false)

gearman异步队列使用:

下面先做个命令行测试:

首先开两个命令行窗口:
tty1:

  1. # gearman -w -f abc  -- wc  -m

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

  1. # gearman -f abc 'aaaa'

4
输出结果正确。

# gearman -f abc < /etc/php.ini

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

Gearman安装及使用的更多相关文章

  1. gearman安装及初次使用

    官网:  http://gearman.org/ 一篇文章: 利用Gearman实现异步任务处理 一.问题分析 问题:在性能测试过程中,发现用户管理平台在进行图片上传时,性能不佳. 分析:经过代码分析 ...

  2. CentOS的Gearman安装

    背景:用PHP做一些简单的上传是没有任何的问题,但是要做断点上传好像也是没有大问题,但要是并发的切片加断点上传可能就会有问题了哟.第一个问题是合并问题:如果一上传就合并,PHP老半天不返回是一个方面( ...

  3. gearman安装实录

    花了5个小时装好了gearman,问题不断,坑爹的服务器yum还坏了,悲催. 服务器系统:centos5.3 64位 gearman版本:1.1.8 安装包(相关依赖)下载 1.gearman安装包 ...

  4. gearman 安装

    yum install gperfyum install libevent-develyum install libuuid-develwget https://launchpad.net/gearm ...

  5. Gearman 安装使用教程

    Gearman是一个分发任务的程序框架,可以用在各种场合,Gearman更偏向于任务分发功能.它的任务分布非常简单,简单得可以只需要用脚本即可完成. Gearman 分布式任务实现原理上只用到2个字段 ...

  6. gearman安装问题总结

    解决configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers. yum ...

  7. Centos7安装gearman和php扩展

    Centos7安装gearman和php扩展 标签(空格分隔): php,linux gearman所需要的依赖 yum install \ vim \ git \ gcc \ gcc-c++ \ w ...

  8. gearman mysql udf

    gearman安装 apt-get install gearman gearman-server libgearman-dev 配置bindip /etc/defalut/gearman-job-se ...

  9. Gearman + Nodejs + MySQL UDF异步实现 MySQL 到 Redis 的数据同步

    [TOC] 1, 环境 CentOS, MySQL, Redis, Nodejs 2, Redis简介 Redis是一个开源的K-V内存数据库,它的key可以是string/set/hash/list ...

随机推荐

  1. JavaScript中类似PHP的uniqid()方法

    JavaScript中类似PHP的uniqid()方法: function generateUIDNotMoreThan1million() { return ("0000" + ...

  2. centos6安装GitLab全程详解和常见问题解决

    GitLab,是一个使用 Ruby on Rails 开发的开源应用程序,与Github类似,能够浏览源代码,管理缺陷和注释,非常适合在团队内部使用. 官方只提供了Debian/Ubuntu系统下的安 ...

  3. SQL的datetime类型数据转换为字符串格式大全

    Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM Select CONVERT(varchar(100), GETDATE( ...

  4. 全选,反选,获取值ajax提交

    //必须先加载jquery //加载 弹出框插件 artdialog http://www.planeart.cn/demo/artDialog/ /****全选反选*开始**/ $(document ...

  5. Hadoop专业解决方案-第12章 为Hadoop应用构建企业级的安全解决方案

    一.前言: 非常感谢Hadoop专业解决方案群:313702010,兄弟们的大力支持,在此说一声辛苦了,春节期间,项目进度有所延迟,不过元宵节以后大家已经步入正轨, 目前第12章 为Hadoop应用构 ...

  6. bzoj 2516: 电梯

    Description Input Output 状压dp,状态表示为表示当前在第x层,电梯内有哪些人,哪些人还没到终点 #include<cstdio> #include<cstr ...

  7. 获取 user-agents

    user-agent "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0. ...

  8. request响应码记录

    响应 -- r.status_code                     #响应状态码 -- r.content                             #会自动为你解码 字节方 ...

  9. 设置多个ip ,实现ip欺骗

    网关和DNS填写: 使用IP欺骗功能必须得本地有多个可用IP,通常普通的PC机只有一个物理网卡,这就需要我们手工设置多IP绑定同一网卡:         a.开始菜单 -> 控制面板 -> ...

  10. sed简单用法

    参数说明: -e 以指定的script来处理输入的文本文件 -f 以指定的script文件来处理输入的文本文件 -h 显示帮助 -n 仅显示script处理后的结果 -V 显示版本信息 -v 反选 动 ...