最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當前位置: 首頁 - 科技 - 知識百科 - 正文

詳細介紹MySQLGroupReplication[Single-PrimaryMode]的搭建部署過程

來源:懂視網(wǎng) 責編:小采 時間:2020-11-09 09:06:05
文檔

詳細介紹MySQLGroupReplication[Single-PrimaryMode]的搭建部署過程

詳細介紹MySQLGroupReplication[Single-PrimaryMode]的搭建部署過程:1,關于MySQL Group Replication基于組的復制(Group-basedReplication)是一種被使用在容錯系統(tǒng)中的技術。Replication-group(復制組)是由能夠相互通信的多個服務器(節(jié)點)組成的。在通信層,Groupreplication實現(xiàn)了一系列的機制:比如原
推薦度:
導讀詳細介紹MySQLGroupReplication[Single-PrimaryMode]的搭建部署過程:1,關于MySQL Group Replication基于組的復制(Group-basedReplication)是一種被使用在容錯系統(tǒng)中的技術。Replication-group(復制組)是由能夠相互通信的多個服務器(節(jié)點)組成的。在通信層,Groupreplication實現(xiàn)了一系列的機制:比如原

1,關于MySQL Group Replication

基于組的復制(Group-basedReplication)是一種被使用在容錯系統(tǒng)中的技術。Replication-group(復制組)是由能夠相互通信的多個服務器(節(jié)點)組成的。

在通信層,Groupreplication實現(xiàn)了一系列的機制:比如原子消息(atomicmessage delivery)和全序化消息(totalorderingof messages)。

這些原子化,抽象化的機制,為實現(xiàn)更先進的數(shù)據(jù)庫復制方案提供了強有力的支持。

MySQL Group Replication正是基于這些技術和概念,實現(xiàn)了一種多主全更新的復制協(xié)議。

簡而言之,一個Replication-group就是一組節(jié)點,每個節(jié)點都可以獨立執(zhí)行事務,而讀寫事務則會在于group內的其他節(jié)點進行協(xié)調之后再commit。

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

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

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

然而,不同的節(jié)點上執(zhí)行的事務之間有可能存在資源爭用。這種現(xiàn)象容易出現(xiàn)在兩個不同的并發(fā)事務上。

假設在不同的節(jié)點上有兩個并發(fā)事務,更新了同一行數(shù)據(jù),那么就會發(fā)生資源爭用。

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

因此,這也是一個無共享的復制方案,每一個節(jié)點都保存了完整的數(shù)據(jù)副本??慈缦聢D片01.png,描述了具體的工作流程,能夠簡潔的和其他方案進行對比。這個復制方案,在某種程度上,和數(shù)據(jù)庫狀態(tài)機(DBSM)的Replication方法比較類似。

2,安裝mysql5.7.17

官方下載,不過官方只保留最新的version,5.7.17這個url地址不一定長期有效,所以,需要的不一定有,我這里在百度云盤保留了下來,版本是5.7.17,可以隨時去下載使用,


在三臺db服務器上面設置/etc/hosts映射,如下:

192.168.121.71 db1

192.168.121.111 db2

192.168.121.24 db3


安裝的數(shù)據(jù)庫服務器:

數(shù)據(jù)庫服務器地址

端口

數(shù)據(jù)目錄

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,創(chuàng)建復制環(huán)境

設置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上建立復制賬號:

GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.%' IDENTIFIED BY 'rlpbright_1927@ys';


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>

plugin-load=group_replication或者直接在配置文件my.cnf中配置:

查看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>

5,配置group replication參數(shù)

確保binlog_format是row格式。

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

兩種配置方式,在線添加 OR 配置文件

5.1在線添加

配置:

(1) 配置命令如下,具體到某一個db節(jié)點會有所調整,大部分參數(shù)是一致的:

set @@global.transaction_write_set_extraction = XXHASH64;
 set @@global.group_replication_start_on_boot = OFF;
 set @@global.group_replication_bootstrap_group = OFF;
 set @@global.group_replication_group_name = "0c6d3e5f-90e2-11e6-802e-842b2b5909d6"; 
 set @@global.group_replication_local_address = 'db1:6606';
 set @@global.group_replication_group_seeds = 'db2:6607,db3:6608';

(2) 在db1執(zhí)行過程如下:

mysql> set @@global.transaction_write_set_extraction = XXHASH64;
Query OK, 0 rows affected (0.00 sec)
 
mysql> set @@global.group_replication_start_on_boot = OFF;
Query OK, 0 rows affected (0.00 sec)
 
mysql> set @@global.group_replication_bootstrap_group = OFF;
Query OK, 0 rows affected (0.00 sec)
 
