系統變數group_replication_group_seeds為空導致MySQL節點無法啟動組複製

潇湘隐者發表於2024-11-06

MySQL InnoDB Cluster叢集中一個節點,在伺服器重啟過後,啟動MySQL例項後,發現status為MISSING,另外memberState為OFFLINE狀態。如下所示:

 MySQL  mysqldbu02:7306 ssl  JS > cluster.status()
{
"clusterName": "yssps",
"defaultReplicaSet": {
"name": "default",
"primary": "mysqldbu02:7306",
"ssl": "REQUIRED",
"status": "OK_NO_TOLERANCE_PARTIAL",
"statusText": "Cluster is NOT tolerant to any failures. 1 member is not active.",
"topology": {
"mysqldbu01:7306": {
"address": "mysqldbu01:7306",
"instanceErrors": [
"NOTE: group_replication is stopped."
],
"memberRole": "SECONDARY",
"memberState": "OFFLINE",
"mode": "n/a",
"readReplicas": {},
"role": "HA",
"status": "(MISSING)",
"version": "8.0.35"
},
"mysqldbu02:7306": {
"address": "mysqldbu02:7306",
"memberRole": "PRIMARY",
"mode": "R/W",
"readReplicas": {},
"replicationLag": "applier_queue_applied",
"role": "HA",
"status": "ONLINE",
"version": "8.0.35"
},
"mysqldbu03:7306": {
"address": "mysqldbu03:7306",
"memberRole": "SECONDARY",
"mode": "R/O",
"readReplicas": {},
"replicationLag": "applier_queue_applied",
"role": "HA",
"status": "ONLINE",
"version": "8.0.35"
}
},
"topologyMode": "Single-Primary"
},
"groupInformationSourceMember": "mysqldbu02:7306"
}
MySQL mysqldbu02:7306 ssl JS >

從錯誤提示資訊來看是組複製沒有啟動(group_replication is stopped)。其實MySQL InnoDB Cluster的節點重啟操作在生產環境和測試環境都做過多次,還是第一次遇到這種情況。

另外,在這個節點上檢視節點的狀態如下:

mysql> select * from performance_schema.replication_group_members order by member_host\G
*************************** 1. row ***************************
CHANNEL_NAME: group_replication_applier
MEMBER_ID: 5ad73846-3fce-11ee-a86c-5254003c1c6e
MEMBER_HOST: mysqldbu01
MEMBER_PORT: 7306
MEMBER_STATE: OFFLINE
MEMBER_ROLE:
MEMBER_VERSION:
MEMBER_COMMUNICATION_STACK: MySQL
1 row in set (0.00 sec)

mysql>

具體的錯誤日誌如下所示

2024-11-06T10:03:19.369090+08:00 29 [Warning] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] Automatically adding IPv4
localhost address to the allowlist. It is mandatory that it is added.'

2024-11-06T10:03:19.369171+08:00 29 [Warning] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] Automatically adding IPv6
localhost address to the allowlist. It is mandatory that it is added.'

2024-11-06T10:03:19.371586+08:00 40 [System] [MY-010597] [Repl] 'CHANGE REPLICATION SOURCE TO FOR CHANNEL 'group_replication_applier
' executed'. Previous state source_host='<NULL>', source_port= 0, source_log_file='', source_log_pos= 4, source_bind=''. New state s
ource_host='<NULL>', source_port= 0, source_log_file='', source_log_pos= 4, source_bind=''.
2024-11-06T10:03:19.391449+08:00 29 [ERROR] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] Unable to join the group: peers not configured. '
2024-11-06T10:03:19.391512+08:00 29 [ERROR] [MY-011639] [Repl] Plugin group_replication reported: 'Error on group communication engine start'
2024-11-06T10:03:19.391581+08:00 29 [ERROR] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] The member is leaving a group without being on one.'

關鍵資訊為:[Repl] Plugin group_replication reported: '[GCS] Unable to join the group: peers not configured.

這個錯誤資訊意味著沒有配置系統變數group_replication_group_seeds。 另外,手工啟動組複製,錯誤日誌依然報同樣的錯誤,執行啟動組複製命令的錯誤資訊如下所示:

mysql> start group_replication;
ERROR 3097 (HY000): The START GROUP_REPLICATION command failed as there was an error when joining the communication group.
mysql>

檢查發現系統變數group_replication_group_seeds的值為空(my.cnf中沒有設定這個系統變數,在mysqld-auto.cnf中系統變數為空值),因為是測試環境,不清楚什麼時候動過這個系統變數,,畢竟測試環境經常被折騰來折騰去。

mysql> show variables like 'group_replication_local_address';
+---------------------------------+---------------------+
| Variable_name | Value |
+---------------------------------+---------------------+
| group_replication_local_address | mysqldbu01:7306 |
+---------------------------------+---------------------+
1 row in set (0.01 sec)

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

mysql> select * from performance_schema.persisted_variables where variable_name='group_replication_group_seeds';
+-------------------------------+----------------+
| VARIABLE_NAME | VARIABLE_VALUE |
+-------------------------------+----------------+
| group_replication_group_seeds | |
+-------------------------------+----------------+
1 row in set (0.01 sec)

mysql>

設定系統變數group_replication_group_seeds的值後,重啟組複製就正常了。

mysql> set persist group_replication_group_seeds='mysqldbu02:7306';
Query OK, 0 rows affected (0.01 sec)

mysql> start group_replication;
Query OK, 0 rows affected, 1 warning (11.28 sec)

mysql>

相關文章