systemctl 启动redis

这次经历主要是一次错误原因的查看过程。
我登陆用户为root
进行了启动redis服务

redis-server /etc/redis.conf

然后杀死了redis服务后,想直接配置为系统启动方式–systemctl

systemctl enable redis
systemctl start redis

启动失败,开始提示我使用 journalctl -ex 可以查看详情
确实可以看到一个错误

-- Unit redis.service has begun starting up.
8月 20 10:58:40 VM_0_12_centos redis-server[4343]: *** FATAL CONFIG FILE ERROR ***
8月 20 10:58:40 VM_0_12_centos redis-server[4343]: Reading the configuration file, at line 163
8月 20 10:58:40 VM_0_12_centos redis-server[4343]: >>> 'logfile /var/log/redis/redis.log'
8月 20 10:58:40 VM_0_12_centos redis-server[4343]: Can't open the log file: Permission denied
8月 20 10:58:40 VM_0_12_centos systemd[1]: redis.service: main process exited, code=exited, status=1
8月 20 10:58:40 VM_0_12_centos redis-shutdown[4344]: Could not connect to Redis at 127.0.0.1:6379: C
8月 20 10:58:40 VM_0_12_centos systemd[1]: redis.service: control process exited, code=exited status
8月 20 10:58:40 VM_0_12_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.
--
-- The result is failed.

可以发现是对日志文件/var/log/redis/redis.log权限不足
查看了该文件属于root用户root组。
然后查看服务文件配置

cat /lib/systemd/system/redis.service
//显示
[Unit]
Description=Redis persistent key-value database
After=network.target

[Service]
ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd
ExecStop=/usr/libexec/redis-shutdown
Type=notify
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=0755

[Install]
WantedBy=multi-user.target

说明这个服务系统启动后是redis组的,所以改文件权限为redis组即可

chown redis:redis /var/log/redis/redis.log
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值