Redis 重启后无法启动(“无法打开日志文件:权限被拒绝”)

Redis 重启后无法启动(“无法打开日志文件:权限被拒绝”)

我在 Ubuntu 18.04 上安装 Redis 4.09 时遇到了问题。每次我重新启动机器时,它/var/log/redis/redis-server.log最终都归以下所有www-data:www-data

# namei -l /var/log/redis/redis-server.log
f: /var/log/redis/redis-server.log
drwxr-xr-x root     root     /
drwxr-xr-x root     root     var
drwxrwxr-x root     syslog   log
drwxr-x--- redis    redis    redis
-rw-r----- www-data www-data redis-server.log


# stat /var/log/redis/redis-server.log

  File: /var/log/redis/redis-server.log
  Size: 0           Blocks: 0          IO Block: 4096   regular empty file
Device: fc04h/64516d    Inode: 131151      Links: 1
Access: (0640/-rw-r-----)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2019-01-01 06:25:03.050853905 +0100
Modify: 2019-01-01 06:25:03.050853905 +0100
Change: 2019-01-01 06:25:03.050853905 +0100
 Birth: -

这导致 redis.service 拒绝启动。当我直接调用 redis-server 时也会发生同样的事情:

# sudo -u redis redis-server /etc/redis/redis.conf 

*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 171
>>> 'logfile /var/log/redis/redis-server.log'
Can't open the log file: Permission denied

答案1

呃。解决了。有点尴尬。
我搞砸了usermod,用户redis最终成为该www-data组的主要组:

# groups redis
redis : www-data

解决办法是usermod -g redis redis

相关内容