【发布时间】:2013-02-07 11:03:49
【问题描述】:
我在我的服务器上安装了 gearmand 1.1.5,并在启动服务器后尝试了安装提供的示例。它们工作得非常正确(回声示例工作,相反的工作没有按预期工作,但没有给出任何错误)。
然后我使用 pecl 安装了 php 包装器。该版本是最后一个稳定版本(1.1.1)。显然我在 php.ini 中添加了扩展,我的 php --info|grep gearman 输出是:
gearman
gearman support => enabled
libgearman version => 1.1.5
PWD => /root/gearman-1.1.1/examples
OLDPWD => /root/gearman-1.1.1
_SERVER["PWD"] => /root/gearman-1.1.1/examples
_SERVER["OLDPWD"] => /root/gearman-1.1.1
然后我尝试了pecl包中的echo示例,worker正常启动:
[~/gearman-1.1.1/examples]# php reverse_worker.php
Starting
Waiting for job...
相反,客户端给了我以下错误:
[~/gearman-1.1.1/examples]# php reverse_client.php
Starting
Sending job
PHP Warning: GearmanClient::do(): send_packet(GEARMAN_COULD_NOT_CONNECT) Failed to send server-options packet -> libgearman/connection.cc:430 in /root/gearman-1.1.1/examples/reverse_client.php on line 26
PHP Stack trace:
PHP 1. {main}() /root/gearman-1.1.1/examples/reverse_client.php:0
PHP 2. GearmanClient->do() /root/gearman-1.1.1/examples/reverse_client.php:26
Warning: GearmanClient::do(): send_packet(GEARMAN_COULD_NOT_CONNECT) Failed to send server-options packet -> libgearman/connection.cc:430 in /root/gearman-1.1.1/examples/reverse_client.php on line 26
Call Stack:
0.0001 228408 1. {main}() /root/gearman-1.1.1/examples/reverse_client.php:0
0.0003 229552 2. GearmanClient->do() /root/gearman-1.1.1/examples/reverse_client.php:26
RET: 26
在 gearman 守护进程的日志中,这个 php 测试没有任何活动迹象,但它记录了我之前尝试过的所有示例。
如何解决此错误?谢谢。
【问题讨论】:
-
关于 gearman 的好博客 ..
http://www.brijneet.com/2011/gearman/ -
你能提供你用来连接的代码吗?我确实发现为 localhost 修复问题添加了 127.0.0.1
-
我们杀死并重新启动了守护进程,现在它正在工作。也许这是一个端口绑定/主机解析问题?我们做了很多测试,可能有些事情搞砸了。我还在 /etc/hosts (127.0.0.1 localhost) 中添加了一行。感谢您的建议