mysql>
mysql>set @@global.group_replication_group_name = "0c6d3e5f-90e2-11e6-802e-842b2b5909d7"; 
Query OK, 0 rows affected (0.00 sec)
 
mysql> set @@global.group_replication_local_address = 'db1:6606';
Query OK, 0 rows affected (0.00 sec)
 
mysql> set @@global.group_replication_group_seeds = 'db2:6607,db3:6608';
Query OK, 0 rows affected (0.00 sec)
 
mysql>

(3) 在db2執(zhí)行過程如下:

mysql> set @@global.transaction_write_set_extraction = XXHASH64;
Query OK, 0 rows affected (0.00 sec)
 
mysql> set @@global.group_replication_start_on_boot = OFF;
Query OK, 0 rows affected (0.00 sec)
 
mysql> set @@global.group_replication_bootstrap_group = OFF;
Query OK, 0 rows affected (0.01 sec)
 
mysql> set @@global.group_replication_group_name = "0c6d3e5f-90e2-11e6-802e-842b2b5909d6";
Query OK, 0 rows affected (0.00 sec)
 
mysql> set @@global.group_replication_local_address = 'db2:6607';
Query OK, 0 rows affected (0.00 sec)
 
mysql> set @@global.group_replication_group_seeds = 'db1:6606,db3:6608';
Query OK, 0 rows affected (0.01 sec)
 
mysql>

(4) 在db3執(zhí)行過程如下:

mysql> set @@global.transaction_write_set_extraction = XXHASH64 ;
Query OK, 0 rows affected (0.00 sec)
 
mysql> set @@global.group_replication_start_on_boot = OFF;
Query OK, 0 rows affected (0.00 sec)
 
mysql> set @@global.group_replication_bootstrap_group = OFF ;
Query OK, 0 rows affected (0.00 sec)
 
mysql> set @@global.group_replication_group_name = "0c6d3e5f-90e2-11e6-802e-842b2b5909d6";
Query OK, 0 rows affected (0.00 sec)
 
mysql> set @@global.group_replication_local_address = 'db3:6608' ;
Query OK, 0 rows affected (0.00 sec)
 
mysql> set @@global.group_replication_group_seeds = 'db1:6606,db2:6607' ;
Query OK, 0 rows affected (0.00 sec)
 
mysql>

5.2配置文件配置

(1) db1上的my.cnf配置:

server-id=12001
transaction_write_set_extraction = XXHASH64
loose-group_replication_group_name = "5f847ff2-d701-11e6-819c-b8ca3af6e36c" 
loose-group_replication_start_on_boot = off
loose-group_replication_local_address = "db1:23306"
loose-group_replication_group_seeds = "db1:23306,db2:23307,db3:23308"
loose-group_replication_bootstrap_group = off
loose-group_replication_single_primary_mode = true
loose-group_replication_enforce_update_everywhere_checks = false

(2)db2上的my.cnf配置:

server-id=12002
transaction_write_set_extraction = XXHASH64
loose-group_replication_group_name = "5f847ff2-d701-11e6-819c-b8ca3af6e36c"
loose-group_replication_start_on_boot = off
loose-group_replication_local_address = "db2:23307"
loose-group_replication_group_seeds = "db1:23306,db2:23307,db3:23308"
loose-group_replication_bootstrap_group = off
loose-group_replication_single_primary_mode = true
loose-group_replication_enforce_update_everywhere_checks = false

(3)db3上的my.cnf配置:

server-id=12003
transaction_write_set_extraction = XXHASH64
loose-group_replication_group_name = "5f847ff2-d701-11e6-819c-b8ca3af6e36c"
loose-group_replication_start_on_boot = off
loose-group_replication_local_address = "db3:23308"
loose-group_replication_group_seeds = "db1:23306,db2:23307,db3:23308"
loose-group_replication_bootstrap_group = off
loose-group_replication_single_primary_mode = true
loose-group_replication_enforce_update_everywhere_checks = false

配置完后,重啟3個db上的mysql服務,本次案例,我們選擇5.2 配置文件配置方式實現(xiàn)。

6,啟動mgr集群

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

mysql> CHANGE MASTER TO MASTER_USER='repl', MASTER_PASSWORD='rlpbright_1927@ys' FOR CHANNEL 'group_replication_recovery';
Query OK, 0 rows affected, 2 warnings (0.02 sec)
 
mysql>

Db1上建立基本主庫master庫:

# 設置group_replication_bootstrap_group為ON是為了標示以后加入集群的服務器以這臺服務器為基準,以后加入的就不需要設置。
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> 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 |
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
1 row in set (0.00 sec)
 
mysql>

Db2上啟動group_replication:

