Redis Persistence

2020-09-07  本文已影响0人  黄耀鸿

Redis is a caching server but it offers some ways to persist the database, so the db can be recovered when the service shut down unexpectingly.

There are two ways to dump the data:

It is possible to combine RDB and AOF in single instance. If both are on, redis will using AOF file to reconstruct the original dataset since it is guaranteed to be the most complete.

RDB

How to configure RDB?

By default Redis save snapshots of dataset on disk, in binary file named dump.rdb.

We can configure redis to have it saved the dataset every N second if there are M keys change in the database.

We can trigger redis to dump dataset by 'SAVE' or 'BGSAVE' commands.

For example, command SAVE 600 1000 means Redis will dump database in every 600 seconds if at least 1000 keys change.

AOF (Append-only File)

AOF is another way to persist redis dataset, which append the key to binary file every time it receive a write command.

We can use command appendonly yes to turn AOF on.

REFERENCE:

https://redis.io/topics/persistence

上一篇 下一篇

猜你喜欢

热点阅读