MySQL semi-synchronous replication practices
Semi-synchronous Replication
MySQL master-slave replication only supports asynchronous replication before MySQL 5.5. That is to say, after the master database executes some transactions, no matter the progress of the slave database, the biggest advantage of this method is fast speed and high efficiency. The disadvantage is that the data consistency between the slave database and the master database cannot be ensured after the master database is down.
The advantage of semi-synchronous replication is that after each transaction is executed, the master database will wait for the slave database to accept the log before returning it to the client. If a small transaction is performed, if the latency of the two hosts is small, zero data loss can be ensured when the performance is low.
Principle
1) each time the master database executes a transaction, the slave database reads the log first to ensure that at least one slave database has the complete data
2) If the master database still does not receive a response from the slave database within a timeout period, the system automatically switches q back to the asynchronous mode to ensure business operation.
3) semi-synchronous replication can only ensure that logs are read from the slave database, and data cannot be written to the slave database. You must also check the execution of the slave Database SQL process.
4) if a slave database catches up with the master database, the mode continues to switch back to the semi-sync status.
Environment Construction practices
The MySQL semi-synchronous replication plug-in is provided by Google. It can be directly used after MySQL 5.5.
!! Note that the master-slave replication must be implemented before the two hosts implement semi-synchronous replication.
Refer to blog: