配置3600s的延遲從庫mysql
stop slave; change master to master_delay = 3600; start slave;
主庫drop表sql
use test;
drop table t1;
若是發現主庫出現誤操做,第一時間關閉從庫sql_thread數據庫
stop slave sql_thread;
主庫解析binlog,找到關鍵字DROP TABLE 相關的那條日誌spa
/usr/local/mysql/bin/mysqlbinlog -vvv --base64-output=decode-rows mysql-bin.000050 > /tmp/1.log日誌
# at 43456042 #190918 14:34:39 server id 1753333 end_log_pos 43456103 GTID last_committed=26452 sequence_number=26453 rbr_only=no SET @@SESSION.GTID_NEXT= '44b68395-ca31-11e9-b10a-00163e3211a2:443813'/*!*/; # at 43456103 #190918 14:34:39 server id 1753333 end_log_pos 43456214 Query thread_id=73858 exec_time=0 error_code=0 SET TIMESTAMP=1568788479/*!*/; DROP TABLE `t1` /* generated by server */ /*!*/;
從庫開啓複製,until到drop以前的事務code
change master to master_delay = 0;
start slave until sql_before_gtids = '44b68395-ca31-11e9-b10a-00163e3211a2:443813';
而後從庫將該表dump出來,導入到主庫中。server
而後從庫重啓一下同步blog
stop slave; change master to master_delay = 3600; start slave;