Db2上mysql命令行上執(zhí)行啟動:
mysql> START GROUP_REPLICATION;
Query OK, 0 rows affected (1.02 sec)
 
mysql>
 
db1上后臺error log顯示:
2017-01-10T07:37:39.946919Z 0 [Note] Plugin group_replication reported: 'getstart group_id 41e28b21'
2017-01-10T07:58:47.624090Z 0 [Note] Plugin group_replication reported: 'getstart group_id 41e28b21'
2017-01-10T07:58:53.116957Z 0 [Note] Plugin group_replication reported: 'Marking group replication view change with view_id 14840330835325176:6'
 
再去master庫db1上,查看group_replication成員,會有db2的顯示
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 | fdf2b02e-d66f-11e6-98a8-18a99b76310d | bpe_service | 3317 | ONLINE |
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
2 rows in set (0.00 sec)
 
mysql>

Db3上啟動group_replication:

-- Db3命令行上執(zhí)行:
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>
 
-- 再去master庫db1上,查看group_replication成員,會有db3的顯示,而且已經(jīng)是ONLINE了
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.01 sec)
 
mysql>
 
-- db1上后臺error log顯示:
2017-01-10T08:00:28.866356Z 0 [Note] Plugin group_replication reported: 'getstart group_id 41e28b21'
2017-01-10T08:00:54.699130Z 0 [Note] Plugin group_replication reported: 'getstart group_id 41e28b21'
2017-01-10T08:00:56.567427Z 0 [Note] Plugin group_replication reported: 'Marking group replication view change with view_id 14840330835325176:9'

最后查看集群狀態(tài),都為ONLINE就表示OK:

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,錄入一條數(shù)據(jù)

mysql> create database db1;
Query OK, 1 row affected (0.00 sec)
 
mysql> create table db1.t1(id int,cnvarchar(32));
Query OK, 0 rows affected (0.02 sec)
 
mysql>
mysql> insert into t1 select 1,'a';
ERROR 3098 (HY000): The table does notcomply with the requirements by an external plugin.
mysql>
mysql> insert into t1(id,cn)values(1,'a');
ERROR 3098 (HY000): The table does notcomply with the requirements by an external plugin.
mysql>
mysql>
-- # 這里原因是group_replaction環(huán)境下面,表必須有主鍵不然不允許往里insert值。所以修改表t1,將id字段設置程主鍵即可。
mysql> alter table t1 modify id intprimary key;
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0
 
mysql> insert into t1 select 1,'a';
Query OK, 1 row affected (0.01 sec)
Records: 1 Duplicates: 0 Warnings: 0
 
mysql>

去db2/db3上可以看到數(shù)據(jù)已經(jīng)同步過去

mysql> select * from db1.t1;
+----+------+
| id | cn |
+----+------+
| 1| a |
+----+------+
1 row in set (0.00 sec)
 
mysql>

然后在db2/db3上執(zhí)行inert操作,則拒絕,因為db2、db3為readonly

mysql> insert into t1 select 2,'b';
ERROR 1290 (HY000): The MySQL server isrunning with the --super-read-only option so it cannot execute this statement
mysql>

8,問題記錄

8.1問題記錄一

MySQL窗口報錯:

ERROR 3092 (HY000): The server is notconfigured properly to be an active member of the group. Please see moredetails on error log.
后臺ERROR LOG報錯:
[ERROR] Plugin group_replication reported:'This member has more executed transactions than those present in the group.
Local transactions: f16f7f74-c283-11e6-ae37-fa163ee40410:1 > Grouptransactions: 3c992270-c282-11e6-93bf-fa163ee40410:1,
 aaaaaa:1-5'
 [ERROR]Plugin group_replication reported: 'The member contains transactions notpresent in the group. The member will now exit the group.'
 [Note] Plugin group_replication reported: 'Toforce this member into the group you can use the group_replication_allow_local_disjoint_gtids_joinoption'

【解決辦法】:

根據(jù)提示打開group_replication_allow_local_disjoint_gtids_join選項,mysql命令行執(zhí)行:

mysql> set globalgroup_replication_allow_local_disjoint_gtids_join=ON;

再執(zhí)行開啟組復制:

mysql> start group_replication;
Query OK, 0 rows affected (7.89 sec)
 
mysql>

8.2 問題記錄二RECOVERING

在db1上查詢集群組成員

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 | RECOVERING |
| group_replication_applier | fdf2b02e-d66f-11e6-98a8-18a99b76310d | bpe_service | 3317 | RECOVERING |
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
3 rows in set (0.00 sec)
 
mysql>

再查看后臺error日志,

