1. 程式人生 > >MySQL Group Replication [Multi-Primary Mode] 詳細搭建部署過程

MySQL Group Replication [Multi-Primary Mode] 詳細搭建部署過程

1,關於MySQL Group Replication

基於組的複製(Group-basedReplication)是一種被使用在容錯系統中的技術。Replication-group(複製組)是由能夠相互通訊的多個伺服器(節點)組成的。

在通訊層,Groupreplication實現了一系列的機制:比如原子訊息(atomicmessage delivery)和全序化訊息(totalorderingof messages)。這些原子化,抽象化的機制,為實現更先進的資料庫複製方案提供了強有力的支援。

MySQL Group Replication正是基於這些技術和概念,實現了一種多主全更新的複製協議。

簡而言之,一個Replication-group就是一組節點,每個節點都可以獨立執行事務,而讀寫事務則會在於group內的其他節點進行協調之後再commit。

因此,當一個事務準備提交時,會自動在group內進行原子性的廣播,告知其他節點變更了什麼內容/執行了什麼事務。

這種原子廣播的方式,使得這個事務在每一個節點上都保持著同樣順序。

這意味著每一個節點都以同樣的順序,接收到了同樣的事務日誌,所以每一個節點以同樣的順序重演了這些事務日誌,最終整個group保持了完全一致的狀態。

然而,不同的節點上執行的事務之間有可能存在資源爭用。這種現象容易出現在兩個不同的併發事務上。

假設在不同的節點上有兩個併發事務,更新了同一行資料,那麼就會發生資源爭用。

面對這種情況,GroupReplication判定先提交的事務為有效事務,會在整個group裡面重演,後提交的事務會直接中斷,或者回滾,最後丟棄掉。

因此,這也是一個無共享的複製方案,每一個節點都儲存了完整的資料副本。看如下圖片01.png,描述了具體的工作流程,能夠簡潔的和其他方案進行對比。這個複製方案,在某種程度上,和資料庫狀態機(DBSM)的Replication方法比較類似。

 

2,安裝mysql 5.7.17

官方下載地址:http://dev.mysql.com/downloads/mysql/,不過官方只保留最新的version,5.7.17這個url地址不一定長期有效,所以,需要的不一定有,我這裡在百度雲盤保留了下來,版本是5.7.17,可以隨時去下載使用,分享地址:連結:http://pan.baidu.com/s/1jIhqSXw  密碼:ifx5

在三臺db伺服器上面設定/etc/hosts對映,如下:

192.168.121.71    db1                                                                                                            

192.168.121.111    db2

192.168.121.24    db3

安裝的資料庫伺服器:

資料庫伺服器地址       

資料目錄

Server-id 

192.168.121.71(db1)

3317

/data/mysql/data

12001        

192.168.121.111(db2)

3317

/data/mysql/data

12002

192.168.121.24(db3)

3317

/data/mysql/data

12003

3,建立複製環境

設定hostname和ip對映

在db1、db2、db3上都設定

vim /etc/hosts

192.168.121.71 db1 hch_test_dbm2_121_71                                           

192.168.121.111 db2 bpe_service

192.168.121.24 db3 hch_test_web_1_24

在db1/db2/db3上建立複製賬號:

mysql> SET SQL_LOG_BIN=0;

Query OK, 0 rows affected (0.00 sec)

mysql>

mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.%' IDENTIFIED BY '[email protected]';

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql>  

mysql> SET SQL_LOG_BIN=1;

Query OK, 0 rows affected (0.00 sec)

mysql>

4,安裝group replication外掛

在db1、db2、db3上依次安裝group replication外掛

mysql> INSTALL PLUGIN group_replication SONAME 'group_replication.so';                        

Query OK, 0 rows affected (0.01 sec)

mysql>

或者直接在配置檔案my.cnf中配置:

plugin-load=group_replication

檢視group replication元件

