[Mysql] mysql-mgr解散集群并重新加入集群


本文总阅读量

1、查看集群状态

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 MySQL  dax-mysql-master:3306  JS > cluster = dba.getCluster("prodCluster")
<Cluster:prodCluster>
MySQL dax-mysql-master:3306 JS > cluster.status()
{
"clusterName": "prodCluster",
"defaultReplicaSet": {
"name": "default",
"primary": "dax-mysql-master:3306",
"ssl": "DISABLED",
"status": "OK_NO_TOLERANCE",
"statusText": "Cluster is NOT tolerant to any failures.",
"topology": {
"dax-mysql-master:3306": {
"address": "dax-mysql-master:3306",
"mode": "R/W",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
},
"dax-mysql-slave:3306": {
"address": "dax-mysql-slave:3306",
"mode": "R/O",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
}
}
},
"groupInformationSourceMember": "mysql://repl@dax-mysql-master:3306"
}

2、解散集群:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 MySQL  dax-mysql-master:3306  JS > cluster.dissolve()
The cluster still has active ReplicaSets.
Please use cluster.dissolve({force: true}) to deactivate replication
and unregister the ReplicaSets from the cluster.

The following replicasets are currently registered:
{
"clusterName": "prodCluster",
"defaultReplicaSet": {
"name": "default",
"topology": [
{
"address": "dax-mysql-slave:3306",
"label": "dax-mysql-slave:3306",
"role": "HA"
},
{
"address": "dax-mysql-master:3306",
"label": "dax-mysql-master:3306",
"role": "HA"
}
]
}
}
MySQL dax-mysql-master:3306 JS > cluster.dissolve({force: true})
WARNING: On instance 'dax-mysql-slave:3306' configuration cannot be persisted since MySQL version 5.7.22 does not support the SET PERSIST command (MySQL version >= 8.0.5 required). Please set the 'group_replication_start_on_boot' variable to 'OFF' in the server configuration file, otherwise it might rejoin the cluster upon restart.
WARNING: On instance 'dax-mysql-master:3306' configuration cannot be persisted since MySQL version 5.7.22 does not support the SET PERSIST command (MySQL version >= 8.0.5 required). Please set the 'group_replication_start_on_boot' variable to 'OFF' in the server configuration file, otherwise it might rejoin the cluster upon restart.
The cluster was successfully dissolved.
Replication was disabled but user data was left intact.

3、查看集群信息已经被删掉了:

1
2
root@db 16:54:  [mysql_innodb_cluster_metadata]> select * from clusters;
Empty set (0.00 sec)

4、重新建立集群:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
MySQL  dax-mysql-master:3306  JS > var cluster = dba.createCluster('prodCluster');
A new InnoDB cluster will be created on instance 'repl@dax-mysql-master:3306'.

Validating instance at dax-mysql-master:3306...

This instance reports its own address as dax-mysql-master
WARNING: The following tables do not have a Primary Key or equivalent column:
aaaa.test

Group Replication requires tables to use InnoDB and have a PRIMARY KEY or PRIMARY KEY Equivalent (non-null unique key). Tables that do not follow these requirements will be readable but not updateable when used with Group Replication. If your applications make updates (INSERT, UPDATE or DELETE) to these tables, ensure they use the InnoDB storage engine and have a PRIMARY KEY or PRIMARY KEY Equivalent.

Instance configuration is suitable.
Creating InnoDB cluster 'prodCluster' on 'repl@dax-mysql-master:3306'...
WARNING: On instance 'dax-mysql-master:3306' membership change cannot be persisted since MySQL version 5.7.22 does not support the SET PERSIST command (MySQL version >= 8.0.5 required). Please use the <Dba>.configureLocalInstance command locally to persist the changes.
Adding Seed Instance...

Cluster successfully created. Use Cluster.addInstance() to add MySQL instances.
At least 3 instances are needed for the cluster to be able to withstand up to
one server failure.

