野生程序员 野生程序员

               流年,长短皆逝 浮生,往来皆客。  

目录
linux服务器用yum安装 redis#解决启动失败的问题
/  

linux服务器用yum安装 redis#解决启动失败的问题

我的服务器重新启动了一下,发现我的远程的redis连接不上了,然后我登陆上服务器也无法启动,然后报错信息为:

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

简直不要太头疼,而且我还重装了好几次redis还是没有用,看来硬来是不行的,于是我仔细观察这个错误,他让输入“journalctl -xe”来查看详情,于是我输入后便显示:

- Subject: Unit redis.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit redis.service has begun starting up.
Nov 22 16:32:16 VM_0_13_centos redis-server[30158]: *** FATAL CONFIG FILE ERROR ***
Nov 22 16:32:16 VM_0_13_centos redis-server[30158]: Reading the configuration file, at line 163
Nov 22 16:32:16 VM_0_13_centos redis-server[30158]: >>> 'logfile /var/log/redis/redis.log'
Nov 22 16:32:16 VM_0_13_centos redis-server[30158]: Can't open the log file: Permission denied
Nov 22 16:32:16 VM_0_13_centos systemd[1]: redis.service: main process exited, code=exited, status=1/FAILURE
Nov 22 16:32:16 VM_0_13_centos redis-shutdown[30160]: Could not connect to Redis at 127.0.0.1:6379: Connection refused
Nov 22 16:32:16 VM_0_13_centos polkitd[2500]: Unregistered Authentication Agent for unix-process:30152:6677862 (system bus name :1.2402, object path /org/free
Nov 22 16:32:16 VM_0_13_centos systemd[1]: redis.service: control process exited, code=exited status=1
Nov 22 16:32:16 VM_0_13_centos systemd[1]: Failed to start Redis persistent key-value database.
-- Subject: Unit redis.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit redis.service has failed.
-- 

通过仔细的阅读,说是无法打开 log file因为权限不允许,也就是这句
Can't open the log file: Permission denied
那么我们只需要把权限给这个文件就好了,因为这个文件是属于root组的,而运行redis后变成redis组的了。
输入:

chown redis:redis /var/log/redis/redis.log

再次启动redis

systemctl start redis

那么你就会发现这次没啥问题了,总结:一定要好好的看日志文件,不要盲目的上网搜索错误,因为网上的错误很可能给你的错误并不匹配。


标题:linux服务器用yum安装 redis#解决启动失败的问题
作者:野生程序员
地址:http://yscxy.net/articles/2019/11/22/1574412559136.html