mysql> show plugins;                                                                                                        
+----------------------------+----------+--------------------+----------------------+---------+
| Name                       | Status   | Type               | Library              | License |
+----------------------------+----------+--------------------+----------------------+---------+
| binlog                     | ACTIVE   | STORAGE ENGINE     | NULL                 | GPL     |
| mysql_native_password      | ACTIVE   | AUTHENTICATION     | NULL                 | GPL     |
| sha256_password            | ACTIVE   | AUTHENTICATION     | NULL                 | GPL     |
| MyISAM                     | ACTIVE   | STORAGE ENGINE     | NULL                 | GPL     |
| PERFORMANCE_SCHEMA         | ACTIVE   | STORAGE ENGINE     | NULL                 | GPL     |
| InnoDB                     | ACTIVE   | STORAGE ENGINE     | NULL                 | GPL     |
| INNODB_TRX                 | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_LOCKS               | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_LOCK_WAITS          | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_CMP                 | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_CMP_RESET           | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_CMPMEM              | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_CMPMEM_RESET        | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_CMP_PER_INDEX       | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_CMP_PER_INDEX_RESET | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_BUFFER_PAGE         | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_BUFFER_PAGE_LRU     | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_BUFFER_POOL_STATS   | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_TEMP_TABLE_INFO     | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_METRICS             | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_FT_DEFAULT_STOPWORD | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_FT_DELETED          | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_FT_BEING_DELETED    | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_FT_CONFIG           | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_FT_INDEX_CACHE      | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_FT_INDEX_TABLE      | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_SYS_TABLES          | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_SYS_TABLESTATS      | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_SYS_INDEXES         | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_SYS_COLUMNS         | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_SYS_FIELDS          | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_SYS_FOREIGN         | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_SYS_FOREIGN_COLS    | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_SYS_TABLESPACES     | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_SYS_DATAFILES       | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| INNODB_SYS_VIRTUAL         | ACTIVE   | INFORMATION SCHEMA | NULL                 | GPL     |
| MRG_MYISAM                 | ACTIVE   | STORAGE ENGINE     | NULL                 | GPL     |
| MEMORY                     | ACTIVE   | STORAGE ENGINE     | NULL                 | GPL     |
| CSV                        | ACTIVE   | STORAGE ENGINE     | NULL                 | GPL     |
| BLACKHOLE                  | ACTIVE   | STORAGE ENGINE     | NULL                 | GPL     |
| partition                  | ACTIVE   | STORAGE ENGINE     | NULL                 | GPL     |
| FEDERATED                  | DISABLED | STORAGE ENGINE     | NULL                 | GPL     |
| ARCHIVE                    | ACTIVE   | STORAGE ENGINE     | NULL                 | GPL     |
| ngram                      | ACTIVE   | FTPARSER           | NULL                 | GPL     |
| group_replication          | ACTIVE   | GROUP REPLICATION  | group_replication.so | GPL     |
+----------------------------+----------+--------------------+----------------------+---------+
45 rows in set (0.00 sec)
 
mysql>

看到有group_replication ACTIVE,表示插group_replication外掛安裝成功。

5,配置group replication引數

確保binlog_formatrow格式。

mysql> show variables like 'binlog_format';                                             
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| binlog_format | ROW   |
+---------------+-------+
1 row in set (0.00 sec)
 
mysql>

兩種配置方式,線上新增 OR 配置檔案

1 db1上的my.cnf配置:

# replication config

server_id=12001

gtid_mode=ON

enforce_gtid_consistency=ON

master_info_repository=TABLE

relay_log_info_repository=TABLE

binlog_checksum=NONE

log_slave_updates=ON

log_bin=binlog

binlog_format=ROW

# group replication config

transaction_write_set_extraction=XXHASH64

loose-group_replication_group_name="e4668cea-d7ca-11e6-86b5-18a99b76310d"                        

loose-group_replication_start_on_boot=off

loose-group_replication_local_address= "db1:24901"

loose-group_replication_group_seeds= "db1:24901,db2:24902,db3:24903"

loose-group_replication_bootstrap_group= off

loose-group_replication_single_primary_mode=FALSE

loose-group_replication_enforce_update_everywhere_checks= TRUE

2db2上的my.cnf配置:

# replication config

server_id=12002

gtid_mode=ON

enforce_gtid_consistency=ON

master_info_repository=TABLE

relay_log_info_repository=TABLE

binlog_checksum=NONE

log_slave_updates=ON

log_bin=binlog

binlog_format=ROW

