本博文介紹了Group Replication的兩種工作模式的架構。 並詳細介紹了Single-Master Mode的部署過程,以及如何切換到Multi-Master Mode。 當然,文末給出了Group Replication的配置要求和一些限制。 〇 結構介紹 在2016年12月發佈的5.7 ...
本博文介紹了Group Replication的兩種工作模式的架構。
並詳細介紹了Single-Master Mode的部署過程,以及如何切換到Multi-Master Mode。
當然,文末給出了Group Replication的配置要求和一些限制。
〇 結構介紹
在2016年12月發佈的5.7.17版本的MySQL,甲骨文宣佈Group Replication已經GA。
Group Replication(下簡稱GR)有兩個工作模式,分別為Single-Master Mode與Multi-Master Mode:
Single-Master Mode:
只有primary成員可讀寫,而其他的節點為只讀,在primary成員發生故障時,將會有其他成員頂替成primary。
Multi-Master Mode:
所有的成員均可讀可寫。
〇 部署
測試實例數量:3台
版本:MySQL 5.7.20
安裝(此處用的是二進位包安裝)
mysql-5.7.20-linux-glibc2.5-x86_64.tar.gz
創建數據目錄及日誌目錄:
mkdir -p /data/mysql57/mysql3306
mkdir -p /data/mysql57/mysql3307
mkdir -p /data/mysql57/mysql3308
mkdir -p /data/mysql57/logs/3306
mkdir -p /data/mysql57/logs/3307
mkdir -p /data/mysql57/logs/3308
解壓二進位包並將其設置為basedir:
上傳二進位包到/usr/local/src
cd /usr/local/src
tar zxvf mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.20-linux-glibc2.12-x86_64 /usr/local/mysql
〇 添加第一臺實例:
添加3306實例的配置文件:
vim /data/mysql57/3306.cnf
[client]
prompt = "(\u@\h) [\d]> "
[mysqld]
server_id = 3306
user = mysql
port = 3306
socket = /tmp/mysql3306.sock
basedir = /usr/local/myssql
datadir = /data/mysql57/mysql3306
pid-file = /data/mysql57/mysql3306/3306.pid
log-error = /data/mysql57/logs/3306/error-log
log-bin = /data/mysql57/logs/3306/binlog
log-bin-index = /data/mysql57/logs/3306/binlog.index
relay-log = /data/mysql57/logs/3306/relaylog
relay-log-index = /data/mysql57/logs/3306/relaylog.index
master_info_repository = TABLE
relay_log_info_repository = TABLE
log_slave_updates = ON
binlog_checksum = NONE
binlog_format = ROW
transaction_isolation = READ-COMMITTED
gtid_mode = ON
enforce_gtid_consistency = ON
# GR 配置項 其中loose首碼表示若Group Replication plugin未載入 mysql server仍繼續啟動
transaction_write_set_extraction = XXHASH64
# 組名,此處可拿select uuid();生成
loose-group_replication_group_name = "33c90212-f120-11e7-8426-6c0b846288f8"
# 在mysqld啟動時不自動啟動組複製
loose-group_replication_start_on_boot = off
loose-group_replication_local_address = "127.0.0.1:24901"
loose-group_replication_group_seeds = "127.0.0.1:24901,127.0.0.1:24902,127.0.0.1:24903"
loose-group_replication_bootstrap_group = off
初始化3306實例datadir:
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql57/3306.cnf --initialize-insecure
啟動3306實例:
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql57/3306.cnf &
通過MySQL Client進入第一個實例(密碼為空)
/usr/local/mysql/bin/mysql -uroot -p -S /tmp/mysql3306.sock
創建複製用戶與授權,並讓其作為group的第一個成員:
SET SQL_LOG_BIN=0;
CREATE USER repl@'%';
GRANT REPLICATION SLAVE ON *.* TO repl@'%' IDENTIFIED BY 'repl@123';
FLUSH PRIVILEGES;
SET SQL_LOG_BIN=1;
change master to master_user='repl',master_passowrd='repl@123' for channel'group_replication_recovery';
安裝GR插件:
INSTALL PLUGIN group_replication SONAME 'group_replication.so';
可以檢查一下是否安裝成功:
(root@localhost) [(none)]> SELECT * FROM information_schema.plugins WHERE PLUGIN_NAME LIKE '%group%'\G
*************************** 1. row ***************************
PLUGIN_NAME: group_replication
PLUGIN_VERSION: 1.0
PLUGIN_STATUS: ACTIVE
PLUGIN_TYPE: GROUP REPLICATION
PLUGIN_TYPE_VERSION: 1.1
PLUGIN_LIBRARY: group_replication.so
PLUGIN_LIBRARY_VERSION: 1.7
PLUGIN_AUTHOR: ORACLE
PLUGIN_DESCRIPTION: Group Replication (1.0.0)
PLUGIN_LICENSE: GPL
LOAD_OPTION: ON
1 row in set (0.00 sec)
開啟第一個組複製:
(root@localhost) [(none)]> SET GLOBAL group_replication_bootstrap_group=ON;
Query OK, 0 rows affected (0.00 sec)
(root@localhost) [(none)]> START GROUP_REPLICATION;
Query OK, 0 rows affected (1.20 sec)
# 啟動組複製之後將group_replication_bootstrap_group設置為OFF
# This option must only be set on one server and only when starting the group for the first time or restarting the entire group. After the group has been bootstrapped, set this option to OFF. It should be set to OFF both dynamically and in the configuration files
(root@localhost) [(none)]> SET GLOBAL group_replication_bootstrap_group=OFF;
Query OK, 0 rows affected (0.01 sec)
檢查一下組複製成員,其中member_id就是@@server_uuid的值
(root@localhost) [(none)]> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 3dc9cf4a-ec61-11e6-bdf3-000c297f23b7 | sAno1y | 3306 | ONLINE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
1 row in set (0.00 sec)
添加測試數據:
(root@localhost) [(none)]> CREATE DATABASE test;
- Query OK, 1 row affected (0.00 sec)
(root@localhost) [(none)]> USE test;
- Database changed
(root@localhost) [test]> CREATE TABLE tb_test(id int PRIMARY KEY, name varchar(20)) CHARACTER SET utf8;
- Query OK, 0 rows affected (0.04 sec)
(root@localhost) [test]> INSERT INTO tb_test VALUES(1,'風暴之靈');
- Query OK, 1 row affected (0.00 sec)
(root@localhost) [test]> INSERT INTO tb_test VALUES(2,'影之靈龕');
- Query OK, 1 row affected (0.01 sec)
(root@localhost) [test]> UPDATE tb_test SET name='斯嘉蒂之眼' WHERE id=2;
- Query OK, 1 row affected (0.02 sec)
- Rows matched: 1 Changed: 1 Warnings: 0
(root@localhost) [test]> SELECT * FROM tb_test;
- +----+-----------------+
- | id | name |
- +----+-----------------+
- | 1 | 風暴之靈 |
- | 2 | 斯嘉蒂之眼 |
- +----+-----------------+
- 2 rows in set (0.00 sec)
〇 添加第二個實例(3307)
修改3307配置文件,將3306改成3307,並且將loose-group_replication_local_address的埠從24901改成24902:
cp /data/mysql57/3306.cnf /data/mysql57/3307.cnf
sed -i "s/3306/3307/g" /data/mysql57/3307.cnf
sed -i "s/24901\"/24902\"/g" 3307.cnf
初始化3307實例:
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql57/3307.cnf --initialize-insecure
啟動3307實例:
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql57/3307.cnf &
通過MySQL Client進入3307實例:
/usr/local/mysql/bin/mysql -uroot -p -S /tmp/mysql3307.sock
重覆在3306實例的操作:
SET SQL_LOG_BIN=0;
CREATE USER repl@'%';
GRANT REPLICATION SLAVE ON *.* TO repl@'%' IDENTIFIED BY 'repl@123';
FLUSH PRIVILEGES;
SET SQL_LOG_BIN=1;
CHANGE MASTER TO MASTER_USER='repl', MASTER_PASSWORD='repl@123' FOR CHANNEL 'group_replication_recovery';
在3307實例上安裝GR插件,開啟組複製:
(root@localhost) [(none)]> INSTALL PLUGIN group_replication SONAME 'group_replication.so';
(root@localhost) [(none)]> START GROUP_REPLICATION;
- Query OK, 0 rows affected (5.61 sec)
檢查一下成員狀態:
- (root@localhost) [(none)]> SELECT * FROM performance_schema.replication_group_members;
- +---------------------------+--------------------------------------+-------------+-------------+--------------+
- | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
- +---------------------------+--------------------------------------+-------------+-------------+--------------+
- | group_replication_applier | 3dc9cf4a-ec61-11e6-bdf3-000c297f23b7 | sAno1y | 3306 | ONLINE |
- | group_replication_applier | 6bddae0d-eca1-11e6-b9d5-000c297f23b7 | sAno1y | 3307 | RECOVERING |
- +---------------------------+--------------------------------------+-------------+-------------+--------------+
- 2 rows in set (0.00 sec)
過了一陣子再檢查,仍然是RECOVERING。
再過一陣子檢查,發現member_state被置為ERROR:
- (root@localhost) [(none)]> SELECT * FROM performance_schema.replication_group_members;
- +---------------------------+--------------------------------------+-------------+-------------+--------------+
- | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
- +---------------------------+--------------------------------------+-------------+-------------+--------------+
- | group_replication_applier | 6bddae0d-eca1-11e6-b9d5-000c297f23b7 | sAno1y | 3307 | ERROR |
- +---------------------------+--------------------------------------+-------------+-------------+--------------+
- 1 row in set (0.01 sec)
此時檢查3306實例的組複製情況,發現檢查不到另一個實例的信息了:
- (root@localhost) [(none)]> SELECT * FROM performance_schema.replication_group_members;
- +---------------------------+--------------------------------------+-------------+-------------+--------------+
- | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
- +---------------------------+--------------------------------------+-------------+-------------+--------------+
- | group_replication_applier | 3dc9cf4a-ec61-11e6-bdf3-000c297f23b7 | sAno1y | 3306 | ONLINE |
- +---------------------------+--------------------------------------+-------------+-------------+--------------+
- 1 row in set (0.00 sec)
開多一個終端,檢查3307實例的error log發現:
- 2017-02-07T12:06:21.674093Z 47 [ERROR] Slave I/O for channel 'group_replication_recovery': error connecting to master 'repl@sAno1y:3306' - retry-time: 60 retries: 1, Error_code: 2005
應該是解析的問題,修改hosts文件,在末尾加上主機名:
- [root@sAno1y 3307]# hostname
- sAno1y
- [root@sAno1y 3307]# cat /etc/hosts
- 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 sAno1y
- ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 sAno1y
重新操作3307實例:
(root@localhost) [(none)]> STOP GROUP_REPLICATION;
- Query OK, 0 rows affected (0.00 sec)
(root@localhost) [(none)]> START GROUP_REPLICATION;
- Query OK, 0 rows affected (7.80 sec)
檢查組複製狀態,發現兩個實例的狀態均為ONLINE了:
- (root@localhost) [(none)]> SELECT * FROM performance_schema.replication_group_members;
- +---------------------------+--------------------------------------+-------------+-------------+--------------+
- | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
- +---------------------------+--------------------------------------+-------------+-------------+--------------+
- | group_replication_applier | 3dc9cf4a-ec61-11e6-bdf3-000c297f23b7 | sAno1y | 3306 | ONLINE |
- | group_replication_applier | 6bddae0d-eca1-11e6-b9d5-000c297f23b7 | sAno1y | 3307 | ONLINE |
- +---------------------------+--------------------------------------+-------------+-------------+--------------+
- 2 rows in set (0.00 sec)
在3307上檢查一下同步狀態:
- (root@localhost) [(none)]> SELECT * FROM test.tb_test;
- +----+-----------------+
- | id | name |
- +----+-----------------+
- | 1 | 風暴之靈 |
- | 2 | 斯嘉蒂之眼 |
- +----+-----------------+
- 2 rows in set (0.00 sec)
〇 添加3308實例:
修改3308配置文件:
cp /data/mysql57/3306.cnf /data/mysql57/3308.cnf
sed -i "s/3306/3308/g" 3308.cnf
sed -i "s/24901\"/24093\"/g" 3308.cnf
然後初始化並啟動3308實例:
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql57/3308.cnf --initialize-insecure
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql57/3308.cnf &
同樣進入3308實例:
/usr/local/mysql/bin/mysql -uroot -p -S /tmp/mysql3308.sock
在3308實例上重覆操作:
SET SQL_LOG_BIN=0;
CREATE USER repl@'%';
GRANT REPLICATION SLAVE ON *.* TO repl@'%' IDENTIFIED BY 'repl@123';
FLUSH PRIVILEGES;
SET SQL_LOG_BIN=1;
CHANGE MASTER TO MASTER_USER='repl', MASTER_PASSWORD='repl@123' FOR CHANNEL 'group_replication_recovery';
繼續重覆操作,安裝GR插件並啟動它:
INSTALL PLUGIN group_replication SONAME 'group_replication.so';
START GROUP_REPLICATION;
最後再檢查一下組複製成員的狀態:
- (root@localhost) [(none)]> SELECT * FROM performance_schema.replication_group_members;
- +---------------------------+--------------------------------------+-------------+-------------+--------------+
- | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
- +---------------------------+--------------------------------------+-------------+-------------+--------------+
- | group_replication_applier | 3dc9cf4a-ec61-11e6-bdf3-000c297f23b7 | sAno1y | 3306 | ONLINE |
- | group_replication_applier | 6bddae0d-eca1-11e6-b9d5-000c297f23b7 | sAno1y | 3307 | ONLINE |
- | group_replication_applier | 6ce8c980-ed4a-11e6-bf00-000c297f23b7 | sAno1y | 3308 | ONLINE |
- +---------------------------+--------------------------------------+-------------+-------------+--------------+
- 3 rows in set (0.00 sec)
當然在3308實例上也已將3306的事務apply過來了:
(root@localhost) [(none)]> SELECT * FROM test.tb_test;
+----+-----------------+
| id | name |
+----+-----------------+
| 1 | 風暴之靈 |
| 2 | 斯嘉蒂之眼 |
+----+-----------------+
2 rows in set (0.00 sec)
root@localhost用戶在上述操作中為空密碼,可以給root@localhost加個密碼……
因為三個實例都在一個GR組裡,所以對3306實例操作就行了:
/usr/local/mysql/bin/mysql -uroot -p -S /tmp/mysql3306.sock -e "ALTER USER root@localhost IDENTIFIED BY 'root123';"
當然ALTER操作會被記錄到3306的binlog里,並同步到3307和3308實例上。
可以查看一下三台實例的read_only和super-read-only值:
- [root@sAno1y mysql57]# /data/mysql57/mysql-basedir/bin/mysql -uroot -proot123 -S /tmp/mysql3306.sock -e "SELECT @@read_only, @@super_read_only";
- mysql: [Warning] Using a password on the command line interface can be insecure.
- +-------------+-------------------+
- | @@read_only | @@super_read_only |
- +-------------+-------------------+
- | 0 | 0 |
- +-------------+-------------------+
- [root@sAno1y mysql57]# /data/mysql57/mysql-basedir/bin/mysql -uroot -proot123 -S /tmp/mysql3307.sock -e "SELECT @@read_only, @@super_read_only";
- mysql: [Warning] Using a password on the command line interface can be insecure.
- +-------------+-------------------+
- | @@read_only | @@super_read_only |
- +-------------+-------------------+
- | 1 | 1 |
- +-------------+-------------------+
- [root@sAno1y mysql57]# /data/mysql57/mysql-basedir/bin/mysql -uroot -proot123 -S /tmp/mysql3308.sock -e "SELECT @@read_only, @@super_read_only";
- mysql: [Warning] Using a password on the command line interface can be insecure.
- +-------------+-------------------+
- | @@read_only | @@super_read_only |
- +-------------+-------------------+
- | 1 | 1 |
- +-------------+-------------------+
可以發現只有3306實例也就是第一個實例屬於可寫實例,而3307和3308均為read-only模式。
決定因素為第一個加入該GR組的成員,之後加入該GR組的均為ro,在該模式與MongoDB Replicate Set很相似。
當然如果要確定哪一個成員是primary,可以在三個成員中的任意一個執行:
SELECT b.member_id, b.member_host, b.member_port
FROM performance_schema.global_status a
JOIN performance_schema.replication_group_members b
ON a.variable_value = b.member_id
WHERE a.variable_name= 'group_replication_primary_member';
# 輸出結果:
+--------------------------------------+-------------+-------------+
| member_id | member_host | member_port |
+--------------------------------------+-------------+-------------+
| 3dc9cf4a-ec61-11e6-bdf3-000c297f23b7 | sAno1y | 3306 |
+--------------------------------------+-------------+-------------+
1 row in set (0.00 sec)
至此,Group Replication預設的single-master mode已經搭建完畢。
〇 將Single-Master Mode修改為Multi-Master Mode
如果要將Single-Master Mode修改為Multi-Master Mode,也比較簡單。
考慮到此時的Primary成員是3306,並且假定3306實例在對外提供寫服務,我這邊的操作如下:
首先停掉兩個secondary的組複製,在3307和3308實例上操作:
STOP GROUP_REPLICATION;
SET GLOBAL group_replication_single_primary_mode=FALSE;
SET GLOBAL group_replication_enforce_update_everywhere_checks=TRUE;
再在3306實例上重覆以上操作:
STOP GROUP_REPLICATION;
SET GLOBAL group_replication_single_primary_mode=FALSE;
SET GLOBAL group_replication_enforce_update_everywhere_checks=TRUE;
然後在3306上作為第一個成員啟動組複製:
(root@localhost) [(none)]> SET GLOBAL group_replication_bootstrap_group=on;
- Query OK, 0 rows affected (0.00 sec)
(root@localhost) [(none)]> START GROUP_REPLICATION;
- Query OK, 0 rows affected (1.05 sec)
(root@localhost) [(none)]> SET GLOBAL group_replication_bootstrap_group=off;
- Query OK, 0 rows affected (0.00 sec)
在停啟組複製的過程中,3306實例仍對外提供服務,此處模擬修改:
(root@localhost) [(none)]> UPDATE test.tb_test SET name='靈魂守衛' WHERE id=1;
- Query OK, 1 row affected (0.02 sec)
- Rows matched: 1 Changed: 1 Warnings: 0
(root@localhost) [(none)]> INSERT INTO test.tb_test VALUES(3,'幻影斧');
- Query OK, 1 row affected (0.00 sec)
(root@localhost) [(none)]> SELECT * FROM test.tb_test;
- +----+-----------------+
- | id | name |
- +----+-----------------+
- | 1 | 靈魂守衛 |
- | 2 | 斯嘉蒂之眼 |
- | 3 | 幻影斧 |
- +----+-----------------+
- 3 rows in set (0.00 sec)
再3307和3308兩個實例上分別開啟組複製:
START GROUP_REPLICATION;
並檢查3307和3308是否將3306的事務應用過來:
- [root@sAno1y mysql57]# /usr/local/mysql/bin/mysql -uroot -proot123 -S /tmp/mysql3307.sock -e "START GROUP_REPLICATION;"
- mysql: [Warning] Using a password on the command line interface can be insecure.
- [root@sAno1y mysql57]#
- [root@sAno1y mysql57]# /usr/local/mysql/bin/mysql -uroot -proot123 -S /tmp/mysql3308.sock -e "START GROUP_REPLICATION;"
- mysql: [Warning] Using a password on the command line interface can be insecure.
- [root@sAno1y mysql57]# /usr/local/mysql/bin/mysql -uroot -proot123 -S /tmp/mysql3307.sock -e "SELECT * FROM test.tb_test;"
- mysql: [Warning] Using a password on the command line interface can be insecure.
- +----+-----------------+
- | id | name |
- +----+-----------------+
- | 1 | 靈魂守衛 |
- | 2 | 斯嘉蒂之眼 |
- | 3 | 幻影斧 |
- +----+-----------------+
- [root@sAno1y mysql57]# /usr/local/mysql/bin/mysql -uroot -proot123 -S /tmp/mysql3308.sock -e "SELECT * FROM test.tb_test;"
- mysql: [Warning] Using a password on the command line interface can be insecure.
- +----+-----------------+
- | id | name |
- +----+-----------------+
- | 1 | 靈魂守衛 |
- | 2 | 斯嘉蒂之眼 |
- | 3 | 幻影斧 |
- +----+-----------------+
當然可以看到,在3306上做的修改,在3307和3308開啟組複製之後也已經同步過來了。
那麼再檢查一下3307和3308是否可寫:
- [root@sAno1y mysql57]# /usr/local/mysql/bin/mysql -uroot -proot123 -S /tmp/mysql3307.sock -e "SELECT @@read_only, @@super_read_only;"
- mysql: [Warning] Using a password on the command line interface can be insecure.
- +-------------+-------------------+
- | @@read_only | @@super_read_only |
- +-------------+-------------------+
- | 0 | 0 |
- +-------------+-------------------+
- [root@sAno1y mysql57]# /usr/local/mysql/bin/mysql -uroot -proot123 -S /tmp/mysql3308.sock -e "SELECT @@read_only, @@super_read_only;"
- mysql: [Warning] Using a password on the command line interface can be insecure.
- +-------------+-------------------+
- | @@read_only | @@super_read_only |
- +-------------+-------------------+
- | 0 | 0 |
- +-------------+-------------------+
顯然和Single-Master Mode不一樣的是,除了3306實例,另外兩個成員也就是3307和3308實例均為可寫成員了。
也就是所謂的Multi-Master Mode。
當然可以測試一下:
在3307實例上做insert,在3308實例上update,最後在3306上查詢:
- [root@sAno1y mysql57]# /usr/local/mysql/bin/mysql -uroot -proot123 -S /tmp/mysql3307.sock -e "INSERT INTO test.tb_test VALUES(4,'吸血面具')";
- mysql: [Warning] Using a password on the command line interface can be insecure.
- [root@sAno1y mysql57]# /usr/local/mysql/bin/mysql -uroot -proot123 -S /tmp/mysql3308.sock -e "UPDATE test.tb_test SET name='撒旦之邪力' WHERE id=4;"
- mysql: [Warning] Using a password on the command line interface can be insecure.
- [root@sAno1y mysql57]# /usr/local/mysql/bin/mysql -uroot -proot123 -S /tmp/mysql3306.sock -e "SELECT * FROM test.tb_test;"
- mysql: [Warning] Using a password on the command line interface can be insecure.
- +----+-----------------+
- | id | name |
- +----+-----------------+
- | 1 | 靈魂守衛 |
- | 2 | 斯嘉蒂之眼 |
- | 3 | 幻影斧 |
- | 4 | 撒旦之邪力 |
- +----+-----------------+
至此,已經成功將Single-Master Mode修改為Multi-Master Mode。
P.S. 在多主模式中,已經不能通過下述SQL來查詢primary member是哪一臺實例了……雖然不明白為毛,可能在後續版本會改進???(猜測)
但總之在多主模式中,每一臺status為online的成員都是primary。
SELECT b.member_id, b.member_host, b.member_port
FROM performance_schema.global_status a
JOIN performance_schema.replication_group_members b
ON a.variable_value = b.member_id
WHERE a.variable_name= 'group_replication_primary_member';
從零開始搭建Multi-Master Mode的GR同樣也很簡單,可以參考:
http://mysqlhighavailability.com/mysqlha/gr/doc/getting_started.html
兩種工作模式在配置參數上的核心差別為:
loose-group_replication_single_primary_mode=FALSE
loose-group_replication_enforce_update_everywhere_checks=TRUE
(single-master mode 這倆個參數的值為TRUE和FALSE)
〇 要求和限制
僅可用於InnoDB存儲引擎(需要事務的支持和行級鎖)
表必須有主鍵(創建無主鍵的表不會報錯,但在插入數據的時候會拋出:ERROR 3098 (HY000): The table does not comply with the requirements by an external plugin.)
必須啟用GTID
必須開啟二進位日誌,並且其格式必須為ROW(binlog_format=row)
衝突DDl、DML只能在同一成員上執行成功
在多主結構中,不完全支持外鍵(單主結構中是沒有問題的)
不支持serializable的事務隔離級別
只支持IPv4,並且需要低延遲,高帶寬的網路環境
GR最大支持9個成員
複製信息元數據必須存在系統表(master-info-repository=TABLE、relay-log-info-repository=TABLE)
二進位日誌checksums必須關閉(binlog-checksum=NONE)
不支持savepoint的使用