确定为什么 Redis 每隔一两分钟就会收到一个 SIGTERM

Determining why Redis is receiving a SIGTERM every minute or two

我是 运行 redis-server Ubuntu 16.04。在最近升级到 redis 3.2.7 之后,我现在看到像

这样的行

signal-handler (1486427812) Received SIGTERM scheduling shutdown... 每隔一两分钟在 redis 日志中,然后 redis 重新启动。

日志中唯一的其他可疑行是:

# WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

任何关于如何诊断为什么会发生这种情况的建议将不胜感激。谢谢!

这已通过 apt-get 清除和 re-install 解决。旧的初始化文件不能很好地与 redis.conf 文件一起播放。

仅作记录: 正如 J G Miller 的评论一样,您必须注意“Type=simple”和“daemonize yes”设置不兼容。当我发现这条评论时,我挣扎了几天。我的 redis 只是给出了 start-limit-hit 错误,因为当服务启动时它立即收到 SIGTERM 信号并停止。

因此,根据您的需要,在服务文件中更改“Type=forking”或“daemonize no”行来解决此问题。

对于仍在寻找解决方案的其他人,Type=forking(与 apt 一起安装的 redis 的默认设置)与 redis.conf 中的 supervised=systemd 不兼容。

必须在 /etc/systemd/system/redis.service 中更新为 Type=simple

仅在守护模式下需要分叉,但 systemd 管理的 Redis 否决了守护模式设置。

Restart=always 更改为 Restart=on-failure

供参考- redis.conf, https://www.freedesktop.org/software/systemd/man/systemd.service.html