# group replication config

transaction_write_set_extraction=XXHASH64

loose-group_replication_group_name="e4668cea-d7ca-11e6-86b5-18a99b76310d"

loose-group_replication_start_on_boot=off

loose-group_replication_local_address= "db2:24902"

loose-group_replication_group_seeds= "db1:24901,db2:24902,db3:24903"

loose-group_replication_bootstrap_group= off

loose-group_replication_single_primary_mode=FALSE

loose-group_replication_enforce_update_everywhere_checks= TRUE

3db3上的my.cnf配置:

# replication config

server_id=12003

gtid_mode=ON

enforce_gtid_consistency=ON

master_info_repository=TABLE

relay_log_info_repository=TABLE

binlog_checksum=NONE

log_slave_updates=ON

log_bin=binlog

binlog_format=ROW

# group replication config

transaction_write_set_extraction=XXHASH64

loose-group_replication_group_name="e4668cea-d7ca-11e6-86b5-18a99b76310d"

loose-group_replication_start_on_boot=off

loose-group_replication_local_address= "db3:24903"

loose-group_replication_group_seeds= "db1:24901,db2:24902,db3:24903"

loose-group_replication_bootstrap_group= off

loose-group_replication_single_primary_mode=FALSE

loose-group_replication_enforce_update_everywhere_checks= TRUE

replication配置引數請參考:

group replication配置參考:

配置完後,重啟3個db上的mysql服務

Db1啟動:

[[email protected]_test_dbm2_121_71 ~]# service mysqld start                                     

Starting MySQL..                                           [確定]

[[email protected]_test_dbm2_121_71 ~]#

Db2啟動:

[[email protected]_service ~]# service mysqld start

Starting MySQL..                                           [確定]                                                     

[[email protected]_service ~]#

Db3啟動:

[[email protected]_test_web_1_24 ~]# service mysqld start                                            

Starting MySQL..                                           [確定]

[[email protected]_test_web_1_24 ~]#

6,啟動mgr叢集

構建之前,保證db1、db2、db3的read_only是關閉的

開始構建group replication叢集,通常操作命令

mysql>  CHANGE MASTER TO MASTER_USER='repl', MASTER_PASSWORD='[email protected]' FOR CHANNEL 'group_replication_recovery';

Query OK, 0 rows affected, 2 warnings (0.02 sec)

mysql>

db1上建立基本主庫master庫:

# 設定group_replication_bootstrap_groupON是為了標示以後加入叢集的伺服器以這臺伺服器為基準,以後加入的就不需要設定。          

mysql> SET GLOBAL group_replication_bootstrap_group = ON;
Query OK, 0 rows affected (0.00 sec)
 
mysql>  START GROUP_REPLICATION;
Query OK, 0 rows affected (1.03 sec)
 
mysql> SET GLOBAL group_replication_bootstrap_group=OFF;
Query OK, 0 rows affected (0.00 sec)
 
mysql>
mysql>  SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST          | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
| group_replication_applier | 3381d155-d7d1-11e6-94f7-b8ca3af6e36c | hch_test_dbm2_121_71 |        3317 | ONLINE       |
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
1 row in set (0.00 sec)
 
mysql>

Db2上啟動group_replication:

Db2上mysql命令列上執行啟動:

mysql>  START GROUP_REPLICATION;

Query OK, 0 rows affected (1.02 sec)

mysql>

db1後臺error log日誌顯示,看到db2加入進來了,進了group:

2017-01-11T07:51:40.623093Z 0 [Note] Plugin group_replication reported: 'Marking group replication view change with view_id 14841207424144277:8'

2017-01-11T07:51:40.650962Z 21 [Note] Start binlog_dump to master_thread_id(21) slave_server(12002), pos(, 4)

2017-01-11T07:51:40.687441Z 0 [Note] Plugin group_replication reported: 'The member with address bpe_service:3317 was declared online within the replication group'

2017-01-11T07:52:40.651481Z 21 [Note] Aborted connection 21 to db: 'unconnected' user: 'repl' host: '192.168.121.111' (failed on flush_net())

再去master庫db1上,檢視group_replication成員,會有db2的顯示,看到MEMBER_STATE都是ONLINE,表示都是MASTER:

