mysql从传统模式切到GTID模式后启动主从,主从异常报错1236

发布时间 2023-04-19 01:46:57作者: whiteY

GTID主从异常报错1236

ast_IO_Errno: 1236
                Last_IO_Error: 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. Replicate the missing transactions from elsewhere, or provision a new slave from backup. Consider increasing the master's binary log expiration period. The GTID set sent by the slave is '', and the missing transactions are '6c15ecda-03f3-11ec-987e-6c92bff6906b:1-5,
a75b06d9-03ec-11ec-9ca3-6c92bff6a8fb:1-6'.'

解决办法:

在主节点执行:

show variables like '%gtid_purged%';
+---------------+------------------------------------------------------------------------------------+
| Variable_name | Value                                                                              |
+---------------+------------------------------------------------------------------------------------+
| gtid_purged   | 6c15ecda-03f3-11ec-987e-6c92bff6906b:1-5,
a75b06d9-03ec-11ec-9ca3-6c92bff6a8fb:1-6 |
+---------------+------------------------------------------------------------------------------------+

然后再在从节点设置gtid_purged为主节点gtid_purged值。

stop slave;
set global gtid_purged="6c15ecda-03f3-11ec-987e-6c92bff6906b:1-5,
a75b06d9-03ec-11ec-9ca3-6c92bff6a8fb:1-6";
start slave;
show slave status\G