欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

MySQL5.6 GTID模式下同步復(fù)制報(bào)錯(cuò)不能跳過(guò)的解決方法

 更新時(shí)間:2020年04月12日 14:08:13   投稿:mdxy-dxy  
搭建虛擬機(jī)centos6.0, mysql5.6.10主從復(fù)制,死活不同步,搞了一整天找到這篇文章終于OK了,特分享一下,需要的朋友可以參考下

數(shù)據(jù)庫(kù)版本:

mysql> select version();

+------------+
| version() |
+------------+
| 5.6.10-log |
+------------+
1 row in set (0.02 sec)

同步復(fù)制信息:

mysql> show slave status\G;

*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.8.25
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000007
Read_Master_Log_Pos: 5036
Relay_Log_File: M2-relay-bin.000008
Relay_Log_Pos: 408
Relay_Master_Log_File: mysql-bin.000007
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB: mysql
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1062
Last_Error: Could not execute Write_rows event on table test.t; Duplicate entry '12'
for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log mysql-bin.000007,
end_log_pos 2267
Skip_Counter: 0
Exec_Master_Log_Pos: 2045
Relay_Log_Space: 3810
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 1062
Last_SQL_Error: Could not execute Write_rows event on table test.t; Duplicate entry '12'
for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log mysql-bin.000007,
end_log_pos 2267
Replicate_Ignore_Server_Ids:
Master_Server_Id: 25
Master_UUID: cf716fda-74e2-11e2-b7b7-000c290a6b8f
Master_Info_File: /usr/local/mysql/data2/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State:
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp: 130313 07:24:43
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: cf716fda-74e2-11e2-b7b7-000c290a6b8f:141-151
Executed_Gtid_Set: cf716fda-74e2-11e2-b7b7-000c290a6b8f:1-140
Auto_Position: 1
1 row in set (0.02 sec)

ERROR:
No query specified

提示主鍵沖突,由于是測(cè)試機(jī),于是我直接跳過(guò),

mysql> set global sql_slave_skip_counter=1;

ERROR 1858 (HY000): sql_slave_skip_counter can not be set when the server is running with GTID_MODE = ON.
Instead, for each transaction that you want to skip, generate an empty transaction with the same GTID as the transaction

提示:由于運(yùn)行在GTID模式,所以不支持sql_slave_skip_counter語(yǔ)法,如果你想跳過(guò),就必須把事務(wù)ID設(shè)置為空值。
看來(lái)只能用這個(gè)方法了。

mysql> show global variables like '%GTID%';

+--------------------------+--------------------------------------------+
| Variable_name | Value |
+--------------------------+--------------------------------------------+
| enforce_gtid_consistency | ON |
| gtid_executed | cf716fda-74e2-11e2-b7b7-000c290a6b8f:1-140 |
| gtid_mode | ON |
| gtid_owned | |
| gtid_purged | cf716fda-74e2-11e2-b7b7-000c290a6b8f:1-140 |
+--------------------------+--------------------------------------------+
5 rows in set (0.04 sec)

mysql> set global gtid_executed='';
ERROR 1238 (HY000): Variable 'gtid_executed' is a read only variable
mysql>
mysql> set global gtid_purged='';

ERROR 1840 (HY000): GTID_PURGED can only be set when GTID_EXECUTED is empty.
郁悶,直接設(shè)置還不行。

查看了手冊(cè),需要執(zhí)行reset master才可以(注:在從上執(zhí)行啊,千萬(wàn)別在主上)。

mysql> reset master;
Query OK, 0 rows affected (0.16 sec)

mysql> reset slave;
ERROR 1198 (HY000): This operation cannot be performed with a running slave; run STOP SLAVE first
mysql> stop slave;
Query OK, 0 rows affected (0.08 sec)

mysql> reset slave;
Query OK, 0 rows affected (0.16 sec)

執(zhí)行reset slave的目的是清空master.info和relay-log.info,以便后面重新change master to主從復(fù)制。
還記得剛才的gtid_purged那個(gè)點(diǎn)嗎,只需重新設(shè)置下一個(gè)點(diǎn)即可。

下面是步驟:

mysql> show global variables like '%GTID%';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| enforce_gtid_consistency | ON |
| gtid_executed | |
| gtid_mode | ON |
| gtid_owned | |
| gtid_purged | |
+--------------------------+-------+
5 rows in set (0.06 sec)

mysql> set global gtid_purged='cf716fda-74e2-11e2-b7b7-000c290a6b8f:1-141';
Query OK, 0 rows affected (0.16 sec)

mysql> CHANGE MASTER TO MASTER_HOST='192.168.8.25',MASTER_USER='repl',MASTER_PASSWORD='repl'
,MASTER_AUTO_POSITION = 1;
Query OK, 0 rows affected, 2 warnings (0.32 sec)

mysql> start slave;
Query OK, 0 rows affected (0.13 sec)

mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.8.25
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000007
Read_Master_Log_Pos: 5036
Relay_Log_File: M2-relay-bin.000008
Relay_Log_Pos: 408
Relay_Master_Log_File: mysql-bin.000007
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB: mysql
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1050
Last_Error: Error 'Table 't0' already exists' on query.
Default database: 'test'. Query: 'create table t0 like t'
Skip_Counter: 0
Exec_Master_Log_Pos: 2298
Relay_Log_Space: 3557
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 1050
Last_SQL_Error: Error 'Table 't0' already exists' on query.
Default database: 'test'. Query: 'create table t0 like t'
Replicate_Ignore_Server_Ids:
Master_Server_Id: 25
Master_UUID: cf716fda-74e2-11e2-b7b7-000c290a6b8f
Master_Info_File: /usr/local/mysql/data2/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State:
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp: 130313 07:50:42
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: cf716fda-74e2-11e2-b7b7-000c290a6b8f:142-151
Executed_Gtid_Set: cf716fda-74e2-11e2-b7b7-000c290a6b8f:1-141
Auto_Position: 1
1 row in set (0.02 sec)

ERROR:
No query specified
### 看,這里的報(bào)錯(cuò)信息已經(jīng)不一樣了,按照這種方法,重復(fù)執(zhí)行,直到同步復(fù)制正常。

mysql> stop slave;
Query OK, 0 rows affected (0.07 sec)

mysql> reset master;
Query OK, 0 rows affected (0.17 sec)

mysql> reset slave;
Query OK, 0 rows affected (0.16 sec)

mysql> set global gtid_purged='cf716fda-74e2-11e2-b7b7-000c290a6b8f:1-151';
Query OK, 0 rows affected (0.13 sec)

mysql> CHANGE MASTER TO MASTER_HOST='192.168.8.25',MASTER_USER='repl',MASTER_PASSWORD='repl'
,MASTER_AUTO_POSITION = 1;
Query OK, 0 rows affected, 2 warnings (0.33 sec)

mysql> start slave;
Query OK, 0 rows affected (0.11 sec)

mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.8.25
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000007
Read_Master_Log_Pos: 5036
Relay_Log_File: M2-relay-bin.000008
Relay_Log_Pos: 408
Relay_Master_Log_File: mysql-bin.000007
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB: mysql
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 5036
Relay_Log_Space: 819
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 25
Master_UUID: cf716fda-74e2-11e2-b7b7-000c290a6b8f
Master_Info_File: /usr/local/mysql/data2/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set: cf716fda-74e2-11e2-b7b7-000c290a6b8f:1-151
Auto_Position: 1
1 row in set (0.01 sec)

ERROR:
No query specified

呵呵,總算是解決好了,真麻煩啊。如果大家有更好、更方便的解決方法,也給我回帖哦,謝謝。

