加入收藏 | 设为首页 | 会员中心 | 我要投稿 财气旺网 - 财气网 (https://www.caiqiwang.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

MySQL GTID复制中断修复步骤

发布时间:2022-04-04 20:54:41 所属栏目:MySql教程 来源:互联网
导读:slave中出现错误: 2020-04-09T07:40:18.719203Z 16 [ERROR] Slave SQL for channel : Could not execute Write_rows event on table mytestdb.t1; Duplicate entry 6 for key PRIMARY, Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the events
      slave中出现错误:
 
      2020-04-09T07:40:18.719203Z 16 [ERROR] Slave SQL for channel '': Could not execute Write_rows event on table mytestdb.t1; Duplicate entry '6' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log mysql-bin.000050, end_log_pos 437, Error_code: 1062
 
      2020-04-09T07:40:18.719237Z 16 [Warning] Slave: Duplicate entry '6' for key 'PRIMARY' Error_code: 1062
 
      2020-04-09T07:40:18.719246Z 16 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.000050' position 194.
 
      这是由于我人为往表中制造了主键冲突
 
| gtid_executed_compression_period | 1000                                                                                  |
 
| gtid_mode                        | ON                                                                                    |
 
| gtid_owned                       |                                                                                       |
 
| gtid_purged                      | 2ff0b1ed-5dc8-11ea-9878-000c29872e9a:1-2                                              |
 
| session_track_gtids              | OFF                                                                                   |
 
+----------------------------------+---------------------------------------------------------------------------------------+
 
查看master的gtid信息:
 
root@dv 15:40:  : [(none)]>show global variables like '%gtid%';
 
+----------------------------------+---------------------------------------------+
 
| Variable_name                    | Value                                       |
 
+----------------------------------+---------------------------------------------+
 
| binlog_gtid_simple_recovery      | ON                                          |
 
| enforce_gtid_consistency         | ON                                          |
 
| gtid_executed                    | 2ff0b1ed-5dc8-11ea-9878-000c29872e9a:1-6958 |
 
| gtid_executed_compression_period | 1000                                        |
 
| gtid_mode                        | ON                                          |
 
| gtid_owned                       |                                             |
 
| gtid_purged                      | 2ff0b1ed-5dc8-11ea-9878-000c29872e9a:1-2    |
 
| session_track_gtids              | OFF                                         |
 
+----------------------------------+---------------------------------------------+
 
设置从库的gtid_next
 
mysql> SET GTID_NEXT="2ff0b1ed-5dc8-11ea-9878-000c29872e9a:1-6957";
 
ERROR 1774 (HY000): Malformed GTID specification '2ff0b1ed-5dc8-11ea-9878-000c29872e9a:1-6958'.
 
mysql> SET GTID_NEXT="2ff0b1ed-5dc8-11ea-9878-000c29872e9a:6957";
 
Query OK, 0 rows affected (0.00 sec)
 
紧接着start slave即可

(编辑:财气旺网 - 财气网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!