怎样进行MySQL5.7.17- Group Replication搭建
怎样进行MySQL5.7.17- Group Replication搭建,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
背景:
mysql>INSTALL PLUGIN group_replication SONAME 'group_replication.so'
mysql> SHOW PLUGINS; +----------------------------+----------+--------------------+----------------------+-------------+ | Name | Status | Type | Library | License | +----------------------------+----------+--------------------+----------------------+-------------+ | binlog | ACTIVE | STORAGE ENGINE | NULL | PROPRIETARY | (...) | group_replication | ACTIVE | GROUP REPLICATION | group_replication.so | PROPRIETARY | +----------------------------+----------+--------------------+----------------------+-------------+
mysql> SET GLOBAL group_replication_bootstrap_group=ON;
mysql> START GROUP_REPLICATION;
mysql> SET GLOBAL group_replication_bootstrap_group=OFF;
mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 550a7cbd-ccce-11e6-829a-a2d813521b2e | sh347 | 3307 | ONLINE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
1 row in set (0.00 sec)
2.4插入一些模拟数据
mysql> CREATE DATABASE test;
Query OK, 1 row affected (0.00 sec)
mysql> use test;
Database changed
mysql> CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 TEXT NOT NULL);
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO t1 VALUES (1, 'Luis');
Query OK, 1 row affected (0.01 sec)
3 往集群里面添加数据库实例
3.1修改第二台数据库配置文件
3.1修改第二台数据库配置文件
[client]
port = 24802
socket = /home/data/mydata/3307/mysql.sock
[mysqld]
port = 24802
socket = /home/data/mydata/3307/mysql.sock
basedir = /home/data/mysql
datadir = /home/data/mydata/3307
pid-file = /home/data/mydata/3307/mysql.pid
##group replication####
server_id = 2
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
transaction_write_set_extraction=XXHASH64
loose-group_replication_group_name = "77e497e2-c59a-11e6-9a68-525400159185"
loose-group_replication_start_on_boot=off
loose-group_replication_local_address="192.168.1.14:34062"
loose-group_replication_group_seeds="192.168.1.247:34061,192.168.1.14:34062,192.168.1.242:34063"
loose-group_replication_bootstrap_group=off
loose-group_replication_single_primary_mode=false
loose-group_replication_enforce_update_everywhere_checks=TRUE
3.2启动数据库进行配置
SET SQL_LOG_BIN=0;
CREATE USER rpl_user@'%';
GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%' IDENTIFIED BY 'rpl_pass';
SET SQL_LOG_BIN=1;
CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='rpl_pass' FOR CHANNEL 'group_replication_recovery'
3.2启动数据库进行配置
SET SQL_LOG_BIN=0;
CREATE USER rpl_user@'%';
GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%' IDENTIFIED BY 'rpl_pass';
SET SQL_LOG_BIN=1;
CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='rpl_pass' FOR CHANNEL 'group_replication_recovery'
3.3 安装引擎,加入gp组
mysql> INSTALL PLUGIN group_replication SONAME 'group_replication.so';
mysql> START GROUP_REPLICATION;
mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+---------------------------+-------------+--------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+---------------------------+-------------+--------------+
| group_replication_applier | 29a03be3-cccf-11e6-9dac-00163e2d2c29 | interface.test.haodai.com | 24802 | ONLINE |
| group_replication_applier | 550a7cbd-ccce-11e6-829a-a2d813521b2e | sh347 | 3307 | ONLINE |
+---------------------------+--------------------------------------+---------------------------+-------------+--------------+
注意:与2操作相比少了两个步骤,千万别执行那两个步骤!那两个步骤是在搭建gp 初始化才需要执行的两个步骤
3.4检验数据
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.00 sec)
mysql> select * from test.t1;
+----+------+
| c1 | c2 |
+----+------+
| 1 | Luis |
+----+------+
1 row in set (0.00 sec)
3.3 安装引擎,加入gp组
mysql> INSTALL PLUGIN group_replication SONAME 'group_replication.so';
mysql> START GROUP_REPLICATION;
mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+---------------------------+-------------+--------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+---------------------------+-------------+--------------+
| group_replication_applier | 29a03be3-cccf-11e6-9dac-00163e2d2c29 | interface.test.haodai.com | 24802 | ONLINE |
| group_replication_applier | 550a7cbd-ccce-11e6-829a-a2d813521b2e | sh347 | 3307 | ONLINE |
+---------------------------+--------------------------------------+---------------------------+-------------+--------------+
注意:与2操作相比少了两个步骤,千万别执行那两个步骤!那两个步骤是在搭建gp 初始化才需要执行的两个步骤
3.4检验数据
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.00 sec)
mysql> select * from test.t1;
+----+------+
| c1 | c2 |
+----+------+
| 1 | Luis |
+----+------+
1 row in set (0.00 sec)
4 模拟数据库down机
关闭247数据库
mysql> SELECT * FROM performance_schema.replication_group_members;
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
| group_replication_applier | | | NULL | OFFLINE |
1 row in set (0.00 sec)
mysql> start GROUP_REPLICATION; ###重新打开即可
Query OK, 0 rows affected (3.50 sec)
mysql> SELECT * FROM performance_schema.replication_group_members;
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
| group_replication_applier | 29a03be3-cccf-11e6-9dac-00163e2d2c29 | interface.test.haodai.com | 24802 | ONLINE |
| group_replication_applier | 550a7cbd-ccce-11e6-829a-a2d813521b2e | sh347 | 3307 | ONLINE |
2 rows in set (0.00 sec)
mysql> stop GROUP_REPLICATION;
Query OK, 0 rows affected (8.47 sec)
mysql> SELECT * FROM performance_schema.replication_group_members;
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
| group_replication_applier | 550a7cbd-ccce-11e6-829a-a2d813521b2e | sh347 | 3307 | OFFLINE |
1 row in set (0.00 sec)
mysql> start GROUP_REPLICATION;
Query OK, 0 rows affected (5.49 sec)
mysql> SELECT * FROM performance_schema.replication_group_members;
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
| group_replication_applier | 29a03be3-cccf-11e6-9dac-00163e2d2c29 | interface.test.haodai.com | 24802 | ONLINE |
| group_replication_applier | 550a7cbd-ccce-11e6-829a-a2d813521b2e | sh347 | 3307 | ONLINE |
2 rows in set (0.00 sec)
关闭247数据库
mysql> SELECT * FROM performance_schema.replication_group_members;
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
| group_replication_applier | | | NULL | OFFLINE |
1 row in set (0.00 sec)
mysql> start GROUP_REPLICATION; ###重新打开即可
Query OK, 0 rows affected (3.50 sec)
mysql> SELECT * FROM performance_schema.replication_group_members;
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
| group_replication_applier | 29a03be3-cccf-11e6-9dac-00163e2d2c29 | interface.test.haodai.com | 24802 | ONLINE |
| group_replication_applier | 550a7cbd-ccce-11e6-829a-a2d813521b2e | sh347 | 3307 | ONLINE |
2 rows in set (0.00 sec)
mysql> stop GROUP_REPLICATION;
Query OK, 0 rows affected (8.47 sec)
mysql> SELECT * FROM performance_schema.replication_group_members;
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
| group_replication_applier | 550a7cbd-ccce-11e6-829a-a2d813521b2e | sh347 | 3307 | OFFLINE |
1 row in set (0.00 sec)
mysql> start GROUP_REPLICATION;
Query OK, 0 rows affected (5.49 sec)
mysql> SELECT * FROM performance_schema.replication_group_members;
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
| group_replication_applier | 29a03be3-cccf-11e6-9dac-00163e2d2c29 | interface.test.haodai.com | 24802 | ONLINE |
| group_replication_applier | 550a7cbd-ccce-11e6-829a-a2d813521b2e | sh347 | 3307 | ONLINE |
2 rows in set (0.00 sec)
至此,数据库集群组搭建完毕!
关于怎样进行MySQL5.7.17- Group Replication搭建问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341