mysql>  SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST          | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
| group_replication_applier | 3381d155-d7d1-11e6-94f7-b8ca3af6e36c | hch_test_dbm2_121_71 |        3317 | ONLINE       |
| group_replication_applier | 84dba8ff-d7d2-11e6-aa9a-18a99b76310d | bpe_service          |        3317 | ONLINE       |
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
2 rows in set (0.00 sec)
 
mysql>

db3上啟動group_replication:

Db3命令列上執行:

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 (1.99 sec)

mysql>

再去masterdb1上,檢視group_replication成員,會有db3的顯示,而且已經是ONLINE

mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST          | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
| group_replication_applier | 21750571-d7d3-11e6-91e2-18a99b763071 | hch_test_web_1_24    |        3317 | ONLINE       |
| group_replication_applier | 3381d155-d7d1-11e6-94f7-b8ca3af6e36c | hch_test_dbm2_121_71 |        3317 | ONLINE       |
| group_replication_applier | 84dba8ff-d7d2-11e6-aa9a-18a99b76310d | bpe_service          |        3317 | ONLINE       |
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
3 rows in set (0.00 sec)
 
mysql>

db1上後臺error log顯示:

2017-01-11T08:13:05.972276Z 0 [Note] Plugin group_replication reported: 'getstart group_id 8da193f6'

2017-01-11T08:13:08.146144Z 0 [Note] Plugin group_replication reported: 'Marking group replication view change with view_id 14841207424144277:11'

2017-01-11T08:13:08.174808Z 25 [Note] Start binlog_dump to master_thread_id(25) slave_server(12003), pos(, 4)

2017-01-11T08:13:08.218338Z 0 [Note] Plugin group_replication reported: 'The member with address hch_test_web_1_24:3317 was declared online within the replication group'

2017-01-11T08:14:08.175308Z 25 [Note] Aborted connection 25 to db: 'unconnected' user: 'repl' host: '192.168.121.24' (failed on flush_net())

最後檢視叢集狀態:

mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST          | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
| group_replication_applier | 3d872c2e-d670-11e6-ac1f-b8ca3af6e36c | hch_test_dbm2_121_71 |        3317 | ONLINE       |
| group_replication_applier | ef8ac2de-d671-11e6-9ba4-18a99b763071 | hch_test_web_1_24    |        3317 | ONLINE       |
| group_replication_applier | fdf2b02e-d66f-11e6-98a8-18a99b76310d | bpe_service          |        3317 | ONLINE       |
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
3 rows in set (0.00 sec)
 
mysql>

7,驗證叢集複製功能

測試,在master庫db1上建立測試庫db1,測試表t1,錄入一條資料

mysql> create database db1;

Query OK, 1 row affected (0.00 sec)

mysql> create table db1.t1(id int,cn varchar(32));

Query OK, 0 rows affected (0.02 sec)

mysql>

mysql> insert into t1(id,cn)values( 1,'a');

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

mysql>

mysql>

# 這裡原因是group_replaction環境下面,表必須有主鍵不然不允許往裡insert值。所以修改表t1,將id欄位設定程主鍵即可。

mysql> alter table t1 modify id int primary key;

Query OK, 0 rows affected (0.02 sec)

Records: 0  Duplicates: 0  Warnings: 0

 

然後在db2上執行insert操作,則成功

然後再db3上執行insert操作,則成功

在db1、db2、db3分部錄入的資料,再分表去db1、db2、db3上檢視t1表的資料,資料都已經複製同步過來了,已經實現了group裡面多成員member多處寫操作。

8 新增新的成員

簡要步驟:

(1)      安裝mysql例項

(2)      準備my.cnf

#replication

server_id=12001 # 這個是隨著新伺服器的新增會變化

gtid_mode=ON

enforce_gtid_consistency=ON

master_info_repository=TABLE

relay_log_info_repository=TABLE

binlog_checksum=NONE

log_slave_updates=ON

log_bin=binlog

binlog_format=ROW

#group replication

transaction_write_set_extraction=XXHASH64

loose-group_replication_group_name="e4668cea-d7ca-11e6-86b5-18a99b76310d"

loose-group_replication_start_on_boot=off

