我有一台装有 Memcached 的 CentOS 7 服务器。有大量请求,通常几个小时后,memcached 守护进程就会崩溃。我总是重新启动该服务,但几个小时后它又会崩溃。
这/var/log/memcached.log文件为空。
这些是/etc/sysconfig/memcached设置:
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="32"
OPTIONS="-vv >> /var/log/memcached.log 2>&1"
journalctl-u memcached抛出这个结果(奇怪的是,最后的日志日期是 12 月,但我在 1 月份每天都会重新启动 memcached 服务)。
Dec 10 23:59:32 myserver systemd[1]: Started Memcached.
Dec 10 23:59:32 myserver systemd[1]: Starting Memcached...
Dec 13 16:44:07 myserver systemd[1]: memcached.service: main process exited, code=killed, status=9/KILL
Dec 13 16:44:07 myserver systemd[1]: Unit memcached.service entered failed state.
Dec 13 16:44:07 myserver systemd[1]: memcached.service failed.
Dec 14 22:22:41 myserver systemd[1]: Started Memcached.
Dec 14 22:22:41 myserver systemd[1]: Starting Memcached...
Dec 15 19:35:50 myserver systemd[1]: memcached.service: main process exited, code=killed, status=9/KILL
Dec 15 19:35:50 myserver systemd[1]: Unit memcached.service entered failed state.
Dec 15 19:35:50 myserver systemd[1]: memcached.service failed.
systemctl cat memcached.service
[Unit]
Description=Memcached
Before=httpd.service
After=network.target
[Service]
Type=simple
EnvironmentFile=-/etc/sysconfig/memcached
ExecStart=/usr/bin/memcached -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTION
[Install]
WantedBy=multi-user.target
经过几个小时的访客请求后,apache 日志错误开始接连显示以下错误:
[Wed Jan 08 11:17:11.017280 2020] [:error] [pid 15793] [client X.X.X.X:22992] PHP Warning: Memcache::connect(): Can't connect to localhost:11211, Connection refused (111) in /www/html/inc/functions.php on line X
这些是 php 5.6.30 环境的 memcached 设置:
我如何才能正确检测导致失败/崩溃行为的原因?