Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MISCONF Redis is configured to save RDB snapshots

Tags:

redis

During writes to Redis ( SET foo bar ) I am getting the following error:

MISCONF 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.

Basically I understand that the problem is that redis is not able to save data on the disk, but have no idea how to get rid of the problem.

Also the following question has the same problem, it is abandoned long time ago with no answers and most probably no attempts to solve the problem.

like image 877
Salvador Dali Avatar asked Oct 25 '13 04:10

Salvador Dali


People also ask

What is RDB snapshot?

Important: RDB snapshots are point in time snapshots of instance data based on the snapshot interval you set. Your application must be able to to tolerate some staleness of data on recovery. When enabled, RDB snapshots make a best effort to ensure backups occur on the specified interval, but this cannot be guaranteed.

What is Redis RDB?

RDB is a very compact single-file point-in-time representation of your Redis data. RDB files are perfect for backups. For instance you may want to archive your RDB files every hour for the latest 24 hours, and to save an RDB snapshot every day for 30 days.

Where is Redis RDB?

rdb file in the /var/lib/redis/ directory. You'll want to update the permissions so the file is owned by the redis user and group: sudo chown redis:redis /var/lib/redis/dump.

How do I make Redis persistent?

Within Redis, there are two different ways of persisting data to disk. One is a method called snapshotting that takes the data as it exists at one moment in time and writes it to disk. The other method is called AOF, or append—only file, and it works by copying incoming write commands to disk as they happen.


4 Answers

Using redis-cli, you can stop it trying to save the snapshot:

config set stop-writes-on-bgsave-error no

This is a quick workaround, but if you care about the data you are using it for, you should check to make sure why bgsave failed in first place.

like image 94
思考zhe Avatar answered Oct 21 '22 05:10

思考zhe


Restart your redis server.

  • macOS (brew): brew services restart redis.
  • Linux: sudo service redis restart / sudo systemctl restart redis
  • Windows: Windows + R -> Type services.msc, Enter -> Search for Redis then click on restart.

I personally had this issue after upgrading redis with Brew (brew upgrade). After rebooting the laptop, it immediately worked.

like image 37
Erowlin Avatar answered Oct 21 '22 06:10

Erowlin


In case you encounter the error and some important data cannot be discarded on the running redis instance (problems with permissions for the rdb file or its directory incorrectly, or running out of disk space), you can always redirect the rdb file to be written somewhere else.

Using redis-cli, you can do something like this:

CONFIG SET dir /tmp/some/directory/other/than/var
CONFIG SET dbfilename temp.rdb

After this, you might want to execute a BGSAVE command to make sure that the data will be written to the rdb file. Make sure that when you execute INFO persistence, bgsave_in_progress is already 0 and rdb_last_bgsave_status is ok. After that, you can now start backing up the generated rdb file somewhere safe.

like image 245
Axel Advento Avatar answered Oct 21 '22 06:10

Axel Advento


There might be errors during the bgsave process due to low memory. Try this (from redis background save FAQ)

echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
sysctl vm.overcommit_memory=1
like image 72
Chris Avatar answered Oct 21 '22 07:10

Chris