Memcached和PHP错误

我已经安装了memcached,当我尝试像这样的脚本testing:

$memcache = new Memcache; $memcache->connect('127.0.0.1', 11211); echo $memcache->getVersion(); 

我收回巢错误:

:注意:MemcachePool :: getversion():服务器127.0.0.1(tcp 11211,udp 0)失败,networking超时(0)在/var/www/html/admin/test.php在62行

可能是什么问题呢? 我是memcached的新手。

确认收听

以root身份运行lsof -i并确认memcache守护进程正在您列出的端口上运行。

格式化为理智:

 memcached 16526 corneliu 31u IPv4 207975 0t0 TCP *:memcache (LISTEN) memcached 16526 corneliu 32u IPv6 207976 0t0 TCP *:memcache (LISTEN) memcached 16526 corneliu 33u IPv4 207979 0t0 UDP *:memcache memcached 16526 corneliu 34u IPv6 207980 0t0 UDP *:memcache 

因此,对于IPv4和IPv6,memcache服务器都在侦听TCP和UDP。 我假设memcache的/ etc / services条目是端口11211.服务正在侦听。

手动validation服务器是否响应命令

我会引用此问题: https : //stackoverflow.com/questions/6045187/memcache-connects-but-doesnt-respond-to-any-command并validation服务器是否响应您通过telnet或netcat发送的命令。 如果您运行tcpdump或wireshark捕获networkingstream量并实际查看哪些数据包正在传输,那么这可能也会非常有帮助。

在不更改内存cachingconfiguration的情况下进行debugging。 试图改变上面这个问题的服务器绑定地址应该是你做的最后一件事。 让我知道你的进步。

很多人用pconnect代替连接都有很好的效果

 $memcache = new Memcache; $memcache->pconnect('127.0.0.1', 11211); echo $memcache->getVersion(); 

更多信息在这里http://hostingfu.com/article/memcachepoolget-server-failed-with-network-timeout-possible-fixes