重启后 Redis 服务不会重新启动

重启后 Redis 服务不会重新启动

升级我的服务器(Ubuntu 18.04.4 LTS)后,Redis 服务拒绝启动:

● redis.service - Redis In-Memory Data Store
  Loaded: loaded (/etc/systemd/system/redis.service; enabled; vendor preset: enabled)
  Active: failed (Result: exit-code) since Sun 2020-04-19 22:07:22 CEST; 37s ago
  Process: 5644 ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf (code=exited, status=1/FAILURE)
  Main PID: 5644 (code=exited, status=1/FAILURE)
Apr 19 22:07:22 vps systemd[1]: redis.service: Service hold-off time over, scheduling restart.
Apr 19 22:07:22 vps systemd[1]: redis.service: Scheduled restart job, restart counter is at 5.
Apr 19 22:07:22 vps systemd[1]: Stopped Redis In-Memory Data Store.
Apr 19 22:07:22 vps systemd[1]: redis.service: Start request repeated too quickly.
Apr 19 22:07:22 vps systemd[1]: redis.service: Failed with result 'exit-code'.
Apr 19 22:07:22 vps systemd[1]: Failed to start Redis In-Memory Data Store.

我尝试手动启动服务器,它成功了(以 sudo 方式)。然后我尝试使用我得到的 redis 用户:

[22:05:05] root@vps:/var/log# sudo -u redis /usr/local/bin/redis-server /etc/redis/redis.conf
  5533:C 19 Apr 22:05:45.755 # Fatal error, can't open config file '/etc/redis/redis.conf'

我在系统日志中发现了同样的错误:

Apr 19 21:27:31 vps redis-server[1246]: 1246:C 19 Apr 21:27:30.067 # Fatal error, can't open config file '/etc/redis/redis.conf'

我将该文件的权限授予 redis 用户,服务现在可以正确启动。

我不明白的是,这个文件自 2016 年起就没有被修改过(在我将权限授予 redis 用户之前,该用户是 root 用户):

[22:16:37] root@vps:/etc/redis# ll /etc/redis/redis.conf
-rw-r----- 1 redis redis 46716 Dec 24  2016 /etc/redis/redis.conf

我不知道发生了什么。我已经重启了很多次,但从未遇到过此错误。我想知道根本原因,这样就不会再发生这种情况,因为发生这种情况时所有托管网站都已关闭。如果您有任何想法,我可以调查一下。谢谢。

相关内容