Mysql

無法在 MySQL InnoDB 集群上添加新實例

  • August 5, 2019

我正在設置由三個實例組成的新 MySQL InnoDB 集群 8.0.16:

  1. srv-mysql-01
  2. srv-mysql-02
  3. srv-mysql-03

我在 mysql shell 中執行 JS 腳本來建構集群:

mysqlsh --file=/tmp/MakeCluster.js

腳本:

var dbPass = "Somepassword"
var clusterName = "cluster"

try {
 print('Setting up InnoDB cluster...\n');
 shell.connect('admin@srv-mysql-01:3306', dbPass)
 var cluster = dba.createCluster(clusterName);
 print('Adding instances to the cluster.');
 cluster.addInstance({user: "admin", host: "srv-mysql-02", password: dbPass})
 print('.');
 cluster.addInstance({user: "admin", host: "srv-mysql-03", password: dbPass})
 print('.\nInstances successfully added to the cluster.');
 print('\nInnoDB cluster deployed successfully.\n');
} catch(e) {
 print('\nThe InnoDB cluster could not be created.\n\nError: ' + e.message + '\n');
}

集群已成功創建,但在將第 2 個實例添加到集群時出現以下錯誤:

A new InnoDB cluster will be created on instance 'admin@srv-mysql-01:3306'.

Validating instance at srv-mysql-01:3306...

This instance reports its own address as 192.168.100.201

Instance configuration is suitable.
Creating InnoDB cluster 'cluster' on 'admin@srv-mysql-01:3306'...

Adding Seed Instance...
Cluster successfully created. Use Cluster.addInstance() to add MySQL instances.
At least 3 instances are needed for the cluster to be able to withstand up to
one server failure.

Adding instances to the cluster.A new instance will be added to the InnoDB cluster. Depending on the amount of
data on the cluster this might take from a few seconds to several hours.

Adding instance to the cluster ...

Validating instance at srv-mysql-02:3306...

This instance reports its own address as 192.168.100.202

Instance configuration is suitable.

The InnoDB cluster could not be created.

Error: Cluster.addInstance: WARNING: Not running locally on the server and can not access its error log.
ERROR: 
Group Replication join failed.
ERROR: Error joining instance to cluster: 'srv-mysql-02:3306' - Query failed. MySQL Error (3092): ClassicSession.query: The server is not configured properly to be an active member of the group. Please see more details on error log.. Query: START group_replication: MySQL Error (3092): ClassicSession.query: The server is not configured properly to be an active member of the group. Please see more details on error log.

我想修復這個錯誤。

我使用 shell-command 檢查了所有可能出現的問題的實例,dba.checkInstanceConfiguration()並沒有出現錯誤。

但是第二個實例的 MySQL 日誌中有一些錯誤:

2019-07-20T23:24:43.085920Z 0 [ERROR] [MY-011526] [Repl] Plugin group_replication reported: 'This member has more executed transactions than those present in the group. Local transactions: 77aabf2e-aa76-11e9-9a4d-525400f0e95b:1-2 > Group transactions: 114adc66-ab3f-11e9-a109-525400f0e95b:1-7,

....

2019-07-20T23:24:43.086303Z 0 [ERROR] [MY-011522] [Repl] Plugin group_replication reported: 'The member contains transactions not present in the group. The member will now exit the group.'

我的.conf

[mysqld]

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

bind-address=192.168.100.202
port=3306

# Replication part
server_id=202
gtid_mode=ON
enforce_gtid_consistency=ON
master_info_repository=TABLE
relay-log=srv-mysql-02-relay-bin
relay_log_info_repository=TABLE
binlog_checksum=NONE
log_slave_updates=ON
log_bin=binlog
binlog_format=ROW

default_authentication_plugin=mysql_native_password

# Group replication part
transaction_write_set_extraction=XXHASH64
loose-group_replication_start_on_boot=OFF
loose-group_replication_local_address="192.168.100.202:33061"
loose-group_replication_bootstrap_group=OFF
report_port=3306
report_host=192.168.100.202

[mysql]
default-character-set=utf8

任何幫助,將不勝感激。

我找到了解決問題的方法:

1.必須使用 和 配置和驗證每個dba.checkInstanceConfiguration()實例dba.configureInstance()

2.指定我們將添加到集群的實例的埠號。

我的腳本中的範例:

cluster.addInstance({user: "admin", host: "srv-mysql-02", port:3306, password: dbPass})

引用自:https://dba.stackexchange.com/questions/243402