报错信息如下:
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.'
解决方法:
查看主库 master gtid_purged
mysql> show global variables like '%gtid%';
从库执行
mysql> stop slave; mysql> reset slave; mysql> reset master; mysql> set @@global.gtid_purged='主库的GITD值'; # 这样会丢失部分数据,知晓 mysql> change master to master_host='MASTER_IP',master_port=PORT,master_user='USERNAME',master_password='PASSWORD',master_auto_position=1; 或 mysql> CHANGE MASTER TO MASTER_AUTO_POSITION=1; mysql> start slave; mysql> show slave status G
注意:设置gtid_purged值时,gtid_executed值必须为空否则报错,该值清空的方法就是reset master,reset slave命令。