Reids报错解决 Job for redis-server.service failed because the control process exited with error code.

此文首发于我的个人博客:zhang0peter的个人博客


早上在启动redis的时候报错如下:

-> # service redis-server start
Job for redis-server.service failed because the control process exited with error code.
See "systemctl status redis-server.service" and "journalctl -xe" for details.

查看报错信息:

-> # systemctl status redis-server.service
 redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2019-05-10 14:48:08 CST; 36s ago
     Docs: http://redis.io/documentation,
           man:redis-server(1)
  Process: 29517 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf2 (code=exited, status=1/FAILURE)
  Process: 29515 ExecStartPre=/bin/run-parts --verbose /etc/redis/redis-server.pre-up.d (code=exited, status=0/SUCCESS)
 Main PID: 17437 (code=exited, status=0/SUCCESS)
      CPU: 10ms

May 10 14:48:08 VM-73-203-debian systemd[1]: Starting Advanced key-value store...
May 10 14:48:08 VM-73-203-debian run-parts[29515]: run-parts: executing /etc/redis/redis-server.pre-up.d/00_example
May 10 14:48:08 VM-73-203-debian redis-server[29517]: 29517:C 10 May 14:48:08.460 # Fatal error, can't open config file '/etc/redis/redi
May 10 14:48:08 VM-73-203-debian systemd[1]: redis-server.service: Control process exited, code=exited status=1
May 10 14:48:08 VM-73-203-debian systemd[1]: Failed to start Advanced key-value store.
May 10 14:48:08 VM-73-203-debian systemd[1]: redis-server.service: Unit entered failed state.
May 10 14:48:08 VM-73-203-debian systemd[1]: redis-server.service: Failed with result 'exit-code'.

-> # journalctl -xe
May 10 14:48:08 VM-73-203-debian systemd[1]: Starting Advanced key-value store...
-- Subject: Unit redis-server.service has begun start-up
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- Unit redis-server.service has begun starting up.
May 10 14:48:08 VM-73-203-debian run-parts[29515]: run-parts: executing /etc/redis/redis-server.pre-up.d/00_example
May 10 14:48:08 VM-73-203-debian redis-server[29517]: 29517:C 10 May 14:48:08.460 # Fatal error, can't open config file '/etc/redis/redi
May 10 14:48:08 VM-73-203-debian systemd[1]: redis-server.service: Control process exited, code=exited status=1
May 10 14:48:08 VM-73-203-debian systemd[1]: Failed to start Advanced key-value store.
-- Subject: Unit redis-server.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- Unit redis-server.service has failed.
-- 
-- The result is failed.
May 10 14:48:08 VM-73-203-debian systemd[1]: redis-server.service: Unit entered failed state.
May 10 14:48:08 VM-73-203-debian systemd[1]: redis-server.service: Failed with result 'exit-code'.

里面有关键的一句: redis-server[29517]: 29517:C 10 May 14:48:08.460 # Fatal error, can't open config file '/etc/redis/redi 这句话让我想起了我修改了redis.conf,现在redis.conf是root用户,而redis用户是没有权限读取的。

解决方法:

chmod 644 /etc/redis/redis.conf
service redis-server start