本帖最后由 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)
- MySQL localhost JS > var c=dba.getCluster()
- MySQL localhost JS > 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"
- }
- MySQL localhost JS > c.setPrimaryInstance('mgr01:3306')
- Cluster.setPrimaryInstance: The instance 'mgr01:3306' does not belong to the cluster: 'mgr_test'. (RuntimeError)
- MySQL localhost JS >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
复制代码
|