Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The implementation method of redis data persistence

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report