zoukankan      html  css  js  c++  java
  • Gearman安装及使用

    基础安装包 

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

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

  • 相关阅读:
    索引访问方法及索引优化
    AS3常用的几个顶级类
    AS3随鼠标移动的蜘蛛
    as去掉字符串中的重复字符
    AS单例模式
    移动的云朵
    (转)探索C++的秘密之详解extern "C"
    (转)YUV / RGB 格式及快速转换算法
    (转)如何解決TRDBD5M CMOS在DE2 delay的問題?
    (转)存储器类型
  • 原文地址:https://www.cnblogs.com/wjoyxt/p/3800635.html
Copyright © 2011-2022 走看看