Get the App
SLTechnology News&Howtos  ›  Database  › 

MySQL master-slave delayed replication

Shulou Source: shulou.com Published: 2022-06-01 21:23:02 10月03日 Update

Master-slave replication of MySQL is the foundation of MySQL large-scale cluster, and it is widely used in daily production environment. After MySQL5.6 began to reconstruct and improve the underlying code of MySQL, master-slave replication of MySQL has made great progress, and master-slave multithreaded replication (https://blog.51cto.com/jim123/1961241) was introduced in version 5.7. Since version 5.6, master-slave replication of MySQL supports delayed replication of master on slave without the need for third-party tools. Master-slave replication delay can quickly recover deleted data after a certain time delay in slave after master mistakenly deleted data. As for the setting, you can simply add a parameter when connecting to the master database from the slave database:

CHANGE MASTER TO MASTER_DELAY = 3600th # the unit here is 3600 seconds, that is, an hour.

When slave is enabled, and if you look at the status of slave at this time, there are two parameters:

SQL_Delay: displays the set delay time of master / slave (in seconds); SQL_Remaining_Delay: displays the remaining delay time of master / slave (in seconds)

Tags: Master-slave unit time parameter data version delay constant code foundation large-scale hour that is tools underlying state environment third party thread cluster Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB OPPO Reno Apple Shulou Technology Linux