MySQL Shell 9.3
To remove a cluster from the InnoDB ClusterSet, use
command. A clusterSet
.removeCluster()force
option is available if the
cluster cannot be contacted at all.
has the following syntax:
clusterSet
.removeCluster()
clusterSet
.removeCluster(clusterName[, options])
Clusters can be removed from a ClusterSet by removing the Cluster, but leaving it intact, or by removing the Cluster and dissolving it into its member instances. All user data is retained by both methods.
A removed cluster is dissolved, by default, into its component
instances. This is configured by the dissolve
option, which defaults to true
.
The primary cluster in an InnoDB ClusterSet cannot be removed using this command. If you do need to remove the primary cluster, you must first carry out a controlled switchover (see Section 9.8, “InnoDB ClusterSet Controlled Switchover”) or an emergency failover (see Section 9.9, “InnoDB ClusterSet Emergency Failover”) to demote the primary cluster to a replica cluster, and promote one of the replica clusters to be the primary cluster. After that, the former primary cluster can be removed using this procedure.
A dissolved InnoDB Cluster cannot be added back into an InnoDB ClusterSet deployment. If you want to use the server instances in the deployment again, you can use them to set up a new cluster and add that cluster to the ClusterSet.
To remove a cluster from the InnoDB ClusterSet, and dissolve the cluster, follow this procedure:
Using MySQL Shell, connect to any member server in the
primary cluster or in one of the replica clusters, using
an InnoDB Cluster administrator account (created with
).
You may also use the InnoDB Cluster server configuration
account, which also has the required permissions. When the
connection is established, get the
cluster
.setupAdminAccount()ClusterSet
object using
dba.getClusterSet()
or
command. It is important to use an InnoDB Cluster
administrator account or server configuration account so
that the default user account stored in the
cluster
.getClusterSet()ClusterSet
object has the correct
permissions.
Check the status of the whole deployment using
AdminAPI's
function in MySQL Shell. For example:
clusterSet
.status()
mysql-js> myclusterset.status({extended: 1})
For an explanation of the output, see Section 9.7, “InnoDB ClusterSet Status and Topology”.
When you issue the
command, there must be an active and reachable primary
cluster in the InnoDB ClusterSet deployment, and this
must not be the cluster you are removing. The cluster you
are removing must currently have the status of a replica
cluster. It can be invalidated, and does not have to be
reachable.
clusterSet
.removeCluster()
Check the routing options that are set for each MySQL Router
instance, and the global policy for the
InnoDB ClusterSet deployment, by issuing
in MySQL Shell while connected to any member server in
the InnoDB ClusterSet deployment. Verify that no
MySQL Router instances are routing traffic to the cluster that
you are going to remove. If any are, you must change their
settings to route traffic to another cluster using a
clusterSet
.routingOptions()
command, as described in
Section 9.6, “Integrating MySQL Router With InnoDB ClusterSet”. A cluster
cannot be removed if any MySQL Router instances known to the
InnoDB ClusterSet deployment are routing traffic to it.
clusterSet
.setRoutingOption()
Issue a
command, naming the cluster that you want to remove from
the InnoDB ClusterSet. For example:
clusterSet
.removeCluster()
mysql-js> myclusterset.removeCluster('clusterone')
The Cluster 'clusterone' will be removed from the InnoDB ClusterSet.
* Waiting for the Cluster to synchronize with the PRIMARY Cluster...
** Transactions replicated ############################################################ 100%
* Updating topology
** Transactions replicated ############################################################ 100%
* Stopping and deleting ClusterSet managed replication channel...
The Cluster 'clusterone' was removed from the ClusterSet.
The clusterName
parameter is
required and specifies the identifier used for the
cluster in the InnoDB ClusterSet, as given in the
output from the
command. In the example,
clusterSet
.status()
is the cluster that is to be removed.
clusterone
Use the dryRun
option if you want
to carry out validations and log the changes without
actually executing them.
Use the timeout
option to specify
the maximum number of seconds to wait for the cluster
to synchronize with the primary cluster in the
InnoDB ClusterSet.
Use the force
option to remove the
cluster from the ClusterSet when the cluster's primary
instance is not reachable.
When you issue the
command, MySQL Shell checks that the primary cluster in
the InnoDB ClusterSet deployment is reachable, that the
target cluster is not the primary cluster, and that no
MySQL Router instances are routing traffic to the target
cluster. If any of these conditions are not met, an error
is returned. If they are met, MySQL Shell carries out the
following tasks to remove the target cluster from the
InnoDB ClusterSet:
clusterSet
.removeCluster()
Drops the replication user that was created for the ClusterSet replication channel on the target cluster.
Synchronizes the primary server of the target cluster
with the primary cluster of the InnoDB ClusterSet,
and waits for all transactions to be applied locally.
If the timeout expires before this is completed, the
operation fails. If synchronization does not work, try
again with the force
option.
Stops the ClusterSet replication channel, then removes the channel and resets its configuration to the default values.
Removes the target cluster's metadata and member information from the InnoDB ClusterSet metadata.
Leaves the
super_read_only
system variable set on all the member servers, to
ensure that no updates are performed on them.
Issue a
command again using the clusterSet
.status()extended
option,
to verify the status of the InnoDB ClusterSet
deployment.
A removed InnoDB Cluster cannot be added back into an InnoDB ClusterSet deployment, so if you want to use the server instances in the deployment again, you will need to set up a new cluster using the standalone instances. The InnoDB Cluster is implicitly dissolved during the removal process, so that all the members become standalone instances.
Note that the Group Replication configuration is not removed from the server instances, so you should exercise caution when reusing these in an InnoDB ClusterSet deployment, as explained in Section 9.1, “InnoDB ClusterSet Requirements”. As the instances were configured for an InnoDB ClusterSet deployment, the possibility of issues is lower, but you should be aware of the potential for configuration differences especially if the instances are reused in a different InnoDB ClusterSet deployment.
To remove a cluster from a ClusterSet and keep the cluster
intact, as a standalone cluster, set the
dissolve
option to
false
.
The following example shows a cluster, named clustertwo, being removed intact from a ClusterSet:
myclusterset.removeCluster('clustertwo', {dissolve: false})
If {dissolve: false}
and
force
is not enabled, the command cannot
proceed if one, or more, members are uncontactable.
If {dissolve: false, force: true}
, the
command proceeds even if one, or more, cluster members are
uncontactable. The cluster is removed intact from the
ClusterSet, but the unreachable members are not synchronized.
However, if the cluster's primary is uncontactable, the
cluster is dissolved to its component instances. It is not
possible to keep the cluster intact if the primary is
unavailable.