How to configure Redis to persist data after reboot on Linux?

14.5k Views Asked by At

I installed Redis on Ubuntu 16.04. I couldn't find Redis directory nor redis.conf file (tried with: sudo find redis.conf).

My application depends on some data pulled from third party APIs. I store the (processed) data in Redis. My problem is, after reboot I lose the data. I guess I need to specify in config file that the data should be persisted on reboot, but I couldn't find the config file. Do I need to create the config file? Are there some templates to use? My goal is just to have the data persisted after reboot.

Thank you!

3

There are 3 best solutions below

3
On

Add this to the config file.

appendonly yes

This will append data as you store new data. This enables durability.

0
On

you should turn on the rdb or aof.

see https://redis.io/topics/persistence

3
On

Use dpkg -L redis-server | grep redis.conf to find config file path. It should be located at /etc/redis/redis.conf as I know.

Redis has 2 methods for persistense: Snapshotting and Append-only file:

  • Snapshotting will be enabled by adding (or uncommenting) save X Y in config file. It means Redis will automatically dump the dataset to disk every X seconds if at least Y keys changed. There could be more than one save options in config file.

  • Append-only file will be enabled by adding (or uncommenting) appendonly yes in config file