1, from a painting of the flowchart.
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/86/4B/wKiom1e7NCrwhi7oAADQH_X2UQ4191.png-wh_500x0-wm_3 -wmp_4-s_4219506885.png "title=" Qq20160823011928.png "alt=" Wkiom1e7ncrwhi7oaadqh_x2uq4191.png-wh_50 "/>
2. Simple description of MySQL master-slave replication principle process
2, 1 (corresponding to step 1)
Execute the start slave command on the slave server to turn on the master-slave copy switch and start the master-slave replication.
2, 2 (corresponding to step 2)
At this point, the I/O thread of the slave server connects to the master server by requesting a copy user right that is already authorized on master, and requests a specified location from the specified Binlog log file (the log file name and location are the change when the master-slave configuration Replication Service is configured The Binlog log content is sent after the master command has been specified.
2, 3 (corresponding to step 3)
After the master server receives a request from an I/O thread from the slave server, the I/O thread on which the replication is responsible reads the Binlog log information from the specified Binlog log file in batches based on the information requested by the I/O thread of the slave server. The I/O thread is then returned to the slave side. In addition to the Binlog log content, the returned information has a new Binlog file name recorded on the master server side, and the next specified update location in the new Binlog.
2, 4 (corresponding to step 4)
When the slave I/O thread obtains the log content, log files, and location points sent by the I/O thread on the master server, the Binlog log contents are written sequentially to the relay of the slave side itself Log (that is, the trunk log) file (mysql-relay-bin.xxxxxx), and record the new Binlog file name and location to the Master-info file so that the next time you read the new Binlog log on the master, you can tell the master server to new Binlog day The specified file and location of the log begins to request a new Binlog journal content.
2, 5 (corresponding to step 5)
The SQL thread on the slave server will detect the added log contents of the I/O lines in the local relay log in real time, then parse the contents of the relay log file into SQL statements in a timely manner, and execute the SQL statements in the order of the SQL statement on its own slave server. The file name and location point of the current application relay log are recorded in Relay-log.info.
3. Precautions
Master-info records the new Binlog file name and file location.
Relay-log.info records the file name and file location of the current relay log (trunk log).
Relay log (trunk log) records the contents of the real log (Binlog).
This article is from the "You can choose Extraordinary" blog, please be sure to keep this source http://ylcodes01.blog.51cto.com/5607366/1841303
MySQL master-slave replication principle process