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

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

MySQL 8.4 参考手册 / 25 MySQL NDB 集群 8.4 / 25.5 NDB 集群程序 / 25.5.7 ndb_config — 提取 NDB 集群配置信息
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 77%

25.5.7 ndb_config — 提取 NDB 集群配置信息25.5.7 ndb_config — Extract NDB Cluster Configuration Information

该工具从多个来源之一提取数据节点、SQL 节点和 API 节点的当前配置信息:NDB Cluster 管理节点,或其 config.ini 或 my.cnf 文件。默认情况下,管理节点是配置数据的来源;要覆盖默认设置,请使用 --config-file 或 --mycnf 选项执行 ndb_config。也可以通过使用数据节点作为来源,通过指定其节点 ID 并使用 --config_from_node=node_id 来实现。This tool extracts current configuration information for data nodes, SQL nodes, and API nodes from one of a number of sources: an NDB Cluster management node, or its config.ini or my.cnf file. By default, the management node is the source for the configuration data; to override the default, execute ndb_config with the --config-file or --mycnf option. It is also possible to use a data node as the source by specifying its node ID with --config_from_node=node_id.

ndb_config 还可以提供所有配置参数的离线转储,这些转储可与其默认值、最大值、最小值及其他信息一起使用。转储可以以文本或 XML 格式生成;有关更多信息,请参阅本节后面关于 --configinfo 和 --xml 选项的讨论。ndb_config can also provide an offline dump of all configuration parameters which can be used, along with their default, maximum, and minimum values and other information. The dump can be produced in either text or XML format; for more information, see the discussion of the --configinfo and --xml options later in this section).

您可以使用以下选项之一 --nodes、--system 或 --connections 按部分(DB、SYSTEM 或 CONNECTIONS)筛选结果。You can filter the results by section (DB, SYSTEM, or CONNECTIONS) using one of the options --nodes, --system, or --connections.