loose-group_replication_local_address= "db1:24901" # 這個是隨著新伺服器的新增會變化

loose-group_replication_group_seeds= "db1:24901,db2:24902,db3:24903"# 這個是隨著新伺服器的新增會變化

loose-group_replication_bootstrap_group= off

loose-group_replication_single_primary_mode=FALSE

loose-group_replication_enforce_update_everywhere_checks= TRUE

(3)      啟動mysql例項,service mysqld start;

(4)      開啟group replication

SET SQL_LOG_BIN=0;  # 在建立複製賬號的時候,不需要進入binlog日誌

GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.%' IDENTIFIED BY '[email protected]';

SET SQL_LOG_BIN=1;

CHANGE MASTER TO MASTER_USER='repl', MASTER_PASSWORD='[email protected]' FOR CHANNEL 'group_replication_recovery';

START group_replication;

SELECT * FROM performance_schema.replication_group_members;

(5)驗證組成員,SELECT * FROM performance_schema.replication_group_members;

9,管理操作命令

檢視group狀態資訊:SELECT * FROM performance_schema.replication_group_members;

 

查詢replication協議的其它資料:select * from performance_schema.replication_group_member_stats\G

 

檢視後臺程序2個:

[[email protected]_test_dbm2_121_71 soft]# netstat -ntpl|grep mysql

tcp        0      0 0.0.0.0:24901               0.0.0.0:*                   LISTEN      3665/mysqld        

tcp        0      0 :::3317                     :::*                        LISTEN      3665/mysqld        

[[email protected]_test_dbm2_121_71 soft]#

組複製成員狀態表:select * from performance_schema.replication_group_member_stats;檢視的是當前的狀態:

performance_schema.replication_applier_status


10,問題記錄

10.1問題記錄一

Db2的mysql視窗報錯:

mysql> START GROUP_REPLICATION;

ERROR 3092 (HY000): The server is not configured properly to be an active member of the group. Please see more details on error log.

mysql>

db2的error log資訊如下:

2017-01-11T07:57:41.161360Z 0 [ERROR] Plugin group_replication reported: 'This member has more executed transactions than those present in the group. Local transactions: 84dba8ff-d7d2-11e6-aa9a-18a99b76310d:1 > Group transactions: 3381d155-d7d1-11e6-94f7-b8ca3af6e36c:1,

e4668cea-d7ca-11e6-86b5-18a99b76310d:1-3'

2017-01-11T07:57:41.161430Z 0 [ERROR] Plugin group_replication reported: 'The member contains transactions not present in the group. The member will now exit the group.'

2017-01-11T07:57:41.161445Z 0 [Note] Plugin group_replication reported: 'To force this member into the group you can use the group_replication_allow_local_disjoint_gtids_join option'

2017-01-11T07:57:41.161589Z 3 [Note] Plugin group_replication reported: 'Going to wait for view modification'

2017-01-11T07:57:41.162126Z 0 [Note] Plugin group_replication reported: 'getstart group_id 8da193f6'

2017-01-11T07:57:44.508236Z 0 [Note] Plugin group_replication reported: 'state 4330 action xa_terminate'

2017-01-11T07:57:44.508429Z 0 [Note] Plugin group_replication reported: 'new state x_start'

2017-01-11T07:57:44.508561Z 0 [Note] Plugin group_replication reported: 'state 4257 action xa_exit'

2017-01-11T07:57:44.508720Z 0 [Note] Plugin group_replication reported: 'Exiting xcom thread'

2017-01-11T07:57:44.508746Z 0 [Note] Plugin group_replication reported: 'new state x_start'

2017-01-11T07:57:49.549137Z 3 [Note] Plugin group_replication reported: 'auto_increment_increment is reset to 1'

2017-01-11T07:57:49.549192Z 3 [Note] Plugin group_replication reported: 'auto_increment_offset is reset to 1'

2017-01-11T07:57:49.549472Z 23 [Note] Error reading relay log event for channel 'group_replication_applier': slave SQL thread was killed

2017-01-11T07:57:49.550037Z 20 [Note] Plugin group_replication reported: 'The group replication applier thread was killed'

