Failed opening .rdb for saving: Permission denied

4,814 views
Skip to first unread message

Robert F

unread,
Oct 17, 2016, 5:58:50 PM10/17/16
to Redis DB
I'm running Redis server 2.8.17 on a Debian server 8.5.  I'm using Redis as a session store for a Django 1.8.4 application.

I haven't changed the software configuration on my server for a couple of months and everything was working just fine until a week ago when Django began raising the following error:

    MISCONF Redis is configured to save RDB snapshots but is currently not able to persist to disk.  Commands that may modify the data set are disabled.  Please check Redis logs for details...

I checked the redis log and saw this happening about once a second:

    1 changes in 900 seconds.  Saving...
    Background saving started by pid 22213
    Failed opening .rdb for saving: Permission denied
    Background saving error

ps shows that user "redis" is running the server:

    redis   26769   ...   /usr/bin/redis-server *.6379

I checked my config file for the redis file name and path:

    grep ^dir /etc/redis/redis.conf shows:
    dir /var/lib/redisredis/redis.conf

    grep ^dbfilename /etc shows:
    dbfilename dump.rdb

The permissons on /var/lib/redis are 755 and it's owned by redis:redis.
The permissons on /var/lib/redis/dump.rdb are 644 and it's owned by redis:redis too.

I also ran strace on the server process:

    ps -C redis-server  # pid = 26769
    sudo strace -p 26769 -o /tmp/strace.out

But when I examine the output, I don't see any errors.  In particular I don't see a "Permission denied" error as I would expect.

Also, /var/lib/redis is not an NFS directory.

Does anyone know what else could be causing this?  I'd hate to have to stop using Redis.  I know I can run the command "set stop-writes-on-bgsave-error yes" but that doesn't solve the problem.

This is now happening on a daily basis and the only way I can stop the error is to restart the Redis server.

Thanks.

George Chilumbu

unread,
Oct 18, 2016, 5:14:47 AM10/18/16
to Redis DB
I would suggest you first locate where your redis dir is:

ubuntu@redis:~$ redis-cli config get dir
1) "dir"
2) "/var/lib/redis"

Then check permissions:

ubuntu@redis:~$ ls -lh /var/lib/redis/
total 16K
drwxr-xr-x  2 redis 4.0K Oct 18 15:38 ./
drwxr-xr-x 57 root  4.0K Sep 21 18:09 ../
-rw-rw----  1 redis  102 Oct 18 15:38 dump.rdb
-rw-r-----  1 redis  112 Jul 26 11:52 nodes.conf
ubuntu@redis:~$


So you wanna make sure that rdis has permissions on the dump.rd file. 
sudo chown redis:redis -R /var/lib/redis/

If this does not work, try setting redis permissions on the root directory instead

sudo chown redis:redis -R /var/


Message has been deleted

Robert F

unread,
Oct 18, 2016, 11:54:10 AM10/18/16
to Redis DB
Thanks George.  I did the first three steps you suggested as I described in my question.  As for your last suggestion, it should not be necessary to give redis ownership of all of /var.  With Unix permissions, you should only need to change the permissions of the directory that file in question resides in, not all the ancestor directories.

George Chilumbu

unread,
Oct 19, 2016, 4:29:36 AM10/19/16
to Redis DB
Glad it worked. ABout Linux permissions, you are right. That why i only suggested that as a last resort if the first three steps do not work for some reason.


sort 

hva...@gmail.com

unread,
Oct 26, 2016, 5:21:54 PM10/26/16
to Redis DB

Connect to your running Redis server process and verify its configuration is the one you expect.  I.e., verify with 'CONFIG GET *' that the snapshot file name and directory are still the same as in the config file.

If the running configuration is different, that's likely the reason you're getting the error.

  -Greg
Reply all
Reply to author
Forward
0 new messages