可以与 ndb_config 一起使用的所有选项显示在下表中。表格后面有附加说明。All options that can be used with ndb_config are shown in the following table. Additional descriptions follow the table.

  • --character-sets-dir

    命令行格式Command-Line Format --character-sets-dir=path--character-sets-dir=path

    包含字符集的目录。Directory containing character sets.

  • cluster-config-suffix

    命令行格式Command-Line Format --cluster-config-suffix=name
    类型Type 字符串String
    默认值Default Value [none][none]

    在读取 my.cnf 中的集群配置部分时覆盖默认的组后缀;用于测试。Override defaults group suffix when reading cluster configuration sections in my.cnf; used in testing.

  • --configinfo

    --configinfo 选项会使 ndb_config 输出 NDB Cluster 分发版所支持的每个 NDB Cluster 配置参数的列表,ndb_config 就是该分发版的一部分,包括以下信息:The --configinfo option causes ndb_config to dump a list of each NDB Cluster configuration parameter supported by the NDB Cluster distribution of which ndb_config is a part, including the following information:

    • 每个参数用途、效果和使用方法的简要说明A brief description of each parameter's purpose, effects, and usage

    • 参数可使用的 config.ini 文件部分The section of the config.ini file where the parameter may be used

    • 参数的数据类型或计量单位The parameter's data type or unit of measurement

    • 如果适用,参数的默认值、最小值和最大值Where applicable, the parameter's default, minimum, and maximum values

    • NDB 集群版本和构建信息NDB Cluster release version and build information

    默认情况下,此输出为文本格式。此处显示了部分输出:By default, this output is in text format. Part of this output is shown here:

    $> ndb_config --configinfo
    
    ****** SYSTEM ******
    
    Name (String)
    Name of system (NDB Cluster)
    MANDATORY
    
    PrimaryMGMNode (Non-negative Integer)
    Node id of Primary ndb_mgmd(MGM) node
    Default: 0 (Min: 0, Max: 4294967039)
    
    ConfigGenerationNumber (Non-negative Integer)
    Configuration generation number
    Default: 0 (Min: 0, Max: 4294967039)
    
    ****** DB ******
    
    MaxNoOfSubscriptions (Non-negative Integer)
    Max no of subscriptions (default 0 == MaxNoOfTables)
    Default: 0 (Min: 0, Max: 4294967039)
    
    MaxNoOfSubscribers (Non-negative Integer)
    Max no of subscribers (default 0 == 2 * MaxNoOfTables)
    Default: 0 (Min: 0, Max: 4294967039)
    
    …
    

    将此选项与 --xml 选项一起使用,以获取 XML 格式的输出。Use this option together with the --xml option to obtain output in XML format.

  • --config-binary-file=path-to-file --config-binary-file=path-to-file

    命令行格式Command-Line Format --config-binary-file=path/to/file--config-binary-file=path/to/file
    类型Type 文件名File name
    默认值Default Value

    提供到管理服务器缓存的二进制配置文件的路径(ndb_nodeID_config.bin.seqno)。这可以是相对路径或绝对路径。如果管理服务器和使用的 ndb_config 二进制文件位于不同主机上,则必须使用绝对路径。Gives the path to the management server's cached binary configuration file (ndb_nodeID_config.bin.seqno). This may be a relative or absolute path. If the management server and the ndb_config binary used reside on different hosts, you must use an absolute path.

    此示例演示了如何将 --config-binary-file 与其他 ndb_config 选项结合使用以获取有用的输出:This example demonstrates combining --config-binary-file with other ndb_config options to obtain useful output:

    $> ndb_config --config-binary-file=../mysql-cluster/ndb_50_config.bin.1 --diff-default --type=ndbd
    config of [DB] node id 5 that is different from default 
    CONFIG_PARAMETER,ACTUAL_VALUE,DEFAULT_VALUE 
    NodeId,5,(mandatory) 
    BackupDataDir,/local/data/8.4,(null) 
    DataDir,/local/data/8.4,. 
    DataMemory,2G,98M 
    FileSystemPath,/local/data/8.4,(null) 
    HostName,127.0.0.1,localhost 
    Nodegroup,0,(null) 
    ThreadConfig,,(null) 
    
    config of [DB] node id 6 that is different from default 
    CONFIG_PARAMETER,ACTUAL_VALUE,DEFAULT_VALUE 
    NodeId,6,(mandatory) 
    BackupDataDir,/local/data/8.4,(null) 
    DataDir,/local/data/8.4. 
    DataMemory,2G,98M 
    FileSystemPath,/local/data/8.4,(null) 
    HostName,127.0.0.1,localhost 
    Nodegroup,0,(null) 
    ThreadConfig,,(null)
    
    $> ndb_config --config-binary-file=../mysql-cluster/ndb_50_config.bin.1 --diff-default --system
    config of [SYSTEM] system 
    CONFIG_PARAMETER,ACTUAL_VALUE,DEFAULT_VALUE 
    Name,MC_20220906060042,(mandatory) 
    ConfigGenerationNumber,1,0 
    PrimaryMGMNode,50,0
    

    以下显示了 config.ini 文件的相关部分:The relevant portions of the config.ini file are shown here:

    [ndbd default]
    DataMemory= 2G
    NoOfReplicas= 2
    
    [ndb_mgmd]
    NodeId= 50
    HostName= 127.0.0.1
    
    [ndbd]
    NodeId= 5
    HostName= 127.0.0.1
    DataDir= /local/data/8.4
    
    [ndbd]
    NodeId= 6
    HostName= 127.0.0.1
    DataDir= /local/data/8.4
    

    通过将输出与配置文件进行比较,可以看到文件中的所有设置都已由管理服务器写入二进制缓存,从而应用到集群中。By comparing the output with the configuration file, you can see that all of the settings in the file have been written by the management server to the binary cache, and thus, applied to the cluster.

  • --config-file=path-to-file --config-file=path-to-file

    命令行格式Command-Line Format --config-file=file_name
    类型Type 文件名File name
    默认值Default Value

    提供集群配置文件的路径(config.ini)。这可以是相对路径或绝对路径。如果管理服务器和使用的 ndb_config 二进制文件位于不同主机上,则必须使用绝对路径。Gives the path to the cluster configuration file (config.ini). This may be a relative or absolute path. If the management server and the ndb_config binary used reside on different hosts, you must use an absolute path.

  • --config_from_node=#

    命令行格式Command-Line Format --config-from-node=#
    类型Type 数字Numeric
    默认值Default Value nonenone
    最小值Minimum Value 1
    最大值Maximum Value 48

    从具有该 ID 的数据节点获取集群的配置信息。Obtain the cluster's configuration data from the data node that has this ID.

    如果具有此 ID 的节点不是数据节点,ndb_config 将报错。(如果想从管理节点获取配置数据,只需省略此选项。)If the node having this ID is not a data node, ndb_config fails with an error. (To obtain configuration data from the management node instead, simply omit this option.)

  • --connect-retries

    命令行格式Command-Line Format --connect-retries=#
    类型Type 整数Integer
    默认值Default Value 12
    最小值Minimum Value 0
    最大值Maximum Value 12

    放弃之前重试连接的次数。Number of times to retry connection before giving up.

  • --connect-retry-delay

    命令行格式Command-Line Format --connect-retry-delay=#
    类型Type 整数Integer
    默认值Default Value 5
    最小值Minimum Value 0
    最大值Maximum Value 5

    尝试联系管理服务器之间等待的秒数。Number of seconds to wait between attempts to contact management server.

  • --connect-string

    命令行格式Command-Line Format --connect-string=connection_string
    类型Type 字符串String
    默认值Default Value [none][none]

    与 --ndb-connectstring 相同。Same as --ndb-connectstring.

  • --connections

    命令行格式Command-Line Format --connections

    告诉 ndb_config 仅打印 CONNECTIONS 信息——也就是关于在集群配置文件的 [tcp]、[tcp default]、[shm] 或 [shm default] 部分中找到的参数的信息(更多信息请参见 第 25.4.3.10 节,“NDB 集群 TCP/IP 连接” 和 第 25.4.3.12 节,“NDB 集群共享内存连接”)。Tells ndb_config to print CONNECTIONS information only—that is, information about parameters found in the [tcp], [tcp default], [shm], or [shm default] sections of the cluster configuration file (see Section 25.4.3.10, “NDB Cluster TCP/IP Connections”, and Section 25.4.3.12, “NDB Cluster Shared-Memory Connections”, for more information).

    此选项与 --nodes 和 --system 互斥;这三者中只能使用其中一个选项。This option is mutually exclusive with --nodes and --system; only one of these 3 options can be used.

  • --core-file

    命令行格式Command-Line Format --core-file

    错误时生成核心文件;用于调试。Write core file on error; used in debugging.

  • --defaults-extra-file

    命令行格式Command-Line Format --defaults-extra-file=path--defaults-extra-file=path
    类型Type 字符串String
    默认值Default Value [none][none]

    在读取全局文件之后读取给定文件。Read given file after global files are read.

  • --defaults-file

    命令行格式Command-Line Format --defaults-file=path
    类型Type 字符串String
    默认值Default Value [none][none]

    仅从指定文件读取默认选项。Read default options from given file only.

  • --defaults-group-suffix

    命令行格式Command-Line Format --defaults-group-suffix=string
    类型Type 字符串String
    默认值Default Value [none][none]

    也读取组合了 concat(group, suffix) 的组。Also read groups with concat(group, suffix).

  • --diff-default

    命令行格式Command-Line Format --diff-default

    仅打印具有非默认值的配置参数。Print only configuration parameters that have non-default values.

  • --fields=delimiter, -f delimiter

    命令行格式Command-Line Format --fields=string
    类型Type 字符串String
    默认值Default Value

    指定用于分隔结果中字段的delimiter字符串。默认值是,(逗号字符)。Specifies a delimiter string used to separate the fields in the result. The default is , (the comma character).

    Note

    如果delimiter包含空格或转义字符(例如用于换行符的\n),则必须加引号。If the delimiter contains spaces or escapes (such as \n for the linefeed character), then it must be quoted.

  • --help

    命令行格式Command-Line Format --help--help

    显示帮助文本并退出。Display help text and exit.

  • --host=hostname --host=hostname

    命令行格式Command-Line Format --host=name
    类型Type 字符串String
    默认值Default Value

    指定要获取配置信息的节点的主机名。Specifies the host name of the node for which configuration information is to be obtained.

    Note

    虽然主机名localhost通常会解析为 IP 地址127.0.0.1,但对于所有操作平台和配置而言,这不一定成立。这意味着,当localhost在config.ini中使用时,ndb_config --host=localhost可能会失败,如果ndb_config在不同主机上运行localhost resolves to a different address (for example, on some versions of SUSE Linux, this is 127.0.0.2). In general, for best results, you should use numeric IP addresses for all NDB Cluster configuration values relating to hosts, or verify that all NDB Cluster hosts handle localhost in the same fashion.While the hostname localhost usually resolves to the IP address 127.0.0.1, this may not necessarily be true for all operating platforms and configurations. This means that it is possible, when localhost is used in config.ini, for ndb_config --host=localhost to fail if ndb_config is run on a different host where localhost resolves to a different address (for example, on some versions of SUSE Linux, this is 127.0.0.2). In general, for best results, you should use numeric IP addresses for all NDB Cluster configuration values relating to hosts, or verify that all NDB Cluster hosts handle localhost in the same fashion.

  • --login-path

    命令行格式Command-Line Format --login-path=path
    类型Type 字符串String
    默认值Default Value [none][none]

    从登录文件读取给定路径。Read given path from login file.

  • --mycnf

    命令行格式Command-Line Format --mycnf

    从 my.cnf 文件读取配置数据。Read configuration data from the my.cnf file.

  • --ndb-connectstring=connection_string, -c connection_string

    命令行格式Command-Line Format --ndb-connectstring=connection_string
    类型Type 字符串String
    默认值Default Value [none][none]

    指定用于连接管理服务器的连接字符串。连接字符串的格式与第 25.4.3.3 节,“NDB 集群连接字符串”中描述的格式相同,默认值为localhost:1186。Specifies the connection string to use in connecting to the management server. The format for the connection string is the same as described in Section 25.4.3.3, “NDB Cluster Connection Strings”, and defaults to localhost:1186.

  • --ndb-mgm-tls

    命令行格式Command-Line Format --ndb-mgm-tls=level
    类型Type 枚举Enumeration
    默认值Default Value relaxedrelaxed
    有效值Valid Values

    relaxedrelaxed

    strictstrict

    设置连接到管理服务器所需的 TLS 支持级别;可以是 relaxed 或 strict。relaxed(默认)表示尝试建立 TLS 连接,但不要求成功;strict表示连接必须使用 TLS。Sets the level of TLS support required to connect to the management server; one of relaxed or strict. relaxed (the default) means that a TLS connection is attempted, but success is not required; strict means that TLS is required to connect.

  • --ndb-mgmd-host

    命令行格式Command-Line Format --ndb-mgmd-host=connection_string
    类型Type 字符串String
    默认值Default Value [none][none]

    与 --ndb-connectstring 相同。Same as --ndb-connectstring.

  • --ndb-nodeid

    命令行格式Command-Line Format --ndb-nodeid=#
    类型Type 整数Integer
    默认值Default Value [none][none]

    为此节点设置节点 ID,覆盖由 --ndb-connectstring 设置的任何 ID。Set node ID for this node, overriding any ID set by --ndb-connectstring.

  • --ndb-optimized-node-selection

    命令行格式Command-Line Format --ndb-optimized-node-selection

    启用事务节点选择的优化。默认启用;使用 --skip-ndb-optimized-node-selection 来禁用。Enable optimizations for selection of nodes for transactions. Enabled by default; use --skip-ndb-optimized-node-selection to disable.

  • --ndb-tls-search-path

    命令行格式Command-Line Format --ndb-tls-search-path=list
    类型Type 路径名Path name
    默认值(Unix)Default Value (Unix) $HOME/ndb-tls$HOME/ndb-tls
    默认值(Windows)Default Value (Windows) $HOMEDIR/ndb-tls

    指定用于搜索 CA 文件的目录列表。在 Unix 平台上,目录名称用冒号 (:) 分隔;在 Windows 系统上,使用分号 (;) 作为分隔符。目录引用可以是相对路径或绝对路径;它可以包含一个或多个环境变量,每个变量以美元符号 ($) 开头,并在使用前进行展开。Specify a list of directories to search for a CA file. On Unix platforms, the directory names are separated by colons (:); on Windows systems, the semicolon character (;) is used as the separator. A directory reference may be relative or absolute; it may contain one or more environment variables, each denoted by a prefixed dollar sign ($), and expanded prior to use.

    搜索从最左边的命名目录开始,按从左到右的顺序进行,直到找到文件。空字符串表示空搜索路径,这会导致所有搜索失败。由单个点 (.) 组成的字符串表示搜索路径仅限于当前工作目录。Searching begins with the leftmost named directory and proceeds from left to right until a file is found. An empty string denotes an empty search path, which causes all searches to fail. A string consisting of a single dot (.) indicates that the search path limited to the current working directory.

    如果未提供搜索路径,则使用编译时的默认值。此值取决于所使用的平台:在 Windows 上,它是 \ndb-tls;在其他平台(包括 Linux)上,它是 $HOME/ndb-tls。可以通过使用 -DWITH_NDB_TLS_SEARCH_PATH 编译 NDB Cluster 来覆盖该值。If no search path is supplied, the compiled-in default value is used. This value depends on the platform used: On Windows, this is \ndb-tls; on other platforms (including Linux), it is $HOME/ndb-tls. This can be overridden by compiling NDB Cluster using -DWITH_NDB_TLS_SEARCH_PATH.

  • --no-defaults

    命令行格式Command-Line Format --no-defaults--no-defaults

    除了登录文件之外,不从任何配置文件读取默认选项。Do not read default options from any option file other than login file.

  • --no-login-paths

    命令行格式Command-Line Format --no-login-paths

    跳过从登录路径文件读取选项。Skips reading options from the login path file.

  • --nodeid=node_id

    命令行格式Command-Line Format --ndb-nodeid=#
    类型Type 整数Integer
    默认值Default Value [none][none]

    指定要获取配置信息的节点的节点 ID。Specify the node ID of the node for which configuration information is to be obtained.

  • --nodes

    命令行格式Command-Line Format --nodes

    告诉 ndb_config 打印仅与集群配置文件中的 [ndbd] 或 [ndbd default] 部分定义的参数相关的信息(参见 第 25.4.3.6 节,“定义 NDB 集群数据节点”)。Tells ndb_config to print information relating only to parameters defined in an [ndbd] or [ndbd default] section of the cluster configuration file (see Section 25.4.3.6, “Defining NDB Cluster Data Nodes”).

    该选项与 --connections 和 --system 互斥;这三个选项中只能使用其中一个。This option is mutually exclusive with --connections and --system; only one of these 3 options can be used.

  • --print-defaults

    命令行格式Command-Line Format --print-defaults

    打印程序参数列表然后退出。Print program argument list and exit.

  • --query=query-options, -q query-options --query=query-options, -q query-options

    命令行格式Command-Line Format --query=string--query=string
    类型Type 字符串String
    默认值Default Value

    这是一个以逗号分隔的查询选项列表——也就是要返回的一个或多个节点属性的列表。这些包括nodeid(节点 ID)、type(节点类型——即ndbd、mysqld或ndb_mgmd)以及任何需要获取其值的配置参数。This is a comma-delimited list of query options—that is, a list of one or more node attributes to be returned. These include nodeid (node ID), type (node type—that is, ndbd, mysqld, or ndb_mgmd), and any configuration parameters whose values are to be obtained.

    例如,--query=nodeid,type,datamemory,datadir为每个节点返回节点 ID、节点类型、DataMemory和DataDir。For example, --query=nodeid,type,datamemory,datadir returns the node ID, node type, DataMemory, and DataDir for each node.

    Note

    如果给定参数不适用于某种类型的节点,则对应的值将返回空字符串。有关详细信息,请参见本节后面的示例。If a given parameter is not applicable to a certain type of node, than an empty string is returned for the corresponding value. See the examples later in this section for more information.

  • --query-all, -a

    命令行格式Command-Line Format --query-all
    类型Type 字符串String
    默认值Default Value

    返回所有查询选项(节点属性)的逗号分隔列表;注意,该列表是单个字符串。Returns a comma-delimited list of all query options (node attributes; note that this list is a single string.

  • --rows=separator, -r separator

    命令行格式Command-Line Format --rows=string
    类型Type 字符串String
    默认值Default Value

    指定用于分隔结果行的separator字符串。默认是空格字符。Specifies a separator string used to separate the rows in the result. The default is a space character.

    Note

    如果separator包含空格或转义字符(例如用于换行的\n),则必须加引号。If the separator contains spaces or escapes (such as \n for the linefeed character), then it must be quoted.

  • --system

    命令行格式Command-Line Format --system

    告诉ndb_config只打印SYSTEM信息。这包括运行时无法更改的系统变量,因此在集群配置文件中没有对应的部分。它们可以在ndb_config --configinfo的输出中看到(前缀为****** SYSTEM ******)。Tells ndb_config to print SYSTEM information only. This consists of system variables that cannot be changed at run time; thus, there is no corresponding section of the cluster configuration file for them. They can be seen (prefixed with ****** SYSTEM ******) in the output of ndb_config --configinfo.

    此选项与 --nodes 和 --connections 互斥;这三个选项中只能使用一个。This option is mutually exclusive with --nodes and --connections; only one of these 3 options can be used.

  • --type=node_type

    命令行格式Command-Line Format --type=name
    类型Type 枚举Enumeration
    默认值Default Value [none][none]
    有效值Valid Values

    ndbd

    mysqldmysqld

    ndb_mgmd

    筛选结果,仅返回适用于指定 node_type (ndbd、mysqld 或 ndb_mgmd)节点的配置值。Filters results so that only configuration values applying to nodes of the specified node_type (ndbd, mysqld, or ndb_mgmd) are returned.

  • --usage,--help,或 -? --usage, --help, or -?

    命令行格式Command-Line Format --help--help

    使 ndb_config 打印可用选项列表,然后退出。Causes ndb_config to print a list of available options, and then exit.

  • --version, -V

    命令行格式Command-Line Format --version

    导致 ndb_config 打印版本信息字符串,然后退出。Causes ndb_config to print a version information string, and then exit.

  • --configinfo --xml

    命令行格式Command-Line Format --configinfo --xml

    通过添加此选项,可以使 ndb_config --configinfo 以 XML 格式输出。此示例显示了部分输出:Cause ndb_config --configinfo to provide output as XML by adding this option. A portion of such output is shown in this example:

    $> ndb_config --configinfo --xml
    
    <configvariables protocolversion="1" ndbversionstring="5.7.44-ndb-7.5.36"
                        ndbversion="460032" ndbversionmajor="7" ndbversionminor="5"
                        ndbversionbuild="0">
      <section name="SYSTEM">
        <param name="Name" comment="Name of system (NDB Cluster)" type="string"
                  mandatory="true"/>
        <param name="PrimaryMGMNode" comment="Node id of Primary ndb_mgmd(MGM) node"
                  type="unsigned" default="0" min="0" max="4294967039"/>
        <param name="ConfigGenerationNumber" comment="Configuration generation number"
                  type="unsigned" default="0" min="0" max="4294967039"/>
      </section>
      <section name="MYSQLD" primarykeys="NodeId">
        <param name="wan" comment="Use WAN TCP setting as default" type="bool"
                  default="false"/>
        <param name="HostName" comment="Name of computer for this node"
                  type="string" default=""/>
        <param name="Id" comment="NodeId" type="unsigned" mandatory="true"
                  min="1" max="255" deprecated="true"/>
        <param name="NodeId" comment="Number identifying application node (mysqld(API))"
                  type="unsigned" mandatory="true" min="1" max="255"/>
        <param name="ExecuteOnComputer" comment="HostName" type="string"
                  deprecated="true"/>
    
        …
    
      </section>
    
      …
    
    </configvariables>
    
    Note

    通常,由 ndb_config --configinfo --xml 生成的 XML 输出是每个元素一行的格式;在前面的示例以及下一个示例中,我们为了可读性添加了额外的空白。这对使用该输出的应用程序不应有影响,因为大多数 XML 处理器通常会忽略非必要的空白,或者可以被指示忽略这些空白。Normally, the XML output produced by ndb_config --configinfo --xml is formatted using one line per element; we have added extra whitespace in the previous example, as well as the next one, for reasons of legibility. This should not make any difference to applications using this output, since most XML processors either ignore nonessential whitespace as a matter of course, or can be instructed to do so.

    XML 输出还会指示在更改给定参数时是否需要使用 --initial 选项重新启动数据节点。如在相应的 <param> 元素中存在 initial="true" 属性所示。此外,还会显示重启类型(system 或 node);如果某个参数需要系统重启,则在相应的 <param> 元素中会显示 restart="system" 属性。例如,更改 Diskless 参数的值需要系统初始重启,如下所示(突出显示了 restart 和 initial 属性以便查看):The XML output also indicates when changing a given parameter requires that data nodes be restarted using the --initial option. This is shown by the presence of an initial="true" attribute in the corresponding <param> element. In addition, the restart type (system or node) is also shown; if a given parameter requires a system restart, this is indicated by the presence of a restart="system" attribute in the corresponding <param> element. For example, changing the value set for the Diskless parameter requires a system initial restart, as shown here (with the restart and initial attributes highlighted for visibility):

    <param name="Diskless" comment="Run wo/ disk" type="bool" default="false"
              restart="system" initial="true"/>
    

    Currently, no initial attribute is included in the XML output for <param> elements corresponding to parameters which do not require initial restarts; in other words, initial="false" is the default, and the value false should be assumed if the attribute is not present. Similarly, the default restart type is node (that is, an online or “rolling” restart of the cluster), but the restart attribute is included only if the restart type is system (meaning that all cluster nodes must be shut down at the same time, then restarted).

    弃用参数在 XML 输出中通过 deprecated 属性表示,如下所示:Deprecated parameters are indicated in the XML output by the deprecated attribute, as shown here:

    <param name="NoOfDiskPagesToDiskAfterRestartACC" comment="DiskCheckpointSpeed"
           type="unsigned" default="20" min="1" max="4294967039" deprecated="true"/>
    

    在这种情况下,comment 指的是一个或多个取代已弃用参数的参数。与 initial 类似,deprecated 属性仅在参数被弃用时显示,即 deprecated="true",对于未弃用的参数则根本不会出现该属性。(Bug #21127135)In such cases, the comment refers to one or more parameters that supersede the deprecated parameter. Similarly to initial, the deprecated attribute is indicated only when the parameter is deprecated, with deprecated="true", and does not appear at all for parameters which are not deprecated. (Bug #21127135)

    必须的参数用 mandatory="true" 表示,如下所示:Parameters that are required are indicated with mandatory="true", as shown here:

    <param name="NodeId"
              comment="Number identifying application node (mysqld(API))"
              type="unsigned" mandatory="true" min="1" max="255"/>
    

    就像 initial 或 deprecated 属性仅显示在需要初始重启或已弃用的参数上一样,mandatory 属性仅在给定参数确实是必需时才包含。In much the same way that the initial or deprecated attribute is displayed only for a parameter that requires an initial restart or that is deprecated, the mandatory attribute is included only if the given parameter is actually required.

    Important

    --xml 选项只能与 --configinfo 选项一起使用。在没有 --configinfo 的情况下使用 --xml 会导致错误。The --xml option can be used only with the --configinfo option. Using --xml without --configinfo fails with an error.

    与用于获取当前配置数据的该程序的其他选项不同,--configinfo 和 --xml 使用在编译 ndb_config 时从 NDB Cluster 来源获取的信息。因此,这两个选项不需要连接到正在运行的 NDB Cluster,也不需要访问 config.ini 或 my.cnf 文件。Unlike the options used with this program to obtain current configuration data, --configinfo and --xml use information obtained from the NDB Cluster sources when ndb_config was compiled. For this reason, no connection to a running NDB Cluster or access to a config.ini or my.cnf file is required for these two options.

将其他 ndb_config 选项(例如 --query 或 --type)与 --configinfo(无论是否使用 --xml 选项)结合使用是不支持的。目前,如果尝试这样做,通常的结果是除了 --configinfo 或 --xml 之外的所有其他选项都会被简单忽略。然而,此行为不保证,并可能随时更改。此外,由于 ndb_config 在与 --configinfo 选项一起使用时,不会访问 NDB 集群或读取任何文件,因此尝试在 --configinfo 中指定诸如 --ndb-connectstring 或 --config-file 等附加选项是没有意义的。Combining other ndb_config options (such as --query or --type) with --configinfo (with or without the --xml option is not supported. Currently, if you attempt to do so, the usual result is that all other options besides --configinfo or --xml are simply ignored. However, this behavior is not guaranteed and is subject to change at any time. In addition, since ndb_config, when used with the --configinfo option, does not access the NDB Cluster or read any files, trying to specify additional options such as --ndb-connectstring or --config-file with --configinfo serves no purpose.

示例Examples

  1. 获取集群中每个节点的节点 ID 和类型:To obtain the node ID and type of each node in the cluster:

    $> ./ndb_config --query=nodeid,type --fields=':' --rows='\n'
    1:ndbd
    2:ndbd
    3:ndbd
    4:ndbd
    5:ndb_mgmd
    6:mysqld
    7:mysqld
    8:mysqld
    9:mysqld
    

    在此示例中,我们使用 --fields 选项,用冒号字符 (:) 分隔每个节点的 ID 和类型,并使用 --rows 选项,将每个节点的值放在输出的新行上。In this example, we used the --fields options to separate the ID and type of each node with a colon character (:), and the --rows options to place the values for each node on a new line in the output.

  2. 生成可供数据节点、SQL 节点和 API 节点连接管理服务器使用的连接字符串:To produce a connection string that can be used by data, SQL, and API nodes to connect to the management server:

    $> ./ndb_config --config-file=usr/local/mysql/cluster-data/config.ini \
    --query=hostname,portnumber --fields=: --rows=, --type=ndb_mgmd
    198.51.100.179:1186
    
  3. 此调用 ndb_config 仅检查数据节点(使用 --type 选项),并显示每个节点的 ID 和主机名的值,以及其 DataMemory 和 DataDir 参数设置的值:This invocation of ndb_config checks only data nodes (using the --type option), and shows the values for each node's ID and host name, as well as the values set for its DataMemory and DataDir parameters:

    $> ./ndb_config --type=ndbd --query=nodeid,host,datamemory,datadir -f ' : ' -r '\n'
    1 : 198.51.100.193 : 83886080 : /usr/local/mysql/cluster-data
    2 : 198.51.100.112 : 83886080 : /usr/local/mysql/cluster-data
    3 : 198.51.100.176 : 83886080 : /usr/local/mysql/cluster-data
    4 : 198.51.100.119 : 83886080 : /usr/local/mysql/cluster-data
    

    在此示例中,我们使用了短选项 -f 和 -r 分别设置字段分隔符和行分隔符,以及短选项 -q 来传递要获取的参数列表。In this example, we used the short options -f and -r for setting the field delimiter and row separator, respectively, as well as the short option -q to pass a list of parameters to be obtained.

  4. 要排除除特定主机之外的所有主机的结果,请使用 --host 选项:To exclude results from any host except one in particular, use the --host option:

    $> ./ndb_config --host=198.51.100.176 -f : -r '\n' -q id,type
    3:ndbd
    5:ndb_mgmd
    

    在此示例中,我们还使用了短形式 -q 来确定要查询的属性。In this example, we also used the short form -q to determine the attributes to be queried.

    同样,您可以使用 --nodeid 选项将结果限制为具有特定 ID 的节点。Similarly, you can limit results to a node with a specific ID using the --nodeid option.