1.延时从库
1.1 作用
处理逻辑损坏
1.2 怎么实现的
SQL线程延时:数据已经写入relaylog中了,SQL线程"慢点"运行
一般企业建议3-6小时,具体看公司运维人员对于故障的反应时间
mysql>stop slave;
mysql>CHANGE MASTER TO MASTER_DELAY = 300;
mysql>start slave;
mysql> show slave status \G
SQL_Delay: 300
SQL_Remaining_Delay: NULL
1.3 怎么处理逻辑损坏
drop 操作:
(1) 感知到故障
(2)停相关业务,挂维护页
(3)停延时从库SQL线程
(4)手工模拟SQL线程恢复后续的relaylog
起点:relaylog.info
终点:drop
(5)直接解除从库替代主库工作
或者,导出故障数据库,倒回到生产
create database guangtouqiang charset utf8mb4;
use guangtouxiang;
create table t1 (id int);
insert into y1 values(1);
insert into t1 values(11);
insert into t1 values(111);
insert into t1 values(1111);
insert into t1 values(11111);
drop database guangtouqiang;
| db01-relay-bin.000002 | 488 | Anonymous_Gtid | 7 | 568 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'
| db01-relay-bin.000002 | 2329 | Anonymous_Gtid | 7 | 2409 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'