4.6.2change process命令

change process [--sequential-restart] old_proc_type[:proc-id]=new_proc_type cluster_name

old_proc_type | new_proc_type:
    {ndbd|ndbmtd}

此命令用于(MySQL NDB Cluster 7.0 及更高版本)将给定 MySQL NDB Cluster 进程或一组 MySQL NDB Cluster 进程的进程类型从一种进程类型(old-process-type)更改为另一种进程类型(new-process-type)。

目前,可用于此命令的仅有两种进程类型是ndbdndbmtd。这意味着change process可用于将运行在一个或多个数据节点上的数据节点进程从单线程数据节点守护进程 ( ndbd ) 更改为多线程数据节点守护进程 ( ndbmtd ),反之亦然。

默认情况下,change process影响所有运行old-process-type. 通过指定一个可选的process_id,它的动作可以被限制在具有该进程 ID 的数据节点上。

假设您有一个名为的集群, 并且有两个使用ndbdmycluster进程的数据节点 ,如以下 命令的输出所示: show status

mcm> show status --process mycluster;
+--------+----------+----------+----------+-----------+
| NodeId | Process  | Host     | Status   | Nodegroup |
+--------+----------+----------+----------+-----------+
| 49     | ndb_mgmd | flundra  | running  |           |
| 1      | ndbd     | tonfisk  | running  | n/a       |
| 2      | ndbd     | grindval | running  | n/a       |
| 50     | mysqld   | haj      | running  |           |
| 51     | mysqld   | torsk    | running  |           |
| 52     | ndbapi   | *        | running  |           |
+--------+----------+----------+----------+-----------+
6 rows in set (0.06 sec)

要将两个数据节点更改为使用多线程 ( ndbmtd ) 进程,请发出此处显示的命令,不带任何process_id 说明符:

mcm> change process ndbd=ndbmtd mycluster;
+------------------------------+
| Command result               |
+------------------------------+
| Process changed successfully |
+------------------------------+
1 row in set (2 min 17.51 sec)

命令执行后,您可以通过检查相应命令的输出 来验证两个数据节点现在是否都在使用ndbmtdshow status,如下所示:

mcm> show status --process mycluster;
+--------+----------+----------+----------+-----------+
| NodeId | Process  | Host     | Status   | Nodegroup |
+--------+----------+----------+----------+-----------+
| 49     | ndb_mgmd | flundra  | running  |           |
| 1      | ndbmtd   | tonfisk  | running  | n/a       |
| 2      | ndbmtd   | grindval | running  | n/a       |
| 50     | mysqld   | haj      | running  |           |
| 51     | mysqld   | torsk    | running  |           |
| 52     | ndbapi   | *        | running  |           |
+--------+----------+----------+----------+-----------+
6 rows in set (0.09 sec)

在命令结束时执行集群的滚动重启 change process对于 MySQL Cluster Manager 1.4.8 及更高版本,使用该 --sequential-restart 选项使滚动重启成为 顺序重启 。

笔记

change process无论要更改的集群或一个或多个数据节点是否正在运行,都可以使用 该命令。但是,如果要更改的一个或多个数据节点未运行,则该命令的执行速度会快得多。下一组示例说明了这一点。

同时使用 ndbdndbmtd数据节点进程是可能的(有时是可取的);因此,也可以使用 将 change process command单个数据节点进程从单线程更改为多线程,或从多线程更改为单线程。为此,您必须使用其进程 ID 指定数据节点进程。

首先,我们停止集群并验证所有进程都不再运行,如下所示:

mcm> stop cluster mycluster;
+------------------------------+
| Command result               |
+------------------------------+
| Cluster stopped successfully |
+------------------------------+
1 row in set (22.93 sec)

mcm> show status --process mycluster;
+--------+----------+----------+----------+-----------+
| NodeId | Process  | Host     | Status   | Nodegroup |
+--------+----------+----------+----------+-----------+
| 49     | ndb_mgmd | flundra  | stopped  |           |
| 1      | ndbmtd   | tonfisk  | stopped  | n/a       |
| 2      | ndbmtd   | grindval | stopped  | n/a       |
| 50     | mysqld   | haj      | stopped  |           |
| 51     | mysqld   | torsk    | stopped  |           |
| 52     | ndbapi   | *        | stopped  |           |
+--------+----------+----------+----------+-----------+
6 rows in set (0.05 sec)

以下命令仅将具有进程 ID 的节点2从使用多线程数据节点守护程序更改为单线程版本:

mcm> change process ndbmtd:2=ndbd mycluster;
+------------------------------+
| Command result               |
+------------------------------+
| Process changed successfully |
+------------------------------+
1 row in set (6.52 sec)

如您所见,change process当要更改的进程未运行时,运行速度要快得多。和以前一样,您可以使用以下命令验证命令是否成功 show status

mcm> show status --process mycluster;
+--------+----------+----------+----------+-----------+
| NodeId | Process  | Host     | Status   | Nodegroup |
+--------+----------+----------+----------+-----------+
| 49     | ndb_mgmd | flundra  | stopped  |           |
| 1      | ndbmtd   | tonfisk  | stopped  | n/a       |
| 2      | ndbd     | grindval | stopped  | n/a       |
| 50     | mysqld   | haj      | stopped  |           |
| 51     | mysqld   | torsk    | stopped  |           |
| 52     | ndbapi   | *        | stopped  |           |
+--------+----------+----------+----------+-----------+
6 rows in set (0.07 sec)

为了完成示例,我们再次启动集群,使用 start cluster,然后使用 将节点号 2 从ndbd(单线程)更改 回ndbmtd(多线程)change process,然后使用 验证更改 show status

mcm> start cluster mycluster;
+------------------------------+
| Command result               |
+------------------------------+
| Cluster started successfully |
+------------------------------+
1 row in set (36.43 sec)

mcm> change process ndbd:2=ndbmtd mycluster;
+------------------------------+
| Command result               |
+------------------------------+
| Process changed successfully |
+------------------------------+
1 row in set (2 min 10.41 sec)

mcm> show status --process mycluster;
+--------+----------+----------+----------+-----------+
| NodeId | Process  | Host     | Status   | Nodegroup |
+--------+----------+----------+----------+-----------+
| 49     | ndb_mgmd | flundra  | running  |           |
| 1      | ndbmtd   | tonfisk  | running  | n/a       |
| 2      | ndbmtd   | grindval | running  | n/a       |
| 50     | mysqld   | haj      | running  |           |
| 51     | mysqld   | torsk    | running  |           |
| 52     | ndbapi   | *        | running  |           |
+--------+----------+----------+----------+-----------+
6 rows in set (0.11 sec)

您可以看到,与在集群运行时更改进程相比,停止集群、更改数据节点进程然后再次启动集群所需的时间要少得多。但是,如果您这样做,集群在停止时不可用。

如前所述,change process仅适用于ndbdndbmtd 进程;尝试使用任何其他进程类型会导致命令失败并出现错误,如下所示:

mcm> change process ndb_mgmd=mysqld mycluster;
ERROR 7009 (00MGR): Processes ndb_mgmd and mysqld are not interchangeable in this package
mcm> change process ndbd=mysqld mycluster;
ERROR 7009 (00MGR): Processes ndbd and mysqld are not interchangeable in this package