Memcache 连接但不响应任何命令

发布于 2024-11-08 12:08:03 字数 1396 浏览 0 评论 0原文

设置: 阿帕奇; PHP 5.2.9; libevent(对于 memcached 是必需的)版本 1.3; memcached服务器版本1.2.2(尝试过1.4.5、1.4.0,现在降级到1.2.2,没有区别); memcached php pecl 模块版本 2.2.6。

问题:

与未解决的问题类似无法将值存储到内存缓存中超级奇怪的 PHP 错误

这些线程都没有解决问题,也没有一个问题作者遵循给出的建议。我都照着做了,还是不行。

如果我通过 PHP 连接,Memcache 代码不会显示任何错误,但一旦我尝试执行任何命令(例如 getVersion),我就会收到响应:

注意:memcache_get_version() [function.memcache-get-version]:服务器 127.0.0.1 (tcp 11211) 失败:无法从流 (0) 中读取行/var/www/html/memcache.php on line 11

尝试的解决方案:

通过命令行连接到 memcache 不起作用。我输入任何命令后连接就会关闭。

[/usr/local/src]$ telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
stats
Connection closed by foreign host.

我尝试了 $ memcached -S 来确保 memcached 是在禁用 SASL 支持的情况下编译的。 响应:“此服务器未构建有 SASL 支持。”

另外,其中一条评论是

您可能在没有 ASCII 协议支持的情况下运行 memcached,例如如果您运行:

 $ memcached -B 二进制文件

如果是这种情况,请完全删除 -B 参数,PHP 和 telnet 应该可以工作。

memcache 起始行是:

memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211

其中没有 B 参数。

有什么想法吗?

Setup:
Apache; PHP 5.2.9; libevent (for memcached it's required) version 1.3; memcached server version 1.2.2 (tried 1.4.5, 1.4.0, now downgraded to 1.2.2, no difference); memcached php pecl module version 2.2.6.

Problem:

Similar to unresolved problems cannot store values into memcache and Super strange PHP error

None of those threads had resolved issue and none of the authors of questions followed recommendations given. I followed them all, and it still doesn't work.

Memcache code doesn't show any error if I am connecting via PHP, but as soon as I'm trying to execute any command (such as getVersion), I get the response:

Notice: memcache_get_version() [function.memcache-get-version]: Server 127.0.0.1 (tcp 11211) failed with: Failed reading line from stream (0) in /var/www/html/memcache.php on line 11

Solutions tried:

Connecting to memcache via command line is not working. After I type any command connection is closing.

[/usr/local/src]$ telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
stats
Connection closed by foreign host.

I tried $ memcached -S to make sure memcached was compiled with SASL support disabled.
Response: "This server is not built with SASL support."

Also, one of the comments was

You may be running memcached without ASCII protocol support, such as if you ran:

 $ memcached -B binary

If this is the case, remove the -B argument entirely, and PHP and telnet should work.

The memcache start line is:

memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211

No B argument in it.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

说谎友 2024-11-15 12:08:03

对谁来说这可能很有趣。

问题已解决。

这就是问题所在(也许它会对两个相关步骤的作者有所帮助)。

在共享主机上,有时您不应该使用 127.0.0.1。相反,请使用站点的 IP 地址。

因此将

memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211

更改

memcached -d -m 1024 -u root -l 123.456.789.123 -p 11211

PHP 代码从

$memcache->pconnect("127.0.0.1",11211);

$memcache->pconnect("123.456.789.123",11211);

解决了该问题。

谢谢大家!

To whom it might be interesting.

Issue resolved.

Here is where problem was(maybe it would help authors from 2 related treads).

On shared hosting sometimes you shouldn't use 127.0.0.1. Instead, use site's IP address.

So changing

memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211

to

memcached -d -m 1024 -u root -l 123.456.789.123 -p 11211

and PHP code from

$memcache->pconnect("127.0.0.1",11211);

to

$memcache->pconnect("123.456.789.123",11211);

fixed the issue.

Thanks everyone!

2024-11-15 12:08:03

我会和你的系统管理员谈谈。我认为可能涉及防火墙。

I would talk to your sys sadmin. I think the there maybe a firewall involved.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文