Mysql synchronizes bitsCN.com
Mysql Replication is an asynchronous Replication process, from one Mysql instace (we call it the Master) to another Mysql instance (we call it the Slave ). The entire replication process between the Master and Slave is mainly completed by three threads, two of which (SQL thread and IO thread) are on the Slave side, and the other (IO thread) on the Master side. To implement MySQL Replication, you must first enable the Binary Log (mysqlbin. xxxxxx) function on the Master side. Otherwise, it cannot be implemented.
1. the IO thread on the Slave connects to the Master, and requests the log content after the specified location of the specified log file (or from the beginning of the log;
2. after the Master receives a request from the Slave IO thread, it reads the log information at the specified location of the specified log based on the request information and returns it to the Slave IO thread. In addition to the information contained in the Log, the returned information also includes the name of the Binary Log file on the Master end and its location in the Binary Log;
3. after the Slave IO thread receives the information, it writes the received Log content to the end of the Relay Log file (mysql-relay-bin.xxxxxx) at the Slave end in sequence, and record the file name and location of the read binlog on the Master end to the master-info file, so that the next read can clearly show the high-speed Master "I need to start from the location of a bin-log, please send it to me"
4. after the Slave SQL thread detects the newly added content in the Relay Log, it will immediately parse the content in the Log file into the executable Query statements during actual execution on the Master end, and execute these queries on your own. In this way, the same Query is actually executed on the Master and Slave ends, so the data at both ends is exactly the same.
BitsCN.com