MySQL MySQL master-slave replication overview

Source: Internet
Author: User

1. Introduction to master-slave replication
MySQL master-slave replication is to copy the data from one MySQL instance (master) to another MySQL real
Example (slave), and this replication is a process of asynchronous replication.
The entire replication operation is performed primarily by three processes, of which two processes are Slave (Sql_thread and
Io_thread), another process on the Master (IO process).
2. Principle and mechanism of master-slave copying
To implement replication, you must first turn on the binary log (Bin-log) function on the Master side, otherwise it cannot be implemented.
Because the entire replication process is actually Slave to get the log from the Master and then complete the sequence on the
Perform various actions that are logged in the log.
The basic process for replication is as follows:
1), Slave above the Io_thread connection on Master, and request from the specified log file at the specified location (or
Log contents from the beginning of the log);
2), Master receives the Io_thread request from Slave, through the IO process responsible for the replication according to please
The request information reads the log information after the specified log location, and returns the Io_thread to Slave. Returns information in addition to
The information contained in the log, including the information returned to the Master side of the Bin-log file, and
Bin-log POS;
3), Slave Io_thread received the message, the received log content is added to the Slave side of the
Relay-log the end of the file and logs the filename and location of the Bin-log read to the Master side to
Master-info file in order to be able to tell Master clearly at the next read, "I need a
Bin-log where to start the log content, please send me ";
4), Slave Sql_thread detected relay-log new additions to the content, will immediately parse Relay-log
Content becomes the executable content at the real execution time of the Master side and executes in this database.

3. master-slave copy schematic diagram

MySQL MySQL master-slave replication overview

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.