Mysql master-slave replication (master-slave replication) Mysql master-slave replication
Synchronous replication
Synchronous replication is a process in which the binlog has been sent to the slave database through the dump thread after the master database commits the transaction. The master database waits for the slave database to confirm the commit. After the slave database completes the replay, the master database replies with an ACK to the master database. The longer the main library waits, the longer it needs to wait out a timeout.
Asynchronous replication
In asynchronous replication mode, to solve the problem that the master database waits too long, the confirmation return is cancelled. That is, after the master database commits the transaction, the master database does not need to wait for the confirmation of the slave database. However, this can cause a problem: when the host hangs after the transaction has been committed, but the binlog has not been synchronized to the slave, forcing a master/slave switch will result in incomplete data for the new master
Semi-synchronous replication
Semi-synchronous is a compromise between synchronous and asynchronous replication: Also the main library or from libraries need to wait for confirmation to perform follow-up after operation, but the difference is this time will not wait from the library after submit the transaction, to send a confirmation to the main library, but after the binlog wrote relaylog from library, will send confirmation to the main library, this not only shorten the waiting time and maintain the security of data
Enhanced semi-synchronous replication
Under the condition of semi synchronous replication if there is such a situation: when the main library after submit the transaction, began to wait from library relay in return, if the accident happened at this time from the library (likely was stolen), leading to the main library waiting timeout, this time the main library will directly to the end of waiting, because the transaction has been submitted, To address this, mysql5.7 introduced enhanced semi-synchronous replication: a transaction is committed only after receiving at least one write acknowledgement from the relay log returned from the library
There will be a large number of interview materials and architect must-see books waiting for you to choose, including Java foundation, Java concurrency, micro services, middleware and more information waiting for you to take oh.