Mysql replication does not require slave to open binlog

Source: Internet
Author: User
Mysql Replication is an asynchronous Replication process (Mysql 5.1.7 or later versions are divided into two modes: asynchronous Replication and semi-synchronization), from the Master to another Slave. The entire replication process between the Master and Slave is mainly completed by three threads. Two threads (SQL thread and IO thread) are on the Slave side, and the other thread (I

Mysql Replication is an asynchronous Replication process (Mysql 5.1.7 or later versions are divided into two modes: asynchronous Replication and semi-synchronization), from the Master to another Slave. The entire replication process between the Master and Slave is mainly completed by three threads. Two threads (SQL thread and IO thread) are on the Slave side, and the other thread (I

Mysql Replication is an asynchronous Replication process (Mysql 5.1.7 or later versions are divided into two modes: asynchronous Replication and semi-synchronization), from the Master to another 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 Replication for MySQL, you must first enable the Binary Log (mysql-bin.xxxxxx) function on the Master side, otherwise it cannot be implemented. The whole replication process is actually because Slave obtains the log from the Master end and then executes the operations recorded in the log in full order on itself. To enable the Binary Log of MySQL, you can use the "-log-bin" parameter option during MySQL Server startup, or. the "log-bin" parameter item is added to the mysqld parameter group (the parameter section marked by [mysqld]) in the cnf configuration file.

Basic MySQL replication process:

1.Slave? The above IO thread connects to the Master and requests the log content after the specified location (or from the beginning) of the specified log file;

2.? Master? After receiving a request from the Slave IO thread, the IO thread responsible for replication reads the log information after the specified log location 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.? Slave? After receiving information, the IO thread will write the received Log content to the end of the Relay Log file (mysql-relay-bin.xxxxxx) of the Slave end in sequence, and record the file name and location of the bin-log 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.? Slave? When the SQL thread detects the newly added content in the Relay Log, it will immediately parse the content in the Log file to become 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.

The above describes so many replication processes, the following describes the mysql bin log settings.

MASTER:

On the master, you only need to open the bin log;

Set binlog replication mode to mixed mode, that is, binlog_format = mixed;

You do not need to open bin-relay.

SLAVE:

You do not need to open the bin-log, because the bin log on the SLAVE comes from the data input from the MASTER. If it is enabled, it actually adds the IO burden to the slave;

The above replication process shows that the IO process on the slave obtains the bin-log on the MASTER, and then records the relay-bin log, then, the SQL process on the slave reads the relay-bin content and runs it on the slave to achieve the replication purpose.

You only need to enable relay-bin.

If you want to use SLAVE as the SLAVE machine of the MASTER, you can change the location at any time and use it as the MASTER, we recommend that you enable binlog on the SLAVE.

Original article address: mysql replication does not require slave to open binlog. Thank you for sharing it with the original author.

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.