MySQL 5.6 支持延遲復(fù)制,可以在Slave服務(wù)器指定一個延遲的值。默認(rèn)值為0秒。使用MASTER_DELAY選項(xiàng)為CHANGE MASTERTO設(shè)置N秒延遲。
創(chuàng)新互聯(lián)主營西區(qū)網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,成都App制作,西區(qū)h5成都小程序開發(fā)搭建,西區(qū)網(wǎng)站營銷推廣歡迎西區(qū)等地區(qū)企業(yè)咨詢
1. 下面來實(shí)際演示,正常運(yùn)行的從節(jié)點(diǎn)執(zhí)行,設(shè)置延遲100秒
STOP SLAVE; CHANGE MASTER TO MASTER_DELAY = 100; START SLAVE; SHOW SLAVE STATUS\G; 顯示 SQL_Delay: 100 --延遲 100S SQL_Remaining_Delay: NULL
2. 設(shè)置取消延遲復(fù)制
STOP SLAVE ; CHANGE MASTER TO MASTER_DELAY=0; START SLAVE; SHOW SLAVE STATUS\G; SQL_Delay: 0 --取消延遲 SQL_Remaining_Delay: NULL
3. 測試
主節(jié)點(diǎn)創(chuàng)建庫 CREATE DATABASE TEST; 從節(jié)點(diǎn)查看 SHOW SLAVE STATUS\G; ....... SQL_Delay: 100 SQL_Remaining_Delay: 83 Slave_SQL_Running_State: Waiting until MASTER_DELAY seconds after master executed event .......
4. 參考官網(wǎng)文檔
https://dev.mysql.com/doc/refman/5.6/en/replication-delayed.html