文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 25 MySQL NDB 集群 8.4 / 25.6 NDB Cluster 的管理 / 25.6.1 NDB 集群管理客户端中的命令
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 84%

25.6.1 NDB 集群管理客户端中的命令25.6.1 Commands in the NDB Cluster Management Client

除了中央配置文件之外,集群还可以通过管理客户端提供的命令行界面进行控制,ndb_mgm。这是对正在运行的集群进行管理的主要接口。In addition to the central configuration file, a cluster may also be controlled through a command-line interface available through the management client ndb_mgm. This is the primary administrative interface to a running cluster.

事件日志的命令在第 25.6.3 节,“在 NDB 集群中生成的事件报告”中给出;创建备份和从备份恢复的命令在第 25.6.8 节,“NDB 集群的在线备份”中提供。Commands for the event logs are given in Section 25.6.3, “Event Reports Generated in NDB Cluster”; commands for creating backups and restoring from them are provided in Section 25.6.8, “Online Backup of NDB Cluster”.

在 MySQL 集群管理器中使用 ndb_mgm。 MySQL 集群管理器负责启动和停止进程,并在内部跟踪其状态,因此对于在 MySQL 集群管理器控制下的 NDB 集群来说,不需要使用 ndb_mgm 来执行这些任务。建议 不要 使用随 NDB 集群发行版提供的 ndb_mgm 命令行客户端来执行涉及启动或停止节点的操作。这些操作包括但不限于 START、STOP、RESTART 和 SHUTDOWN 命令。欲了解更多信息,请参见 MySQL 集群管理器进程命令。Using ndb_mgm with MySQL Cluster Manager.  MySQL Cluster Manager handles starting and stopping processes and tracks their states internally, so it is not necessary to use ndb_mgm for these tasks for an NDB Cluster that is under MySQL Cluster Manager control. It is recommended not to use the ndb_mgm command-line client that comes with the NDB Cluster distribution to perform operations that involve starting or stopping nodes. These include but are not limited to the START, STOP, RESTART, and SHUTDOWN commands. For more information, see MySQL Cluster Manager Process Commands.

