Home  >  Article  >  Database  >  When does redis master-slave replication replicate?

When does redis master-slave replication replicate?

(*-*)浩
(*-*)浩Original
2019-11-21 09:08:382960browse

When does redis master-slave replication replicate?

The master-slave replication mechanism of Redis allows the slave server (slave) to accurately copy the data of the master server (master), as shown in the following figure: ( Recommended learning: Redis video tutorial)

When does redis master-slave replication replicate?

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

When does redis master-slave replication replicate?

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

When does redis master-slave replication replicate?

Master-slave replication method and working principle

Redis’ master-slave replication is asynchronous replication. Asynchronous is divided into two aspects. One is that the master server is asynchronous when synchronizing data to the slave, so the master server can still receive other requests here. The other is The slave is also asynchronous when receiving synchronous data.

Replication method

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

1. When master When the server and slave server are connected normally, the master server will send a data command stream to the slave server and copy its own data changes to the slave server.

2. When the master server is disconnected from the slave server for various reasons, the slave server will try to reacquire the unsynchronized data after the disconnection, that is, partial synchronization, when the slave server reconnects to the master server. Called partial replication.

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

The above is the detailed content of When does redis master-slave replication replicate?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn