MySQL Master-Slave synchronization

Source: Internet
Author: User

MySQL master-Slave synchronization process

The following is from the old boy education

1. Execute start slave on slave server and turn on master-slave copy switch.

2. At this point, the IO thread of the slave server connects to the master server by requesting a copy user authorized on Master and requests that the specified location of the Binlog log file (log file and location is specified when the master-slave Replication service is configured to perform the Change Master command). ) after the Binlog log content.

3. After the master server receives a request from an IO thread from the slave server, the IO thread responsible for replication on the master server reads Binlog log information from the Binlog log file at the specified location according to the IO thread request of the slave server. Then return the IO thread to the slave end, the returned information in addition to the log content, there is the log content returned on the master side of the new Binlog file name and at the specified location in Binlog

4. When the IO thread of the slave server acquires the log content and the log file location point from the IO thread on the master server, the Binlog log content is written sequentially to the relay log (trunk log) file of the slave side itself ( MYSQL-RELAY-BIN.XXXX), and record the new Binlog file name and location into the Master-info file, So that the next time you read the new Binlog log on the master side, you can tell the master server which location to start requesting new Binlog log content from the file from the newly binlog log.

5. The SQL thread of the slave server checks the newly added log contents in the local relay log in real time, and then resolves the contents of the log file into the SQL statements executed on the master side in a timely manner. These SQL statements are executed in the order of the statements on their own slave server

6, through the above process, you can ensure that the master side and the Skave end of the same SQL statement, when the replication state is normal, the master and slave end of the data is exactly the same

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/FE/wKioL1YL4DKTH2csAAFsT-8YCeY714.jpg "title=" 20131215104910_127.jpg "alt=" Wkiol1yl4dkth2csaafst-8ycey714.jpg "/>

This article is from the "Struggle Bar" blog, please be sure to keep this source http://lvnian.blog.51cto.com/7155281/1699668

MySQL Master-Slave synchronization

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.