Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis is configured to save RDB snapshots, but is currently not able to persist on disk

Tags:

redis

I get the following error, whenever I execute any commands that modify data in redis

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

I installed redis using brew on mac. How can I get the location of log files where redis-server logs information to. I tried looking for redis conf. file, but couldn't find it either.

What is the default location of [1] redis conf file [2] redis log file.

How do I get rid of the above error, and be able to execute commands that modify data in redis.

like image 972
user462455 Avatar asked Nov 09 '13 06:11

user462455


2 Answers

When installing with brew the logfile is set to stdout. You need to edit /usr/local/etc/redis.conf and change logfile to something else. I set mine to:

logfile /var/log/redis-server.log 

You'll also make sure the user that runs redis has write permissions to the logfile, or redis will simply fail to launch completely. Then just restart redis:

brew services restart redis 

After restarting it'll take a while for the error to show up in the logs, because it happens after redis fails its timed flushes. You should be seeing something like:

[7051] 29 Dec 02:37:47.164 # Background saving error [7051] 29 Dec 02:37:53.009 * 10 changes in 300 seconds. Saving... [7051] 29 Dec 02:37:53.010 * Background saving started by pid 7274 [7274] 29 Dec 02:37:53.010 # Failed opening .rdb for saving: Permission denied 

After a brew install it attempts to save to /usr/local/var/db/redis/ and since redis is probably running as your current user and not root, it can't write to it. Once redis has permission to write to the directory, your logfile will say:

[7051] 29 Dec 03:08:59.098 * 1 changes in 900 seconds. Saving... [7051] 29 Dec 03:08:59.098 * Background saving started by pid 8833 [8833] 29 Dec 03:08:59.099 * DB saved on disk [7051] 29 Dec 03:08:59.200 * Background saving terminated with success 

and the stop-writes-on-bgsave-error error will no longer get raised.

like image 199
Kit Sunde Avatar answered Sep 21 '22 02:09

Kit Sunde


So I guess it is a bit late for adding an answer here but since I wondered on your question as I had the same error. I got it solved by changing my redis.conf 's dir variable like this:

# The filename where to dump the DB
dbfilename dump.rdb

# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
# 
# The Append Only File will also be created inside this directory.
# 
# Note that you must specify a directory here, not a file name.
dir /root/path/to/dir/with/write/access/

The default value is: ./, so depending on how you launch your redis server you might not be able to save snapshots.

Hope it helps someone !

like image 38
mcorbe Avatar answered Sep 21 '22 02:09

mcorbe