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

giliev picture giliev · May 14, 2017 · Viewed 8.8k times · Source

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!

Answer

Seyed Mehran Siadati picture Seyed Mehran Siadati · Feb 10, 2018

Use dpkg -L | 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