2017-01-10T09:17:39.449488Z 146 [ERROR] Slave I/O for channel 'group_replication_recovery': 
error connecting to master 'repl@hch_test_dbm2_121_71:3317' - retry-time: 60 retries: 1, Error_code: 2003
2017-01-10T09:17:39.450289Z 146 [Note] Slave I/O thread for channel 'group_replication_recovery' killed while connecting to master
2017-01-10T09:17:39.450449Z 146 [Note] Slave I/O thread exiting for channel 'group_replication_recovery', read up to log 'FIRST', position 4
2017-01-10T09:17:39.451579Z 144 [ERROR] Plugin group_replication reported: 'There was an error when connecting to the donor server. 
Check group replication recovery's connection credentials.'
2017-01-10T09:17:39.452341Z 144 [Note] Plugin group_replication reported: 'Retrying group recovery connection with another donor. Attempt 2/10'
2017-01-10T09:17:39.457834Z 0 [Note] Plugin group_replication reported: 'Marking group replication view change with view_id 14840330835325176:25'
2017-01-10T09:18:39.456629Z 144 [Note] 'CHANGE MASTER TO FOR CHANNEL 'group_replication_recovery' executed'. 
Previous state master_host='hch_test_dbm2_121_71', master_port= 3317, master_log_file='', master_log_pos= 4, master_bind=''. 
New state master_host='hch_test_dbm2_121_71', master_port= 3317, master_log_file='', master_log_pos= 4, master_bind=''.
2017-01-10T09:18:39.485250Z 144 [Note] Plugin group_replication reported: 'Establishing 
connection to a group replication recovery donor 3d872c2e-d670-11e6-ac1f-b8ca3af6e36c at hch_test_dbm2_121_71 port: 3317.'
2017-01-10T09:18:39.489356Z 150 [Warning] Storing MySQL user name or 
password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and 
PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
2017-01-10T09:18:39.493511Z 150 [ERROR] Slave I/O for channel 'group_replication_recovery': 
error connecting to master 'repl@hch_test_dbm2_121_71:3317' - retry-time: 60 retries: 1, Error_code: 2005
2017-01-10T09:18:39.493912Z 150 [Note] Slave I/O thread for channel 'group_replication_recovery' killed while connecting to master
2017-01-10T09:18:39.494069Z 150 [Note] Slave I/O thread exiting for channel 'group_replication_recovery', read up to log 'FIRST', position 4
2017-01-10T09:18:39.495155Z 144 [ERROR] Plugin group_replication reported: 
'There was an error when connecting to the donor server. Check group replication recovery's connection credentials.'
2017-01-10T09:18:39.496838Z 144 [Note] Plugin group_replication reported: 'Retrying group recovery connection with another donor. Attempt 3/10'

【解決辦法】:

看報錯[ERROR] Slave I/O for channel'group_replication_recovery': error connecting to master 'repl@hch_test_dbm2_121_71:3317'- retry-time: 60 retries: 1, Error_code:2005,連接master庫不上,所以問題在這里,我們賦予的復制賬號是ip的repl@'192.168.%',所以還需要做一個hostname(hch_test_dbm2_121_71)和db1的ip地址192.168.121.71的映射關系。

建立hostname和ip映射

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

然后在db2上執(zhí)行如下命令后重新開啟group_replication即可。

mysql> stop group_replication;
Query OK, 0 rows affected (0.02 sec) 
 
mysql> start group_replication;
Query OK, 0 rows affected (5.68 sec)
 
mysql>

再去master庫db1上,查看group_replication成員,會有db2的顯示

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 | fdf2b02e-d66f-11e6-98a8-18a99b76310d | bpe_service | 3317 | ONLINE |
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
2 rows in set (0.00 sec)
 
mysql>

8.3問題記錄三

操作問題

mysql>
mysql> START GROUP_REPLICATION;
ERROR 3092 (HY000): The server is notconfigured properly to be an active member of the group. Please see moredetails on error log.

【解決辦法】:

mysql> SET GLOBALgroup_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>

聲明:本網(wǎng)頁內容旨在傳播知識,若有侵權等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

詳細介紹MySQLGroupReplication[Single-PrimaryMode]的搭建部署過程

詳細介紹MySQLGroupReplication[Single-PrimaryMode]的搭建部署過程:1,關于MySQL Group Replication基于組的復制(Group-basedReplication)是一種被使用在容錯系統(tǒng)中的技術。Replication-group(復制組)是由能夠相互通信的多個服務器(節(jié)點)組成的。在通信層,Groupreplication實現(xiàn)了一系列的機制:比如原
推薦度:
標簽: 介紹 簡介 搭建
  • 熱門焦點

最新推薦

猜你喜歡

熱門推薦

專題
Top