MySQL學習筆記16分組複製的幾個常見問題以及解決辦法

來源:互聯網
上載者:User

標籤:pos   ase   and   log   組複製   UI   values   exe   war   

MySQL分組複製提供的功能很強大,但是有時會出現一些問題,或者使用上存在一些限制主要包括:

(1)分組複製的限制。

(a)儲存引擎只能是InnoDB。

(b)二進位日誌格式只支援ROW格式。

(c)只支援使用GTID模式。

(d)每個分組最多隻支援9個成員節點。

 

(2)資料表必須有主鍵。

mysql> create table test (name varchar(100));

Query OK, 0 rows affected (0.05 sec)

 

mysql> insert into test values( now()),(now());

ERROR 3098 (HY000): The table does not comply with the requirements by an external plugin.

 

查看日誌:

2017-08-19T06:23:22.253181Z 13 [ERROR] Plugin group_replication reported: ‘Table test does not have any PRIMARY KEY. This is not compatible with Group Replication‘

2017-08-19T06:24:18.493848Z 13 [ERROR] Plugin group_replication reported: ‘Table test does not have any PRIMARY KEY. This is not compatible with Group Replication‘

 

解決辦法:

建立有主鍵的資料表。

mysql> create table test ( name varchar(100) primary key);

Query OK, 0 rows affected (0.02 sec)

 

mysql> insert into test (name) values (‘001‘);

Query OK, 1 row affected (0.02 sec)

 

mysql> insert into test (name) values (‘002‘);

Query OK, 1 row affected (0.01 sec)

 

mysql> insert into test (name) values (‘003‘);

Query OK, 1 row affected (0.00 sec)

 

mysql> insert into test (name) values (now());

Query OK, 1 row affected (0.01 sec)

 

 

(3)資料庫已經存在。

日誌中出現了資料庫已經存在而無法建立資料庫的錯誤。

2017-08-19T06:51:50.784471Z 28 [ERROR] Slave SQL for channel ‘group_replication_recovery‘: Error ‘Can‘t create database ‘test‘; database exists‘ on query. Default database: ‘test‘. Query: ‘create database test‘, Error_code: 1007

2017-08-19T06:51:50.784523Z 28 [Warning] Slave: Can‘t create database ‘test‘; database exists Error_code: 1007

2017-08-19T06:51:50.784530Z 28 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log ‘binlog.000001‘ position 1082

 

解決辦法:

 

mysql> stop group_replication;

Query OK, 0 rows affected (9.43 sec)

 

mysql> drop database test;

ERROR 1290 (HY000): The MySQL server is running with the --super-read-only option so it cannot execute this statement

 

mysql> set global super_read_only=0;

Query OK, 0 rows affected (0.00 sec)

 

mysql> drop database test;

Query OK, 0 rows affected (0.00 sec)

 

mysql> set global super_read_only=1;

Query OK, 0 rows affected (0.00 sec)

 

mysql> set global group_replication_allow_local_disjoint_gtids_join=ON;

Query OK, 0 rows affected (0.00 sec)

 

mysql> start group_replication;

Query OK, 0 rows affected (3.19 sec)

 

 

為了防止在MySQL的節點在啟動時出現此問題,可將下面的配置加入MySQL設定檔。

loose-group_replication_allow_local_disjoint_gtids_join=on

 

MySQL學習筆記16分組複製的幾個常見問題以及解決辦法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.