How to disable persistence with redis?

Redis

Redis Problem Overview


I was wondering how to disable presistence in redis. There is mention of the possibility of doing this here: http://redis.io/topics/persistence. I mean it in the exact same sense as described there. Any help would be very much appreciated!

Redis Solutions


Solution 1 - Redis

To disable all data persistence in Redis do the following in the redis.conf file:

  1. Disable AOF by setting the appendonly configuration directive to no (it is the default value). like this:

    appendonly no
    
  2. Disable RDB snapshotting by commenting all of the save configuration directives (there are 3 that are defined by default) and explicitly disabling saving:

    #save 900 1
    #save 300 10
    #save 60 10000
    save ""
    

After change, make sure you restart Redis to apply them.

Alternatively, you can use the CONFIG SET command to apply these changes during runtime (just make sure you also do a CONFIG REWRITE to persist the changes).

Note: depending on your Redis' version, there are other tweaks that prevent Redis from accessing the disk for replication-related tasks.

Solution 2 - Redis

If you want to avoid playing with redis.conf (dev/test environments), you can do it through the command line with

redis-server --save "" --appendonly no

(tested with redis server 3.2.6 and 5.0.5)

Solution 3 - Redis

As AOF (appendonly) is disabled by default, there is only one thing that is to be done for disabling persistence without redis service restart is to disable save configuration.

For disabling it on runtime and verifying run below commands

Check current save configuration

pawan@devops:~$ redis-cli config get save
1) "save"
2) "900 1 300 10 60 10000"

Same setting will be present in redis.conf file as well

pawan@devops:~$ grep -w 'save' /etc/redis/redis.conf | grep -v '#'
save 900 1
save 300 10
save 60 10000

Disable save configuration

pawan@devops:~$ redis-cli config set save ""
OK

Modify redis.conf file with the new save configuration so that the configuration remains permanent on redis service restarts

root@ip-172-16-3-114:~# redis-cli config rewrite
OK

Confirm the new save configuration

pawan@devops:~$ redis-cli config get save
1) "save"
2) ""

Now if you will scan the redis.conf file for save configuration there won't be any results

pawan@devops:~$ grep -w 'save' /etc/redis/redis.conf | grep -v '#'  
pawan@devops:~$

Solution 4 - Redis

For RDB snapshotting you can disable it by using

$ sed -e '/save/ s/^#*/#/' -i /etc/redis/redis.conf && sudo service redis-server restart

It will comment the save lines in redis.conf and restarts the redis-server

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCenocView Question on Stackoverflow
Solution 1 - RedisItamar HaberView Answer on Stackoverflow
Solution 2 - RedisKostisView Answer on Stackoverflow
Solution 3 - RedisPKSinghView Answer on Stackoverflow
Solution 4 - RedisNaren YellavulaView Answer on Stackoverflow