[Mysql] mysql-mgr(双节点)依次修改server-id


本文总阅读量

1、查看从节点server-id信息:

1
2
3
4
5
6
7
8
9
10
11
12
root@db 16:55:  [(none)]> show variables like "%server%";
+---------------------------------------------------+--------------------------------------+
| Variable_name | Value |
+---------------------------------------------------+--------------------------------------+
| character_set_server | utf8mb4 |
| collation_server | utf8mb4_general_ci |
| group_replication_recovery_ssl_verify_server_cert | OFF |
| innodb_ft_server_stopword_table | |
| server_id | 3306102 |
| server_id_bits | 32 |
| server_uuid | bddd9c32-8fee-11e8-ac79-525400edbe8d |
+---------------------------------------------------+--------------------------------------+

2、登录mysql-shell查看集群信息:

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 = dba.getCluster("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"
}

将从节点移除集群:
MySQL dax-mysql-master:3306 JS > cluster.removeInstance(‘dax-mysql-slave:3306’)

1
2
3
4
5
6
7
8
9
The instance will be removed from the InnoDB cluster. Depending on the 
instance being the Seed or not, the Metadata session might become invalid.
If so, please start a new session to the Metadata Storage R/W instance.

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.
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.
The instance 'dax-mysql-slave:3306' was successfully removed from the cluster.

WARNING: The 'group_replication_start_on_boot' variable must be set to 'OFF' in the server configuration file, otherwise it might silently rejoin the cluster upon restart.

重新扫描集群信息:

1
2
3
4
5
6
7
8
9
10
11
 MySQL  dax-mysql-master:3306  JS > cluster.rescan();
Rescanning the cluster...

Result of the rescanning operation:
{
"defaultReplicaSet": {
"name": "default",
"newlyDiscoveredInstances": [],
"unavailableInstances": []
}
}

查看集群信息:

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"
}

3、从节点修改server-id,并重启库,之后将从节点加入集群:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
mysql-shell > 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.

查看集群信息:

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
 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"
}

其他节点修改方法如上。

目录
  1. 1. 1、查看从节点server-id信息:
  2. 2. 2、登录mysql-shell查看集群信息:
  3. 3. 3、从节点修改server-id,并重启库,之后将从节点加入集群:

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