MySQL开启GTID同步出现1236错误解决过程记录
故障描述
版本:MySQL8.0
故障详情:主从同步,开启GTID。从库正常重启后,启动同步报错。
Got fatal error 1236 from master when reading data from binary log
处理方法:重置从库,重新设置gtid_purged
解决步骤
01
确定gtid_purged值
查询主库的gtid_purged值,并记录
show variables like 'gtid_purged';
查询从库已经执行过的gtid值,并记录
show variables like 'gtid_executed'; 或者 show slave status\G
主库的
主库的gtid_purged值加上从库gtid_executed值,重新设置为从库的gtid_purged值
关键点:这里一定要加上从库已经执行过的gitd值,否则会因为重复数据导致主从再次中断。
02
重置
stop slave;
reset slave;
reset master;
重置从库gtid_urged
set @@global.gtid_purged='0335cb84-e6b9-11ea-9569-6c92bf639532:7-8,
10713c7a-1fd7-11eb-b635-b4055d0b4fda:105451-231385,
4a8b5954-65cb-11ea-9332-b4055d0b4e52:1-173,
4f407376-cd09-11ea-9a0c-6c92bf639a41:1085062-1085415:1085417-150003065,
66a3f0c0-465b-11ea-ac3a-b4055d0b4fe2:40034588-220460366,
66fde4d5-9974-11ea-95f7-b4055d0b4fda:1-5312188,
716b5f9b-644d-11ea-8967-b4055d0b48c2:270,
78f7f542-ecdd-11ea-b613-6c92bf31cbe2:1-315445161,
96f0a48b-606c-11ea-8b8c-b4055d0b49c6:1-242784286:242786642-404146913,
b789bfae-7479-11ea-ac17-48df370ddcc4:1-282728:282863-2005584,
d08b7d59-863e-11ea-94af-b4055d0b4fa2:196472533-576840068,
d1c81876-44c3-11eb-a1e9-005056ba6886:1-5208663:5208665-5208674:5208677-26183131:26227235-26228590:26318774-27187460,
da84d08a-44c3-11eb-9d10-005056baf5a5:1-26087,
0335cb84-e6b9-11ea-9569-6c92bf639532:7-10,
10713c7a-1fd7-11eb-b635-b4055d0b4fda:105451-235508,
4a8b5954-65cb-11ea-9332-b4055d0b4e52:1-175,
4f407376-cd09-11ea-9a0c-6c92bf639a41:1085062-1085415:1085417-150659254,
66a3f0c0-465b-11ea-ac3a-b4055d0b4fe2:40034588-222376175,
66fde4d5-9974-11ea-95f7-b4055d0b4fda:1-5312188,
716b5f9b-644d-11ea-8967-b4055d0b48c2:270-272,
78f7f542-ecdd-11ea-b613-6c92bf31cbe2:1-316904683,
96f0a48b-606c-11ea-8b8c-b4055d0b49c6:1-242784286:242786642-407710418,
b789bfae-7479-11ea-ac17-48df370ddcc4:1-282728:282863-2013999,
c6c5f8c6-9195-11ea-9e03-b4055d0b4f66:3-4,
d08b7d59-863e-11ea-94af-b4055d0b4fa2:196472533-585834663,
d1c81876-44c3-11eb-a1e9-005056ba6886:26227235-26228590:26318774-27678080,
da84d08a-44c3-11eb-9d10-005056baf5a5:26085-26087';
重新配置同步
change master to master_host='1.2.3.4',master_port=3306,master_user='rpl',master_password='123456',master_auto_position=1;
start slave;
检查同步状态