在使用 启动MySQL 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.
err.log文件中:
2025-01-22T02:14:04.090619Z 4 [ERROR] Plugin group_replication reported: 'The group name 'repl_group1' is not a valid UUID'
“Plugin group_replication reported: ‘The group name ‘repl_group1’ is not a valid UUID'” 通常意味着你在配置组复制时使用了不正确的组名格式。在 MySQL 的 Group Replication 中,组名必须是一个有效的 UUID。
解决步骤
1.生成一个有效的 UUID:
可以使用在线工具或者命令行来生成一个 UUID。例如,在 Linux 系统中,你可以使用 uuidgen 命令:
[mysql@localhost mysql]$ uuidgen 2366d798-4dc1-421a-a9de-3c825bfada7d
这将输出一个形如 2366d798-4dc1-421a-a9de-3c825bfada7d 的 UUID。
2.修改配置文件:
在你的 MySQL 配置文件(通常是 my.cnf 或 my.ini)中,将 group_replication_group_name 的值设置为上一步生成的 UUID。例如:
[mysql@localhost mysql]$ vi mysql1.cnf loose-group_replication_group_name="2366d798-4dc1-421a-a9de-3c825bfada7d"
3.重启 MySQL 服务:
修改配置后,需要重启 MySQL 服务以使更改生效。可以使用如下命令:
[mysql@localhost mysql]$ mysqld --defaults-file=/mysqlsoft/mysql/mysql1.cnf
4.验证配置:
在 MySQL 命令行中,你可以使用以下命令来检查组复制的配置:
mysql> SHOW GLOBAL VARIABLES LIKE 'group_replication_%'; +----------------------------------------------------+-------------------------------------------------+ | Variable_name | Value | +----------------------------------------------------+-------------------------------------------------+ | group_replication_allow_local_disjoint_gtids_join | OFF | | group_replication_allow_local_lower_version_join | OFF | | group_replication_auto_increment_increment | 7 | | group_replication_bootstrap_group | OFF | | group_replication_components_stop_timeout | 31536000 | | group_replication_compression_threshold | 1000000 | | group_replication_enforce_update_everywhere_checks | OFF | | group_replication_exit_state_action | READ_ONLY | | group_replication_flow_control_applier_threshold | 25000 | | group_replication_flow_control_certifier_threshold | 25000 | | group_replication_flow_control_mode | QUOTA | | group_replication_force_members | | | group_replication_group_name | 2366d798-4dc1-421a-a9de-3c825bfada7d | | group_replication_group_seeds | 127.0.0.1:24901,127.0.0.1:24902,127.0.0.1:24903 | | group_replication_gtid_assignment_block_size | 1000000 | | group_replication_ip_whitelist | AUTOMATIC | | group_replication_local_address | 127.0.0.1:24903 | | group_replication_member_weight | 50 | | group_replication_poll_spin_loops | 0 | | group_replication_recovery_complete_at | TRANSACTIONS_APPLIED | | group_replication_recovery_reconnect_interval | 60 | | group_replication_recovery_retry_count | 10 | | group_replication_recovery_ssl_ca | | | group_replication_recovery_ssl_capath | | | group_replication_recovery_ssl_cert | | | group_replication_recovery_ssl_cipher | | | group_replication_recovery_ssl_crl | | | group_replication_recovery_ssl_crlpath | | | group_replication_recovery_ssl_key | | | group_replication_recovery_ssl_verify_server_cert | OFF | | group_replication_recovery_use_ssl | OFF | | group_replication_single_primary_mode | ON | | group_replication_ssl_mode | DISABLED | | group_replication_start_on_boot | OFF | | group_replication_transaction_size_limit | 0 | | group_replication_unreachable_majority_timeout | 0 | +----------------------------------------------------+-------------------------------------------------+ 36 rows in set (0.01 sec)
确保 group_replication_group_name 的值是你设置的 UUID。
5.初始化组复制:
如果这是第一次设置组复制,确保每个服务器都已经正确配置并且可以相互通信。然后,你可以初始化组复制:
mysql> CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='123456' FOR CHANNEL 'group_replication_recovery'; Query OK, 0 rows affected, 2 warnings (0.02 sec) mysql> START GROUP_REPLICATION; Query OK, 0 rows affected (3.29 sec)
确保 repl_user 和 123456是正确设置的复制用户和密码。
通过以上步骤,你应该能够解决因组名格式不正确导致的错误,并成功设置 MySQL 的 Group Replication。如果问题仍然存在,请检查网络设置和防火墙规则是否允许服务器之间的通信。