【解決辦法】設定group_replication_allow_local_disjoint_gtids_join為ON

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 (5.52 sec)

mysql>

10.2問題記錄二

Sql介面顯示狀態為ERROR:

Errorlog顯示:

2017-01-11T08:07:34.587378Z 12 [Note] 'CHANGE MASTER TO FOR CHANNEL 'group_replication_recovery' executed'. Previous state master_host='bpe_service', master_port= 3317, master_log_file='', master_log_pos= 4, master_bind=''. New state master_host='<NULL>', master_port= 0, master_log_file='', master_log_pos= 4, master_bind=''.

2017-01-11T08:07:34.591679Z 12 [ERROR] Plugin group_replication reported: 'Fatal error during the Recovery process of Group Replication. The server will leave the group.'

2017-01-11T08:07:34.592447Z 0 [Note] Plugin group_replication reported: 'getstart group_id 8da193f6'

2017-01-11T08:07:37.943536Z 0 [Note] Plugin group_replication reported: 'state 4330 action xa_terminate'

2017-01-11T08:07:37.943852Z 0 [Note] Plugin group_replication reported: 'new state x_start'

2017-01-11T08:07:37.943879Z 0 [Note] Plugin group_replication reported: 'state 4257 action xa_exit'

2017-01-11T08:07:37.943981Z 0 [Note] Plugin group_replication reported: 'Exiting xcom thread'

2017-01-11T08:07:37.943999Z 0 [Note] Plugin group_replication reported: 'new state x_start'

【解決辦法】:

mysql> CHANGE MASTER TO MASTER_USER='repl', MASTER_PASSWORD='[email protected]' FOR CHANNEL 'group_replication_recovery';
Query OK, 0 rows affected, 2 warnings (0.01 sec)
 
mysql> stop group_replication;
Query OK, 0 rows affected (0.01 sec)
 
mysql> start group_replication;
Query OK, 0 rows affected (2.20 sec)
 
mysql>
mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST          | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
| group_replication_applier | 21750571-d7d3-11e6-91e2-18a99b763071 | hch_test_web_1_24    |        3317 | ONLINE       |
| group_replication_applier | 3381d155-d7d1-11e6-94f7-b8ca3af6e36c | hch_test_dbm2_121_71 |        3317 | ONLINE       |
| group_replication_applier | 84dba8ff-d7d2-11e6-aa9a-18a99b76310d | bpe_service          |        3317 | ONLINE       |
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
3 rows in set (0.00 sec)
 
mysql>

參考文章:

相關推薦

MySQL Group Replication [Multi-Primary Mode] 詳細搭建部署過程

1,關於MySQL Group Replication基於組的複製(Group-basedReplication)是一種被使用在容錯系統中的技術。Replication-group(複製組)是由能夠相互通訊的多個伺服器(節點)組成的。在通訊層,Groupreplication

[MGR——Mysql的組復制之多主模式 ] 詳細搭建部署過程

狀態 eve 語句 star mysql命令行 password 是否 集合 功能 組復制可以在兩種模式下運行。 1.在單主模式下,組復制具有自動選主功能,每次只有一個 server成員接受更新。2.在多主模式下,所有的 server 成員都可以同時接受更新.

MySQL group replication介紹

group replication“MySQL group replication”group replication是MySQL官方開發的一個開源插件,是實現MySQL高可用集群的一個工具。第一個GA版本正式發布於MySQL5.7.17中;想要使用group replication只需要從官網上下載MySQ

MySQL group replication

出現 上下 art 處理 自動創建 mit 排序 主從 同時 本篇文章主要講解MySQL group replication介紹,文中有關MySQL,group的內容,希望對大家有所幫助。 “MySQL group replication” group replicatio

Mysql Group Replication 簡介及單主模式組復制配置【轉】

ror ipv4 mysql命令 value tail force action dmi where 一 Mysql Group Replication簡介 Mysql Group Replication(MGR)是一個全新的高可用和高擴張的MySQL集群服務。

Mysql Group Replication 簡析

group http 9.png tex 圖片 關於 clas png src 前段時間做了組內分享,寫的關於mysql Group Replication 文章             3, 高擴展     

MySQL Group Replication(多主同步復制MGR)

