1. 程式人生 > >[MySQL] 記一次MGR組複製GTID(1236)異常的解決

[MySQL] 記一次MGR組複製GTID(1236)異常的解決

現象:

應用服務向MGR其中一個節點發起寫請求報錯

(3101, 'Plugin instructed the server to rollback the current transaction.')

檢查該節點日誌報錯

2018-10-09T14:51:14.297753+08:00 63 [ERROR] Error reading packet from server for channel 'group_replication_recovery': The slave is connecting using CH1, but the master has purged binary logs containing GTIDs that the slave requires. (server_errno=1236)
2018-10-09T14:51:14.297851+08:00 63 [ERROR] Slave I/O for channel 'group_replication_recovery': Got fatal error 1236 from master when reading data fromusing CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.', Error_code: 1236
2018-10-09T14:52:14.341067+08:00 90 [Warning] Storing MySQL user name or password information in the master info repository is not secure and is therefsing the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
2018-10-09T14:52:14.857120+08:00 90 [ERROR] Error reading packet from server for channel 'group_replication_recovery': The slave is connecting using CH1, but the master has purged binary logs containing GTIDs that the slave requires. (server_errno=1236)
2018-10-09T14:52:14.857185+08:00 90 [ERROR] Slave I/O for channel 'group_replication_recovery': Got fatal error 1236 from master when reading data fromusing CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.', Error_code: 1236

解決步驟:

1. 檢視各節點同步狀態,找出異常的節點

select * from performance_schema.replication_group_member_stats \G

2. 檢視各節點GTID狀態

show variables like '%GTID%' \G

3. 異常節點停止組複製

mysql> stop group_replication;

4. 根據正常節點的gtid_purged,更改異常節點的gtid_purged。如果異常節點的gtid_purged非空,先要reset master;

mysql> set global gtid_purged='3cccaa6c-d580-11e7-82f6-0050568d292a:1-40....';

5. 啟動組複製,異常節點的gtid_purged會開始複製,一段時間複製完成即可恢復。 

mysql> start group_replication;

6. 完成複製後組複製恢復正常

mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+--------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST  | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+--------------+-------------+--------------+
| group_replication_applier | xxxxxxxxxxxxxxxxxxxxxxxxxxxx | mysql-01 |        3306 | ONLINE       |
| group_replication_applier | xxxxxxxxxxxxxxxxxxxxxxxxxxx1 | mysql-02   |        3306 | RECOVERING   |
| group_replication_applier | xxxxxxxxxxxxxxxxxxxxxxxxxxx9 | mysql-03   |        3306 | ONLINE       |
+---------------------------+--------------------------------------+--------------+-------------+--------------+
3 rows in set (0.00 sec)

mysql>