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

What are the three ways of Mysql master-slave replication?

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

Share

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

This article mainly explains "what are the three ways of Mysql master-slave replication". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the three ways of Mysql master-slave replication?"

Synchronous replication

Synchronous replication means that when the master database commits the transaction, the binlog has been transferred to the secondary log of the slave database through the dump thread. The master database needs to wait for the commit confirmation of the slave database all the time. After the replay of the slave library is completed, reply an ACK to the master database, then the master database ends waiting and performs subsequent operations. Note: if there are multiple slave nodes at this time, the waiting time of the master database will be longer, so you need to set a timeout waiting time.

Insert a picture here to describe asynchronous replication

In order to solve the problem that the waiting time of the master database is too long, the asynchronous replication mode cancels the return confirmation, that is, when the master database commits the transaction, it does not need to wait for the slave library to commit confirmation, it directly performs the follow-up operation and returns to the client. But this will cause such a problem: when the host hangs after committing the transaction, but at this time the binlog has not been synchronized to the slave database. If the master and slave are forced to switch, the data of the new master library will be incomplete.

Insert picture description semi-synchronous copy here

Semi-synchronous mode makes a compromise between synchronous and asynchronous replication: similarly, the master database still needs to wait for the confirmation of the slave library before performing subsequent operations, but the difference is that this time it is not waiting for the slave library to commit the transaction before sending a confirmation notification to the master database, but when the slave library writes the binlog to relaylog, it will send a confirmation notification to the master database, which not only shortens the waiting time but also maintains the security of the data.

Insert a picture description here to enhance semi-synchronous replication

In the case of semi-synchronous replication, if there is such a situation: when the master library commits the transaction, it starts to wait for the relay write of the slave library to return, and if an accident occurs at this time from the slave library (it may be stolen), resulting in the master database waiting timeout, then the master database will directly end the wait, because the transaction has been committed, the user can definitely see the data that has not been synchronized, in order to solve this problem Mysql5.7 introduces enhanced semi-synchronous replication: the transaction is committed only when at least one relay log write acknowledgment returned from the library is received, that is, after the commit transaction receives the acknowledgment

Thank you for your reading, the above is the content of "what are the three ways of Mysql master-slave replication respectively". After the study of this article, I believe you have a deeper understanding of what the three ways of Mysql master-slave replication are, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report