update mod src xtra sla class replicat local trac 開啟replication配置: server-id=1 #標識服務器唯一 log-bin=mys

MySQL Group Replication (MGR) 安裝

exit ever 信息采集 false 操作記錄 create .so lob 一個 MySQL Group Replication 安裝 192.168.10.65192.168.10.66192.168.10.67 OS : CentOS 7.4mysql soft

MySQL Group Replication(組複製MGR)

MGR基本要求: 1、InnoDB儲存引擎 2、主鍵,每個表必須具有已定義的主鍵或等效的主鍵,其中等效項是非null唯一鍵 3、IPv4網路 4、網路效能 5、開啟二進位制日誌並開啟GTID模式 6、mysql版本在5.7.17以上 MGR限制: 1、組複製不支援mysiam引擎 2、不支援

Mysql group replication

(每臺)安裝元件: 注意:在單個主機上執行的多例項。需要在my.cnf中增加此選項 放在每個選項[mysqld3306]的下面 :report_host=127.0.0.1 並且:skip-name-resolve mysql > INSTALL PLUG

Mysql group replication(MGR)實現高可用切換應用無感知方案的思考

一開始考慮使用ProxySQL+MGR來實現資料庫切換應用無感知方向,考慮了可能的兩種部署模型的優缺點:ProxySQL部署的兩種模型:1、靠近應用端方式:在應用伺服器上直接部署優點:  A、每個應用伺服器有自己的配置 ,配置內容簡單,不容易相互影響故障,變更故障風險最小 

MySQL Group Replication 介紹

2016-12-12,一個重要的日子,mysql5.7.17 GA版釋出,正式推出Group Replication(組複製) 外掛,通過這個外掛增強了mysql原有的高可用方案(原有的Replication方案),提供了重要的特性——多寫,保證組內高可用,確保

Mysql Group Replication關閉和啟動所有的組成員的注意點

由於的我mgr建立在虛擬機器上面(即使是正式環境,如果計劃內的停機或者斷電都需要關閉所有的節點),如何關閉所有的組成員,關閉的順序還是比較重要的。我的環境是一個primary,多個slave的架構,qht131為parmary,其它qht132,qht133,qht134為s

Centos6.8 下 部署Mysql組複製(MySQL Group Replication)之多主模式(5.7新特性)

MySQL Group Replication(簡稱MGR)是MySQL官方於2016年12月推出的一個全新的高可用與高擴充套件的解決方案。MySQL組複製提供了高可用、高擴充套件、高可靠的MySQL叢集服務。 1.關於MGR介紹 1.1提供的特性:

MySQL Group Replication 技術點

mysql group replication,組複製,提供了多寫(multi-master update)的特性,增強了原有的mysql的高可用架構。mysql group replication基於mysql外掛架構實現,本身就是一個mysql外掛。 提供

配置Mysql Group Replication遇到的問題筆記

一 在配置第一臺伺服器 START GROUP_REPLICATION; 後出現以下問題: ERROR 3092 (HY000): The server is not configured properly to be an active mem

Mysql Group Replication 簡介及單主模式組複製配置

mysql> create database test;2017-03-31T23:23:45.535115Z8[Note]Plugin group_replication reported:'Primary had applied all relay logs, disabled conflict d

MySQL Group Replication增加節點

在上一篇文章中,我們大概介紹了Mysql Group Replication的構架及叢集搭建步驟。那麼我們知道,一組優秀的叢集環境有一個很必要的特性,那就是可拓展性。Group Replication的拓展性怎麼樣呢?我們設定如下幾個場景,來看看Group Re

MySQL Group Replication初測

MySQL Group Replication 對測試版(on labs)的Group Replication的第一印象:這個MySQL外掛讓多主結構的MySQL叢集能夠進行全更新(update everywhere)。 它糅合了分散式系統(比如組通訊)

MySQL Group Replication 動態新增成員節點

1. 背景 前面文章已經介紹如何部署MySQL GR 的兩種模式: 在前面的部署裡面,因為是預先知道需要部署的組節點規模,所以我們能夠在my.cnf裡面體現出組成員資訊。但是,前面的部署並沒有體現出動態新增組節點。 這篇文章介紹如何動態地往一個組裡面新