千家信息网

启用auto_position=1一直报错

发表于:2024-09-23 作者:千家信息网编辑
千家信息网最后更新 2024年09月23日,启用auto_position=1一直报错 Got fatal error 1236 from master when reading data from binary log: 'The slave
千家信息网最后更新 2024年09月23日启用auto_position=1一直报错


启用auto_position=1一直报错 Got fatal error 1236 from master when reading data from binary log: 'The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.', Error_code: 1236


gtid中一些变量的理解

Retrieved_Gtid_Set: 接收到gtid集合

Executed_Gtid_Set: slave 已经执行过gtid集合,这个值使用从库的gtid_executed 这个变量初始化

gtid_executed:执行过的gtid集合

gtid_purged:已经被purge清除掉gtid集合



在执行start slave 的时候 ,如何计算起始的gtid值/集合

在从库已经执行的gtid集合

gtid_executed={0dd527e9-af3e-11e8-9ed6-00505683b926:1-62,0dd527e9-af3e-11e8-9ed6-00505683b927:1-3,87cf7b97-c393-11e8-845b-005056a95814:1,bb014309-e1a6-11e8-b284-00505683b926:1-12,c488995b-e256-11e8-abb7-00505683b926:1-9}


主库上执行的gtid集合

master_gtid_executed = { c488995b-e256-11e8-abb7-00505683b926:1-10 }


主库发送给从库的第一个gtid值(也可能是一个集合)

send_first_gtids={master_gtid_executed - gtid_executed}

send_first_gtids = { c488995b-e256-11e8-abb7-00505683b926:10 }



这个时候就计算出master需要发送给slave的第一个gtid值/集合,

如果这个值已经被master purge清理掉了(也就说在master的binlog文件中找不到了)

slave 就会报错 1236 错误

具体报错如下 :

Got fatal error 1236 from master when reading data from binary log: 'The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.', Error_code: 1236


对于这种错误 有两种解决方案

1.重做slave

2.找到历史的binlog文件,收到从binlog文件cp出需要的gtid集合日志在slave执行(这里需用到mysqlbinlog --include-gtids ),重新初始化从库的gtid_executed 的值


0