MySQL Replication principle

Source: Internet
Author: User

Reference official website: https://dev.mysql.com/doc/refman/5.7/en/replication-implementation-details.html

The MySQL replication feature is implemented through three threads, including the Lord's Binlog dump tread and the SQL thread from the top, I/O ttread

Binlog Dump Thread

Master creates the Binlog dump thread, which is used to send Binlog events to slave when it connects to master, and the dump thread reads every event that will be sent to slave every time

First get lock in binary log, and then release after reading.

Slave I/O thread

When execution is START SLAVE performed on the slave side, Slave creates an I/O thread connection to the master active read dump thread that writes the latest Binlog events to the local relay log

Slave SQL Thread

Slave create SQL thread to read the event from the relay log and apply

The I/O thread reads the event without slowing down the server execution, even if the slave I/O thread is stopped for a while, and when it is turned on again, it can quickly get all the

The latest Binlog content to relay log, even if the SQL thread has a significant delay. If slave is stopped before SQL thread finishes using all relay logs, the I/O thread gets at least

All the transaction logs that have occurred on master so far to relay log, ensuring secure replication, to be applied at the next boot of slave.

If Maser does not see the Binlog dump thread through show processlist, replication has stopped.

MySQL Replication principle

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.