MySQL Shell搭建的单主MGR集群却无法切换主节点
本帖最后由 tony 于 2024-3-28 10:30 编辑1.首先使用mysql客户端切换主节点到mgr02成功
mysql> select group_replication_set_as_primary('f4343bed-e68a-11ee-9d06-000c293b6e72');
+--------------------------------------------------------------------------+
| group_replication_set_as_primary('f4343bed-e68a-11ee-9d06-000c293b6e72') |
+--------------------------------------------------------------------------+
| Primary server switched to: f4343bed-e68a-11ee-9d06-000c293b6e72 |
+--------------------------------------------------------------------------+
1 row in set (1.16 sec)
mysql> select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+----------------------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION | MEMBER_COMMUNICATION_STACK |
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+----------------------------+
| group_replication_applier | 2b5c6540-e5d0-11ee-8376-000c29ec4ae4 | mgr01 | 3306 | ONLINE | SECONDARY | 8.0.35 | MySQL |
| group_replication_applier | 3ac2f4f2-e68b-11ee-8c27-000c2978862a | mgr03 | 3306 | ONLINE | SECONDARY | 8.0.35 | MySQL |
| group_replication_applier | f4343bed-e68a-11ee-9d06-000c293b6e72 | mgr02 | 3306 | ONLINE | PRIMARY | 8.0.35 | MySQL |
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+----------------------------+
3 rows in set (0.00 sec)
mysql> 2.利用MySQL Shell在mgr02上切换主节点却失败,报错Cluster.setPrimaryInstance: The instance 'mgr01:3306' does not belong to the cluster: 'mgr_test'. (RuntimeError)
MySQLlocalhostJS > var c=dba.getCluster()
MySQLlocalhostJS > c.status()
{
"clusterName": "mgr_test",
"defaultReplicaSet": {
"name": "default",
"primary": "mgr02:3306",
"ssl": "REQUIRED",
"status": "OK",
"statusText": "Cluster is ONLINE and can tolerate up to ONE failure.",
"topology": {
"mgr01:3306": {
"address": "mgr01:3306",
"memberRole": "SECONDARY",
"memberState": "(MISSING)",
"mode": "n/a",
"readReplicas": {},
"role": "HA",
"shellConnectError": "MySQL Error 1045: Could not open connection to 'mgr01:3306': Access denied for user 'root'@'mgr02' (using password: YES)",
"status": "ONLINE",
"version": "8.0.35"
},
"mgr02:3306": {
"address": "mgr02:3306",
"memberRole": "PRIMARY",
"memberState": "(MISSING)",
"mode": "n/a",
"readReplicas": {},
"role": "HA",
"shellConnectError": "MySQL Error 1045: Could not open connection to 'mgr02:3306': Access denied for user 'root'@'mgr02' (using password: YES)",
"status": "ONLINE",
"version": "8.0.35"
},
"mgr03:3306": {
"address": "mgr03:3306",
"memberRole": "SECONDARY",
"memberState": "(MISSING)",
"mode": "n/a",
"readReplicas": {},
"role": "HA",
"shellConnectError": "MySQL Error 1045: Could not open connection to 'mgr03:3306': Access denied for user 'root'@'mgr02' (using password: YES)",
"status": "ONLINE",
"version": "8.0.35"
}
},
"topologyMode": "Single-Primary"
},
"groupInformationSourceMember": "mgr02:3306"
}
MySQLlocalhostJS > c.setPrimaryInstance('mgr01:3306')
Cluster.setPrimaryInstance: The instance 'mgr01:3306' does not belong to the cluster: 'mgr_test'. (RuntimeError)
MySQLlocalhostJS >c.setPrimaryInstance('mgr01:3306')mysql shell 日志如下
2024-03-26 16:00:02: Info: Dba.getCluster: tid=93: CONNECTED: /data%2Fmysql%2Fdata%2Fmysql.sock
2024-03-26 16:00:02: Info: Connecting to MySQL at: mysql://root@/data%2Fmysql%2Fdata%2Fmysql.sock?connect-timeout=5000
2024-03-26 16:00:02: Info: Dba.getCluster: tid=94: CONNECTED: /data%2Fmysql%2Fdata%2Fmysql.sock
2024-03-26 16:00:03: Info: Group Replication 'group_name' value: cb3fe36c-eb4e-11ee-bd6a-000c29ec4ae4
2024-03-26 16:00:03: Info: Metadata 'group_name' value: cb3fe36c-eb4e-11ee-bd6a-000c29ec4ae4
2024-03-26 16:01:25: Info: Connecting to MySQL at: mysql://root@mgr01:3306?connect-timeout=5000
2024-03-26 16:01:25: Info: Connecting to MySQL at: mysql://root@mgr02:3306?connect-timeout=5000
2024-03-26 16:01:25: Info: Connecting to MySQL at: mysql://root@mgr03:3306?connect-timeout=5000
2024-03-26 16:02:51: Info: Connecting to MySQL at: mysql://root@mgr01:3306?connect-timeout=5000
2024-03-26 16:09:08: Info: Connecting to MySQL at: mysql://root@mgr01:3306?connect-timeout=5000
mgr01这个节点要在Shell里重新join一次
1. removeInstance()删掉节点
2. addInstance()加入节点 yejr 发表于 2024-3-27 08:52
mgr01这个节点要在Shell里重新join一次
1. removeInstance()删掉节点
2. addInstance()加入节点 ...
叶老师找到原因了,我MySQL Shell使用root用户登录切换的,我改用mgr用户可以切换成功了。 tony 发表于 2024-3-27 10:22
叶老师找到原因了,我MySQL Shell使用root用户登录切换的,我改用mgr用户可以切换成功了。 ...
记得在shell里,root账户是没办法操纵MGR的,需要切换到MGR专用账户 yejr 发表于 2024-3-27 17:10
记得在shell里,root账户是没办法操纵MGR的,需要切换到MGR专用账户
是的,所以切换失败了,mgr专用账户没问题。
页:
[1]