Redis fails to start after reboot ("Can't open the log file: Permission denied")

0

I've ran into a problem with my Redis 4.09 installation on Ubuntu 18.04. Each time I reboot the machine the /var/log/redis/redis-server.log ends up being owned by 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: -

This results in the redis.service refusing to start. The same thing happens when I invoke redis-server directly:

# 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

Alphakilo23

Posted 2019-01-11T21:53:47.663

Reputation: 11

Answers

1

Eh. Solved it. Slightly embarrassing.
I botched an usermod and the redis-user ended up in the www-data group as the primary group:

# groups redis
redis : www-data

The fix was usermod -g redis redis.

Alphakilo23

Posted 2019-01-11T21:53:47.663

Reputation: 11