管理客户端具有以下基本命令。在下列列表中,node_id 表示数据节点 ID 或关键字 ALL,表示命令应应用于集群的所有数据节点。The management client has the following basic commands. In the listing that follows, node_id denotes either a data node ID or the keyword ALL, which indicates that the command should be applied to all of the cluster's data nodes.

  • CONNECT connection-string

    连接到由连接字符串指定的管理服务器。如果客户端已经连接到此服务器,客户端将重新连接。Connects to the management server indicated by the connection string. If the client is already connected to this server, the client reconnects.

  • CREATE NODEGROUP nodeid[, nodeid, ...]

    创建一个新的 NDB 集群节点组,并使数据节点加入该组。Creates a new NDB Cluster node group and causes data nodes to join it.

    此命令在向 NDB 集群在线添加新数据节点后使用,使它们加入新的节点组,从而开始在集群中完全参与。该命令的唯一参数是以逗号分隔的节点 ID 列表——这些是刚刚添加并启动的节点的 ID,它们将加入新的节点组。列表中不得有重复的 ID;如果存在任何重复,则命令将返回错误。列表中的节点数量必须与集群中每个已有节点组的节点数量相同(每个 NDB 集群节点组必须有相同数量的节点)。换句话说,如果 NDB 集群由 2 个节点组组成,每个节点组有 2 个数据节点,那么新的节点组也必须有 2 个数据节点。This command is used after adding new data nodes online to an NDB Cluster, and causes them to join a new node group and thus to begin participating fully in the cluster. The command takes as its sole parameter a comma-separated list of node IDs—these are the IDs of the nodes just added and started, and that are to join the new node group. The list must contain no duplicate IDs; the presence of any duplicates causes the command to return an error. The number of nodes in the list must be the same as the number of nodes in each node group that is already part of the cluster (each NDB Cluster node group must have the same number of nodes). In other words, if the NDB Cluster consists of 2 node groups having 2 data nodes each, then the new node group must also have 2 data nodes.

    由此命令创建的新节点组的节点组 ID 会自动确定,并且始终是集群中下一个未使用的最高节点组 ID;无法手动设置。The node group ID of the new node group created by this command is determined automatically, and always the next highest unused node group ID in the cluster; it is not possible to set it manually.

    有关更多信息,请参见 第 25.6.7 节,“在线添加 NDB Cluster 数据节点”。For more information, see Section 25.6.7, “Adding NDB Cluster Data Nodes Online”.

  • DROP NODEGROUP nodegroup_id

    删除具有指定 nodegroup_id 的 NDB Cluster 节点组。Drops the NDB Cluster node group with the given nodegroup_id.

    此命令可用于从 NDB Cluster 中删除节点组。DROP NODEGROUP 的唯一参数是要删除的节点组的节点组 ID。This command can be used to drop a node group from an NDB Cluster. DROP NODEGROUP takes as its sole argument the node group ID of the node group to be dropped.

    DROP NODEGROUP 仅用于从受影响的节点组中移除数据节点。它不会停止数据节点,不会将它们分配到其他节点组,也不会将它们从集群配置中移除。一个不属于任何节点组的数据节点将在管理客户端的 SHOW 命令输出中显示为 no nodegroup 以替代节点组 ID,如下所示(用粗体文本表示):DROP NODEGROUP acts only to remove the data nodes in the effected node group from that node group. It does not stop data nodes, assign them to a different node group, or remove them from the cluster's configuration. A data node that does not belong to a node group is indicated in the output of the management client SHOW command with no nodegroup in place of the node group ID, like this (indicated using bold text):

    id=3    @10.100.2.67  (8.4.7-ndb-8.4.7, no nodegroup)
    

    DROP NODEGROUP 仅在要删除的节点组中的所有数据节点完全没有任何表数据和表定义时才有效。由于目前无法使用 ndb_mgm 或 mysql 客户端从特定数据节点或节点组中删除所有数据,这意味着该命令仅在以下两种情况下成功:DROP NODEGROUP works only when all data nodes in the node group to be dropped are completely empty of any table data and table definitions. Since there is currently no way using ndb_mgm or the mysql client to remove all data from a specific data node or node group, this means that the command succeeds only in the two following cases:

    1. 在 ndb_mgm 客户端中发出 CREATE NODEGROUP 之后,但在 mysql 客户端中发出任何 ALTER TABLE ... REORGANIZE PARTITION 语句之前。After issuing CREATE NODEGROUP in the ndb_mgm client, but before issuing any ALTER TABLE ... REORGANIZE PARTITION statements in the mysql client.

    2. 使用 DROP TABLE 删除所有 NDBCLUSTER 表之后。After dropping all NDBCLUSTER tables using DROP TABLE.

      TRUNCATE TABLE 对此目的无效,因为它只会删除表数据;数据节点仍然会存储NDBCLUSTER表的定义,直到执行DROP TABLE语句,从而导致表元数据被删除。TRUNCATE TABLE does not work for this purpose because this removes only the table data; the data nodes continue to store an NDBCLUSTER table's definition until a DROP TABLE statement is issued that causes the table metadata to be dropped.

    有关 DROP NODEGROUP 的更多信息,请参见 第 25.6.7 节,“在线添加 NDB 集群数据节点”。For more information about DROP NODEGROUP, see Section 25.6.7, “Adding NDB Cluster Data Nodes Online”.

  • ENTER SINGLE USER MODE node_id ENTER SINGLE USER MODE node_id

    进入单用户模式,此模式下只有由节点 ID node_id 标识的 MySQL 服务器被允许访问数据库。Enters single user mode, whereby only the MySQL server identified by the node ID node_id is permitted to access the database.

    ndb_mgm 客户端会清楚地确认已发出此命令并已生效,如下所示:The ndb_mgm client provides a clear acknowledgement that this command has been issued and has taken effect, as shown here:

    ndb_mgm> ENTER SINGLE USER MODE 100
    Single user mode entered
    Access is granted for API node 100 only.
    

    此外,当处于单用户模式时,API 或 SQL 节点拥有独占访问权限,这在 SHOW 命令的输出中会显示如下:In addition, the API or SQL node having exclusive access when in single user mode is indicated in the output of the SHOW command, like this:

    ndb_mgm> SHOW
    Cluster Configuration
    ---------------------
    [ndbd(NDB)]     2 node(s)
    id=5    @127.0.0.1  (mysql-8.4.7 ndb-8.4.7, single user mode, Nodegroup: 0, *)
    id=6    @127.0.0.1  (mysql-8.4.7 ndb-8.4.7, single user mode, Nodegroup: 0)
    
    [ndb_mgmd(MGM)] 1 node(s)
    id=50   @127.0.0.1  (mysql-8.4.7 ndb-8.4.7)
    
    [mysqld(API)]   2 node(s)
    id=100  @127.0.0.1  (mysql-8.4.7 ndb-8.4.7, allowed single user)
    id=101 (not connected, accepting connect from any host)
    
  • EXIT SINGLE USER MODE

    退出单用户模式,使所有 SQL 节点(即所有运行中的 mysqld 进程)可以访问数据库。Exits single user mode, enabling all SQL nodes (that is, all running mysqld processes) to access the database.

    Note

    即使不处于单用户模式,也可以使用 EXIT SINGLE USER MODE,尽管在这种情况下该命令不会产生任何效果。It is possible to use EXIT SINGLE USER MODE even when not in single user mode, although the command has no effect in this case.

  • HELP HELP

    显示所有可用命令的信息。Displays information on all available commands.

  • node_id NODELOG DEBUG {ON|OFF} node_id NODELOG DEBUG {ON|OFF}

    切换节点日志中的调试日志,就像受影响的数据节点已使用 --verbose 选项启动一样。NODELOG DEBUG ON 启动调试日志;NODELOG DEBUG OFF 关闭调试日志。Toggles debug logging in the node log, as though the effected data node or nodes had been started with the --verbose option. NODELOG DEBUG ON starts debug logging; NODELOG DEBUG OFF switches debug logging off.

  • PROMPT [prompt]

    将ndb_mgm显示的提示符更改为字符串字面值prompt。Changes the prompt shown by ndb_mgm to the string literal prompt.

    prompt 不应加引号(除非你希望提示符包含引号)。与 mysql 客户端不同,特殊字符序列和转义不会被识别。如果在没有参数的情况下调用该命令,提示符将重置为默认值(ndb_mgm>)。prompt should not be quoted (unless you want the prompt to include the quotation marks). Unlike the case with the mysql client, special character sequences and escapes are not recognized. If called without an argument, the command resets the prompt to the default value (ndb_mgm>).

    以下是一些示例:Some examples are shown here:

    ndb_mgm> PROMPT mgm#1:
    mgm#1: SHOW
    Cluster Configuration
    ...
    mgm#1: PROMPT mymgm >
    mymgm > PROMPT 'mymgm:'
    'mymgm:' PROMPT  mymgm:
    mymgm: PROMPT
    ndb_mgm> EXIT
    $>
    

    请注意,prompt 字符串的前导空格和中间空格不会被去掉。尾随空格将被删除。Note that leading spaces and spaces within the prompt string are not trimmed. Trailing spaces are removed.

  • QUIT, EXIT

    终止管理客户端。Terminates the management client.

    此命令不会影响连接到集群的任何节点。This command does not affect any nodes connected to the cluster.

  • node_id REPORT report-type

    显示由node_id标识的数据节点的report-type类型报告,或者使用ALL显示所有数据节点的报告。Displays a report of type report-type for the data node identified by node_id, or for all data nodes using ALL.

    目前,对于report-type,有三个可接受的值:Currently, there are three accepted values for report-type:

    • BackupStatus 提供正在进行的集群备份的状态报告BackupStatus provides a status report on a cluster backup in progress

    • MemoryUsage 显示每个数据节点使用了多少数据内存和索引内存,如下示例所示:MemoryUsage displays how much data memory and index memory is being used by each data node as shown in this example:

      ndb_mgm> ALL REPORT MEMORY
      
      Node 1: Data usage is 5%(177 32K pages of total 3200)
      Node 1: Index usage is 0%(108 8K pages of total 12832)
      Node 2: Data usage is 5%(177 32K pages of total 3200)
      Node 2: Index usage is 0%(108 8K pages of total 12832)
      

      这些信息也可以从 ndbinfo.memoryusage 表中获取。This information is also available from the ndbinfo.memoryusage table.

    • EventLog 报告来自一个或多个数据节点的事件日志缓冲区的事件。EventLog reports events from the event log buffers of one or more data nodes.

    report-type 不区分大小写,并且是“模糊”的;对于 MemoryUsage,你可以使用 MEMORY(如前例所示)、memory,甚至可以简单地使用 MEM(或 mem)。你也可以以类似的方式缩写 BackupStatus。report-type is case-insensitive and “fuzzy”; for MemoryUsage, you can use MEMORY (as shown in the prior example), memory, or even simply MEM (or mem). You can abbreviate BackupStatus in a similar fashion.

  • node_id RESTART [-n] [-i] [-a] [-f]

    重启由 node_id 指定的数据节点(或所有数据节点)。Restarts the data node identified by node_id (or all data nodes).

    使用 -i 选项配合 RESTART 会导致数据节点执行初始重启;也就是说,节点的文件系统会被删除并重新创建。其效果与先停止数据节点进程,然后使用系统 shell 通过 ndbd --initial 再次启动节点相同。Using the -i option with RESTART causes the data node to perform an initial restart; that is, the node's file system is deleted and recreated. The effect is the same as that obtained from stopping the data node process and then starting it again using ndbd --initial from the system shell.

    Note

    使用此选项时,备份文件和磁盘数据文件不会被删除。Backup files and Disk Data files are not removed when this option is used.

    使用 -n 选项会导致数据节点进程重新启动,但数据节点实际上不会上线,直到执行相应的 START 命令为止。此选项的效果与停止数据节点然后使用 ndbd --nostart 或 ndbd -n 从系统命令行再次启动获得的效果相同。Using the -n option causes the data node process to be restarted, but the data node is not actually brought online until the appropriate START command is issued. The effect of this option is the same as that obtained from stopping the data node and then starting it again using ndbd --nostart or ndbd -n from the system shell.

    使用 -a 会导致所有依赖此节点的当前事务被中止。当节点重新加入集群时,不会进行 GCP 检查。Using the -a causes all current transactions relying on this node to be aborted. No GCP check is done when the node rejoins the cluster.

    通常,如果将节点下线会导致集群不完整,RESTART 会失败。-f 选项会强制节点在不检查的情况下重新启动。如果使用此选项并且导致集群不完整,则整个集群会被重启。Normally, RESTART fails if taking the node offline would result in an incomplete cluster. The -f option forces the node to restart without checking for this. If this option is used and the result is an incomplete cluster, the entire cluster is restarted.

  • SHOW

    显示有关集群和集群节点的基本信息。对于所有节点,输出包括节点的 ID、类型以及 NDB 软件版本。如果节点已连接,还会显示其 IP 地址;否则输出会显示 not connected, accepting connect from ip_address,对于允许从任何地址连接的节点,则显示 any host。Displays basic information about the cluster and cluster nodes. For all nodes, the output includes the node's ID, type, and NDB software version. If the node is connected, its IP address is also shown; otherwise the output shows not connected, accepting connect from ip_address, with any host used for nodes that are permitted to connect from any address.

    此外,对于数据节点,如果节点尚未启动,输出中会包括 starting,并显示该节点所属的节点组。如果数据节点充当主节点,则会用星号 (*) 表示。In addition, for data nodes, the output includes starting if the node has not yet started, and shows the node group of which the node is a member. If the data node is acting as the master node, this is indicated with an asterisk (*).

    考虑一个其配置文件包括此处显示信息的集群(为了清晰省略了可能的其他设置):Consider a cluster whose configuration file includes the information shown here (possible additional settings are omitted for clarity):

    [ndbd default]
    DataMemory= 128G
    NoOfReplicas= 2
    
    [ndb_mgmd]
    NodeId=50
    HostName=198.51.100.150
    
    [ndbd]
    NodeId=5
    HostName=198.51.100.10
    DataDir=/var/lib/mysql-cluster
    
    [ndbd]
    NodeId=6
    HostName=198.51.100.20
    DataDir=/var/lib/mysql-cluster
    
    [ndbd]
    NodeId=7
    HostName=198.51.100.30
    DataDir=/var/lib/mysql-cluster
    
    [ndbd]
    NodeId=8
    HostName=198.51.100.40
    DataDir=/var/lib/mysql-cluster
    
    [mysqld]
    NodeId=100
    HostName=198.51.100.100
    
    [api]
    NodeId=101
    

    在启动此集群(包括一个 SQL 节点)后,SHOW 显示以下输出:After this cluster (including one SQL node) has been started, SHOW displays the following output:

    ndb_mgm> SHOW
    Connected to Management Server at: localhost:1186 (using cleartext)
    Cluster Configuration
    ---------------------
    [ndbd(NDB)]     4 node(s)
    id=5    @198.51.100.10  (mysql-8.4.7 ndb-8.4.7, Nodegroup: 0, *)
    id=6    @198.51.100.20  (mysql-8.4.7 ndb-8.4.7, Nodegroup: 0)
    id=7    @198.51.100.30  (mysql-8.4.7 ndb-8.4.7, Nodegroup: 1)
    id=8    @198.51.100.40  (mysql-8.4.7 ndb-8.4.7, Nodegroup: 1)
    
    [ndb_mgmd(MGM)] 1 node(s)
    id=50   @198.51.100.150  (mysql-8.4.7 ndb-8.4.7)
    
    [mysqld(API)]   2 node(s)
    id=100  @198.51.100.100  (mysql-8.4.7 ndb-8.4.7)
    id=101 (not connected, accepting connect from any host)
    

    此命令的输出还会指示集群处于单用户模式的时间(请参见 ENTER SINGLE USER MODE 命令的说明,以及 第 25.6.6 节,“NDB 集群单用户模式”)。它还会指示在此模式生效时哪个 API 或 SQL 节点拥有独占访问权限。The output from this command also indicates when the cluster is in single user mode (see the description of the ENTER SINGLE USER MODE command, as well as Section 25.6.6, “NDB Cluster Single User Mode”). It also indicates which API or SQL node has exclusive access when this mode is in effect.

  • SHUTDOWN

    关闭所有集群数据节点和管理节点。完成此操作后,要退出管理客户端,请使用 EXIT 或 QUIT。Shuts down all cluster data nodes and management nodes. To exit the management client after this has been done, use EXIT or QUIT.

    此命令 不会 关闭连接到集群的任何 SQL 节点或 API 节点。This command does not shut down any SQL nodes or API nodes that are connected to the cluster.

  • node_id START

    上线由 node_id 标识的数据节点(或所有数据节点)。Brings online the data node identified by node_id (or all data nodes).

    ALL START 仅对所有数据节点生效,不影响管理节点。ALL START works on all data nodes only, and does not affect management nodes.

    Important

    要使用此命令将数据节点上线,该数据节点必须使用 --nostart 或 -n 启动。To use this command to bring a data node online, the data node must have been started using --nostart or -n.

  • node_id STATUS

    显示由 node_id 标识的数据节点(或所有数据节点)的状态信息。Displays status information for the data node identified by node_id (or for all data nodes).

    可能的节点状态值包括 UNKNOWN、NO_CONTACT、NOT_STARTED、STARTING、STARTED、SHUTTING_DOWN 和 RESTARTING。Possible node status values include UNKNOWN, NO_CONTACT, NOT_STARTED, STARTING, STARTED, SHUTTING_DOWN, and RESTARTING.

    此命令的输出还指示集群何时处于单用户模式。The output from this command also indicates when the cluster is in single user mode.

  • node_id STOP [-a] [-f]

    停止由 node_id 标识的数据节点或管理节点。Stops the data or management node identified by node_id.

    Note

    ALL STOP 只能停止所有数据节点,不影响管理节点。ALL STOP works to stop all data nodes only, and does not affect management nodes.

    受此命令影响的节点将从集群断开,其关联的 ndbd 或 ndb_mgmd 进程会终止。A node affected by this command disconnects from the cluster, and its associated ndbd or ndb_mgmd process terminates.

    -a 选项会导致节点立即停止,而不等待任何未完成事务的完成。The -a option causes the node to be stopped immediately, without waiting for the completion of any pending transactions.

    通常,如果操作结果会导致集群不完整,STOP 会失败。-f 选项强制节点关闭,而不检查这一点。如果使用此选项且结果导致集群不完整,则集群会立即关闭。Normally, STOP fails if the result would cause an incomplete cluster. The -f option forces the node to shut down without checking for this. If this option is used and the result is an incomplete cluster, the cluster immediately shuts down.

    Warning

    使用 -a 选项还会禁用在调用 STOP 时通常执行的安全检查,以确保停止节点不会导致集群不完整。换句话说,由于该选项可能导致集群强制关闭,因为它不再拥有存储在 NDB 中的所有数据的完整副本,因此在使用 -a 选项与 STOP 命令时,应非常小心。Use of the -a option also disables the safety check otherwise performed when STOP is invoked to insure that stopping the node does not cause an incomplete cluster. In other words, you should exercise extreme care when using the -a option with the STOP command, due to the fact that this option makes it possible for the cluster to undergo a forced shutdown because it no longer has a complete copy of all data stored in NDB.

  • TLS INFO

    显示集群 TLS 信息,例如当前连接是否使用 TLS、管理节点当前已知的 TLS 证书,以及管理节点的总连接数、升级为 TLS 的连接数和授权失败次数。示例输出如下所示:Displays cluster TLS information such as whether the current connection is using TLS, TLS certificates currently known to the management node, and the management node's counts of total connections, connections upgraded to TLS, and authorization failures. Sample output is shown here:

    ndb_mgm> TLS INFO
    
    Session ID:          1
    Peer address:        127.0.0.1
    Certificate name:    NDB Management Node Jun 2023
    Certificate serial:  B5:23:8F:D1:11:85:E5:93:ED
    Certificate expires: 23-Nov-2023
    
    Server statistics since restart
    Total accepted connections:        6
    Total connections upgraded to TLS: 2
    Current connections:               3
    Current connections using TLS:     2
    Authorization failures:            0
    
    ndb_mgm>
    

    有关更多信息,请参见 第 25.6.19.5 节,“NDB 集群的 TLS 链接加密”。For more information, see Section 25.6.19.5, “TLS Link Encryption for NDB Cluster”.

其他命令。 在 ndb_mgm 客户端中还提供了许多其他命令,这些命令在其他地方有描述,如下所示:Additional commands.  A number of other commands available in the ndb_mgm client are described elsewhere, as shown in the following list: