怎樣進(jìn)行MySQL5.7.17- Group Replication搭建,針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。
目前創(chuàng)新互聯(lián)公司已為上千多家的企業(yè)提供了網(wǎng)站建設(shè)、域名、雅安服務(wù)器托管、網(wǎng)站托管、企業(yè)網(wǎng)站設(shè)計(jì)、市北網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。
背景:
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)
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.1修改第二臺(tái)數(shù)據(jù)庫(kù)配置文件
[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啟動(dòng)數(shù)據(jù)庫(kù)進(jìn)行配置
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操作相比少了兩個(gè)步驟,千萬(wàn)別執(zhí)行那兩個(gè)步驟!那兩個(gè)步驟是在搭建gp 初始化才需要執(zhí)行的兩個(gè)步驟
3.4檢驗(yàn)數(shù)據(jù)
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)
關(guān)閉247數(shù)據(jù)庫(kù)
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)
至此,數(shù)據(jù)庫(kù)集群組搭建完畢!
關(guān)于怎樣進(jìn)行MySQL5.7.17- Group Replication搭建問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識(shí)。