Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable persistence with redis?

Tags:

redis

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!

like image 379
Cenoc Avatar asked Feb 28 '15 18:02

Cenoc


People also ask

Is Redis persistent by default?

By default Redis saves snapshots of the dataset on disk, in a binary file called dump. rdb . You can configure Redis to have it save the dataset every N seconds if there are at least M changes in the dataset, or you can manually call the SAVE or BGSAVE commands. This strategy is known as snapshotting.

How do I disable Redis?

If you started the Redis server using the redis-server command, you could stop the Redis server by pressing CTRL + C.

Is Redis good for persistence?

Redis PersistenceNo persistence: Redis can be entirely ephemeral with no persistence at all. Our data is only available while the server is running, and if for some reason the server was terminated or rebooted our data is lost.


2 Answers

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.

like image 119
Itamar Haber Avatar answered Sep 19 '22 00:09

Itamar Haber


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)

like image 22
Kostis Avatar answered Sep 21 '22 00:09

Kostis