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

How to realize Master-Slave synchronization in redis

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

Share

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

How does redis achieve master-slave synchronization? In response to this problem, today Xiaobian summarized this article, hoping to help more friends who want to solve this problem find a simpler and easier way.

Redis master-slave replication can be divided into full synchronization and incremental synchronization according to whether it is full.

1 Total synchronization

The full synchronization process of Redis is mainly divided into three stages:

Synchronous snapshot phase: Master creates and sends snapshot to Slave,Slave loads and parses snapshot. The Master also stores new write commands generated during this phase into the buffer.

Synchronous write buffer phase: Master synchronizes write commands stored in buffer to Slave.

Synchronous increment phase: Master writes synchronous operation commands to Slave.

After completing the above steps, all operations of data initialization from the server are completed, and the slave server can now receive read requests from users.

2 incremental synchronization

Redis incremental synchronization mainly refers to the process of synchronizing the write operations of the Master to the Slave when the Slave starts working normally after initialization. Typically, every time a Master executes a write command, it sends the same write command to the Slave, which then receives and executes it.

3 Redis master-slave synchronization strategy

When the master and slave are just connected, full synchronization is performed; after full synchronization is completed, incremental synchronization is performed. Of course, slaves can initiate full synchronization at any time if needed. The redis strategy is to try incremental synchronization first anyway, and if unsuccessful, require full synchronization from the slave.

About redis to achieve master-slave synchronization scheme to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.

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