Redis: Failed opening .rdb for saving: Permission

2019-01-17 14:57发布

I have a redis server 2.8 installed using ubuntu apt-get on ubuntu 12.04.

I have copied a dump.rdb from an other database. Now when I try to start the new server, I constantly get:

[35763] 04 Mar 01:51:47.088 * 1 changes in 900 seconds. Saving...
[35763] 04 Mar 01:51:47.088 * Background saving started by pid 43313
[43313] 04 Mar 01:51:47.088 # Failed opening .rdb for saving: Permission denied

How can I solve this?

标签: redis
11条回答
祖国的老花朵
2楼-- · 2019-01-17 15:35

I spent some time on this until i realised that my cmd line session was running in the wrong drive :/. Just in case this might help anyone else!

查看更多
淡お忘
3楼-- · 2019-01-17 15:37

My /lib/system/systemd/redis-server.service file contained the following:

ReadOnlyDirectories=/
ReadWriteDirectories=-/var/lib/redis

My /etc/redis/redis.conf file stated that the database should be located in /data/redis

dir /data/redis

The systemd config file above effectively makes /data/redis read-only.

Once I changed the redis.conf file to read:

dir /var/lib/redis

I stopped getting the error.

查看更多
Summer. ? 凉城
4楼-- · 2019-01-17 15:38

You should check your redis.conf file to see the permissions in dir and dbfilename. If the file named in the dbfilename which is located in the path specified in the dir path exists and the permission is also right. then the problem should be fixed.

Hope this will help someone.

P.S.

To find the redis.conf file location, you can use the #ps ax | grep redis to check. Usually it will be passed to the redis-server as input file.

For the dir permissions:it should be 755, for the dbfilename, it should be 644

Sometimes you also need to use top command to check whether the user:group of the redis-server and the owner of dir are consistent. i.e. The redis-server is running by redis:redis, but the dir is under root:root. In this case, you need to chown redis:redis -R dir.

查看更多
Explosion°爆炸
5楼-- · 2019-01-17 15:39

For windows only : This means the user does not have permission for this. BY default owner of this file is NETWORK SERVICE, which has very limited access and need to changed(as per documentation)

solution :

  1. go to ur redis folder.

  2. right click --> go to properties--> security tab.

  3. click on advanced.

  4. click on Add to add ur user.

  5. click on select a principal.

  6. enter ur user (for eg GLOBAL\xxx).

  7. click on check names and click on ok

  8. give permissions to this user.

  9. finally change the owner to this user.

查看更多
Evening l夕情丶
6楼-- · 2019-01-17 15:39

If anyone encounters this again and doesn't have a problem upgrading, just upgrade your Redis installation to the latest version. I encountered this problem with Redis 2.8.15, and upgraded to Redis 2.8.22 that was available at the time of this writing. A sysadmin in my company assured me that this was a bug with Redis 2.8.15, and the problem just went away after upgrading.

查看更多
登录 后发表回答