4.4.2delete cluster命令

delete cluster [--removedirs] cluster_name

此命令删除名为 的集群 cluster_name,将其从 MySQL Cluster Manager 管理的集群列表中移除。

delete cluster不会 从主机中删除任何 MySQL Cluster 二进制文件但是,它 删除驻留在 MySQL Cluster Manager 数据存储库中的集群配置、数据和日志文件。

此示例演示如何删除名为的集群 mycluster

mcm> delete cluster mycluster;
+------------------------------+
| Command result               |
+------------------------------+
| Cluster deleted successfully |
+------------------------------+
1 row in set (1.22 sec)

查看 MySQL Cluster Manager 数据存储库( /opt/mcm_data/在本例中为 at)表明,用于托管mycluster ( /opt/mcm_data/clusters/mycluster) 的配置、数据和日志文件的文件夹不再存在:

$> ls -l /opt/mcm_data/clusters
total 0

要删除 MySQL Cluster Manager 数据存储库之外的配置和数据文件,delete cluster必须使用该--removedirs选项调用,如下所示:

mcm> delete cluster --removedirs mycluster;
+------------------------------+
| Command result               |
+------------------------------+
| Cluster deleted successfully |
+------------------------------+
1 row in set (1.22 sec)

例如,如果其中一个数据节点 mycluster的数据目录位于 MySQL Cluster Manager 数据存储库之外:

mcm> get Datadir mycluster;
+---------+---------------------------+----------+---------+----------+---------+---------+---------+
| Name    | Value                     | Process1 | NodeId1 | Process2 | NodeId2 | Level   | Comment |
+---------+---------------------------+----------+---------+----------+---------+---------+---------+
| DataDir | /home/dso/mycluster/cdata | ndbd     | 1       |          |         | Process |         |
...

在不 使用的情况下删除 mycluster--removedirs 不会删除节点 1 的数据目录:

$> ls -l /home/dso/mycluster
total 4 drwxr-xr-x. 3 dso dso 4096 Sep 10 18:00 cdata

但是,如果--removedirs使用该选项,节点 1 的数据目录也会被删除:

$> ls -l /home/dso/mycluster
total 0

delete cluster如果要删除的集群正在运行,则会失败,如下所示:

mcm> delete cluster mycluster;
ERROR 5010 (00MGR): All processes must be stopped to delete cluster mycluster

您必须先关闭集群,使用 stop cluster.