4.4.10upgrade cluster命令

upgrade cluster {--package=|-P }package_name
 [{--nodeid|-n }node_id_list] [--force|-f]
 [--retry|-L] [--set=attribute_assignment_list] cluster_name

node_id_list:
    node_id[, node_id[, ...]]

attribute_assignment_list:
    attribute_assignment[,attribute_assignment][,...]

attribute_assignment:
    attribute_name:process_name[=value]

此命令将名为的集群升级为 指定 cluster_name的软件包 。它通过对集群执行滚动重启来完成升级,其中数据节点重新启动, 并可选择重建其数据文件系统。 package_name--package--initial

新包必须先注册使用 add package,然后才能使用它进行升级;否则,upgrade cluster 失败并出现错误。

要使用该命令对集群进行升级,除非使用一些特殊选项(请参阅下面对 、 和 选项的说明 --force--retry, 否则--nodeid集群必须处于fully operational状态(您可以使用命令 来检查)。在导入完成之前,无法升级为导入创建的集群。有关更多信息,请参阅第 4.4.1 节,“命令”第 3.5 节,“将 MySQL NDB 集群导入 MySQL 集群管理器”show status --cluster cluster_namecreate cluster

假设mycluster正在使用 MySQL NDB Cluster 7.4.8,并且二进制文件已注册到名为 的包 7.4.8,如以下 list clusters命令所示:

mcm> list clusters mysite;
+-----------+---------+
| Cluster   | Package |
+-----------+---------+
| mycluster | 7.4.8   |
+-----------+---------+
1 row in set (1.80 sec)

现在您希望升级mycluster到 MySQL NDB Cluster。假设您已将 NDB 7.6.13 二进制文件放在每个主机上的同一目录中, add package创建一个名为7.6.13包含这些二进制文件的新包的命令可能如下所示:

mcm> add package --basedir=/usr/local/ndb-7.6.13 7.6.13;
+----------------------------+
| Command result             |
+----------------------------+
| Package added successfully |
+----------------------------+
1 row in set (0.88 sec)
笔记

在 Windows 上,您必须将\用于 add package命令 --basedir选项的路径中的任何反斜杠 () 字符替换为正斜杠 ( /)。有关更多信息和示例, 请参见第 4.3.1 节“add package命令” 。

这两个包现在应该列在命令的输出中 list packages mysite。要执行 7.6.13程序包升级,请使用 upgrade cluster如下所示的命令:

mcm> upgrade cluster --package=7.6.13 mycluster;
+-------------------------------+
| Command result                |
+-------------------------------+
| Cluster upgraded successfully |
+-------------------------------+
1 row in set (3 min 17.00 sec)

命令upgrade cluster 成功执行后,您可以 从相应 命令 的输出中验证mycluster现在正在使用该 包:7.6.13list clusters

mcm> list clusters mysite;
+-----------+---------+
| Cluster   | Package |
+-----------+---------+
| mycluster | 7.6.13  |
+-----------+---------+
1 row in set (1.80 sec)

该命令可以执行主要和次要系列升级。尽管这个命令的名字,upgrade cluster也可以用来执行 MySQL NDB Cluster 降级。

该命令并不支持所有不同版本的 MySQL NDB Cluster 之间的升级和降级。必须满足三个标准:

  • 涉及的 MySQL NDB Cluster 版本必须支持升级或降级。有关允许升级和降级的列表,请参阅 MySQL NDB Cluster 手册中的以下部分:

  • Both the versions you upgrade or downgrade to and from must be supported by the version of MySQL Cluster Manager you are using (for example, upgrade from MySQL NDB Cluster 6.3 to 7.5 must be performed manually, because MySQL Cluster Manager no longer supports MySQL NDB Cluster 6.3).

When using the upgrade cluster command, you can use the --set option to reconfigure your MySQL NDB Cluster at the same time. This is particularly helpful when the upgrade requires configuration changes to your cluster. This option takes as its argument an attribute assignment list similar in format to that used with the get and set commands; see description of the set command on the proper way to formulate an attribute assignment list. For example: if you want to change the memory assigned to each data node for storing database records to 750M, specify that with the --set option in your upgrade cluster command:

mcm> upgrade cluster --package=7.6.13 --set=DataMemory:ndbd=750M  mycluster;
+-------------------------------+
| Command result                |
+-------------------------------+
| Cluster upgraded successfully |
+-------------------------------+
1 row in set (3 min 17.04 sec)
Note

Unlike the way you use the set command, an equal sign (=) immediately following the --set option is required.

Options for dealing with failed upgrades

The --force option (-f for short) should be used when you want to run the upgrade cluster command again after a failed upgrade attempt that ends up with any failed management or data nodes. Without the --force option, the upgrade cluster command only runs when the cluster is in the fully operational status.

The --retry option (-L for short) should be used when you want to retry the upgrade cluster command after a failed attempt that ends up with some nodes being upgraded, and some not. Without the --retry option, the upgrade cluster command cannot be run on the same cluster twice using the same package.

In the case of a failed or incomplete upgrade, instead of using the --force and --retry option, you can also choose to retry the upgrade only on the failed nodes by specifying them using the --nodeid option (-n in short). Check for any failed nodes after a failed upgrade:

mcm> upgrade cluster -P next mycluster;
ERROR 7006 (00MGR): Process error: <reason of failure>
mcm> show status --process mycluster;
+--------+----------+----------+---------+-----------+-----------+
| NodeId | Process  | Host     | Status  | Nodegroup | Package   |
+--------+----------+----------+---------+-----------+-----------+
| 49     | ndb_mgmd | thinkpad | running |           | next      |
| 1      | ndbmtd   | thinkpad | running | 0         | next      |
| 2      | ndbmtd   | thinkpad | running | 0         | next      |
| 50     | mysqld   | thinkpad | running |           | next      |
| 51     | mysqld   | thinkpad | failed  |           | next      |
| 52     | ndbapi   | *        | added   |           |           |
+--------+----------+----------+---------+-----------+-----------+
6 rows in set (0.03 sec)

然后,再次发出命令,使用以下--nodeid 选项指定故障节点:

mcm> upgrade cluster --nodeid=51 -P next mycluster;
+-------------------------------+
| Command result                |
+-------------------------------+
| Cluster upgraded successfully |
+-------------------------------+
1 row in set (26.03 sec)
警告

--nodeid在命令中不恰当地 使用该 选项upgrade cluster可能会导致部分升级。仅当先前的升级尝试失败时才使用它,并且只能在适当的支持人员的指导下使用。