您好,登錄后才能下訂單哦!
slave中出現(xiàn)錯誤:
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.
這是由于我人為往表中制造了主鍵沖突
查看slave的gtid信息:
mysql> 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-6957,
3853efe2-5dc8-11ea-86cb-000c295618b3:1-2 |
| 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 |
+----------------------------------+---------------------------------------------+
設(shè)置從庫的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)
mysql>
mysql> begin;
Query OK, 0 rows affected (0.00 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
這里是模擬一個事務(wù),代替出錯的事務(wù)
mysql> SET GTID_NEXT="AUTOMATIC"
-> ;
Query OK, 0 rows affected (0.00 sec)
緊接著start slave即可
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。