redis服务失败,附加文件的权限被拒绝

问题描述 投票:0回答:1

我的redis服务(从源安装)在/var/log/redis.log中失败并显示此消息

2309:C 16 Mar 2019 20:16:10.633 # Redis version=5.0.3, bits=64, commit=00000000, modified=0, pid=2309, just started
2309:C 16 Mar 2019 20:16:10.633 # Configuration loaded
2311:M 16 Mar 2019 20:16:10.634 # Can't open the append-only file: Permission denied

然而:

root@redis:~# sudo su - redis
redis@redis:~$ touch /var/lib/redis/foobar.txt
redis@redis:~$ echo $?
0

这是我的/etc/redis.conf

root@redis:~# cat /etc/redis.conf 
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes
dir /var/lib/redis
daemonize yes
logfile "/var/log/redis.log"

这是我的redis自定义单元文件

root@redis:~# cat /etc/systemd/system/redis.service 
Description=Redis In-Memory Data Store                       
After=network.target                                         

[Service]                                                    
Type=forking                                                 
User=redis                                                   
Group=redis                                                                                
PermissionsStartOnly=true                                                              
ExecStop=/bin/kill -s TERM $MAINPID
PIDFile=/var/run/redis/redis-server.pid
ExecStart=/opt/redis-stable/src/redis-server /etc/redis.conf
Restart=always                                               
RestartSec=3                                                 
LimitNOFILE=65535
ReadWriteDirectories=-/var/lib/redis
ReadOnlyDirectories=/
ReadWriteDirectories=-/var/lib/redis
ReadWriteDirectories=-/var/log/redis
ReadWriteDirectories=-/var/run/redis



[Install]                                                    
WantedBy=multi-user.target  
redis
1个回答
0
投票

错误是redis无法写入仅附加文件。默认情况下,仅附加文件放在启动redis的目录中。

我的猜测是redis用户在启动的位置没有写访问权限。只需确保从redis用户有权访问的woring目录启动redis。

要阅读有关AOF文件的更多信息,请查看文档:http://redis.io/topics/persistence

© www.soinside.com 2019 - 2024. All rights reserved.