背景
近期在做InnoDB Cluster的压测,期间想偷个懒,直接克隆了一台虚拟机,想拿来直接做集群的一个新节点 虚拟机克隆出来之后,执行了以下操作
- 更改了IP地址和主机名
- 删除了
datadir
下的auto.cnf
文件 - 更改了
my.cnf
中的server_id
然后启动数据库 - 并将新的IP地址和主机名对应关系加入到了
/etc/hosts
中
但是在添加节点时一直报错
报错信息
通过MySQL Shell添加实例时提示:
JS >cluster.addInstance("test20231201:3306")
WARNING: A GTID set check of the MySQL instance at 'test20231201:3306' determined that it contains transactions that do not originate from the cluster, which must be discarded before it can join the cluster.
test20231201:3306 has the following errant GTIDs that do not exist in the cluster:
9c55f128-8f31-11ee-8f22-fa163e2b3e11:1
WARNING: Discarding these extra GTID events can either be done manually or by completely overwriting the state of test20231201:3306 with a physical snapshot from an existing cluster member. To use this method by default, set the 'recoveryMethod' option to 'clone'.
Having extra GTID events is not expected, and it is recommended to investigate this further and ensure that the data can be removed prior to choosing the clone recovery method.
Please select a recovery method [C]lone/[A]bort (default Abort): C
Validating instance configuration at test20231201:3306...
This instance reports its own address as test20231201:3306
Instance configuration is suitable.
NOTE: Group Replication will communicate with other members using 'test20231201:3306'. Use the localAddress option to override.
* Checking connectivity and SSL configuration...
ERROR: RuntimeError: Authentication error during connection check
Cluster.addInstance: Authentication error during connection check (RuntimeError)
新机器的错误日志:
rce_bind=''. New state source_host='gxjtest20231130', source_port= 3306, source_log_file='', source_log_pos= 4, source_bind=''.
2023-12-01T14:17:49.036551+08:00 243 [Warning] [MY-010897] [Repl] Storing MySQL user name or password information in the connection metadata repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START REPLICA; see the 'START REPLICA Syntax' in the MySQL Manual for more information.
2023-12-01T14:17:49.042996+08:00 243 [ERROR] [MY-013117] [Repl] Replica I/O for channel 'mysqlsh.test': Fatal error: The replica I/O thread stops because source and replica have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on replica but this does not always make sense; please check the manual before using it). Error_code: MY-013117
2023-12-01T14:17:49.258054+08:00 240 [System] [MY-010597] [Repl] 'CHANGE REPLICATION SOURCE TO FOR CHANNEL 'mysqlsh.test' executed'. Previous state source_host='', source_port= 3306, source_log_file='', source_log_pos= 4, source_bind=''. New state source_host='dbtest20231201', source_port= 3306, source_log_file='', source_log_pos= 4, source_bind=''.
2023-12-01T14:17:49.271013+08:00 246 [Warning] [MY-010897] [Repl] Storing MySQL user name or password information in the connection metadata repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START REPLICA; see the 'START REPLICA Syntax' in the MySQL Manual for more information.
2023-12-01T14:17:49.279509+08:00 246 [ERROR] [MY-010584] [Repl] Replica I/O for channel 'mysqlsh.test': Error connecting to source 'mysqlsh.test@dbtest20231201:3306'. This was attempt 1/0, with a delay of 60 seconds between attempts. Message: Access denied for user 'mysqlsh.test'@'127.0.0.1' (using password: YES), Error_code: MY-001045
排查过程
经历一番波折,最后发现是克隆机器的hosts文件中存在这样一行,导致 127.0.0.1 dbtest20231201
处理方法
删除/etc/hosts
中的以下内容就可以正常添加集群节点了 127.0.0.1 dbtest20231201
结论:一定要仔细检查hosts文件!!!