Reduce mysql master slave data synchronization delay problem in detail

  • 2020-05-19 06:04:55
  • OfStack

The LAN based master/slave mechanism is generally ready for 'real-time' backup. If the delay is large, confirm the following factors:
1. Network delay
2. master load
3. slave load
One way to do this is to use multiple slave to split the read requests, and then take one dedicated server from these slave and use it as a backup without doing anything else, thus achieving the 'real time' requirement to the maximum extent possible

In addition, introduce two more parameters that can reduce delay

� slave net - timeout = seconds
Parameter meaning: when slave fails to read log data from the master database, how long should you wait to reestablish the connection and retrieve the data

slave_net_timeout units are set to 3600 seconds by default
| slave_net_timeout | 3600

� master connect - retry = seconds
Parameter meaning: when reestablishing a master-slave connection, if the connection fails, how long will it take to retry the connection?

The master-connect-retry unit is set to 60 seconds by default

In general, the configuration of the above two parameters can reduce the master-slave data synchronization delay caused by network problems

1 common network problem error is:

070401 16:16:55 [ERROR] Error reading packet from server: Lost connection to MySQL server during query (server_errno=2013)
070401 16:16:55 [ERROR] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'mysql_master-bin.000134' position 115817861


Related articles: