MGR单主模式搭建

三个节点

192.168.0.156 oceanbase06
192.168.0.157 oceanbase07
192.168.0.158 oceanbase08

数据库端口:3306
组复制端口:24901

准备工作

关闭防火墙,修改SELinux为disabled

service iptables stop
chkconfig iptables off
setenforce 0

下载数据库二进制包,拷贝到/tmp目录下
准备好初始化配置文件,可以去叶老师博客自动生成,网址http://imysql.com

MySQL单机环境搭建

创建数据目录及日志目录:

groupadd mysql
useradd -r -g mysql -s /bin/false mysql

mkdir -p /data/mysql/datadir
mkdir -p /data/mysql/logs
chown -R mysql:mysql  /data/mysql

解压二进制包并将其设置为basedir:

mv /tmp/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz /data/mysql/
cd /data/mysql/
tar zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.22-linux-glibc2.12-x86_64 basedir
ln -s /data/mysql/basedir /usr/local/mysql

叶老师网站自动生成配置文件

[root@oceanbase06 tmp]# cat OB06_mysql.conf 
#
## optimized mysql configure file my.cnf
## generated by yejr([email protected], http://imysql.com, QQ: 4700963)
## 叶金荣(yejr)
## 叶金荣(yejr),最有良心、最有品质的在线培训品牌知数堂培训(http://zhishuedu.com)联合创始人
## 新浪微博: @叶金荣, 微信公众:老叶茶馆
## QQ群:579036588、529671799
## 注意:个别建议可能需要根据实际情况作调整,请自行判断或联系我,本人不对这些建议结果负相应责任
## 本配置文件主要适用于MySQL 5.7版本
#
## 初始化参考指令:
## ./bin/mysqld --defaults-file=./my.cnf --initialize --user=mysql --basedir=/usr/local/mysql57 --datadir=/data/mysql57
#
[client]
port    = 3306
socket  = /tmp/mysql.sock

[mysql]
prompt="\u@oceanbase06 \R:\m:\s [\d]> "
no-auto-rehash  # MySQL开启命令自动补全功能(auto-rehash)

[mysqld]
user    = mysql
port    = 3306
basedir = /usr/local/mysql
datadir = /data/mysql/datadir
socket  = /tmp/mysql.sock
pid-file = oceanbase06.pid
character-set-server = utf8mb4
skip_name_resolve = 1
open_files_limit    = 65535
back_log = 1024
max_connections = 512
max_connect_errors = 1000000
table_open_cache = 1024
table_definition_cache = 1024
table_open_cache_instances = 64
thread_stack = 512K
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 4M
join_buffer_size = 4M
thread_cache_size = 768
query_cache_size = 0
query_cache_type = 0
interactive_timeout = 600
wait_timeout = 600
tmp_table_size = 32M
max_heap_table_size = 32M
slow_query_log = 1
slow_query_log_file = /data/mysql/datadir/slow.log
log-error = /data/mysql/datadir/error.log
long_query_time = 0.1
log_queries_not_using_indexes =1
log_throttle_queries_not_using_indexes = 60
min_examined_row_limit = 100
log_slow_admin_statements = 1
log_slow_slave_statements = 1
server-id = 192156
log-bin = /data/mysql/logs/mybinlog
sync_binlog = 1
binlog_cache_size = 4M
max_binlog_cache_size = 2G
max_binlog_size = 1G
expire_logs_days = 7
master_info_repository = TABLE
relay_log_info_repository = TABLE
gtid_mode = on
enforce_gtid_consistency = 1
log_slave_updates
binlog_format = row
binlog_checksum = 1
relay_log_recovery = 1
relay-log-purge = 1
key_buffer_size = 32M
read_buffer_size = 8M
read_rnd_buffer_size = 4M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
lock_wait_timeout = 3600
explicit_defaults_for_timestamp = 1
innodb_thread_concurrency = 0
innodb_sync_spin_loops = 100
innodb_spin_wait_delay = 30

transaction_isolation = REPEATABLE-READ
#innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 50176M
innodb_buffer_pool_instances = 8
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_data_file_path = ibdata1:1G:autoextend
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 32M
innodb_log_file_size = 2G
innodb_log_files_in_group = 2
innodb_max_undo_log_size = 4G

# 根据您的服务器IOPS能力适当调整
# 一般配普通SSD盘的话,可以调整到 10000 - 20000
# 配置高端PCIe SSD卡的话,则可以调整的更高,比如 50000 - 80000
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_flush_neighbors = 0
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_purge_threads = 4
innodb_page_cleaners = 4
innodb_open_files = 65535
innodb_max_dirty_pages_pct = 50
innodb_flush_method = O_DIRECT
innodb_lru_scan_depth = 4000
innodb_checksums = 1
innodb_checksum_algorithm = crc32
#innodb_file_format = Barracuda
#innodb_file_format_max = Barracuda
innodb_lock_wait_timeout = 10
innodb_rollback_on_timeout = 1
innodb_print_all_deadlocks = 1
innodb_file_per_table = 1
innodb_online_alter_log_max_size = 4G
internal_tmp_disk_storage_engine = InnoDB
innodb_stats_on_metadata = 0

innodb_status_file = 1
# 注意: 开启 innodb_status_output & innodb_status_output_locks 后, 可能会导致log-error文件增长较快
innodb_status_output = 0
innodb_status_output_locks = 0

#performance_schema
performance_schema = 1
performance_schema_instrument = '%=on'

#innodb monitor
innodb_monitor_enable="module_innodb"
innodb_monitor_enable="module_server"
innodb_monitor_enable="module_dml"
innodb_monitor_enable="module_ddl"
innodb_monitor_enable="module_trx"
innodb_monitor_enable="module_os"
innodb_monitor_enable="module_purge"
innodb_monitor_enable="module_log"
innodb_monitor_enable="module_lock"
innodb_monitor_enable="module_buffer"
innodb_monitor_enable="module_index"
innodb_monitor_enable="module_ibuf_system"
innodb_monitor_enable="module_buffer_page"
innodb_monitor_enable="module_adaptive_hash"

[mysqldump]
quick
max_allowed_packet = 32M

初始化实例:

mv /tmp/OB06_mysql.conf /data/mysql/
chown mysql:mysql /data/mysql/OB06_mysql.conf
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/OB06_mysql.conf --initialize-insecure --user=mysql

启动数据库实例:

/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/OB06_mysql.conf &

通过MySQL Client进入实例
由于在初始化时指定了参数–initialize-insecure,不需要密码即可进入

/usr/local/mysql/bin/mysql -uroot

MySQL多机环境搭建

只需要在初始化之前,
1. OB06_mysql.conf的文件名修改
2. 修改配置文件OB06_mysql.conf中server-id
3. 其他配置可改可不改

配置组复制

创建复制账号,安装group replication插件

GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.%' IDENTIFIED BY 'lijingkuan';
flush privileges;   

INSTALL PLUGIN group_replication SONAME 'group_replication.so';

在配置文件的mysqld部分添加如下配置:

plugin-load=group_replication.so

– 虽然经过测试,只要在命令行中执行了安装group_replication插件的命令,配置文件中不添加此配置,数据库重启后还是会显示插件已经加载,但是为了严谨,仍旧添加此配置到配置文件。

查看group replication组件是否Active

show plugins;

配置group replication参数
首先确认binlog_format为row格式

show variables like 'binlog_format';

两种配置方式,在线添加 OR 配置文件
第一种配置方式:在线添加
三个节点分别执行如下命令(最后两项配置根据节点不同修改,其他配置相同)

set @@global.transaction_write_set_extraction = XXHASH64;
set @@global.group_replication_start_on_boot = OFF;
set @@global.group_replication_bootstrap_group = OFF;
set @@global.group_replication_group_name = "0c6d3e5f-90e2-11e6-802e-842b2b5909d6";
#务必以uuid形式配置

set @@global.group_replication_local_address = 'oceanbase06:24901';
set @@global.group_replication_group_seeds = 'oceanbase07:24901,oceanbase08:24901';
#不同节点配置不同节点本身的主机名和端口,区分MYSQL自身的3306端口
#注意:这地方一定要用主机名,不要用IP地址,否则后面开启组复制的时候会失败,具体看后面的排错部分。
#这个问题可能是个bug

第二种配置方式:修改配置文件
三个节点配置文件分别添加如下配置 –只有一个配置需要根据实际情况修改

transaction_write_set_extraction = XXHASH64
loose-group_replication_group_name = "0c6d3e5f-90e2-11e6-802e-842b2b5909d6"
loose-group_replication_start_on_boot = off
loose-group_replication_local_address = "oceanbase06:24901"    
loose-group_replication_group_seeds = "oceanbase06:24901,oceanbase07:24901,oceanbase08:24901"
loose-group_replication_bootstrap_group = off
loose-group_replication_single_primary_mode = true
loose-group_replication_enforce_update_everywhere_checks = false

推荐采用第二种(修改配置文件)的方式
配置完后重启数据库

启动mgr集群

CHANGE MASTER TO MASTER_USER='repl', MASTER_PASSWORD='lijingkuan' FOR CHANNEL 'group_replication_recovery';  
#需要在三个节点都执行
#第一次搭建时,只在第一个节点上执行了这个命令,结果在二三节点启动组复制时报错,看后面的问题排错部分。

SET GLOBAL group_replication_bootstrap_group = ON; 
#  只需要在一台机器上执行即可
# 设置group_replication_bootstrap_group为ON是为了标示以后加入集群的服务器以这台服务器为基准,以后加入的就不需要设置。

# 在三个节点分别执行如下命令,先在主节点上执行,否则在其他节点执行会报错,提示无法加入集群,看后面问题排错部分:
start group_replication;


# 查看集群中各个节点状态
SELECT * FROM performance_schema.replication_group_members;

问题排错

问题一:
在一节点执行
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.

查看日志:
2018-06-12T09:50:17.911574Z 2 [ERROR] Plugin group_replication reported: ‘binlog_checksum should be NONE for Group Replication’
解决办法:(三个节点都执行,不要忘记在配置文件中也要更新)

mysql> show variables like  '%binlog_checksum%';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| binlog_checksum | CRC32 |
+-----------------+-------+
1 row in set (0.00 sec)

mysql> set @@global.binlog_checksum='none';
Query OK, 0 rows affected (0.09 sec)

mysql> show variables like  '%binlog_checksum%';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| binlog_checksum | NONE  |
+-----------------+-------+
1 row in set (0.00 sec)

mysql> START GROUP_REPLICATION;
Query OK, 0 rows affected (12.40 sec)

问题二:
在第二节点执行:
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.

查看日志:
2018-06-12T10:07:14.824207Z 0 [ERROR] Plugin group_replication reported: ‘This member has more executed transactions than those present in the group. Local transactions: 891a79fd-6e1d-11e8-8f06-000c295585b9:1-2 > Group transactions: 0c6d3e5f-90e2-11e6-802e-842b2b5909d6:1,
466acf38-6e16-11e8-a7cf-000c29fa2dbb:1-2’
2018-06-12T10:07:14.824253Z 0 [ERROR] Plugin group_replication reported: ‘The member contains transactions not present in the group. The member will now exit the group.’
2018-06-12T10:07:14.824257Z 0 [Note] Plugin group_replication reported: ‘To force this member into the group you can use the group_replication_allow_local_disjoint_gtids_join option’

在第一节点观察到的现象:(短暂出现二节点的recoving信息后,又消失了,然后二节点命令报错)

mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 466acf38-6e16-11e8-a7cf-000c29fa2dbb | oceanbase06 |        3306 | ONLINE       |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
1 row in set (0.00 sec)

mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 466acf38-6e16-11e8-a7cf-000c29fa2dbb | oceanbase06 |        3306 | ONLINE       |
| group_replication_applier | 891a79fd-6e1d-11e8-8f06-000c295585b9 | oceanbase07 |        3306 | RECOVERING   |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
2 rows in set (0.00 sec)

mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 466acf38-6e16-11e8-a7cf-000c29fa2dbb | oceanbase06 |        3306 | ONLINE       |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
1 row in set (0.00 sec)

解决办法:
剩余节点执行以下命令:
set global group_replication_allow_local_disjoint_gtids_join=ON;

问题三:
节点一直处于recoving状态

mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 466acf38-6e16-11e8-a7cf-000c29fa2dbb | oceanbase06 |        3306 | ONLINE       |
| group_replication_applier | 891a79fd-6e1d-11e8-8f06-000c295585b9 | oceanbase07 |        3306 | RECOVERING   |
| group_replication_applier | ee06bb98-6e1c-11e8-9f74-000c2945e5fb | oceanbase08 |        3306 | RECOVERING   |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
3 rows in set (0.00 sec)

查看error log,信息如下:
2018-06-12T10:18:17.841565Z 16 [Note] Plugin group_replication reported: ‘Retrying group recovery connection with another donor. Attempt 7/10’
2018-06-12T10:19:17.841853Z 16 [Note] ‘CHANGE MASTER TO FOR CHANNEL ‘group_replication_recovery’ executed’. Previous state master_host=’oceanbase06’, master_port= 3306, master_log_file=”, master_log_pos= 4, master_bind=”. New state master_host=’oceanbase06’, master_port= 3306, master_log_file=”, master_log_pos= 4, master_bind=”.
2018-06-12T10:19:17.943309Z 16 [Note] Plugin group_replication reported: ‘Establishing connection to a group replication recovery donor 466acf38-6e16-11e8-a7cf-000c29fa2dbb at oceanbase06 port: 3306.’
2018-06-12T10:19:17.943581Z 27 [Warning] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the ‘START SLAVE Syntax’ in the MySQL Manual for more information.
2018-06-12T10:19:17.943629Z 27 [ERROR] Slave I/O for channel ‘group_replication_recovery’: Fatal error: Invalid (empty) username when attempting to connect to the master server. Connection attempt terminated. Error_code: 1593
2018-06-12T10:19:17.943636Z 27 [Note] Slave I/O thread for channel ‘group_replication_recovery’ killed while connecting to master
2018-06-12T10:19:17.943641Z 27 [Note] Slave I/O thread exiting for channel ‘group_replication_recovery’, read up to log ‘FIRST’, position 4
2018-06-12T10:19:17.943741Z 16 [ERROR] Plugin group_replication reported: ‘There was an error when connecting to the donor server. Please check that group_replication_recovery channel credentials and all MEMBER_HOST column values of performance_schema.replication_group_members table are correct and DNS resolvable.’
2018-06-12T10:19:17.943753Z 16 [ERROR] Plugin group_replication reported: ‘For details please check performance_schema.replication_connection_status table and error log messages of Slave I/O for channel group_replication_recovery.’

解决办法:
报这个错误的原因是,配置组复制,在二三节点开始组复制的时候,未指定组复制使用的用户的用户名。
Invalid (empty) username when attempting to connect to the master server.
具体原因是,在二三节点启动mgr集群时,未执行下面的命令,即未在二三节点创建复制通道(只在一节点执行了)
CHANGE MASTER TO MASTER_USER=’repl’, MASTER_PASSWORD=’lijingkuan’ FOR CHANNEL ‘group_replication_recovery’;
在二三节点执行此命令,然后再执行start group_replication,不再报此错误。

问题四:
重试10次之后,二节点和三节点依然无法连接到主节点。
重新执行start group_replication命令
报错如下:
mysql> start group_replication;
ERROR 3093 (HY000): The START GROUP_REPLICATION command failed since the group is already running.
解决办法:
stop group_replication;
start group_replication;

问题五:
在二三节点执行start group_replication
二三节点一直处于recoving状态

日志报错如下:
2018-06-13T01:39:36.061586Z 65 [Note] Plugin group_replication reported: ‘Retrying group recovery connection with another donor. Attempt 4/10’
2018-06-13T01:40:36.061884Z 65 [Note] ‘CHANGE MASTER TO FOR CHANNEL ‘group_replication_recovery’ executed’. Previous state master_host=’oceanbase06’, master_port= 3306, master_log_file=”, master_log_pos= 4, master_bind=”. New state master_host=’oceanbase06’, master_port= 3306, master_log_file=”, master_log_pos= 4, master_bind=”.
2018-06-13T01:40:36.143679Z 65 [Note] Plugin group_replication reported: ‘Establishing connection to a group replication recovery donor 466acf38-6e16-11e8-a7cf-000c29fa2dbb at oceanbase06 port: 3306.’
2018-06-13T01:40:36.193982Z 73 [Warning] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the ‘START SLAVE Syntax’ in the MySQL Manual for more information.
2018-06-13T01:40:46.202349Z 73 [ERROR] Slave I/O for channel ‘group_replication_recovery’: error connecting to master ‘repl@oceanbase06:3306’ - retry-time: 60 retries: 1, Error_code: 2005
2018-06-13T01:40:46.202390Z 73 [Note] Slave I/O thread for channel ‘group_replication_recovery’ killed while connecting to master
2018-06-13T01:40:46.202396Z 73 [Note] Slave I/O thread exiting for channel ‘group_replication_recovery’, read up to log ‘FIRST’, position 4
2018-06-13T01:40:46.202590Z 65 [ERROR] Plugin group_replication reported: ‘There was an error when connecting to the donor server. Please check that group_replication_recovery channel credentials and all MEMBER_HOST column values of performance_schema.replication_group_members table are correct and DNS resolvable.’
2018-06-13T01:40:46.202648Z 65 [ERROR] Plugin group_replication reported: ‘For details please check performance_schema.replication_connection_status table and error log messages of Slave I/O for channel group_replication_recovery.’

解决办法:
这应该是一个bug,在配置文件中配置了以下配置
loose-group_replication_local_address = “192.168.0.156:24901”
loose-group_replication_group_seeds = “192.168.0.156:24901,192.168.0.157:24901,192.168.0.158:24901”
使用的是IP地址方式
解决办法是,将IP地址改为主机名(三节点都改),在/etc/host文件中配置IP与主机名映射关系
loose-group_replication_local_address = “oceanbase06:24901”
loose-group_replication_group_seeds = “oceanbase06:24901,oceanbase07:24901,oceanbase08:24901”

问题六:
三个节点都关闭重启后,执行
start 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.

查看日志信息如下:
2018-06-13T02:08:47.292106Z 2 [Note] Plugin group_replication reported: ‘Group communication SSL configuration: group_replication_ssl_mode: “DISABLED”’
2018-06-13T02:08:47.292261Z 2 [Note] Plugin group_replication reported: ‘[GCS] Added automatically IP ranges 127.0.0.1/8,192.168.0.156/24 to the whitelist’
2018-06-13T02:08:47.292448Z 2 [Note] Plugin group_replication reported: ‘[GCS] Translated ‘oceanbase06’ to 192.168.0.156’
2018-06-13T02:08:47.292571Z 2 [Warning] Plugin group_replication reported: ‘[GCS] Automatically adding IPv4 localhost address to the whitelist. It is mandatory that it is added.’
2018-06-13T02:08:47.292614Z 2 [Note] Plugin group_replication reported: ‘[GCS] SSL was not enabled’
2018-06-13T02:08:47.292635Z 2 [Note] Plugin group_replication reported: ‘Initialized group communication with configuration: group_replication_group_name: “0c6d3e5f-90e2-11e6-802e-842b2b5909d6”; group_replication_local_address: “oceanbase06:24901”; group_replication_group_seeds: “oceanbase06:24901,oceanbase07:24901,oceanbase08:24901”; group_replication_bootstrap_group: false; group_replication_poll_spin_loops: 0; group_replication_compression_threshold: 1000000; group_replication_ip_whitelist: “AUTOMATIC”’
2018-06-13T02:08:47.292669Z 2 [Note] Plugin group_replication reported: ‘[GCS] Configured number of attempts to join: 0’
2018-06-13T02:08:47.292681Z 2 [Note] Plugin group_replication reported: ‘[GCS] Configured time between attempts to join: 5 seconds’
2018-06-13T02:08:47.292706Z 2 [Note] Plugin group_replication reported: ‘Member configuration: member_id: 192156; member_uuid: “466acf38-6e16-11e8-a7cf-000c29fa2dbb”; single-primary mode: “true”; group_replication_auto_increment_increment: 7; ’
2018-06-13T02:08:47.293035Z 9 [Note] ‘CHANGE MASTER TO FOR CHANNEL ‘group_replication_applier’ executed’. Previous state master_host=’’, master_port= 0, master_log_file=”, master_log_pos= 4, master_bind=”. New state master_host=’’, master_port= 0, master_log_file=”, master_log_pos= 4, master_bind=”.
2018-06-13T02:08:47.538522Z 2 [Note] Plugin group_replication reported: ‘Group Replication applier module successfully initialized!’
2018-06-13T02:08:47.538541Z 12 [Note] Slave SQL thread for channel ‘group_replication_applier’ initialized, starting replication in log ‘FIRST’ at position 0, relay log ‘./oceanbase06-relay-bin-group_replication_applier.000003’ position: 4
2018-06-13T02:08:47.538548Z 2 [Note] Plugin group_replication reported: ‘auto_increment_increment is set to 7’
2018-06-13T02:08:47.538560Z 2 [Note] Plugin group_replication reported: ‘auto_increment_offset is set to 192156’
2018-06-13T02:08:47.538690Z 0 [Note] Plugin group_replication reported: ‘XCom protocol version: 3’
2018-06-13T02:08:47.538711Z 0 [Note] Plugin group_replication reported: ‘XCom initialized and ready to accept incoming connections on port 24901’
2018-06-13T02:08:47.541898Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase07:24901 on local port: 24901.’
2018-06-13T02:08:47.542143Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase08:24901 on local port: 24901.’
2018-06-13T02:08:47.542356Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase07:24901 on local port: 24901.’
2018-06-13T02:08:47.542564Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase08:24901 on local port: 24901.’
2018-06-13T02:08:47.542727Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase07:24901 on local port: 24901.’
2018-06-13T02:08:47.542885Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase08:24901 on local port: 24901.’
2018-06-13T02:08:47.543045Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase07:24901 on local port: 24901.’
2018-06-13T02:08:47.543202Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase08:24901 on local port: 24901.’
2018-06-13T02:08:47.543376Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase07:24901 on local port: 24901.’
2018-06-13T02:08:47.543569Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase08:24901 on local port: 24901.’
2018-06-13T02:08:47.543743Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase07:24901 on local port: 24901.’
2018-06-13T02:08:47.543921Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase08:24901 on local port: 24901.’
2018-06-13T02:08:47.544097Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase07:24901 on local port: 24901.’
2018-06-13T02:08:47.544282Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase08:24901 on local port: 24901.’
2018-06-13T02:08:47.544458Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase07:24901 on local port: 24901.’
2018-06-13T02:08:47.544633Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase08:24901 on local port: 24901.’
2018-06-13T02:08:47.544809Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase07:24901 on local port: 24901.’
2018-06-13T02:08:47.545004Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase08:24901 on local port: 24901.’
2018-06-13T02:08:47.545183Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase07:24901 on local port: 24901.’
2018-06-13T02:08:47.545364Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error on opening a connection to oceanbase08:24901 on local port: 24901.’
2018-06-13T02:08:47.545378Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] Error connecting to all peers. Member join failed. Local port: 24901’
2018-06-13T02:08:47.545485Z 0 [Warning] Plugin group_replication reported: ‘read failed’
2018-06-13T02:08:47.561721Z 0 [ERROR] Plugin group_replication reported: ‘[GCS] The member was unable to join the group. Local port: 24901’
2018-06-13T02:09:47.538674Z 2 [ERROR] Plugin group_replication reported: ‘Timeout on wait for view after joining group’
2018-06-13T02:09:47.538754Z 2 [Note] Plugin group_replication reported: ‘Requesting to leave the group despite of not being a member’
2018-06-13T02:09:47.538779Z 2 [ERROR] Plugin group_replication reported: ‘[GCS] The member is leaving a group without being on one.’
2018-06-13T02:09:47.538930Z 2 [Note] Plugin group_replication reported: ‘auto_increment_increment is reset to 1’
2018-06-13T02:09:47.538943Z 2 [Note] Plugin group_replication reported: ‘auto_increment_offset is reset to 1’
2018-06-13T02:09:47.539105Z 12 [Note] Error reading relay log event for channel ‘group_replication_applier’: slave SQL thread was killed
2018-06-13T02:09:47.612449Z 9 [Note] Plugin group_replication reported: ‘The group replication applier thread was killed’

解决办法:
查看日志信息可知,节点开始组复制后,会连接其他节点,获取信息,但是无法连接,因为此时集群中其他节点尚未开始组复制,集群中也没有主节点。
在一节点上执行如下命令,让该节点成为主节点,其他节点复制该节点上的数据。
mysql> SET GLOBAL group_replication_bootstrap_group = ON;
Query OK, 0 rows affected (0.00 sec)
mysql> start group_replication;
Query OK, 0 rows affected (2.27 sec)

查看日志如下:
2018-06-13T02:10:58.894079Z 2 [Note] Plugin group_replication reported: ‘Group communication SSL configuration: group_replication_ssl_mode: “DISABLED”’
2018-06-13T02:10:58.894236Z 2 [Note] Plugin group_replication reported: ‘[GCS] Added automatically IP ranges 127.0.0.1/8,192.168.0.156/24 to the whitelist’
2018-06-13T02:10:58.894418Z 2 [Note] Plugin group_replication reported: ‘[GCS] Translated ‘oceanbase06’ to 192.168.0.156’
2018-06-13T02:10:58.894536Z 2 [Warning] Plugin group_replication reported: ‘[GCS] Automatically adding IPv4 localhost address to the whitelist. It is mandatory that it is added.’
2018-06-13T02:10:58.894578Z 2 [Note] Plugin group_replication reported: ‘[GCS] SSL was not enabled’
2018-06-13T02:10:58.894598Z 2 [Note] Plugin group_replication reported: ‘Initialized group communication with configuration: group_replication_group_name: “0c6d3e5f-90e2-11e6-802e-842b2b5909d6”; group_replication_local_address: “oceanbase06:24901”; group_replication_group_seeds: “oceanbase06:24901,oceanbase07:24901,oceanbase08:24901”; group_replication_bootstrap_group: true; group_replication_poll_spin_loops: 0; group_replication_compression_threshold: 1000000; group_replication_ip_whitelist: “AUTOMATIC”’
2018-06-13T02:10:58.894625Z 2 [Note] Plugin group_replication reported: ‘[GCS] Configured number of attempts to join: 0’
2018-06-13T02:10:58.894636Z 2 [Note] Plugin group_replication reported: ‘[GCS] Configured time between attempts to join: 5 seconds’
2018-06-13T02:10:58.894656Z 2 [Note] Plugin group_replication reported: ‘Member configuration: member_id: 192156; member_uuid: “466acf38-6e16-11e8-a7cf-000c29fa2dbb”; single-primary mode: “true”; group_replication_auto_increment_increment: 7; ’
2018-06-13T02:10:58.895002Z 14 [Note] ‘CHANGE MASTER TO FOR CHANNEL ‘group_replication_applier’ executed’. Previous state master_host=’’, master_port= 0, master_log_file=”, master_log_pos= 4, master_bind=”. New state master_host=’’, master_port= 0, master_log_file=”, master_log_pos= 4, master_bind=”.
2018-06-13T02:10:59.158397Z 2 [Note] Plugin group_replication reported: ‘Group Replication applier module successfully initialized!’
2018-06-13T02:10:59.158412Z 17 [Note] Slave SQL thread for channel ‘group_replication_applier’ initialized, starting replication in log ‘FIRST’ at position 0, relay log ‘./oceanbase06-relay-bin-group_replication_applier.000003’ position: 4
2018-06-13T02:10:59.158430Z 2 [Note] Plugin group_replication reported: ‘auto_increment_increment is set to 7’
2018-06-13T02:10:59.158462Z 2 [Note] Plugin group_replication reported: ‘auto_increment_offset is set to 192156’
2018-06-13T02:10:59.158569Z 0 [Note] Plugin group_replication reported: ‘XCom protocol version: 3’
2018-06-13T02:10:59.158600Z 0 [Note] Plugin group_replication reported: ‘XCom initialized and ready to accept incoming connections on port 24901’
2018-06-13T02:11:00.160220Z 20 [Note] Plugin group_replication reported: ‘Only one server alive. Declaring this server as online within the replication group’
2018-06-13T02:11:00.160288Z 0 [Note] Plugin group_replication reported: ‘Group membership changed to oceanbase06:3306 on view 15288558601599560:1.’
2018-06-13T02:11:00.221870Z 0 [Note] Plugin group_replication reported: ‘This server was declared online within the replication group’
2018-06-13T02:11:00.221921Z 0 [Note] Plugin group_replication reported: ‘A new primary with address oceanbase06:3306 was elected, enabling conflict detection until the new primary applies all relay logs.’
2018-06-13T02:11:00.221964Z 22 [Note] Plugin group_replication reported: ‘This server is working as primary member.’

