zoukankan      html  css  js  c++  java
  • Ubuntu gearman 搭建

    近阶段一直在查看项目里所使用到的一些技术点,发现了gearman,于是就动手搞了下环境,下面是来自百度百科关于gearman的介绍:

    Gearman是一个用来把工作委派给其他机器、分布式的调用更适合做某项工作的机器、并发的做某项工作在多个调用间做负载均衡、或用来在调用其它语言的函数的系统。
    可用于sso 分发连接,但有弊端就是占用系统资源较多,例如CPU、内存。
     

    1.更新

    sudo apt-get update


    wget https://launchpad.net/gearmand/1.2/1.1.12/+download/gearmand-1.1.12.tar.gz


    tar zxvf gearmand-1.1.12.tar.gz


    cd gearmand-1.1.12/


    ./configure


    configure: error: could not find boost


    sudo apt-get install libboost-dev


    接着重新执行:./configure


    configure: error: Could not find a version of the library!


    sudo apt-get install libboost-all-dev


    接着重新执行:./configure


    configure: error: could not find gperf


    sudo apt-get install gperf*


    接着重新执行:./configure


    configure: error: Unable to find libevent


    sudo apt-get install libevent-dev


    接着重新执行:./configure


    configure: error: Unable to find libuuid



    安装libuuid


    这里不能通过 sudo apt-get install 来安装了,找不到,通过下面方式安装


    wget http://nchc.dl.sourceforge.net/project/libuuid/libuuid-1.0.3.tar.gz


    sudo tar zxvf libuuid-1.0.3.tar.gz


    cd libuuid-1.0.3/


    ./configure


    没有错误的情况下继续


    sudo make


    sudo make install


    接下来继续上面的安装



    ./configure


    sudo make && make install


    这里要等一段时间。。

    根据上图运行结果来看并没安装成功,继续往下


    sudo make clean (清除上次的make命令所产生的object文件(后缀为“.o”的文件)及可执行文件。)


    重新安装


    ./configure


    sudo make


    sudo make install


    貌似没有错误,继续


    gearman


    第一次运行会看到以下提示:

    gearman: error while loading shared libraries: libgearman.so.8: cannot open shared object file: No such file or directory

    (这表示系统不知道libgearman.so.8 放在哪个目录下。 要在/etc/ld.so.conf中加入libgearman.so.8所在的目录。 检查了下,文件所在目录为/usr/local/lib 因此出现这个问题的原因是libgearman.so.8刚生成,没有加入到ld.so.cache中,所以这时需要重新运行一下 /sbin/ldconfig( ldconfig命令的作用))


    sudo /sbin/ldconfig



    此时再执行 gearman 则已安装成功!


    安装完Job Server之后,用gearmand –d命令启动


    gearmand -d


    第一次运行会看到以下提示:


    gearmand: Could not open log file "/usr/local/var/log/gearmand.log", from "/home/wangyulu/下载/gearmand-1.1.12", switching to stderr. (No such file or directory)


    在提示的目录下创建好/log/gearmand.log文件,再次执行上述命令,就正常启动了job server



    sudo gearmand -d


    到这里就已经完全ok






    安装PHP Gearman扩展


    wget http://pecl.php.net/get/gearman-1.1.2.tgz


    sudo tar zxvf gearman-1.1.2.tgz


    cd gearman-1.1.2/


    sudo phpize (这里可能会提示没有此命令,执行 sudo apt-get install php5-dev 安装)


    sudo ./configure


    sudo make


    sudo make install



    sudo echo "extension=gearman.so" >> /etc/php5/apache2/php.ini (注意这里php.ini位置)


    sudo /etc/init.d/apache2 restart


    这时查看php_info时就应该看到 gearman扩展了

    代码完成:

    https://gist.github.com/andreaspag/6242671/archive/a66d18d191b880c1f8210deb612eb51b185f0892.zip

    解压后把里面的文件复制到相应目录即可,如我是在用netbeans开发,我会把它放在 

    /usr/local/netbeans-8.1/php/phpstubs/phpruntime 这个目录里;

    以下是安装Job Server时的部分截图

    PHP Gearman 扩展

  • 相关阅读:
    重链剖分的总结与模板
    PBDS学习笔记(一)
    LCT 第一题 洛谷模板
    2018年暑假第四次周赛-图论部分题解
    后缀数组求不同子串的个数
    Codeforces Round #106 (Div. 2) Coloring Brackets(区间DP)
    Codeforces Round #510 (Div. 2) D. Petya and Array (权值线段树)
    HDU 3974 Assign the task (dfs序+线段树)
    Manthan, Codefest 18 (rated, Div. 1 + Div. 2) D.Valid BFS? (模拟)
    POJ
  • 原文地址:https://www.cnblogs.com/wangyulu/p/5252950.html
Copyright © 2011-2022 走看看