Get the App
SLTechnology News&Howtos  ›  Database  › 

The implementation method of redis data persistence

Shulou Source: shulou.com Published: 2022-06-01 04:31:49 09月16日 Update

Editor to share with you the implementation of redis data persistence, I hope you will learn a lot after reading this article, let's discuss it together!

There are two ways to implement data persistence in Redis:

RDB: saves a snapshot of data within a specified time interval

AOF: append commands to the end of the operation log to save all historical operations

1. RDB implements Redis data persistence (default)

1. Edit redis.conf

Note: use the whereis redis command to see where redis is installed, then go to the etc directory of the redis installation directory and edit redis.conf.

2. Default backup interval

3. The file name of the default backup

4. Default backup RDB file location

5. You can also actively trigger saving redis data snapshots, as follows

6. Shortcomings

Because it is persisted under certain conditions (at regular intervals), it may result in partial data loss once the redis crashes and recovers again.

II. AOF persistence scheme

First append the command to the end of the operation log to save all historical operations.

1. Compared with RDB persistence scheme, the advantages are as follows:

(1) the data is very complete and less data is lost in fault recovery.

(2) Historical operations can be handled.

2. How to turn on AOF persistence mode

After changing the appendonly parameter in the redis.conf configuration file to yes, redis starts to start AOF data persistence mode

Sets the mode of AOF synchronization. The default synchronization set here is once per second.

3. When AOF synchronization mode is enabled, the backup file looks like this

As you can see from the above, it records all the operation commands since I opened AOF.

4. Shortcomings

(1) because AOF mode records every step of the redis command, the size of the file will be very large.

(2) and it will result in lower speed than RDB and slow recovery.

After reading this article, I believe you have a certain understanding of the implementation of redis data persistence, want to know more related knowledge, welcome to follow the industry information channel, thank you for reading!

Tags: Data commands files backup mode history method time synchronization method location tail snapshot scheme log directory article disadvantage speed very large Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Shulou Information MariaDB MySQL Xiaomi