5、 查看集群状态,现在只有一个节点信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
MySQL  dax-mysql-master:3306  JS > cluster.status();
{
"clusterName": "prodCluster",
"defaultReplicaSet": {
"name": "default",
"primary": "dax-mysql-master:3306",
"ssl": "DISABLED",
"status": "OK_NO_TOLERANCE",
"statusText": "Cluster is NOT tolerant to any failures.",
"topology": {
"dax-mysql-master:3306": {
"address": "dax-mysql-master:3306",
"mode": "R/W",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
}
}
},
"groupInformationSourceMember": "mysql://repl@dax-mysql-master:3306"
}

6、添加新的节点:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
cluster.addInstance('dax-mysql-slave:3306')

MySQL dax-mysql-master:3306 JS > cluster.addInstance('dax-mysql-slave:3306')
A new instance will be added to the InnoDB cluster. Depending on the amount of
data on the cluster this might take from a few seconds to several hours.

Please provide the password for 'root@dax-mysql-slave:3306': ********
Adding instance to the cluster ...

Validating instance at dax-mysql-slave:3306...

This instance reports its own address as dax-mysql-slave
WARNING: The following tables do not have a Primary Key or equivalent column:
aaaa.test

Group Replication requires tables to use InnoDB and have a PRIMARY KEY or PRIMARY KEY Equivalent (non-null unique key). Tables that do not follow these requirements will be readable but not updateable when used with Group Replication. If your applications make updates (INSERT, UPDATE or DELETE) to these tables, ensure they use the InnoDB storage engine and have a PRIMARY KEY or PRIMARY KEY Equivalent.

Instance configuration is suitable.
WARNING: On instance 'dax-mysql-slave:3306' membership change cannot be persisted since MySQL version 5.7.22 does not support the SET PERSIST command (MySQL version >= 8.0.5 required). Please use the <Dba>.configureLocalInstance command locally to persist the changes.
WARNING: On instance 'dax-mysql-master:3306' membership change cannot be persisted since MySQL version 5.7.22 does not support the SET PERSIST command (MySQL version >= 8.0.5 required). Please use the <Dba>.configureLocalInstance command locally to persist the changes.
The instance 'root@dax-mysql-slave:3306' was successfully added to the cluster.

7、查看集群状态,可以看到两个节点了:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 MySQL  dax-mysql-master:3306  JS > cluster.status();
{
"clusterName": "prodCluster",
"defaultReplicaSet": {
"name": "default",
"primary": "dax-mysql-master:3306",
"ssl": "DISABLED",
"status": "OK_NO_TOLERANCE",
"statusText": "Cluster is NOT tolerant to any failures.",
"topology": {
"dax-mysql-master:3306": {
"address": "dax-mysql-master:3306",
"mode": "R/W",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
},
"dax-mysql-slave:3306": {
"address": "dax-mysql-slave:3306",
"mode": "R/O",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
}
}
},
"groupInformationSourceMember": "mysql://repl@dax-mysql-master:3306"
}

root@db 17:14: [mysql_innodb_cluster_metadata]> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+------------------+-------------+--------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+------------------+-------------+--------------+
| group_replication_applier | bddd9c32-8fee-11e8-ac79-525400edbe8d | dax-mysql-slave | 3306 | ONLINE |
| group_replication_applier | d5bd8edd-9a1d-11e8-993e-525400578639 | dax-mysql-master | 3306 | ONLINE |
+---------------------------+--------------------------------------+------------------+-------------+--------------+
2 rows in set (0.00 sec)

root@db 17:14: [mysql_innodb_cluster_metadata]> show status like '%primary%';
+----------------------------------+--------------------------------------+
| Variable_name | Value |
+----------------------------------+--------------------------------------+
| group_replication_primary_member | d5bd8edd-9a1d-11e8-993e-525400578639 |
+----------------------------------+--------------------------------------+
1 row in set (0.01 sec)
目录
  1. 1. 1、查看集群状态
  2. 2. 2、解散集群:
  3. 3. 3、查看集群信息已经被删掉了:
  4. 4. 4、重新建立集群:
  5. 5. 5、 查看集群状态,现在只有一个节点信息
  6. 6. 6、添加新的节点:
  7. 7. 7、查看集群状态,可以看到两个节点了:

Proudly powered by Hexo and Theme by Lap
本站访客数人次
© 2020 zeven0707's blog