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 working principle and replication mode of redis master-slave replication

2025-03-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article will explain in detail the working principle and replication mode of redis master-slave replication, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

The master-slave replication mechanism of Redis enables the slave server (slave) to accurately copy the data of the master server (master), as shown in the following figure:

The figure above shows a master server and a slave server. In fact, a master server can also correspond to multiple slave servers, as shown in the following figure:

In addition, the slave server can also have its own slave server, which is called sub-slave, and these sub-slave can also be consistent with master through master-slave replication of the final data, as shown in the following figure:

The way and working principle of master-slave replication

The master-slave replication of Redis is asynchronous replication, which is divided into two aspects: one is that the master server is asynchronous when synchronizing data to slave, so the master server can still receive other requests here, and the other is that slave is also asynchronous when receiving synchronous data.

Replication mode

Redis master-slave replication is divided into the following three ways:

First, when the master server connects with the slave server normally, the master server will send data commands to the slave server and copy the changes of its own data to the slave server.

Second, when the master server is disconnected from the slave server for various reasons, the slave server will try to get the unsynchronized data after the disconnection, that is, partial synchronization, or partial replication, when reconnecting to the master server.

Third, if partial synchronization is not possible (such as initial synchronization), a full synchronization will be requested. At this time, the master server will send its own rdb file to the slave server for data synchronization, and record other writes during the synchronization period, and then send it to the slave server to achieve complete synchronization. This method is called full replication.

On the working principle of redis master-slave replication and replication mode to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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