1. Phenomenon In the early morning, an index was added to an online table. The amount of data in the table was too large (more than 100 million data, more than 50G of data), causing a delay of several hours between the master and slave. The systems that depended on the slave database were unable to query the data, ultimately affecting the business. Now let's sort out the principle of master-slave delay. 2. Principle According to the description in the MySQL official document MySQL Replication Implementation Details, MySQL master-slave replication relies on three threads: one thread for When the master server and the slave server are connected, create
When the slave server receives the START_SLAVE command, it creates
Note: After the You can view the thread status through SHOW PROCESSLIST: Binlog dump thread: mysql> SHOW PROCESSLIST\G *************************** 1. row *************************** Id: 2 User: root Host: localhost:32931 db: NULL Command: Binlog Dump Time: 94 State: Has sent all binlog to slave; waiting for binlog to be updated Info: NULL I/O thread and SQL thread: mysql> SHOW PROCESSLIST\G *************************** 1. row *************************** Id: 10 User: system user Host: db: NULL Command: Connect Time: 11 State: Waiting for master to send event Info: NULL *************************** 2. row *************************** Id: 11 User: system user Host: db: NULL Command: Connect Time: 11 State: Has read all relay logs; waiting for the slave I/O thread to update it Info: NULL Analysis According to the above principle, since
An index is created here. After consulting the DBA, it is found that the generated 4. Solution From the perspective of the causes of master-slave delay, the solution can be started from the following directions:
Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
>>: Solve the cross-domain problem of Vue+SpringBoot+Shiro
First, before posting! Thanks again to I Want to S...
The first step is to unzip the compressed package...
Talk about the scene Send Email Embedding HTML in...
I have seen many relevant tutorials on the Intern...
The purpose of writing scripts is to avoid having...
introduction With the widespread popularity of In...
Use Javascript to implement a message board examp...
When I first used docker, I didn't use docker...
Docker-compose deployment configuration jenkins 1...
Recently, I have a need to list all host names in...
<!--[if IE 6]> Only IE6 can recognize <![...
<br />Structure and hierarchy reduce complex...
Table of contents 1. Reference plugins in the uni...
Required effect: After clicking to send the verif...
Analyze the execution process. Move the mouse int...