Memcache连接但不响应任何命令 [英] Memcache connects but doesn't respond to any command

查看:441
本文介绍了Memcache连接但不响应任何命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设置: 阿帕奇; 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.

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.

问题:

类似于未解决的问题无法将值存储到memcache

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代码不会显示任何错误,但是一旦我尝试执行任何命令(例如getVersion),我就会得到响应:

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

尝试的解决方案:

通过命令行连接到memcache无效.输入后,所有命令连接都将关闭.

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.

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

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

此外,评论之一是

您可能正在运行不支持ASCII协议的memcached,例如您是否运行过:

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

 $ memcached -B binary

在这种情况下,请完全删除-B参数,PHP和telnet应该可以工作.

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

内存缓存的起始行是:

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

其中没有B参数.

有什么想法吗?

推荐答案

对谁来说可能很有趣.

To whom it might be interesting.

问题已解决.

问题出在这里(也许可以从两个相关方面帮助作者).

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

在共享主机上,有时您不应该使用127.0.0.1.而是使用站点的IP地址.

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

正在更改

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

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

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

解决了该问题.

谢谢大家!

这篇关于Memcache连接但不响应任何命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