There is a problem with the master library, what should I do with the slave library?

In the previous article, I introduced to you the basic structure of MySQL master-slave replication, but these are all one-master and one-standby structures.

Most Internet application scenarios require more reads and fewer writes. Therefore, the business you are responsible for is likely to encounter read performance problems during the development process. Solving the read performance problem at the database layer involves the architecture to be discussed in the next two articles: one master and multiple slaves.

In today's article, let's talk about the correctness of switching between one master and multiple slaves. Then, in the next article, we will talk about the method to solve the logical correctness of the query with one master and multiple slaves.

As shown in Figure 1, it is a basic one-master-many-slave structure.
insert image description here
In the figure, the dotted arrow indicates the master-backup relationship, that is, A and A' are mutual masters and backups, and the slave libraries B, C, and D point to the master library A. The setting of one master and multiple slaves is generally used for read-write separation. The master library is responsible for all writing and part of reading, and other read requests are shared by the slave library.

What we are going to discuss today is the master-slave switchover after the failure of the master database under the one-master-multiple-slave architecture. As shown in Figure 2, it is the result after the main database fails and the main and standby switches.
insert image description here
Compared with the switching process of one master and one backup, after the switch of one master and multiple slaves is completed, A' will become the new master library, and slave libraries B, C, and D will also be connected to A'. It is precisely because of the process of re-pointing from libraries B, C, and D that the complexity of active-standby switchover also increases accordingly.

Next, let's take a look at how a switching system will complete the master-slave switching process of one master and multiple slaves. Site-based active/standby switchover

Site-based active/standby switchover

Here, we need to review a knowledge point first

Guess you like

Origin blog.csdn.net/yzh_2017/article/details/128665931