set [--sequential-restart] attribute_assignment_list cluster_name
attribute_assignment_list:
attribute_assignment[,attribute_assignment][,...]
attribute_assignment:
attribute_name:process_specification[+process_specification][=value]
process_specification:
[process_name][:process_id]
process_name:
{ndb_mgmd|ndbd|ndbmtd|mysqld|ndbapi}
此命令用于设置一个或多个配置属性的值。可以在进程级别或实例级别设置属性。
set
无论集群是否已经启动,命令都会被执行。在未运行的集群中,MySQL 集群管理器仅更新配置文件。但是,在正在运行的集群中,MySQL Cluster Manager 还自动执行
使属性更改生效所需的任何节点重启或滚动重启(请参阅执行 NDB Cluster 的滚动重启)(对于 MySQL Cluster Manager 1.4。 8 及更高版本,使用
--sequential-restart
选项使滚动重新启动
顺序
一)。但是,由于重启操作(尤其是滚动重启)可能会花费大量时间,因此最好在启动集群并将其投入使用之前更改配置。
要在进程级别设置属性,请使用
set
包含具有以下形式的属性分配的语句
attribute_name
:process_name
= value
。
例如,要
在ndbdDataMemory
进程级别设置为 500 MB ,以便新值适用于集群中的所有ndbd进程,您可以发出包含属性分配的命令,如下所示:
set
DataMemory:ndbd=500M
mcm> set DataMemory:ndbd=500M mycluster;
+-----------------------------------+
| Command result |
+-----------------------------------+
| Cluster reconfigured successfully |
+-----------------------------------+
1 row in set (5.68 sec)
要验证是否正在使用新设置,您可以发出以下get
命令:
mcm> get DataMemory mycluster;
+------------+-------+----------+------+----------+------+---------+---------+
| Name | Value | Process1 | Id1 | Process2 | Id2 | Level | Comment |
+------------+-------+----------+------+----------+------+---------+---------+
| DataMemory | 500M | ndbd | 1 | | | Process | |
| DataMemory | 500M | ndbd | 2 | | | Process | |
+------------+-------+----------+------+----------+------+---------+---------+
2 rows in set (0.79 sec)
有关此命令的更多信息,请参阅
第 4.5.1 节 “get
命令”。
要为特定流程实例设置属性,请在属性分配中包含流程 ID;这种属性赋值的形式是
attribute_name
: process_name
: process_id
= value
。例如,要将
进程 ID
为 200 的mysqld50
进程的 wait_timeout 属性设置为 200,您将发出
set
包含属性分配的命令wait_timeout:mysqld:51=200
,如下所示:
mcm> set wait_timeout:mysqld:50=200 mycluster;
+-----------------------------------+
| Command result |
+-----------------------------------+
| Cluster reconfigured successfully |
+-----------------------------------+
1 row in set (6.18 sec)
get
您可以使用适用的命令
验证设置是否生效:
mcm> get wait_timeout mycluster;
+--------------+-------+----------+------+----------+------+-------+---------+
| Name | Value | Process1 | Id1 | Process2 | Id2 | Level | Comment |
+--------------+-------+----------+------+----------+------+-------+---------+
| wait_timeout | 200 | mysqld | 50 | | | | |
+--------------+-------+----------+------+----------+------+-------+---------+
1 row in set (0.50 sec)
Read only
无法设置
标记的属性。尝试这样做失败并出现错误,如下所示:
mcm> get :ndbd mycluster;
+--------------+-------------+----------+-----+----------+-----+-------+-----------+
| Name | Value | Process1 | Id1 | Process2 | Id2 | Level | Comment |
+--------------+-------------+----------+-----+----------+-----+-------+-----------+
| DataDir | /opt/c2data | ndbd | 1 | | | | |
| HostName | tonfisk | ndbd | 1 | | | | Read only |
| NodeId | 2 | ndbd | 1 | | | | Read only |
| DataDir | /opt/c3data | ndbd | 2 | | | | |
| HostName | grindval | ndbd | 2 | | | | Read only |
| NodeId | 3 | ndbd | 2 | | | | Read only |
+--------------+-------------+----------+-----+----------+-----+-------+-----------+
6 rows in set (1.42 sec)
mcm> set HostName:ndbd:1=lax mycluster;
ERROR 6008 (00MGR): Config attribute HostName is read only and cannot be changed
但是,您可以设置强制属性,例如本节前面显示的示例,其中
DataDir
配置属性设置为用户定义的值。
NoOfReplicas
必须仅在进程级别设置
强制
属性。尝试在实例级别设置它可能会使集群、MySQL 集群管理器或两者都处于无法使用的配置中。
与get
命令的情况不同,您不能set
在“全局”范围内发出操作——也就是说,您不能在单个属性分配中为属性设置单个值,以便新属性值适用于所有进程,而不管进程类型,即使具有该名称的属性可以应用于所有进程类型。您也不能在单个属性分配中指定多个进程类型。尝试做这些事情中的任何一个都会导致错误,如下所示:
mcm> set DataDir=/var/cluster-data mycluster;
ERROR 3 (00MGR): Illegal syntax
mcm> set DataDir:ndb_mgmd,ndbd,mysqld=/var/cluster-data mycluster;
ERROR 3 (00MGR): Illegal syntax
相反,您必须为每个流程类型使用流程级属性分配。但是,您不一定需要为每种进程类型发出单独的设置命令。相反,您还可以在单个
set
命令中进行多个属性分配,以逗号分隔列表的形式提供分配。此命令为名为的集群中的所有 MySQL NDB Cluster 进程
set
分配/var/cdata
数据目录 ( ) :
DataDir
mycluster
mcm> set DataDir:ndb_mgmd=/var/cdata, \
DataDir:ndbd=/var/cdata, \
DataDir:mysqld=/var/cdata mycluster;
+-----------------------------------+
| Command result |
+-----------------------------------+
| Cluster reconfigured successfully |
+-----------------------------------+
1 row in set (7.66 sec)
mcm> get DataDir mycluster;
+---------+------------+----------+---------+----------+---------+-------+---------+
| Name | Value | Process1 | NodeId1 | Process2 | NodeId2 | Level | Comment |
+---------+------------+----------+---------+----------+---------+-------+---------+
| DataDir | /var/cdata | ndbmtd | 1 | | | | |
| DataDir | /var/cdata | ndbmtd | 2 | | | | |
| DataDir | /var/cdata | ndb_mgmd | 49 | | | | |
| datadir | /var/cdata | mysqld | 50 | | | | |
| datadir | /var/cdata | mysqld | 51 | | | | |
+---------+------------+----------+---------+----------+---------+-------+---------+
5 rows in set (0.08 sec)
从get
刚才的命令可以看出,属性赋值成功,并在进程级别生效。
在 MySQL Cluster Manager 中,配置属性名称不区分大小写。有关MySQL Cluster Manager 中区分大小写问题的更多信息, 请参阅字符串搜索中的区分大小写。
同样,您不能在单个属性分配中引用多个进程 ID,即使它们是同一类型的进程;以下命令不起作用:
mcm> set DataMemory:ndbd:1,2=750M mycluster;
ERROR 3 (00MGR): Illegal syntax
相反,您需要使用以下命令:
mcm> set DataMemory:ndbd:1=750M,DataMemory:ndbd:2=750M mycluster;
+-----------------------------------+
| Command result |
+-----------------------------------+
| Cluster reconfigured successfully |
+-----------------------------------+
1 row in set (7.70 sec)
(当然,如果这些是中仅有的两个数据节点
mycluster
,那么该命令set
DataMemory:ndbd=750M mycluster
也可以完成相同的任务。)
一些配置属性适用于进程之间的连接,因此需要您在设置它们的过程中引用这两个进程。在这种情况下,您必须使用特殊的流程规范语法;有关如何完成此操作的信息, 请参阅 设置 TCP 连接属性。
您也不能在单个属性分配中为多个属性设置值;这意味着以下命令 不起作用:
mcm> set UndoDataBuffer=32M,UndoIndexBuffer=8M:ndbd mycluster;
ERROR 3 (00MGR): Illegal syntax
mcm> set DataMemory,IndexMemory:ndbd=1G mycluster;
ERROR 3 (00MGR): Illegal syntax
但是,如果您为要更新其值的每个属性编写完整且有效的属性分配,则可以重写这两个命令,以便它们成功执行,如下所示:
mcm> set UndoDataBuffer:ndbd=32M,UndoIndexBuffer:ndbd=8M mycluster;
+-----------------------------------+
| Command result |
+-----------------------------------+
| Cluster reconfigured successfully |
+-----------------------------------+
1 row in set (6.62 sec)
mcm> set DataMemory:ndbd=1G,IndexMemory:ndbd=1G mycluster;
+-----------------------------------+
| Command result |
+-----------------------------------+
| Cluster reconfigured successfully |
+-----------------------------------+
1 row in set (7.04 sec)
事实上,没有理由不能在一个set
命令中执行所有四个赋值,使用四个属性赋值的列表,如下所示:
mcm> set UndoDataBuffer:ndbd=32M,UndoIndexBuffer:ndbd=8M, \
DataMemory:ndbd=1G, IndexMemory:ndbd=1G mycluster;
+-----------------------------------+
| Command result |
+-----------------------------------+
| Cluster reconfigured successfully |
+-----------------------------------+
1 row in set (6.24 sec)
但是,最好不要在任何单个set
命令中执行过多的属性分配,因为这会使发现错误变得更加困难。
在 Windows 上,设置其值包含路径(例如DataDir
)的属性时,必须将路径中的所有反斜杠字符替换为正斜杠。假设您要使用在 Windows 上运行的名为 MySQL NDB 集群中节点 ID 为 50的mysqldC:\temp\node50
进程的
tmpdir
属性
。可以使用适当的命令查看此属性的原始值:
mycluster
get
mcm> get tmpdir mycluster;
+--------+----------------+----------+-----+----------+-----+-------+---------+
| Name | Value | Process1 | Id1 | Process2 | Id2 | Level | Comment |
+--------+----------------+----------+-----+----------+-----+-------+---------+
| tmpdir | c:\c50data\tmp | mysqld | 50 | | | | |
+--------+----------------+----------+-----+----------+-----+-------+---------+
1 row in set (0.22 sec)
进行所需配置更改的正确set
命令如下所示:
mcm> set tmpdir:mysqld:50=c:/temp/node50 mycluster;
+-----------------------------------+
| Command result |
+-----------------------------------+
| Cluster reconfigured successfully |
+-----------------------------------+
1 row in set (2.62 sec)
当您使用检查值时
get
——即使它最初是使用反斜杠显示的——在显示新值时使用正斜杠:
mcm> get tmpdir mycluster;
+--------+----------------+----------+-----+----------+-----+-------+---------+
| Name | Value | Process1 | Id1 | Process2 | Id2 | Level | Comment |
+--------+----------------+----------+-----+----------+-----+-------+---------+
| tmpdir | c:/temp/node50 | mysqld | 50 | | | | |
+--------+----------------+----------+-----+----------+-----+-------+---------+
1 row in set (0.22 sec)
但是,如果您尝试在发出set
命令时在路径中使用反斜杠,命令将失败:
mcm> set tmpdir:mysqld:4=c:\temp\4 mycluster;
Outfile disabled.
ERROR:
Unknown command '\4'.
ERROR 6014 (00MGR): Path name for parameter tmpdir must be absolute.
The value 'c:mp4' is illegal.
设置 TCP 连接属性。
For a few attributes that apply only when using TCP
connections (such as the
SendBufferMemory
and
ReceiveBufferMemory
attributes), it is necessary to use a modified syntax for
attribute value assignments. In this case, the attribute
assignment contains two process specifications, one for each
process type or instance to which the setting applies, joined
with a plus sign (+
). For the
following example, consider the cluster named
mycluster2
, consisting of the processes
shown here:
mcm> list processes mycluster2;
+------+----------+-------------+
| Id | Name | Host |
+------+----------+-------------+
| 49 | ndb_mgmd | grindval |
| 1 | ndbd | tonfisk |
| 2 | ndbd | flundra |
| 50 | mysqld | haj |
| 51 | mysqld | torsk |
+------+----------+-------------+
5 rows in set (0.16 sec)
(See Section 4.6.3, “The list processes
Command”, for more information
about this command.)
get
除非已设置,否则
TCP 连接属性不会显示在命令的输出中
。这意味着,在
SendBufferMemory
第一次设置之前,如果您尝试检索其值,您将获得一个空结果,如下所示:
mcm> get SendBufferMemory mycluster2;
Empty set (0.18 sec)
mcm> get --include-defaults SendBufferMemory mycluster2;
Empty set (0.93 sec)
要将
SendBufferMemory
数据节点和 SQL 节点之间的所有 TCP 连接设置为 4 MB,您可以使用此处显示的命令:
mcm> set SendBufferMemory:ndbd+mysqld=4M mycluster2;
+-----------------------------------+
| Command result |
+-----------------------------------+
| Cluster reconfigured successfully |
+-----------------------------------+
1 row in set (6.44 sec)
If you check the attribute's value afterwards using
get
, you can see that the value
is applied to all possible connections between each of the two
ndbd processes and each of the two
mysqld processes in
mycluster2
, thus there are four rows in the
output:
mcm> get SendBufferMemory mycluster2;
+------------------+-------+----------+-----+----------+-----+---------+---------+
| Name | Value | Process1 | Id1 | Process2 | Id2 | Level | Comment |
+------------------+-------+----------+-----+----------+-----+---------+---------+
| SendBufferMemory | 4M | ndbd | 2 | mysqld | 4 | Process | |
| SendBufferMemory | 4M | ndbd | 2 | mysqld | 5 | Process | |
| SendBufferMemory | 4M | ndbd | 3 | mysqld | 4 | Process | |
| SendBufferMemory | 4M | ndbd | 3 | mysqld | 5 | Process | |
+------------------+-------+----------+-----+----------+-----+---------+---------+
4 rows in set (1.63 sec)
To override this setting for only the connection between the
data node with process ID 2
and the mysqld
process (process ID 4
), you can include the
process ID in each of the two parts of the process
specification, as shown here:
mcm> set SendBufferMemory:ndbd:2+mysqld:4=8M mycluster2;
+-----------------------------------+
| Command result |
+-----------------------------------+
| Cluster reconfigured successfully |
+-----------------------------------+
1 row in set (7.95 sec)
When you check the result using a
get
command, you can see that
the new setting applies on the instance level, and only to the
connection between processes having IDs 2
and
4
; the process-level setting made previously
still applies to the remaining 3 connections:
mcm> get SendBufferMemory mycluster2;
+------------------+-------+----------+-----+----------+-----+---------+---------+
| Name | Value | Process1 | Id1 | Process2 | Id2 | Level | Comment |
+------------------+-------+----------+-----+----------+-----+---------+---------+
| SendBufferMemory | 8M | ndbd | 2 | mysqld | 50 | | |
| SendBufferMemory | 4M | ndbd | 2 | mysqld | 51 | Process | |
| SendBufferMemory | 4M | ndbd | 3 | mysqld | 50 | Process | |
| SendBufferMemory | 4M | ndbd | 3 | mysqld | 51 | Process | |
+------------------+-------+----------+-----+----------+-----+---------+---------+
4 rows in set (0.24 sec)
You cannot set a connection attribute on the process level in one part of the process specification (that is, for one end of the connection) and on the instance level in the other. Attempting to do so fails with an error, as shown here:
mcm> set SendBufferMemory:ndbd+mysqld:4=2M mycluster2;
ERROR 3 (00MGR): Illegal syntax
mcm> set SendBufferMemory:ndbd:2+mysqld=2M mycluster2;
ERROR 3 (00MGR): Illegal syntax
Setting Attributes for mysqld nodes. When a dynamic variable is set, mcmd sends out a SET GLOBAL statement to the mysqld to apply the value and also saves the value to the mysqld configuration file, so the value can be applied again at the next mysqld restart; however, an immediate restart is triggered when a non-dynamic variable is set.
Setup for mysqld connection pooling.
Enabling connection pooling for mysqld can
be done by setting the
ndb-cluster-connection-pool
attribute to
the desired number of connections, but also requires an extra
step in creating the cluster.
Because the mysqld process attempts to make
multiple connections to the cluster when connection pooling is
enabled, the cluster must be configured with
“spare” or “empty” connections. You
can do this by adding (otherwise) unused
ndbapi
entries in the process_host list used
in the create cluster
command,
as shown here:
mcm> create cluster -P mypackage
> -R ndb_mgmd@10.100.10.97,ndbd@10.100.10.98,ndbd@10.100.10.99, \
mysqld@10.100.10.100,ndbapi@10.100.10.100, \
ndbapi@10.100.10.100,ndbapi@10.100.10.100
> mycluster;
+------------------------------+
| Command result |
+------------------------------+
| Cluster created successfully |
+------------------------------+
1 row in set (6.58 sec)
After this, you can use a set
command like
this one to set the size of the connection pool according to the
number of excess connections available in the
config.ini
file:
mcm> set ndb_cluster_connection_pool:mysqld=4;
user
mysqld不支持属性
。
当前不支持尝试为mysqlduser
进程设置属性,这
会导致将警告写入 MySQL Cluster Manager 日志。