国内最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2
您当前位置:首页 > 数据库 > 数据库应用 > MySQL Group Replication [Single-Primary Mode] 详细搭建部署过程

MySQL Group Replication [Single-Primary Mode] 详细搭建部署过程

来源:程序员人生   发布时间:2017-03-03 08:37:18 阅读次数:9759次

1,关于MySQL Group Replication

基于组的复制(Group-basedReplication)是1种被使用在容错系统中的技术。Replication-group(复制组)是由能够相互通讯的多个服务器(节点)组成的。

在通讯层,Groupreplication实现了1系列的机制:比如原子消息(atomicmessage delivery)和全序化消息(totalorderingof messages)。

这些原子化,抽象化的机制,为实现更先进的数据库复制方案提供了强有力的支持。

 

MySQL Group Replication正是基于这些技术和概念,实现了1种多主全更新的复制协议。

简而言之,1个Replication-group就是1组节点,每一个节点都可以独立履行事务,而读写事务则会在于group内的其他节点进行调和以后再commit。

因此,当1个事务准备提交时,会自动在group内进行原子性的广播,告知其他节点变更了甚么内容/履行了甚么事务。

这类原子广播的方式,使得这个事务在每个节点上都保持着一样顺序。

这意味着每个节点都以一样的顺序,接收到了一样的事务日志,所以每个节点以一样的顺序重演了这些事务日志,终究全部group保持了完全1致的状态。

 

但是,不同的节点上履行的事务之间有可能存在资源争用。这类现象容易出现在两个不同的并发事务上。

假定在不同的节点上有两个并发事务,更新了同1行数据,那末就会产生资源争用。

面对这类情况,GroupReplication判定先提交的事务为有效事务,会在全部group里面重演,后提交的事务会直接中断,或回滚,最后抛弃掉。

 

因此,这也是1个无同享的复制方案,每个节点都保存了完全的数据副本。看以下图片01.png,描写了具体的工作流程,能够简洁的和其他方案进行对照。这个复制方案,在某种程度上,和数据库状态机(DBSM)的Replication方法比较类似。

 

 

 

2,安装mysql5.7.17

官方下载地址:http://dev.mysql.com/downloads/mysql/,不过官方只保存最新的version,5.7.17这个url地址不1定长时间有效,所以,需要的不1定有,我这里在百度云盘保存了下来,版本是5.7.17,可以随时去下载使用,分享地址:链接:http://pan.baidu.com/s/1jIhqSXw密码:ifx5

 

安装进程参考我的blog地址:http://blog.csdn.net/mchdba/article/details/53889781,大概变化的地方就是my.cnf里面的server-id需要修改。

 

在3台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

 

 blog源地址为:http://blog.csdn.net/mchdba/article/details/54318316,作者mchdba(黄杉),谢绝转载

 

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上建立复制账号:

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参数

确保binlog_formatrow格式。

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


 

两种配置方式,在线添加 OR 配置文件

5.1在线添加

配置:

(1)     配置命令以下,具体到某1个db节点会有所调剂,大部份参数是1致的:

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⑼0e2⑴1e6⑻02e⑻42b2b5909d6"       ;                                                                                                                          

 set @@global.group_replication_local_address = 'db1:6606'                                ;

 set @@global.group_replication_group_seeds = 'db2:6607,db3:6608'                         ;

 

(2)     db1履行进程以下:

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⑼0e2⑴1e6⑻02e⑻42b2b5909d7";                             

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履行进程以下:

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⑼0e2⑴1e6⑻02e⑻42b2b5909d6"       ;

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履行进程以下:

 

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⑼0e2⑴1e6⑻02e⑻42b2b5909d6"       ;

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⑴1e6⑻19c-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

 

2db2上的my.cnf配置:

server-id=12002

transaction_write_set_extraction = XXHASH64

loose-group_replication_group_name = "5f847ff2-d701⑴1e6⑻19c-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

 

 

3db3上的my.cnf配置:

server-id=12003

transaction_write_set_extraction = XXHASH64

loose-group_replication_group_name = "5f847ff2-d701⑴1e6⑻19c-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 配置文件配置方式实现。

 

 

 

 

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⑴1e6-ac1f-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显示:
2017-01⑴0T07:37:39.946919Z 0 [Note] Plugin group_replication reported: 'getstart group_id 41e28b21'
2017-01⑴0T07:58:47.624090Z 0 [Note] Plugin group_replication reported: 'getstart group_id 41e28b21'
2017-01⑴0T07: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⑴1e6-ac1f-b8ca3af6e36c | hch_test_dbm2_121_71 |        3317 | ONLINE       |
| group_replication_applier | fdf2b02e-d66f⑴1e6⑼8a8⑴8a99b76310d | 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>
 
