gearman 给我 GEARMAN_COULD_NOT_CONNECT,它肯定在运行

2022-01-24 00:00:00 debian php gearman

我的开发服务器是 Debian Squeeze,我正在运行 Gearman 1.1.5,它是从源代码编译的,带有 php pecl 扩展 v1.1.1

My dev server is Debian Squeeze and I'm running Gearman 1.1.5 which I compiled from source along with the php pecl extension v1.1.1

如果我运行 reverse_client.php 脚本,我会收到 GEARMAN_COULD_NOT_CONNECT 错误.

If I run the reverse_client.php script I get the GEARMAN_COULD_NOT_CONNECT error.

PHP 警告:GearmanClient::do(): send_packet(GEARMAN_COULD_NOT_CONNECT) 发送服务器选项包失败 ->libgearman/connection.cc:430 在/home/bealers/build/gearman-1.1.1/examples/reverse_client.php 第 26 行

这里有一些类似的帖子,它们都指向通用汽车没有运行.

There are a few similar posts on here about this and they all point to GM not running.

确实在运行.

我从这些参数开始:

PARAMS="--queue-type=MySQL --mysql-db=test_db --mysql-user=gearman --mysql-password=gearman"

如果我在 test_db 中删除 gearman_queue 表,然后重新启动守护程序,该表将重新创建,因此它的 mysql 连接正常并且它显然正在启动.

If I drop the gearman_queue table in test_db then restart the daemon the table is recreated, so its mysql connection is fine and it's clearly starting.

我也可以在 localhost 上 telnet 到 4730,所以没有防火墙问题.

I can also telnet to 4730 on localhost, so there's no firewall issue.

最初GM启动有问题,因为它比mysql先启动,所以我编辑了init脚本

Initially GM had problems starting because it was starting before mysql, so I edited the init script

### BEGIN INIT INFO
# Provides:          gearman-job-server
# Required-Start:    $network $remote_fs $syslog mysql

和一个 update-rd.c gearman-job-server defaults 将其设置为在之后启动,并且在现在启动时正常启动.

and an update-rd.c gearman-job-server defaults sets it to start after and it starts fine on boot up now.

我唯一能想到的另一件事是,最初我是通过 apt 安装的,但版本太旧了,所以我将其删除并从源代码编译./usr/sbin/gearmand 不再存在,唯一的版本是/usr/local/sbin/gearmand

The only other thing I can think of is that initially I'd installed via apt but the version was to old so I removed it and compiled from source. /usr/sbin/gearmand no longer exists the only version is /usr/local/sbin/gearmand

ps 斧头 |grep gearman 显示只有一个进程在运行.

ps ax | grep gearman shows only one process running.

Netstat 显示只有一个进程正在运行`

Netstat shows only one process running`

tcp 0 0 *:4730 *:* LISTEN 2325/gearmand

PECL 库看起来不错:

The PECL lib seems fine:

<代码>php -i |grep 齿轮人

/etc/php5/cli/conf.d/gearman.ini,
gearman
gearman support => enabled
libgearman version => 1.1.5

我没有想法

推荐答案

我遇到了同样的问题,经过几天的挫折,最近解决了(很难解决,因为要担心三个过程:-)

I had the same problem and recently solved them after a couple days of frustration (hard to troubleshoot since there are three processes to worry about :-)

似乎(至少在我的情况下) GearmanClient::addServer() 和 GearmanWorker::addServer() 的 PHP 文档不正确.具体来说,文档似乎暗示主机名和端口号是可选的,如果您不指定它们,它将使用 localhost 和端口 4730 作为默认值.这从不有效 - 今天我突然想到尝试为客户端和工作进程明确指定它们,一切都开始工作了.

It appears (at least in my case) that the PHP documentation for GearmanClient::addServer() and GearmanWorker::addServer() is incorrect. Specifically, the docs seem to imply that hostname and port number are optional and that it will use localhost and port 4730 as defaults if you do not specify them. This never works - it suddenly occurred to me today to try explicitly specifying them for both client and worker processes and everything started working.

尝试指定主机名和端口的所有值,看看这是否适合您.

Try specifying all values for hostnames and ports and see if this works for you.

相关文章