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

RDB data persistence (theory)

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

Share

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

Persistence principle:

RDB is snapshot snapshot storage and is the default persistence method.

RDB will periodically save the data to disk according to a certain strategy. (the next cycle will be a failure on arrival, and data will be lost)

With the help of the copy on write mechanism of the fork command, the current process is fork out of a child process when the snapshot is generated.

Then cycle through all the data in the child process and write the data into a RDB file.

Advantages: using a single child process for persistence, the main process will not do any IO operation, ensuring the high performance of redis.

Disadvantages: RDB is persisted according to periodic strategy

If redis fails during persistence, data loss will occur.

So this method is suitable for the environment where the data requirements are not strict.

Profile related parameters:

Dbfilename dump.rdb # specify persistent data file name

Dir / usr/local/redis-3.0.6-6379 / # default dir. /

Save 900 1

Save 300 10

Save 60 10000

Persistence process:

When the conditions of save are met, such as changing 1 key,900s, the data will be written to a temporary file.

Replace the temporary file with the old dump.rdb when the persistence is complete.

Use RDB to recover data: (it takes time)

Restart the server of redis (data will be synchronized from dump.rdb when starting server of redis)

Use the command to persist save storage:

. / redis-cli-h ip-p port save # Front desk for storage

. / redis-cli-h ip-p port bgsave # storage in the background

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