【Mysql】MySQL5.7.17- Group Replication搭建
背景:
4 模擬資料庫down機
至此,資料庫叢集組搭建完畢!!!!未完待續!!!!
效能測試參考姜老師部落格:
實現原理與維護可參考acumg部落格
http://mp.weixin.qq.com/s/pBAOXW7Kx_EtdRVe4VaCYg
參考:
http://dev.mysql.com/doc/refman/5.7/en/group-replication-adding-instances.html
- 環境
- host dbport
-
192.168.1.247 3307
192.168.1.14 24802
192.168.1.242 3307
1.配置hosts資訊
-
192.168.1.247 sh247
-
192.168.1.14 interface.test.haodai.com
- 192.168.1.242 sh242
2 第一臺資料庫操作
-
2.1修改配置檔案
-
[client]
port = 3307
socket = /home/data/mydata/3307/mysql.sock
[mysqld]
port = 3307
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 = 1
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.247:34061"
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
2.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'
2.3 安裝引擎
-
- 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 | sh247 | 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修改第二臺資料庫配置檔案
-
-
[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
-
[client]
-
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'
-
-
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 | sh247 | 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)
-
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 | sh247 | 3307 | ONLINE |
- +---------------------------+--------------------------------------+---------------------------+-------------+--------------+
- 注意:與2操作相比少了兩個步驟,千萬別執行那兩個步驟!那兩個步驟是在搭建gp 初始化才需要執行的兩個步驟
-
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 | sh247 | 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 | sh247 | 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 | sh247 | 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 | sh247 | 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 | sh247 | 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 | sh247 | 3307 | ONLINE |
-
+---------------------------+--------------------------------------+---------------------------+-------------+--------------+
- 2 rows in set (0.00 sec)
效能測試參考姜老師部落格:
實現原理與維護可參考acumg部落格
http://mp.weixin.qq.com/s/pBAOXW7Kx_EtdRVe4VaCYg
參考:
http://dev.mysql.com/doc/refman/5.7/en/group-replication-adding-instances.html
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29096438/viewspace-2131537/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MYSQL Group Replication搭建過程記錄MySql
- MGR(MySQL Group Replication)部署搭建測試MySql
- MySQL Group ReplicationMySql
- MySQL group replication介紹MySql
- MySQL Group Replication小試MySql
- MySQL Group Replication 學習(部署篇)MySql
- 配置Mysql Group Replication遇到的問題筆記MySql筆記
- MySQL8.0.16新特性:The Communication Protocol In Group ReplicationMySqlProtocol
- MySQL 5.7組複製(group replication)的要求和限制MySql
- MySQL 5.7.17 組複製(group replication)的要求和限制MySql
- 分分鐘搭建MySQL Group Replication測試環境(r11筆記第83天)MySql筆記
- group_replication_bootstrap_group 用於什麼boot
- Mysql 5.7 基於組複製(MySQL Group Replication) - 運維小結MySql運維
- 分分鐘搭建MySQL Group Replication測試環境(二)(r12筆記第41天)MySql筆記
- 【MySQL】MySQL Replication 一主一備搭建步驟(GTID方式)MySql
- 【MySQL】MySQL Replication 一主一備搭建步驟(傳統方式)MySql
- Build mysql replicationUIMySql
- Mysql Replication(轉)MySql
- 使用ProxySQL實現MySQL Group Replication的故障轉移、讀寫分離(一)MySql
- 系統變數group_replication_group_seeds為空導致MySQL節點無法啟動組複製變數MySql
- 動態建立MySQL Group Replication的節點(r11筆記第84天)MySql筆記
- MySQL案例-replication"卡死"MySql
- 【MySQL】Semisynchronous Replication 概述MySql
- MySQL Replication淺析MySql
- On MySQL replication, again…MySqlAI
- MySQL 5.7.17 Group Relication(組複製)搭建手冊MySql
- An Overview of PostgreSQL & MySQL Cross ReplicationViewMySqlROS
- Mysql replication check指令碼MySql指令碼
- mysql replication之GTIDMySql
- 【恩墨學院】深入剖析 Group Replication核心的引擎特性
- MySQL基於GTIDs的MySQL ReplicationMySql
- mysql replication /mysql 主從複製原理MySql
- 【MySql】MySQL Replication Fatal Error 1236MySqlError
- Mysql Replication學習記錄MySql
- 理解 MySQL(3):複製(Replication)MySql
- MySQL now supports an interface for semisynchronous replication:MySql
- MySQL Replication ConfigurationMySql
- mysql replication常見錯誤MySql