os: centos 7.4.1708
db: mysql 8.0.20
标题写的是 mysql 5.7,实际使用的是 mysql 8
ip规划入下
192.168.56.61 node1
192.168.56.62 node2
192.168.56.63 node3
# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core)
#
#
# yum list installed |grep -i mysql80
mysql-community-client.x86_64 8.0.20-1.el7 @mysql80-community
mysql-community-common.x86_64 8.0.20-1.el7 @mysql80-community
mysql-community-devel.x86_64 8.0.20-1.el7 @mysql80-community
mysql-community-libs.x86_64 8.0.20-1.el7 @mysql80-community
mysql-community-libs-compat.x86_64 8.0.20-1.el7 @mysql80-community
mysql-community-server.x86_64 8.0.20-1.el7 @mysql80-community
mysql-community-test.x86_64 8.0.20-1.el7 @mysql80-community
mysql80-community-release.noarch el7-3 installed
# mysql -e "select version();"
+-----------+
| version() |
+-----------+
| 8.0.20 |
+-----------+
# cat /etc/my.cnf
plugin_load_add='group_replication.so'
##########################
# group replication
##########################
transaction_write_set_extraction=XXHASH64
# show master status.Executed_Gtid_Set;
loose-group_replication_group_name="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
loose-group_replication_bootstrap_group=off
loose-group_replication_start_on_boot=off
loose-group_replication_recovery_retry_count=31536000
# singe primary or multi primary mode
loose-group_replication_single_primary_mode=on
loose-group_replication_enforce_update_everywhere_checks=off
loose-group_replication_local_address= "192.168.56.61:24901"
loose-group_replication_group_seeds="192.168.56.61:24901,192.168.56.62:24901,192.168.56.63:24901"
loose-group_replication_ip_whitelist="192.168.56.0/24,127.0.0.1/8"
3台机器都重启,在node1节点手动启动 group replication 失败
mysql> start group_replication;
ERROR 3092 (HY000): The server is not configured properly to be an active member of the group. Please see more details on error log.
查看日志
# tail -f /var/log/mysqld.log
2020-07-03T00:38:41.484292Z 0 [ERROR] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] Error on opening a connection to 192.168.56.62:24901 on local port: 24901.'
2020-07-03T00:38:41.484632Z 0 [ERROR] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] Error on opening a connection to 192.168.56.63:24901 on local port: 24901.'
2020-07-03T00:38:41.485076Z 0 [ERROR] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] Error on opening a connection to 192.168.56.62:24901 on local port: 24901.'
2020-07-03T00:38:41.485421Z 0 [ERROR] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] Error on opening a connection to 192.168.56.63:24901 on local port: 24901.'
2020-07-03T00:38:41.485473Z 0 [ERROR] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] Error connecting to all peers. Member join failed. Local port: 24901'
2020-07-03T00:38:42.597729Z 0 [ERROR] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] The member was unable to join the group. Local port: 24901'
发现需要在 node1 节点上设置下 group_replication_bootstrap_group = ON
SET GLOBAL group_replication_bootstrap_group = ON;
start group_replication;
SET GLOBAL group_replication_bootstrap_group = OFF;
其余节点可以按照如下操作
stop group_replication;
SET GLOBAL group_replication_bootstrap_group = OFF;
# mysql 5.7 need set group_replication_allow_local_disjoint_gtids_join
# set global group_replication_allow_local_disjoint_gtids_join=on;
start group_replication;
mysql> select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION |
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
| group_replication_applier | 3eb9fbf6-bc59-11ea-98ff-080027b25b0c | node1 | 3306 | ONLINE | PRIMARY | 8.0.20 |
| group_replication_applier | 972d0ab4-bc5b-11ea-8597-080027e63b6a | node3 | 3306 | ONLINE | SECONDARY | 8.0.20 |
| group_replication_applier | f72957f5-bc5a-11ea-ae97-080027429574 | node2 | 3306 | ONLINE | SECONDARY | 8.0.20 |
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
3 rows in set (0.00 sec)