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!
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.
Redis has two persistence mechanisms: RDB and AOF. RDB uses a scheduler global snapshooting and AOF writes update to an apappend-only log file similar to MySql. You can use one of them or both. When Redis reboots,it constructes data from reading the RDB file or AOF file.
As previously stated, snapshotting is the default persistence mode for Redis. It asynchronously performs a full dump of your database to disk, overwriting the previous dump only if successful. Therefore, the latest dump should always be in your dbfilename location.
No 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.
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
you should turn on the rdb or aof.
see https://redis.io/topics/persistence
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With