侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

wdlinux centos 7 gearman安装

2023-12-18 星期一 / 0 评论 / 0 点赞 / 132 阅读 / 5395 字

一、GearMan环境安装依赖环境:yum install -y boost-devel gperf libevent-devel libuuid-devel如果boost版本太低,则要自己编译安装/

一、GearMan环境安装

  • 依赖环境:yum install -y boost-devel gperf libevent-devel libuuid-devel
  • 如果boost版本太低,则要自己编译安装
//注意:wdlinux centos 5.11 验证的版本//ICU4C :icu4c-56_1-src.zip//Boost:boost_1_50_0.tar.gz//安装ICU4C wget http://downloads.sourceforge.net/project/icu/ICU4C/4.0/icu4c-4_0-src.tgz?use_mirror=cdnetworks-kr-2tar zxvf icu4c-4_0-src.tgzcd icu/source./configure –prefix=/usrmakemake installldconfig//安装Boost wget http://sourceforge.net/projects/boost/files/boost/1.43.0/boost_1_43_0.tar.gz/downloadtar zxvf boost_1_43_0.tar.gzcd boost_1_43_0rm -rf /usr/include/boost/rm -rf /usr/lib/libboost*./bootstrap.sh -prefix=/usr/local/boost./b2编译大概半小时,完成后:./b2 install
  • 下载地址:https://launchpad.net/gearmand/
  • wget https://launchpad.net/gearmand/1.2/1.1.12/+download/gearmand-1.1.12.tar.gz
  • tar zxf gearmand-1.1.12.tar.gz
  • cd gearmand-1.1.12
  • ./configure --with-boost=/usr/local/boost --with-boost-libdir=/usr/local/boost/lib
  • make && make install

二、PHP拓展环境安装

  • 下载列表:http://pecl.php.net/package/gearman
  • wget http://pecl.php.net/get/gearman-1.1.2.tgz
  • tar zxf gearman-1.1.2.tgz
  • cd gearman-1.1.2
  • /www/wdlinux/php/bin/phpize
  • ./configure --with-php-config=/www/wdlinux/php/bin/php-config
  • make
  • cp ./modules/gearman.so /www/wdlinux/php/lib/php/extensions/no-debug-non-zts-20131226/
  • vim /www/wdlinux/php/etc/php.ini 在文件最后添加 :extension=gearman.so
  • 重启PHP服务
  • 查看状态:/www/wdlinux/php/bin/php --info |grep gearman

三、启动gearman

  • gearman -d

四、测试

//worker.php<?php$worker= new GearmanWorker();$worker->addServer();$worker->addFunction("reverse", "my_reverse_function");while ($worker->work());function my_reverse_function($job){  return strrev($job->workload());}?>
  • php worker.php
//client.php<?php$client= new GearmanClient();$client->addServer();print $client->do("reverse", "Hello World!");?>

错误集:

在编译过程会遇到以下几种错误,是由于你的系统默认缺少这依赖类库。报错一:checking for boostlib >= 1.39… configure: We could not detect the boost libraries (version 1.39 or higher). If you have a staged boost library (still not installed) please specify $BOOST_ROOT in your environment and do not give a PATH to –with-boost option. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.configure: error: could not find boost解决方法yum install boost-devel报错二:configure: error: could not find gperf解决方法yum install gperf报错三:configure: error: Unable to find libevent解决方法yum install libevent-devel报错四:configure: error: Unable to find libuuid解决方法yum install libuuid-devel你可以使用以下一条命令涵盖之前的4条命令:yum install -y boost-devel gperf libevent-devel libuuid-devel以上命令会一次性安装完所有的依赖类库。报错五:gearmand: Could not open log file "/usr/local/var/log/gearmand.log", from ......解决方法mkdir -p /usr/local/var/log/cd /usr/local/var/log/touch gearmand.log报错六:./libgearman-1.0/gearman.h:53:23: error: cinttypes: No such file or directorymake[1]: *** [libgearman/libgearman_libgearman_la-check.lo] 错误 1make[1]: Leaving directory `/root/gearmand-1.1.12'make: *** [all] 错误 2解决办法:命令:yum install gcc44 gcc44-c++ libstdc++44-devel -y然后在环境变量里加入:export CC=/usr/bin/gcc44 or export CC=/usr/bin/gccexport CXX=/usr/bin/g++44保存退出后执行:source /etc/profile删除gearmand-0.34文件夹重新进行编译.重新进行编译后执行make这步......在后面有详细的说明,可以不source直接设置环境变量,因为编译后也不一定要这个版本的gcc的。报错七:完成后,执行 gearmand -dgearmand: error while loading shared libraries: libboost_program_options.so.1.50.0: cannot open shared object file: No such file or directory解决办法:vim /etc/ld.so.conf加上路径:/usr/local/boost/libldconfig报错八:如果安装成功,启动worker时报如下错误,很有可能是gearmand 没有启动起来。GearmanWorker fails with 'Failed to set exception option'gearmand -d或者gearmand -d -u root都启动不起来。gearmand -vvv调试模式却提示未定义选项-v。这时应该是触发gearmand新版本的bug了,查看log应该能看到“000000 [  main ] socket()(Address family not supported by protocol) -> libgearman-server/gearmand.cc:470”这个错误,解决办法是启动时添加参数-L 0.0.0.0,限定只绑定ipv4地址,忽略ipv6。或者安装不高于1.0.2的版本。参见官方反馈帖子:https://bugs.launchpad.net/gearmand/+bug/1134534参考链接:http://www.usamurai.com/2013/05/01/install-gearman-from-source-in-centos/

广告 广告

评论区