遇到 systemctl status redis-server.service状态为fail,systemctl restart redis-server.service又无法重启,通过原始命令:/usr/bin/redis-server /etc/redis/redis.conf 又能正常运行redis。如下图:
systemctl status redis-server.service
解决方案:
移除redis-server.service
#systemctl disable redis-server.service
重新把redis-server加入到 systemctl管理中
#systemctl enable redis-server
redis启动设置,数据目录,日志目录
#vim /lib/systemd/system/redis-server.service
ReadWriteDirectories=-/data/redis
ReadWriteDirectories=-/data/logs/redis#systemctl daemon-reload //重载service unit命令
redis日志目录,数据目录权限,所属组变更
#mkdir /data/logs/redis/redis-server.log
#chown -R redis:redis /data/logs/redis
#mkdir /data/redis
#chown -R redis:redis /data/redis
启动redis
#systemctl start redis-server.service