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
葉老師網站自動生成配置檔案
[[email protected] 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="\[email protected] \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 ‘[email protected]: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 ‘[email protected]: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 ‘[email protected]’ ignored in –skip-name-resolve mode.
2018-06-13T02:20:19.419707Z 19 [Warning] ‘user’ entry ‘[email protected]’ ignored in –skip-name-resolve mode.
2018-06-13T02:20:19.419722Z 19 [Warning] ‘user’ entry ‘[email protected]’ ignored in –skip-name-resolve mode.
2018-06-13T02:20:19.419744Z 19 [Warning] ‘db’ entry ‘performance_schema [email protected]’ ignored in –skip-name-resolve mode.
2018-06-13T02:20:19.419754Z 19 [Warning] ‘db’ entry ‘sys [email protected]’ ignored in –skip-name-resolve mode.
2018-06-13T02:20:19.419765Z 19 [Warning] ‘proxies_priv’ entry ‘@ [email protected]’ ignored in –skip-name-resolve mode.
2018-06-13T02:20:19.419951Z 19 [Warning] ‘tables_priv’ entry ‘user [email protected]’ ignored in –skip-name-resolve mode.
2018-06-13T02:20:19.419968Z 19 [Warning] ‘tables_priv’ entry ‘sys_config [email protected]’ 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’