Get the App
SLTechnology News&Howtos  ›  Database  › 

MySQL 5.6 delayed replication, database recovery after misoperation

Shulou Source: shulou.com Published: 2022-06-01 11:33:00 11月18日 Update

MySQL 5.6supports deferred replication, and you can specify a value for latency on the Slave server. The default value is 0 seconds. Use the MASTER_DELAY option to set the N-second delay for CHANGE MASTERTO.

1. The following is an actual demonstration, which is executed normally from the slave node, and the setting delay is 100 seconds.

STOP SLAVE;CHANGE MASTER TO MASTER_DELAY = 100s start SLAVE;SHOW SLAVE STATUS\ G; display SQL_Delay: 100s-delay 100s SQL_Remaining_Delay: NULL

two。 Set to cancel delayed replication

STOP SLAVE; CHANGE MASTER TO MASTER_DELAY=0;START SLAVE;SHOW SLAVE STATUS\ G; SQL_Delay: 0-cancel delay SQL_Remaining_Delay: NULL

3. test

The master node creates a library CREATE DATABASE TEST; from the slave node to view the SHOW SLAVE STATUS\ Ghost. SQL_Delay: 100 SQL_Remaining_Delay: 83 Slave_SQL_Running_State: Waiting until MASTER_DELAY seconds after master executed event.

4. Refer to the official website documentation

Https://dev.mysql.com/doc/refman/5.6/en/replication-delayed.html

Tags: Latency node actual document server reference support service test demonstration run data database Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Docker Apple OPPO Reno Shulou Technology