MySQL master-slave synchronization delay

dba@(none) 02:48:05>show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.15.11
Master_User: dbsync
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.002351
Read_Master_Log_Pos: 276113513
Relay_Log_File: relaylog.007789
Relay_Log_Pos: 178335825
Relay_Master_Log_File: mysql-bin.002339
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 178335662
Relay_Log_Space: 13178574309
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0

 

Restart the slave library, the master-slave synchronization is normal.

 

Since the synchronization between the read-only slave library and the master library adopts single-threaded synchronization, and the pressure of the master library is concurrent multi-threaded writing, this will cause the data delay of the slave library.
Solution:
Enabling parallel replication of read-only slave libraries is the fundamental way to solve this problem. To completely solve this problem, we have to check whether the business write pressure is normal, optimize or split the business appropriately, and ensure that the TPS of the master library will not cause the slave to delay. .
 
expand:
In MySQL 5.6, concurrent replication was introduced. This concurrent replication is at the database level, which means that one SQL thread can process continuous transactions of one database without waiting for other databases to complete. This version of concurrent replication can be understood as one database and one SQL thread. Its parameters related to concurrency are as follows:
slave_parallel_workers // Number of worker threads
slave-checkpoint-group // How many transactions to do a checkpoint
slave-checkpoint-period // How often to do checkpoint
slave-pending-jobs-size-max // The upper limit of the size of events in the waiting state distributed to workers
 
 
 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325084096&siteId=291194637