gearman 安装配置

   下载gearman-0.8.0.tgz并安装
   #cd /opt/build/
   #wget http://pecl.php.net/get/gearman-0.8.0.tgz
   # yum install -y libgearman-devel.x86_64
   # yum install -y re2c
   #tar zxf gearman-0.8.0.tgz
   #cd gearman-0.8.0.tgz
   #phpize
   # ./configure
   # make && make install
2.编辑php.ini配置文件加载相应模块并使之生效
   # vim /etc/php.ini
   extension = "gearman.so"
3.查看gearman.so模块是否加载
   # php --info | grep gearman
   gearman
   gearman support => enabled
   libgearman version => 0.14
   PWD => /opt/build/gearman-0.8.0
   _SERVER["PWD"] => /opt/build/gearman-0.8.0
   # php -m | grep gearman
   gearman
4.启动job
gearmand -d
如果当前用户是 root 的话,则需要这样操作:
gearmand -d -u root
缺省会使用 4730 端口,下面会用到。
   注意:如果找不到 gearmand 命令的路径,别忘了用 whereis gearmand 确认

[client -- 172.16.1.181]
   安装如work同。如上所示。

三、测试:
[Job Server (gearmand) -- 172.16.1.183]
启动gearmand

以命令行工具来验证gearman的功能
启动 Worker:gearman -h 172.16.1.183 -w -f wc -- wc -l &
运行Client:gearman -h 172.16.1.183 -f wc < /etc/passwd
42
可以看到验证成功。

以php验证gearman的功能
编写 Worker
worker.php 文件内容如下:
<?php
$worker= new GearmanWorker();
$worker->addServer('172.16.1.183', 4730);
$worker->addFunction('reverse', 'my_reverse_function');
while ($worker->work());
function my_reverse_function($job) {
return strrev($job->workload());
}
?>
设置后台运行 work
php worker.php &
编写 Client
client.php 文件内容如下:
<?php
$client= new GearmanClient();
$client->addServer('172.16.1.183', 4730);
echo $client->do('reverse', 'Hello World!'), "\n";
?>
运行 client
php client.php
输出:!dlroW olleH

Q:

I've been trying to get Gearman compiled on CentOS 5.8 all afternoon. Unfortunately I am restricted to this version of CentOS by my CTO and how he has our entire network configured. I think it's simply because we don't have enough resources to upgrade our network... But anyways, the problem at hand.

I have searched through Server Fault, Stack Overflow, Google, and am unable to locate a working solution. What I have below is stuff I have pieced together from my searching.

Searches have told said to install the following via yum:

yum -y install --enablerepo=remi boost141-devel libgearman-devel e2fsprogs-devel e2fsprogs gcc44 gcc-c++

To get the Boost headers working correctly I did this:

cp -f /usr/lib/boost141/* /usr/lib/ cp -f /usr/lib64/boost141/* /usr/lib64/ rm -f /usr/include/boost ln -s /usr/include/boost141/boost /usr/include/boost

With all of the dependancies installed and paths setup I then download and compile gearmand-1.1.2 just fine.

wget -O /tmp/gearmand-1.1.2.tar.gz https://launchpad.net/gearmand/1.2/1.1.2/+download/gearmand-1.1.2.tar.gz cd /tmp && tar zxvf gearmand-1.1.2.tar.gz ./configure && make -j8 && make install

That works correctly. So now I need to install the Gearman library for PHP. I have attempted through PECL and downloading the source directly, both result in the same error:

checking whether to enable gearman support... yes, shared not found configure: error: Please install libgearman

What I don't understand is I installed the libgearman-devel package which also installed the core libgearman. The installation installs libgearman-devel-0.14-3.el5.x86_64, libgearman-devel-0.14-3.el5.i386, libgearman-0.14-3.el5.x86_64, and libgearman-0.14-3.el5.i386.

Is it possible the package version is lower than what is required? I'm still poking around with this, but figured I'd throw this up to see if anyone has a solution while I continue to research a fix.

Thanks!

A:

This should do the trick:

export GEARMAN_LIB_DIR=/usr/include/libgearman
export GEARMAN_INC_DIR=/usr/include/libgearman

That should work, if not you'll have to do some minor edits to config.m4.

你可能感兴趣的:(gearman,安装配置)