相關(guān)文章

  • mysql增加新用戶無(wú)法登陸解決方法

    mysql增加新用戶無(wú)法登陸解決方法

    在使用mysql增加新用戶之后,發(fā)現(xiàn)新增的用戶無(wú)法登陸,一時(shí)束手無(wú)策,網(wǎng)上搜集整理了一下,曬出來(lái)和大家分享一下,希望可以幫助你們
    2012-11-11
  • Mysql中有關(guān)Datetime和Timestamp的使用總結(jié)

    Mysql中有關(guān)Datetime和Timestamp的使用總結(jié)

    mysql數(shù)據(jù)庫(kù)常用的時(shí)間類(lèi)型有timestamp和datetime,兩者主要區(qū)別是占用存儲(chǔ)空間長(zhǎng)度不一致、可存儲(chǔ)的時(shí)間也有限制,本文就來(lái)詳細(xì)的介紹一下,感興趣的可以了解一下
    2021-12-12
  • centos7下mysqldump定時(shí)備份數(shù)據(jù)庫(kù)的方法實(shí)現(xiàn)

    centos7下mysqldump定時(shí)備份數(shù)據(jù)庫(kù)的方法實(shí)現(xiàn)

    MySQL Dump是MySQL提供的方便導(dǎo)出數(shù)據(jù)庫(kù)數(shù)據(jù)的工具,本文主要介紹了centos7下mysqldump定時(shí)備份數(shù)據(jù)庫(kù)的方法實(shí)現(xiàn),感興趣的可以了解一下
    2023-08-08
  • 安裝配置mysql及Navicat prenium的詳細(xì)流程

    安裝配置mysql及Navicat prenium的詳細(xì)流程

    這篇文章主要介紹了安裝配置mysql及Navicat Premium的詳細(xì)流程,配置方法也真的很簡(jiǎn)單,本文給大家詳細(xì)介紹mysql Navicat Premium安裝配置相關(guān)知識(shí)感興趣的朋友,一起學(xué)習(xí)吧
    2021-06-06
  • Mysql分庫(kù)分表之后主鍵處理的幾種方法

    Mysql分庫(kù)分表之后主鍵處理的幾種方法

    Mysql分庫(kù)分表之后,主鍵如何處理?本文主要介紹了Mysql分庫(kù)分表之后主鍵處理的幾種方法,具有一定的參考價(jià)值,感興趣的可以了解一下
    2022-02-02
  • MySQL不推薦使用uuid或者雪花id作為主鍵的原因分析

    MySQL不推薦使用uuid或者雪花id作為主鍵的原因分析

    在數(shù)據(jù)庫(kù)設(shè)計(jì)中,選擇適當(dāng)?shù)闹麈I類(lèi)型對(duì)于數(shù)據(jù)的存儲(chǔ)和查詢(xún)效率至關(guān)重要,在MySQL中,有些開(kāi)發(fā)者傾向于使用UUID或者雪花ID作為主鍵,以確保數(shù)據(jù)的唯一性,本文將探討在MySQL中不推薦使用UUID或者雪花ID作為主鍵的原因,并與其他主鍵類(lèi)型進(jìn)行差異化對(duì)比
    2023-11-11
  • MySQL中庫(kù)的基本操作指南(推薦!)

    MySQL中庫(kù)的基本操作指南(推薦!)

    MySQL這個(gè)數(shù)據(jù)庫(kù)是一個(gè)客戶端-服務(wù)器結(jié)構(gòu)的程序,下面這篇文章主要給大家介紹了關(guān)于MySQL中庫(kù)的基本操作指南,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-02-02
  • .Net Core導(dǎo)入千萬(wàn)級(jí)數(shù)據(jù)至Mysql的步驟

    .Net Core導(dǎo)入千萬(wàn)級(jí)數(shù)據(jù)至Mysql的步驟

    最近在工作中,涉及到一個(gè)數(shù)據(jù)遷移功能,從一個(gè)txt文本文件導(dǎo)入到MySQL功能。數(shù)據(jù)遷移,在互聯(lián)網(wǎng)企業(yè)可以說(shuō)經(jīng)常碰到,而且涉及到千萬(wàn)級(jí)、億級(jí)的數(shù)據(jù)量是很常見(jiàn)的。今天我們就來(lái)談?wù)凪ySQL怎么高性能插入千萬(wàn)級(jí)的數(shù)據(jù)。
    2021-05-05
  • mysql下普通索引和唯一索引的效率對(duì)比

    mysql下普通索引和唯一索引的效率對(duì)比

    昨天有位同事說(shuō),他的網(wǎng)頁(yè)查詢(xún)過(guò)程中發(fā)現(xiàn)普通索引和唯一索引的效率是有差別的,普通索引比唯一索引快
    2010-12-12
  • mysql中如何設(shè)置大小寫(xiě)不敏感

    mysql中如何設(shè)置大小寫(xiě)不敏感

    這篇文章主要介紹了mysql中如何設(shè)置大小寫(xiě)不敏感問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-04-04

最新評(píng)論