Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the replication thread of MySQL Replication

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

In this issue, the editor will bring you a copy thread about how to understand MySQL Replication. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

The MySQL Replication consists of the following threads:

(1). Binlog Dump thread

The Binlog Dump thread runs on the master server and can be checked by the statement show processlist, which is responsible for sending the contents of the binary log file on the master server to the I / O thread of the slave server. The Binlog Dump thread also locks each event to be transmitted, and the lock is released as soon as the event is transferred.

(2) I / O thread

When the start slave statement is executed from the server side, an Icano thread runs. It will establish a connection with the primary server and send an update request to the primary server to send updated events in the binary log files on the primary server to this process. After that, the I / O thread copies the passed update to the log of the local Relay Log, through the

Statement show slave status to view the status of the I / O thread, and Slave_IO_Running is the state parameter for this thread.

(3) .SQL thread

The SQL thread is responsible for reading the update events in the Relay Log log and executing these events one by one to update the database on the server. Similarly, the SQL thread also needs a state parameter Slave_SQL_Running, which, together with the state parameter provided by the SQL O thread, is an important parameter to judge the operation of the replication process.

Remarks:

The Binlog file on the master server is the primary file to implement the replication function. It should be noted that before starting the database, you need to enable the binary log feature, remove the comment before the parameter log-bin in the configuration file my.cnf, and set the name, for example:

[mysqld]

Log_bin=mysql-bin

From the server-side Relay Log file, generated after running the start slave command. Relay Log and Binlog have the same format, and both log files can be viewed through the mysqlbinlog tool, except that the SQL thread automatically deletes events that have been executed in the Relay Log file.

The above is the editor for you to share how to understand the copy thread of MySQL Replication, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report