MySQL 5.6 支持延迟复制,可以在Slave服务器指定一个延迟的值。默认值为0秒。使用MASTER_DELAY 选项为CHANGE MASTERTO 设置N秒延迟。
-
下面来实际演示,正常运行的从节点执行,设置延迟100秒
STOP SLAVE;
CHANGE MASTER TO MASTER_DELAY = 100;
START SLAVE;
SHOW SLAVE STATUS\G;
显示
SQL_Delay: 100 --延迟 100S
SQL_Remaining_Delay: NULL -
设置取消延迟复制
STOP SLAVE ;
CHANGE MASTER TO MASTER_DELAY=0;
START SLAVE;
SHOW SLAVE STATUS\G;
SQL_Delay: 0 --取消延迟
SQL_Remaining_Delay: NULL -
测试
主节点创建库
CREATE DATABASE TEST;
从节点查看
SHOW SLAVE STATUS\G;
.......
SQL_Delay: 100
SQL_Remaining_Delay: 83
Slave_SQL_Running_State: Waiting until MASTER_DELAY seconds after master executed event
....... - 参考官网文档
https://dev.mysql.com/doc/refman/5.6/en/replication-delayed.html
https://www.linuxidc.com/Linux/2017-04/142714.htm
mysql5.6延迟复制
http://francs3.blog.163.com/blog/static/405767272014111231645106/
转载于:https://blog.51cto.com/wujianwei/2106470