-- 再去master库db1上,查看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 | 3d872c2e-d670⑴1e6-ac1f-b8ca3af6e36c | hch_test_dbm2_121_71 |        3317 | ONLINE       |
| group_replication_applier | ef8ac2de-d671⑴1e6⑼ba4⑴8a99b763071 | hch_test_web_1_24    |        3317 | ONLINE       |
| group_replication_applier | fdf2b02e-d66f⑴1e6⑼8a8⑴8a99b76310d | bpe_service          |        3317 | ONLINE       |
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
3 rows in set (0.01 sec)
 
mysql>
 
-- db1上后台error log显示:
2017-01⑴0T08:00:28.866356Z 0 [Note] Plugin group_replication reported: 'getstart group_id 41e28b21'
2017-01⑴0T08:00:54.699130Z 0 [Note] Plugin group_replication reported: 'getstart group_id 41e28b21'
2017-01⑴0T08:00:56.567427Z 0 [Note] Plugin group_replication reported: 'Marking group replication view change with view_id 14840330835325176:9'



 

最后查看集群状态,都为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⑴1e6-ac1f-b8ca3af6e36c | hch_test_dbm2_121_71 |        3317 | ONLINE       |
| group_replication_applier | ef8ac2de-d671⑴1e6⑼ba4⑴8a99b763071 | hch_test_web_1_24    |        3317 | ONLINE       |
| group_replication_applier | fdf2b02e-d66f⑴1e6⑼8a8⑴8a99b76310d | bpe_service          |        3317 | ONLINE       |
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
3 rows in set (0.00 sec)
 
mysql>


 

7,验证集群复制功能


测试,在master库db1上建立测试库db1,测试表t1,录入1条数据

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环境下面,表必须有主键不然不允许往里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上可以看到数据已同步过去

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

 

 

然后在db2/db3上履行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问题记录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⑴1e6-ae37-fa163ee40410:1 > Grouptransactions: 3c992270-c282⑴1e6⑼3bf-fa163ee40410:1,

 aaaaaa:1⑸'

 [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'

 

【解决办法】:

根据提示打开group_replication_allow_local_disjoint_gtids_join选项,mysql命令行履行:

mysql> set globalgroup_replication_allow_local_disjoint_gtids_join=ON;

 

再履行开启组复制:

mysql> start group_replication;

Query OK, 0 rows affected (7.89 sec)

 

mysql>

 

 

8.2 问题记录2RECOVERING  

在db1上查询集群组成员

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

 

再查看后台error日志,

2017-01⑴0T09: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⑴0T09:17:39.450289Z 146 [Note] Slave I/O thread for channel 'group_replication_recovery' killed while connecting to master
2017-01⑴0T09:17:39.450449Z 146 [Note] Slave I/O thread exiting for channel 'group_replication_recovery', read up to log 'FIRST', position 4
2017-01⑴0T09: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⑴0T09:17:39.452341Z 144 [Note] Plugin group_replication reported: 'Retrying group recovery connection with another donor. Attempt 2/10'
2017-01⑴0T09:17:39.457834Z 0 [Note] Plugin group_replication reported: 'Marking group replication view change with view_id 14840330835325176:25'
2017-01⑴0T09: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⑴0T09:18:39.485250Z 144 [Note] Plugin group_replication reported: 'Establishing connection to a group replication recovery donor 3d872c2e-d670⑴1e6-ac1f-b8ca3af6e36c at hch_test_dbm2_121_71 port: 3317.'
2017-01⑴0T09: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⑴0T09: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⑴0T09:18:39.493912Z 150 [Note] Slave I/O thread for channel 'group_replication_recovery' killed while connecting to master
2017-01⑴0T09:18:39.494069Z 150 [Note] Slave I/O thread exiting for channel 'group_replication_recovery', read up to log 'FIRST', position 4
2017-01⑴0T09: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⑴0T09: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库不上,所以问题在这里,我们赋予的复制账号是iprepl@'192.168.%',所以还需要做1个hostname(hch_test_dbm2_121_71)db1ip地址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上履行以下命令后重新开启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⑴1e6-ac1f-b8ca3af6e36c | hch_test_dbm2_121_71 |        3317 | ONLINE       |
| group_replication_applier | fdf2b02e-d66f⑴1e6⑼8a8⑴8a99b76310d | bpe_service          |        3317 | ONLINE       |
+---------------------------+--------------------------------------+----------------------+-------------+--------------+
2 rows in set (0.00 sec)
 
mysql>
 


 

8.3问题记录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>

生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠
程序员人生
------分隔线----------------------------
分享到:
------分隔线----------------------------
关闭
程序员人生