=============================================================================

节点正常连接到主节点,启动组复制的日志如下:
2018-06-13T02:20:16.091292Z 8 [Note] Plugin group_replication reported: ‘Group communication SSL configuration: group_replication_ssl_mode: “DISABLED”’
2018-06-13T02:20:16.091491Z 8 [Note] Plugin group_replication reported: ‘[GCS] Added automatically IP ranges 127.0.0.1/8,192.168.0.158/24 to the whitelist’
2018-06-13T02:20:16.091739Z 8 [Note] Plugin group_replication reported: ‘[GCS] Translated ‘oceanbase08’ to 192.168.0.158’
2018-06-13T02:20:16.091894Z 8 [Warning] Plugin group_replication reported: ‘[GCS] Automatically adding IPv4 localhost address to the whitelist. It is mandatory that it is added.’
2018-06-13T02:20:16.091944Z 8 [Note] Plugin group_replication reported: ‘[GCS] SSL was not enabled’
2018-06-13T02:20:16.091970Z 8 [Note] Plugin group_replication reported: ‘Initialized group communication with configuration: group_replication_group_name: “0c6d3e5f-90e2-11e6-802e-842b2b5909d6”; group_replication_local_address: “oceanbase08:24901”; group_replication_group_seeds: “oceanbase06:24901,oceanbase07:24901,oceanbase08:24901”; group_replication_bootstrap_group: false; group_replication_poll_spin_loops: 0; group_replication_compression_threshold: 1000000; group_replication_ip_whitelist: “AUTOMATIC”’
2018-06-13T02:20:16.092003Z 8 [Note] Plugin group_replication reported: ‘[GCS] Configured number of attempts to join: 0’
2018-06-13T02:20:16.092019Z 8 [Note] Plugin group_replication reported: ‘[GCS] Configured time between attempts to join: 5 seconds’
2018-06-13T02:20:16.092054Z 8 [Note] Plugin group_replication reported: ‘Member configuration: member_id: 192158; member_uuid: “ee06bb98-6e1c-11e8-9f74-000c2945e5fb”; single-primary mode: “true”; group_replication_auto_increment_increment: 7; ’
2018-06-13T02:20:16.092413Z 10 [Note] ‘CHANGE MASTER TO FOR CHANNEL ‘group_replication_applier’ executed’. Previous state master_host=’’, master_port= 0, master_log_file=”, master_log_pos= 4, master_bind=”. New state master_host=’’, master_port= 0, master_log_file=”, master_log_pos= 4, master_bind=”.
2018-06-13T02:20:16.257448Z 8 [Note] Plugin group_replication reported: ‘Group Replication applier module successfully initialized!’
2018-06-13T02:20:16.257465Z 13 [Note] Slave SQL thread for channel ‘group_replication_applier’ initialized, starting replication in log ‘FIRST’ at position 0, relay log ‘./oceanbase08-relay-bin-group_replication_applier.000005’ position: 4
2018-06-13T02:20:16.257516Z 8 [Note] Plugin group_replication reported: ‘auto_increment_increment is set to 7’
2018-06-13T02:20:16.257549Z 8 [Note] Plugin group_replication reported: ‘auto_increment_offset is set to 192158’
2018-06-13T02:20:16.259459Z 0 [Note] Plugin group_replication reported: ‘XCom protocol version: 3’
2018-06-13T02:20:16.259486Z 0 [Note] Plugin group_replication reported: ‘XCom initialized and ready to accept incoming connections on port 24901’
2018-06-13T02:20:18.457595Z 0 [ERROR] Plugin group_replication reported: ‘This member has more executed transactions than those present in the group. Local transactions: ee06bb98-6e1c-11e8-9f74-000c2945e5fb:1-2 > Group transactions: 0c6d3e5f-90e2-11e6-802e-842b2b5909d6:1-12,
466acf38-6e16-11e8-a7cf-000c29fa2dbb:1-2,
891a79fd-6e1d-11e8-8f06-000c295585b9:1-2’
2018-06-13T02:20:18.457643Z 0 [Warning] Plugin group_replication reported: ‘The member contains transactions not present in the group. It is only allowed to join due to group_replication_allow_local_disjoint_gtids_join option’
2018-06-13T02:20:18.457709Z 8 [Note] Plugin group_replication reported: ‘This server is working as secondary member with primary member address oceanbase06:3306.’
2018-06-13T02:20:18.457919Z 16 [Note] Plugin group_replication reported: ‘Establishing group recovery connection with a possible donor. Attempt 1/10’
2018-06-13T02:20:18.457966Z 0 [Note] Plugin group_replication reported: ‘Group membership changed to oceanbase06:3306, oceanbase07:3306, oceanbase08:3306 on view 15288558601599560:7.’
2018-06-13T02:20:18.646979Z 16 [Note] ‘CHANGE MASTER TO FOR CHANNEL ‘group_replication_recovery’ executed’. Previous state master_host=’’, master_port= 0, master_log_file=”, master_log_pos= 4, master_bind=”. New state master_host=’oceanbase06’, master_port= 3306, master_log_file=”, master_log_pos= 4, master_bind=”.
2018-06-13T02:20:18.846851Z 16 [Note] Plugin group_replication reported: ‘Establishing connection to a group replication recovery donor 466acf38-6e16-11e8-a7cf-000c29fa2dbb at oceanbase06 port: 3306.’
2018-06-13T02:20:18.847075Z 18 [Warning] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the ‘START SLAVE Syntax’ in the MySQL Manual for more information.
2018-06-13T02:20:18.847997Z 18 [Note] Slave I/O thread for channel ‘group_replication_recovery’: connected to master ‘repl@oceanbase06:3306’,replication started in log ‘FIRST’ at position 4
2018-06-13T02:20:18.881421Z 19 [Note] Slave SQL thread for channel ‘group_replication_recovery’ initialized, starting replication in log ‘FIRST’ at position 0, relay log ‘./oceanbase08-relay-bin-group_replication_recovery.000001’ position: 4
2018-06-13T02:20:19.419672Z 19 [Warning] ‘user’ entry ‘root@localhost’ ignored in –skip-name-resolve mode.
2018-06-13T02:20:19.419707Z 19 [Warning] ‘user’ entry ‘mysql.session@localhost’ ignored in –skip-name-resolve mode.
2018-06-13T02:20:19.419722Z 19 [Warning] ‘user’ entry ‘mysql.sys@localhost’ ignored in –skip-name-resolve mode.
2018-06-13T02:20:19.419744Z 19 [Warning] ‘db’ entry ‘performance_schema mysql.session@localhost’ ignored in –skip-name-resolve mode.
2018-06-13T02:20:19.419754Z 19 [Warning] ‘db’ entry ‘sys mysql.sys@localhost’ ignored in –skip-name-resolve mode.
2018-06-13T02:20:19.419765Z 19 [Warning] ‘proxies_priv’ entry ‘@ root@localhost’ ignored in –skip-name-resolve mode.
2018-06-13T02:20:19.419951Z 19 [Warning] ‘tables_priv’ entry ‘user mysql.session@localhost’ ignored in –skip-name-resolve mode.
2018-06-13T02:20:19.419968Z 19 [Warning] ‘tables_priv’ entry ‘sys_config mysql.sys@localhost’ ignored in –skip-name-resolve mode.
2018-06-13T02:20:20.355821Z 16 [Note] Plugin group_replication reported: ‘Terminating existing group replication donor connection and purging the corresponding logs.’
2018-06-13T02:20:20.372833Z 19 [Note] Slave SQL thread for channel ‘group_replication_recovery’ exiting, replication stopped in log ‘mybinlog.000007’ at position 2050
2018-06-13T02:20:20.390079Z 18 [Note] Slave I/O thread killed while reading event for channel ‘group_replication_recovery’
2018-06-13T02:20:20.390103Z 18 [Note] Slave I/O thread exiting for channel ‘group_replication_recovery’, read up to log ‘mybinlog.000007’, position 2050
2018-06-13T02:20:20.589939Z 16 [Note] ‘CHANGE MASTER TO FOR CHANNEL ‘group_replication_recovery’ executed’. Previous state master_host=’oceanbase06’, master_port= 3306, master_log_file=”, master_log_pos= 4, master_bind=”. New state master_host=’’, master_port= 0, master_log_file=”, master_log_pos= 4, master_bind=”.
2018-06-13T02:20:20.796753Z 0 [Note] Plugin group_replication reported: ‘This server was declared online within the replication group’

猜你喜欢

转载自blog.csdn.net/lijingkuan/article/details/80827779