Cari di MySQL 
    MySQL Manual
Daftar Isi
(Sebelumnya) 17.3.3. Overview of MySQL Clus ...17.5. Management of MySQL Cluster (Berikutnya)

17.4. MySQL Cluster Programs

Using and managing a MySQL Cluster requires several specialized programs, which we describe in this chapter. We discuss the purposes of these programs in a MySQL Cluster, how to use the programs, and what startup options are available for each of them.

These programs include the MySQL Cluster data, management, and SQL node processes (ndbd, ndbmtd, ndb_mgmd, and mysqld) and the management client (ndb_mgm).

For information about using mysqld as a MySQL Cluster process, see Section 17.5.4, "MySQL Server Usage for MySQL Cluster".

Other NDB utility, diagnostic, and example programs are included with the MySQL Cluster distribution. These include ndb_restore, ndb_show_tables, and ndb_config. These programs are also covered in this section.

The final portion of this section contains tables of options that are common to all the various MySQL Cluster programs.

17.4.1. ndbd - The MySQL Cluster Data Node Daemon

ndbd is the process that is used to handle all the data in tables using the NDB Cluster storage engine. This is the process that empowers a data node to accomplish distributed transaction handling, node recovery, checkpointing to disk, online backup, and related tasks.

In a MySQL Cluster, a set of ndbd processes cooperate in handling data. These processes can execute on the same computer (host) or on different computers. The correspondences between data nodes and Cluster hosts is completely configurable.

The following table includes command options specific to the MySQL Cluster data node program ndbd. Additional descriptions follow the table. For options common to most MySQL Cluster programs (including ndbd), see Section 17.4.24, "Options Common to MySQL Cluster Programs - Options Common to MySQL Cluster Programs".

Table 17.10. ndbd Options and Variables: MySQL 5.5

FormatDescriptionAdded / Removed

--initial

Perform initial start of ndbd, including cleaning the file system. Consult the documentation before using this option

All MySQL 5.5 based releases

--nostart,

-n

Don't start ndbd immediately; ndbd waits for command to start from ndb_mgmd

All MySQL 5.5 based releases

--daemon,

-d

Start ndbd as daemon (default); override with --nodaemon

All MySQL 5.5 based releases

--nodaemon

Do not start ndbd as daemon; provided for testing purposes

All MySQL 5.5 based releases

--foreground

Run ndbd in foreground, provided for debugging purposes (implies --nodaemon)

All MySQL 5.5 based releases

--nowait-nodes=list

Do not wait for these data nodes to start (takes comma-separated list of node IDs). Also requires --ndb-nodeid to be used.

All MySQL 5.5 based releases

--initial-start

Perform partial initial start (requires --nowait-nodes)

All MySQL 5.5 based releases

--bind-address=name

Local bind address

All MySQL 5.5 based releases

--install[=name]

Used to install the data node process as a Windows service. Does not apply on non-Windows platforms.

All MySQL 5.5 based releases

--remove[=name]

Used to remove a data node process that was previously installed as a Windows service. Does not apply on non-Windows platforms.

All MySQL 5.5 based releases

--connect-retries=#

Number of times to try contacting the management server; set to -1 to keep trying indefinitely

ADDED: NDB 7.2.9

--connect-delay=#

Time to wait between attempts to contact a management server, in seconds

ADDED: NDB 7.2.9


Note

All of these options also apply to the multi-threaded version of this program (ndbmtd) and you may substitute "ndbmtd" for "ndbd" wherever the latter occurs in this section.

  • --bind-address

    Command-Line Format--bind-address=name
     Permitted Values
    Typestring
    Default

    Causes ndbd to bind to a specific network interface (host name or IP address). This option has no default value.

  • --daemon, -d

    Command-Line Format--daemon
    -d
     Permitted Values
    Typeboolean
    DefaultTRUE

    Instructs ndbd or ndbmtd to execute as a daemon process. This is the default behavior. --nodaemon can be used to prevent the process from running as a daemon.

    This option has no effect when running ndbd or ndbmtd on Windows platforms.

  • --nodaemon

    Command-Line Format--nodaemon
     Permitted Values
    Typeboolean
    DefaultFALSE

    Prevents ndbd or ndbmtd from executing as a daemon process. This option overrides the --daemon option. This is useful for redirecting output to the screen when debugging the binary.

    The default behavior for ndbd and ndbmtd on Windows is to run in the foreground, making this option unnecessary on Windows platforms, where it has no effect.

  • --foreground

    Command-Line Format--foreground
     Permitted Values
    Typeboolean
    DefaultFALSE

    Causes ndbd or ndbmtd to execute as a foreground process, primarily for debugging purposes. This option implies the --nodaemon option.

    This option has no effect when running ndbd or ndbmtd on Windows platforms.

  • --initial

    Command-Line Format--initial
     Permitted Values
    Typeboolean
    DefaultFALSE

    Instructs ndbd to perform an initial start. An initial start erases any files created for recovery purposes by earlier instances of ndbd. It also re-creates recovery log files. Note that on some operating systems this process can take a substantial amount of time.

    An --initial start is to be used only when starting the ndbd process under very special circumstances; this is because this option causes all files to be removed from the MySQL Cluster file system and all redo log files to be re-created. These circumstances are listed here:

    • When performing a software upgrade which has changed the contents of any files.

    • When restarting the node with a new version of ndbd.

    • As a measure of last resort when for some reason the node restart or system restart repeatedly fails. In this case, be aware that this node can no longer be used to restore data due to the destruction of the data files.

    Use of this option prevents the StartPartialTimeout and StartPartitionedTimeout configuration parameters from having any effect.

    Important

    This option does not affect either of the following types of files:

    This option also has no effect on recovery of data by a data node that is just starting (or restarting) from data nodes that are already running. This recovery of data occurs automatically, and requires no user intervention in a MySQL Cluster that is running normally.

    It is permissible to use this option when starting the cluster for the very first time (that is, before any data node files have been created); however, it is not necessary to do so.

  • --initial-start

    Command-Line Format--initial-start
     Permitted Values
    Typeboolean
    DefaultFALSE

    This option is used when performing a partial initial start of the cluster. Each node should be started with this option, as well as --nowait-nodes.

    Suppose that you have a 4-node cluster whose data nodes have the IDs 2, 3, 4, and 5, and you wish to perform a partial initial start using only nodes 2, 4, and 5-that is, omitting node 3:

    shell> ndbd --ndb-nodeid=2 --nowait-nodes=3 --initial-startshell> ndbd --ndb-nodeid=4 --nowait-nodes=3 --initial-startshell> ndbd --ndb-nodeid=5 --nowait-nodes=3 --initial-start

    When using this option, you must also specify the node ID for the data node being started with the --ndb-nodeid option.

    Important

    Do not confuse this option with the --nowait-nodes option for ndb_mgmd, which can be used to enable a cluster configured with multiple management servers to be started without all management servers being online.

  • --nowait-nodes=node_id_1[, node_id_2[, ...]]

    Command-Line Format--nowait-nodes=list
     Permitted Values
    Typestring
    Default

    This option takes a list of data nodes which for which the cluster will not wait for before starting.

    This can be used to start the cluster in a partitioned state. For example, to start the cluster with only half of the data nodes (nodes 2, 3, 4, and 5) running in a 4-node cluster, you can start each ndbd process with --nowait-nodes=3,5. In this case, the cluster starts as soon as nodes 2 and 4 connect, and does not wait StartPartitionedTimeout milliseconds for nodes 3 and 5 to connect as it would otherwise.

    If you wanted to start up the same cluster as in the previous example without one ndbd (say, for example, that the host machine for node 3 has suffered a hardware failure) then start nodes 2, 4, and 5 with --nowait-nodes=3. Then the cluster will start as soon as nodes 2, 4, and 5 connect and will not wait for node 3 to start.

  • --nostart, -n

    Command-Line Format--nostart
    -n
     Permitted Values
    Typeboolean
    DefaultFALSE

    Instructs ndbd not to start automatically. When this option is used, ndbd connects to the management server, obtains configuration data from it, and initializes communication objects. However, it does not actually start the execution engine until specifically requested to do so by the management server. This can be accomplished by issuing the proper START command in the management client (see Section 17.5.2, "Commands in the MySQL Cluster Management Client").

  • --install[=name]

    Command-Line Format--install[=name]
     Permitted Values
    Typestring
    Defaultndbd

    Causes ndbd to be installed as a Windows service. Optionally, you can specify a name for the service; if not set, the service name defaults to ndbd. Although it is preferable to specify other ndbd program options in a my.ini or my.cnf configuration file, it is possible to use together with --install. However, in such cases, the --install option must be specified first, before any other options are given, for the Windows service installation to succeed.

    It is generally not advisable to use this option together with the --initial option, since this causes the data node file system to be wiped and rebuilt every time the service is stopped and started. Extreme care should also be taken if you intend to use any of the other ndbd options that affect the starting of data nodes-including --initial-start, --nostart, and --nowait-nodes-together with --install, and you should make absolutely certain you fully understand and allow for any possible consequences of doing so.

    The --install option has no effect on non-Windows platforms.

  • --remove[=name]

    Command-Line Format--remove[=name]
     Permitted Values
    Typestring
    Defaultndbd

    Causes an ndbd process that was previously installed as a Windows service to be removed. Optionally, you can specify a name for the service to be uninstalled; if not set, the service name defaults to ndbd.

    The --remove option has no effect on non-Windows platforms.

  • --connect-retries=#

    Version Introduced5.5.27-ndb-7.2.9
    Command-Line Format--connect-retries=#
     Permitted Values
    Typenumeric
    Default12
    Range-1 .. 65535

    Determines the number of times that the data node attempts to contact a management server when starting. Setting this option to -1 causes the data node to keep trying to make contact indefinitely. The default is 12 attempts. The time to wait between attempts is controlled by the --connect-delay option.

    This option was added in MySQL Cluster NDB 7.2.9.

  • --connect-delay=#

    Version Introduced5.5.27-ndb-7.2.9
    Command-Line Format--connect-delay=#
     Permitted Values
    Typenumeric
    Default5
    Range0 .. 3600

    Determines the time to wait between attempts to contact a management server when starting (the time between attempts is controlled by the --connect-retries option). The default is 5 attempts.

    This option was added in MySQL Cluster NDB 7.2.9.

ndbd generates a set of log files which are placed in the directory specified by DataDir in the config.ini configuration file.

These log files are listed below. node_id is the node's unique identifier. Note that node_id represents the node's unique identifier. For example, ndb_2_error.log is the error log generated by the data node whose node ID is 2.

  • ndb_node_id_error.log is a file containing records of all crashes which the referenced ndbd process has encountered. Each record in this file contains a brief error string and a reference to a trace file for this crash. A typical entry in this file might appear as shown here:

    Date/Time: Saturday 30 July 2004 - 00:20:01Type of error: errorMessage: Internal program error (failed ndbrequire)Fault ID: 2341Problem data: DbtupFixAlloc.cppObject of reference: DBTUP (Line: 173)ProgramName: NDB KernelProcessID: 14909TraceFile: ndb_2_trace.log.2***EOM***

    Listings of possible ndbd exit codes and messages generated when a data node process shuts down prematurely can be found in ndbd Error Messages.

    Important

    The last entry in the error log file is not necessarily the newest one (nor is it likely to be). Entries in the error log are not listed in chronological order; rather, they correspond to the order of the trace files as determined in the ndb_node_id_trace.log.next file (see below). Error log entries are thus overwritten in a cyclical and not sequential fashion.

  • ndb_node_id_trace.log.trace_id is a trace file describing exactly what happened just before the error occurred. This information is useful for analysis by the MySQL Cluster development team.

    It is possible to configure the number of these trace files that will be created before old files are overwritten. trace_id is a number which is incremented for each successive trace file.

  • ndb_node_id_trace.log.next is the file that keeps track of the next trace file number to be assigned.

  • ndb_node_id_out.log is a file containing any data output by the ndbd process. This file is created only if ndbd is started as a daemon, which is the default behavior.

  • ndb_node_id.pid is a file containing the process ID of the ndbd process when started as a daemon. It also functions as a lock file to avoid the starting of nodes with the same identifier.

  • ndb_node_id_signal.log is a file used only in debug versions of ndbd, where it is possible to trace all incoming, outgoing, and internal messages with their data in the ndbd process.

It is recommended not to use a directory mounted through NFS because in some environments this can cause problems whereby the lock on the .pid file remains in effect even after the process has terminated.

To start ndbd, it may also be necessary to specify the host name of the management server and the port on which it is listening. Optionally, one may also specify the node ID that the process is to use.

shell> ndbd --connect-string="nodeid=2;host=ndb_mgmd.mysql.com:1186"

See Section 17.3.2.3, "The MySQL Cluster Connectstring", for additional information about this issue. Section 17.4.1, "ndbd - The MySQL Cluster Data Node Daemon", describes other options for ndbd.

When ndbd starts, it actually initiates two processes. The first of these is called the "angel process"; its only job is to discover when the execution process has been completed, and then to restart the ndbd process if it is configured to do so. Thus, if you attempt to kill ndbd using the Unix kill command, it is necessary to kill both processes, beginning with the angel process. The preferred method of terminating an ndbd process is to use the management client and stop the process from there.

The execution process uses one thread for reading, writing, and scanning data, as well as all other activities. This thread is implemented asynchronously so that it can easily handle thousands of concurrent actions. In addition, a watch-dog thread supervises the execution thread to make sure that it does not hang in an endless loop. A pool of threads handles file I/O, with each thread able to handle one open file. Threads can also be used for transporter connections by the transporters in the ndbd process. In a multi-processor system performing a large number of operations (including updates), the ndbd process can consume up to 2 CPUs if permitted to do so.

For a machine with many CPUs it is possible to use several ndbd processes which belong to different node groups; however, such a configuration is still considered experimental and is not supported for MySQL 5.5 in a production setting. See Section 17.1.6, "Known Limitations of MySQL Cluster".

17.4.2. ndbinfo_select_all - Select From ndbinfo Tables

ndbinfo_select_all is a client program that selects all rows and columns from one or more tables in the ndbinfo database.

Not all ndbinfo tables can be accessed by this program. ndbinfo_select_all can access the counters, diskpagebuffer, logbuffers, logspaces, nodes, resources, threadblocks, threadstat, and transporters tables.

To select from one or more ndbinfo tables using ndbinfo_select_all, it is necessary to supply the names of the tables when invoking the program as shown here:

shell> ndbinfo_select_all table_name1  [table_name2] [...]

For example:

shell> ndbinfo_select_all logbuffers logspaces== logbuffers ==node_id log_type log_id  log_part total   used high5   0   0   0   33554432 262144  06   0   0   0   33554432 262144  07   0   0   0   33554432 262144  08   0   0   0   33554432 262144  0== logspaces ==node_id log_type log_id  log_part total   used high5   0   0   0   268435456   0   05   0   0   1   268435456   0   05   0   0   2   268435456   0   05   0   0   3   268435456   0   06   0   0   0   268435456   0   06   0   0   1   268435456   0   06   0   0   2   268435456   0   06   0   0   3   268435456   0   07   0   0   0   268435456   0   07   0   0   1   268435456   0   07   0   0   2   268435456   0   07   0   0   3   268435456   0   08   0   0   0   268435456   0   08   0   0   1   268435456   0   08   0   0   2   268435456   0   08   0   0   3   268435456   0   0shell>   

The following table includes options that are specific to ndbinfo_select_all. Additional descriptions follow the table. For options common to most MySQL Cluster programs (including ndbinfo_select_all), see Section 17.4.24, "Options Common to MySQL Cluster Programs - Options Common to MySQL Cluster Programs".

Table 17.11. ndbinfo_select_all Options and Variables: MySQL 5.5

FormatDescriptionAdded / Removed

--delay=#

Set the delay in seconds between loops. Default is 5.

All MySQL 5.5 based releases

--loops=#,

-l

Set the number of times to perform the select. Default is 1.

All MySQL 5.5 based releases

--database=db_name,

-d

Name of the database where the table located.

All MySQL 5.5 based releases

--parallelism=#,

-p

Set the degree of parallelism.

All MySQL 5.5 based releases


  • --delay=seconds

    Command-Line Format--delay=#
     Permitted Values
    Typenumeric
    Default5
    Range0 .. MAX_INT

    This option sets the number of seconds to wait between executing loops. Has no effect if --loops is set to 0 or 1.

  • --loops=number, -l number

    Command-Line Format--loops=#
    -l
     Permitted Values
    Typenumeric
    Default1
    Range0 .. MAX_INT

    This option sets the number of times to execute the select. Use --delay to set the time between loops.

17.4.3. ndbmtd - The MySQL Cluster Data Node Daemon (Multi-Threaded)

ndbmtd is a multi-threaded version of ndbd, the process that is used to handle all the data in tables using the NDBCLUSTER storage engine. ndbmtd is intended for use on host computers having multiple CPU cores. Except where otherwise noted, ndbmtd functions in the same way as ndbd; therefore, in this section, we concentrate on the ways in which ndbmtd differs from ndbd, and you should consult Section 17.4.1, "ndbd - The MySQL Cluster Data Node Daemon", for additional information about running MySQL Cluster data nodes that apply to both the single-threaded and multi-threaded versions of the data node process.

Command-line options and configuration parameters used with ndbd also apply to ndbmtd. For more information about these options and parameters, see Section 17.4.1, "ndbd - The MySQL Cluster Data Node Daemon", and Section 17.3.2.6, "Defining MySQL Cluster Data Nodes", respectively.

ndbmtd is also file system-compatible with ndbd. In other words, a data node running ndbd can be stopped, the binary replaced with ndbmtd, and then restarted without any loss of data. (However, when doing this, you must make sure that MaxNoOfExecutionThreads is set to an apppriate value before restarting the node if you wish for ndbmtd to run in multi-threaded fashion.) Similarly, an ndbmtd binary can be replaced with ndbd simply by stopping the node and then starting ndbd in place of the multi-threaded binary. It is not necessary when switching between the two to start the data node binary using --initial.

Using ndbmtd differs from using ndbd in two key respects:

  1. Because ndbmtd runs by default in single-threaded mode (that is, it behaves like ndbd), you must configure it to use multiple threads. This can be done by setting an appropriate value in the config.ini file for the MaxNoOfExecutionThreads configuration parameter or (in MySQL Cluster NDB 7.2.3 and later) the ThreadConfig configuration parameter. Using MaxNoOfExecutionThreads is simpler, but ThreadConfig offers more flexibility. For more information about these configuration parameters and their use, see Multi-Threading Configuration Parameters (ndbmtd).

  2. Trace files are generated by critical errors in ndbmtd processes in a somewhat different fashion from how these are generated by ndbd failures. These differences are discussed in more detail in the next few paragraphs.

Like ndbd, ndbmtd generates a set of log files which are placed in the directory specified by DataDir in the config.ini configuration file. Except for trace files, these are generated in the same way and have the same names as those generated by ndbd.

In the event of a critical error, ndbmtd generates trace files describing what happened just prior to the error' occurrence. These files, which can be found in the data node's DataDir, are useful for analysis of problems by the MySQL Cluster Development and Support teams. One trace file is generated for each ndbmtd thread. The names of these files have the following pattern:

  ndb_node_id_trace.log.trace_id_tthread_id,

In this pattern, node_id stands for the data node's unique node ID in the cluster, trace_id is a trace sequence number, and thread_id is the thread ID. For example, in the event of the failure of an ndbmtd process running as a MySQL Cluster data node having the node ID 3 and with MaxNoOfExecutionThreads equal to 4, four trace files are generated in the data node's data directory. If the is the first time this node has failed, then these files are named ndb_3_trace.log.1_t1, ndb_3_trace.log.1_t2, ndb_3_trace.log.1_t3, and ndb_3_trace.log.1_t4. Internally, these trace files follow the same format as ndbd trace files.

The ndbd exit codes and messages that are generated when a data node process shuts down prematurely are also used by ndbmtd. See ndbd Error Messages, for a listing of these.

Note

It is possible to use ndbd and ndbmtd concurrently on different data nodes in the same MySQL Cluster. However, such configurations have not been tested extensively; thus, we cannot recommend doing so in a production setting at this time.

17.4.4. ndb_mgmd - The MySQL Cluster Management Server Daemon

The management server is the process that reads the cluster configuration file and distributes this information to all nodes in the cluster that request it. It also maintains a log of cluster activities. Management clients can connect to the management server and check the cluster's status.

The following table includes options that are specific to the MySQL Cluster management server program ndb_mgmd. Additional descriptions follow the table. For options common to most MySQL Cluster programs (including ndb_mgmd), see Section 17.4.24, "Options Common to MySQL Cluster Programs - Options Common to MySQL Cluster Programs".

Table 17.12. ndb_mgmd Options and Variables: MySQL 5.5

FormatDescriptionAdded / Removed

--config-file=file,

-f,

-c

Specify the cluster configuration file; in NDB-6.4.0 and later, needs --reload or --initial to override configuration cache if present

All MySQL 5.5 based releases

--configdir=directory

Specify the cluster management server's configuration cache directory

All MySQL 5.5 based releases

--bind-address=ip_address

Local bind address

All MySQL 5.5 based releases

--print-full-config,

-P

Print full configuration and exit

All MySQL 5.5 based releases

--daemon,

-d

Run ndb_mgmd in daemon mode (default)

All MySQL 5.5 based releases

--nodaemon

Do not run ndb_mgmd as a daemon

All MySQL 5.5 based releases

--interactive

Run ndb_mgmd in interactive mode (not officially supported in production; for testing purposes only)

All MySQL 5.5 based releases

--log-name=name

A name to use when writing messages applying to this node in the cluster log.

All MySQL 5.5 based releases

--no-nodeid-checks

Do not provide any node id checks

All MySQL 5.5 based releases

--mycnf

Read cluster configuration data from the my.cnf file

All MySQL 5.5 based releases

--reload

Causes the management server to compare the configuration file with its configuration cache

All MySQL 5.5 based releases

--initial

Causes the management server reload its configuration data from the configuration file, bypassing the configuration cache

All MySQL 5.5 based releases

--nowait-nodes=list

Do not wait for these management nodes when starting this management server. Also requires --ndb-nodeid to be used.

All MySQL 5.5 based releases

--config-cache=value

Enable the management server configuration cache; ON by default.

All MySQL 5.5 based releases

--install[=name]

Used to install the management server process as a Windows service. Does not apply on non-Windows platforms.

All MySQL 5.5 based releases

--remove[=name]

Used to remove a management server process that was previously installed as a Windows service, optionally specifying the name of the service to be removed. Does not apply on non-Windows platforms.

All MySQL 5.5 based releases


  • --bind-address=host[:port]

    Command-Line Format--bind-address=ip_address
     Permitted Values
    Typestring
    Default[none]

    When specified, this option limits management server connections by management clients to clients at the specified host name or IP address (and possibly port, if this is also specified). In such cases, a management client attempting to connect to the management server from any other address fails with the error Unable to setup port: host:port!

    If the port is not specified, the management client attempts to use port 1186.

  • --no-nodeid-checks

    Command-Line Format--no-nodeid-checks
     Permitted Values
    Typeboolean
    DefaultFALSE

    Do not perform any checks of node IDs.

  • --configdir=path

    Command-Line Format--configdir=directory
     Permitted Values
    Typefile name
    Default$INSTALLDIR/mysql-cluster

    Specifies the cluster management server's configuration cache directory. --config-dir is an alias for this option.

  • This option, whose default value is 1 (or TRUE, or ON), can be used to disable the management server's configuration cache, so that it reads its configuration from config.ini every time it starts (see Section 17.3.2, "MySQL Cluster Configuration Files"). You can do this by starting the ndb_mgmd process with any one of the following options:

    • --config-cache=0

    • --config-cache=FALSE

    • --config-cache=OFF

    • --skip-config-cache

    Using one of the options just listed is effective only if the management server has no stored configuration at the time it is started. If the management server finds any configuration cache files, then the --config-cache option or the --skip-config-cache option is ignored. Therefore, to disable configuration caching, the option should be used the first time that the management server is started. Otherwise-that is, if you wish to disable configuration caching for a management server that has already created a configuration cache-you must stop the management server, delete any existing configuration cache files manually, then restart the management server with --skip-config-cache (or with --config-cache set equal to 0, OFF, or FALSE).

    Configuration cache files are normally created in a directory named mysql-cluster under the installation directory (unless this location has been overridden using the --configdir option). Each time the management server updates its configuration data, it writes a new cache file. The files are named sequentially in order of creation using the following format:

    ndb_node-id_config.bin.seq-number

    node-id is the management server's node ID; seq-number is a sequence number, beginning with 1. For example, if the management server's node ID is 5, then the first three configuration cache files would, when they are created, be named ndb_5_config.bin.1, ndb_5_config.bin.2, and ndb_5_config.bin.3.

    If your intent is to purge or reload the configuration cache without actually disabling caching, you should start ndb_mgmd with one of the options --reload or --initial instead of --skip-config-cache.

    To re-enable the configuration cache, simply restart the management server, but without the --config-cache or --skip-config-cache option that was used previously to disable the configuration cache.

    Beginning with MySQL Cluster NDB 7.2.5, ndb_mgmd no longer checks for the configuration directory (--configdir) or attempts to create one when --skip-config-cache is used. (Bug #13428853)

  • --config-file=filename, -f filename

    Command-Line Format--config-file=file
    -f
    -c
     Permitted Values
    Typefile name
    Default./config.ini

    Instructs the management server as to which file it should use for its configuration file. By default, the management server looks for a file named config.ini in the same directory as the ndb_mgmd executable; otherwise the file name and location must be specified explicitly.

    This option is ignored unless the management server is forced to read the configuration file, either because ndb_mgmd was started with the --reload or --initial option, or because the management server could not find any configuration cache. This option is also read if ndb_mgmd was started with --config-cache=OFF. See Section 17.3.2, "MySQL Cluster Configuration Files", for more information.

  • --mycnf

    Command-Line Format--mycnf
     Permitted Values
    Typeboolean
    DefaultFALSE

    Read configuration data from the my.cnf file.

  • --daemon, -d

    Command-Line Format--daemon
    -d
     Permitted Values
    Typeboolean
    DefaultTRUE

    Instructs ndb_mgmd to start as a daemon process. This is the default behavior.

    This option has no effect when running ndb_mgmd on Windows platforms.

  • --interactive

    Command-Line Format--interactive
     Permitted Values
    Typeboolean
    DefaultFALSE

    Starts ndb_mgmd in interactive mode; that is, an ndb_mgm client session is started as soon as the management server is running. This option does not start any other MySQL Cluster nodes.

  • --initial

    Command-Line Format--initial
     Permitted Values
    Typeboolean
    DefaultFALSE

    Configuration data is cached internally, rather than being read from the cluster global configuration file each time the management server is started (see Section 17.3.2, "MySQL Cluster Configuration Files"). Using the --initial option overrides this behavior, by forcing the management server to delete any existing cache files, and then to re-read the configuration data from the cluster configuration file and to build a new cache.

    This differs in two ways from the --reload option. First, --reload forces the server to check the configuration file against the cache and reload its data only if the contents of the file are different from the cache. Second, --reload does not delete any existing cache files.

    If ndb_mgmd is invoked with --initial but cannot find a global configuration file, the management server cannot start.

    When a management server starts, it checks for another management server in the same MySQL Cluster and tries to use the other management server's configuration data; ndb_mgmd ignores --initial unless it is the only management server running. This behavior also has implications when performing a rolling restart of a MySQL Cluster with multiple management nodes. See Section 17.5.5, "Performing a Rolling Restart of a MySQL Cluster", for more information.

  • --log-name=name

    Command-Line Format--log-name=name
     Permitted Values
    Typestring
    DefaultMgmtSrvr

    Provides a name to be used for this node in the cluster log.

  • --nodaemon

    Command-Line Format--nodaemon
     Permitted Values
    Typeboolean
    DefaultFALSE

    Instructs ndb_mgmd not to start as a daemon process.

    The default behavior for ndb_mgmd on Windows is to run in the foreground, making this option unnecessary on Windows platforms.

  • --print-full-config, -P

    Command-Line Format--print-full-config
    -P
     Permitted Values
    Typeboolean
    DefaultFALSE

    Shows extended information regarding the configuration of the cluster. With this option on the command line the ndb_mgmd process prints information about the cluster setup including an extensive list of the cluster configuration sections as well as parameters and their values. Normally used together with the --config-file (-f) option.

  • --reload

    Command-Line Format--reload
     Permitted Values
    Typeboolean
    DefaultFALSE

    In MySQL Cluster NDB 7.2, configuration data is stored internally rather than being read from the cluster global configuration file each time the management server is started (see Section 17.3.2, "MySQL Cluster Configuration Files"). Using this option forces the management server to check its internal data store against the cluster configuration file and to reload the configuration if it finds that the configuration file does not match the cache. Existing configuration cache files are preserved, but not used.

    This differs in two ways from the --initial option. First, --initial causes all cache files to be deleted. Second, --initial forces the management server to re-read the global configuration file and construct a new cache.

    If the management server cannot find a global configuration file, then the --reload option is ignored.

    When a management server starts, it checks for another management server in the same MySQL Cluster and tries to use the other management server's configuration data; ndb_mgmd ignores --reload unless it is the only management server running. This behavior also has implications when performing a rolling restart of a MySQL Cluster with multiple management nodes. See Section 17.5.5, "Performing a Rolling Restart of a MySQL Cluster", for more information.

  • --nowait-nodes

    Command-Line Format--nowait-nodes=list
     Permitted Values
    Typenumeric
    Default
    Range1 .. 255

    When starting a MySQL Cluster is configured with two management nodes, each management server normally checks to see whether the other ndb_mgmd is also operational and whether the other management server's configuration is identical to its own. However, it is sometimes desirable to start the cluster with only one management node (and perhaps to allow the other ndb_mgmd to be started later). This option causes the management node to bypass any checks for any other management nodes whose node IDs are passed to this option, permitting the cluster to start as though configured to use only the management node that was started.

    For purposes of illustration, consider the following portion of a config.ini file (where we have omitted most of the configuration parameters that are not relevant to this example):

    [ndbd]NodeId = 1HostName = 192.168.0.101[ndbd]NodeId = 2HostName = 192.168.0.102[ndbd]NodeId = 3HostName = 192.168.0.103[ndbd]NodeId = 4HostName = 192.168.0.104[ndb_mgmd]NodeId = 10HostName = 192.168.0.150[ndb_mgmd]NodeId = 11HostName = 192.168.0.151[api]NodeId = 20HostName = 192.168.0.200[api]NodeId = 21HostName = 192.168.0.201

    Assume that you wish to start this cluster using only the management server having node ID 10 and running on the host having the IP address 192.168.0.150. (Suppose, for example, that the host computer on which you intend to the other management server is temporarily unavailable due to a hardware failure, and you are waiting for it to be repaired.) To start the cluster in this way, use a command line on the machine at 192.168.0.150 to enter the following command:

    shell> ndb_mgmd --ndb-nodeid=10 --nowait-nodes=11

    As shown in the preceding example, when using --nowait-nodes, you must also use the --ndb-nodeid option to specify the node ID of this ndb_mgmd process.

    You can then start each of the cluster's data nodes in the usual way. If you wish to start and use the second management server in addition to the first management server at a later time without restarting the data nodes, you must start each data node with a connectstring that references both management servers, like this:

    shell> ndbd -c 192.168.0.150,192.168.0.151

    The same is true with regard to the connectstring used with any mysqld processes that you wish to start as MySQL Cluster SQL nodes connected to this cluster. See Section 17.3.2.3, "The MySQL Cluster Connectstring", for more information.

    When used with ndb_mgmd, this option affects the behavior of the management node with regard to other management nodes only. Do not confuse it with the --nowait-nodes option used with ndbd or ndbmtd to permit a cluster to start with fewer than its full complement of data nodes; when used with data nodes, this option affects their behavior only with regard to other data nodes.

    Multiple management node IDs may be passed to this option as a comma-separated list. Each node ID must be no less than 1 and no greater than 255. In practice, it is quite rare to use more than two management servers for the same MySQL Cluster (or to have any need for doing so); in most cases you need to pass to this option only the single node ID for the one management server that you do not wish to use when starting the cluster.

    Note

    When you later start the "missing" management server, its configuration must match that of the management server that is already in use by the cluster. Otherwise, it fails the configuration check performed by the existing management server, and does not start.

It is not strictly necessary to specify a connectstring when starting the management server. However, if you are using more than one management server, a connectstring should be provided and each node in the cluster should specify its node ID explicitly.

See Section 17.3.2.3, "The MySQL Cluster Connectstring", for information about using connectstrings. Section 17.4.4, "ndb_mgmd - The MySQL Cluster Management Server Daemon", describes other options for ndb_mgmd.

The following files are created or used by ndb_mgmd in its starting directory, and are placed in the DataDir as specified in the config.ini configuration file. In the list that follows, node_id is the unique node identifier.

  • config.ini is the configuration file for the cluster as a whole. This file is created by the user and read by the management server. Section 17.3, "MySQL Cluster Configuration", discusses how to set up this file.

  • ndb_node_id_cluster.log is the cluster events log file. Examples of such events include checkpoint startup and completion, node startup events, node failures, and levels of memory usage. A complete listing of cluster events with descriptions may be found in Section 17.5, "Management of MySQL Cluster".

    When the size of the cluster log reaches one million bytes, the file is renamed to ndb_node_id_cluster.log.seq_id, where seq_id is the sequence number of the cluster log file. (For example: If files with the sequence numbers 1, 2, and 3 already exist, the next log file is named using the number 4.)

  • ndb_node_id_out.log is the file used for stdout and stderr when running the management server as a daemon.

  • ndb_node_id.pid is the process ID file used when running the management server as a daemon.

  • --install[=name]

    Command-Line Format--install[=name]
     Permitted Values
    Typestring
    Defaultndb_mgmd

    Causes ndb_mgmd to be installed as a Windows service. Optionally, you can specify a name for the service; if not set, the service name defaults to ndb_mgmd. Although it is preferable to specify other ndb_mgmd program options in a my.ini or my.cnf configuration file, it is possible to use them together with --install. However, in such cases, the --install option must be specified first, before any other options are given, for the Windows service installation to succeed.

    It is generally not advisable to use this option together with the --initial option, since this causes the configuration cache to be wiped and rebuilt every time the service is stopped and started. Care should also be taken if you intend to use any other ndb_mgmd options that affect the starting of the management server, and you should make absolutely certain you fully understand and allow for any possible consequences of doing so.

    The --install option has no effect on non-Windows platforms.

  • --remove[=name]

    Command-Line Format--remove[=name]
     Permitted Values
    Typestring
    Defaultndb_mgmd

    Causes an ndb_mgmd process that was previously installed as a Windows service to be removed. Optionally, you can specify a name for the service to be uninstalled; if not set, the service name defaults to ndb_mgmd.

    The --remove option has no effect on non-Windows platforms.

17.4.5. ndb_mgm - The MySQL Cluster Management Client

The ndb_mgm management client process is actually not needed to run the cluster. Its value lies in providing a set of commands for checking the cluster's status, starting backups, and performing other administrative functions. The management client accesses the management server using a C API. Advanced users can also employ this API for programming dedicated management processes to perform tasks similar to those performed by ndb_mgm.

To start the management client, it is necessary to supply the host name and port number of the management server:

shell> ndb_mgm [host_name [port_num]]

For example:

shell> ndb_mgm ndb_mgmd.mysql.com 1186

The default host name and port number are localhost and 1186, respectively.

The following table includes options that are specific to the MySQL Cluster management client program ndb_mgm. Additional descriptions follow the table. For options common to most MySQL Cluster programs (including ndb_mgm), see Section 17.4.24, "Options Common to MySQL Cluster Programs - Options Common to MySQL Cluster Programs".

Table 17.13. ndb_mgm Options and Variables: MySQL 5.5

FormatDescriptionAdded / Removed

--try-reconnect=#,

-t

Specify number of tries for connecting to ndb_mgmd (0 = infinite)

All MySQL 5.5 based releases

--execute=name,

-e

Execute command and exit

All MySQL 5.5 based releases


  • --execute=command, -e command

    Command-Line Format--execute=name
    -e

    This option can be used to send a command to the MySQL Cluster management client from the system shell. For example, either of the following is equivalent to executing SHOW in the management client:

    shell> ndb_mgm -e "SHOW"shell> ndb_mgm --execute="SHOW"

    This is analogous to how the --execute or -e option works with the mysql command-line client. See Section 4.2.3.1, "Using Options on the Command Line".

    Note

    If the management client command to be passed using this option contains any space characters, then the command must be enclosed in quotation marks. Either single or double quotation marks may be used. If the management client command contains no space characters, the quotation marks are optional.

  • --try-reconnect=number

    Command-Line Format--try-reconnect=#
    -t
     Permitted Values
    Typeboolean
    DefaultTRUE

    If the connection to the management server is broken, the node tries to reconnect to it every 5 seconds until it succeeds. By using this option, it is possible to limit the number of attempts to number before giving up and reporting an error instead.

Additional information about using ndb_mgm can be found in Section 17.5.2, "Commands in the MySQL Cluster Management Client".

17.4.6. ndb_config - Extract MySQL Cluster Configuration Information

This tool extracts current configuration information for data nodes, SQL nodes, and API nodes from one of a number of sources: a MySQL 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 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).

You can filter the results by section (DB, SYSTEM, or CONNECTIONS) using one of the options --nodes, --system, or --connections.

The following table includes options that are specific to ndb_config. Additional descriptions follow the table. For options common to most MySQL Cluster programs (including ndb_config), see Section 17.4.24, "Options Common to MySQL Cluster Programs - Options Common to MySQL Cluster Programs".

Table 17.14. ndb_config Options and Variables: MySQL 5.5

FormatDescriptionAdded / Removed

--nodes

Print node information (DB section) only.

All MySQL 5.5 based releases

--connections

Print CONNECTIONS section information only. Cannot be used with --nodes or --system option.

All MySQL 5.5 based releases

--query=string,

-q

One or more query options (attributes)

All MySQL 5.5 based releases

--host=name

Specify host

All MySQL 5.5 based releases

--type=name

Specify node type

All MySQL 5.5 based releases

--nodeid,

--id

Get configuration of node with this ID

All MySQL 5.5 based releases

--fields=string,

-f

Field separator

All MySQL 5.5 based releases

--rows=string,

-r

Row separator

All MySQL 5.5 based releases

--config-file=path

Set the path to config.ini file

All MySQL 5.5 based releases

--mycnf

Read configuration data from my.cnf file

All MySQL 5.5 based releases

-c

Short form for --ndb-connectstring

All MySQL 5.5 based releases

--configinfo

Dumps information about all NDB configuration parameters in text format with default, maximum, and minimum values. Use with --xml to obtain XML output.

All MySQL 5.5 based releases

--configinfo --xml

Use --xml with --configinfo to obtain a dump of all NDB configuration parameters in XML format with default, maximum, and minimum values.

All MySQL 5.5 based releases

--system

Print SYSTEM section information only. Cannot be used with --nodes or --connections option.

All MySQL 5.5 based releases

--config_from_node=#

Obtain configuration data from the node having this ID (must be a data node).

All MySQL 5.5 based releases


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

    Command-Line Format--help
    --usage
    -?

    Causes ndb_config to print a list of available options, and then exit.

  • --config_from_node=#

    Command-Line Format--config_from_node=#
     Permitted Values
    Typenumeric
    Defaultnone
    Range1 .. 48

    Obtain the cluster's configuration data from the data node that has this ID.

    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.)

  • --version, -V

    Command-Line Format--version
    -V

    Causes ndb_config to print a version information string, and then exit.

  • --ndb-connectstring=connect_string, -c connect_string

    Specifies the connectstring to use in connecting to the management server. The format for the connectstring is the same as described in Section 17.3.2.3, "The MySQL Cluster Connectstring", and defaults to localhost:1186.

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

    Command-Line Format--config-file=path
     Permitted Values
    Typefile name
    Default

    Gives the path to the management server's configuration file (config.ini). This may be a relative or absolute path. If the management node resides on a different host from the one on which ndb_config is invoked, then an absolute path must be used.

  • --mycnf

    Command-Line Format--mycnf
     Permitted Values
    Typeboolean
    DefaultFALSE

    Read configuration data from the my.cnf file.

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

    Command-Line Format--query=string
    -q
     Permitted Values
    Typestring
    Default

    This is a comma-delimited list of query options-that is, a list of one or more node attributes to be returned. These include id (node ID), type (node type-that is, ndbd, mysqld, or ndb_mgmd), and any configuration parameters whose values are to be obtained.

    For example, --query=id,type,indexmemory,datamemory returns the node ID, node type, DataMemory, and IndexMemory 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.

  • --host=hostname

    Command-Line Format--host=name
     Permitted Values
    Typestring
    Default

    Specifies the host name of the node for which configuration information is to be obtained.

    Note

    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 MySQL Cluster configuration values relating to hosts, or verify that all MySQL Cluster hosts handle localhost in the same fashion.

  • --id=node_id

    --nodeid=node_id

    Either of these options can be used to specify the node ID of the node for which configuration information is to be obtained. --nodeid is the preferred form.

  • --nodes

    Command-Line Format--nodes
     Permitted Values
    Typeboolean
    DefaultFALSE

    Tells ndb_config to print information from parameters defined in DB sections only. This option cannot be used together with --connections or --system.

  • --connections

    Command-Line Format--connections
     Permitted Values
    Typeboolean
    DefaultFALSE

    Tells ndb_config to print CONNECTIONS information only. This option cannot be used together with --nodes or --system.

  • --system

    Command-Line Format--system
     Permitted Values
    Typeboolean
    DefaultFALSE

    Tells ndb_config to print SYSTEM information only.

    This option cannot be used together with the --nodes or --system options.

  • --type=node_type

    Command-Line Format--type=name
     Permitted Values
    Typeenumeration
    Default
    Valid Values

    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.

  • --fields=delimiter, -f delimiter

    Command-Line Format--fields=string
    -f
     Permitted Values
    Typestring
    Default

    Specifies a delimiter string used to separate the fields in the result. The default is "," (the comma character).

    Note

    If the delimiter contains spaces or escapes (such as \n for the linefeed character), then it must be quoted.

  • --rows=separator, -r separator

    Command-Line Format--rows=string
    -r
     Permitted Values
    Typestring
    Default

    Specifies a separator string used to separate the rows in the result. The default is a space character.

    Note

    If the separator contains spaces or escapes (such as \n for the linefeed character), then it must be quoted.

  • --configinfo

    The --configinfo option causes ndb_config to dump a list of each MySQL Cluster configuration parameter supported by the MySQL Cluster distribution of which ndb_config is a part, including the following information:

    • A brief description of each parameter's purpose, effects, and usage

    • 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

    • A brief description of the parameter's purpose, effects, and usage

    • MySQL Cluster release version and build information

    By default, this output is in text format. Part of this output is shown here:

    shell> ndb_config --configinfo****** SYSTEM ******Name (String)Name of system (NDB Cluster)MANDATORYPrimaryMGMNode (Non-negative Integer)Node id of Primary ndb_mgmd(MGM) nodeDefault: 0 (Min: 0, Max: 4294967039)ConfigGenerationNumber (Non-negative Integer)Configuration generation numberDefault: 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)�

    --configinfo --xml

    Command-Line Format--configinfo --xml
     Permitted Values
    Typeboolean
    Defaultfalse

    You can obtain the output of ndb_config --configinfo as XML by adding the --xml option. A portion of the resulting output is shown in this example:

    shell> ndb_config --configinfo --xml<configvariables protocolversion="1" ndbversionstring="5.5.29-ndb-7.2.10" ndbversion="458758" ndbversionmajor="7" ndbversionminor="0" ndbversionbuild="6">  <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="NDBD"> <param name="MaxNoOfSubscriptions"   comment="Max no of subscriptions (default 0 == MaxNoOfTables)"  type="unsigned" default="0" min="0" max="4294967039"/> <param name="MaxNoOfSubscribers"   comment="Max no of subscribers (default 0 == 2 * MaxNoOfTables)"  type="unsigned" default="0" min="0" max="4294967039"/> �  </section>  �</configvariables>
    Note

    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.

    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).

    Important

    The --xml option can be used only with the --configinfo option. Using --xml without --configinfo fails with an error.

    Unlike the options used with this program to obtain current configuration data, --configinfo and --xml use information obtained from the MySQL Cluster sources when ndb_config was compiled. For this reason, no connection to a running MySQL Cluster or access to a config.ini or my.cnf file is required for these two options.

    Combining other ndb_config options (such as --query or --type) with --configinfo or --xml 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 MySQL Cluster or read any files, trying to specify additional options such as --ndb-connectstring or --config-file with --configinfo serves no purpose.

Examples

  1. To obtain the node ID and type of each node in the cluster:

    shell> ./ndb_config --query=id,type --fields=':' --rows='\n'1:ndbd2:ndbd3:ndbd4:ndbd5:ndb_mgmd6:mysqld7:mysqld8:mysqld9:mysqld

    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. To produce a connectstring that can be used by data, SQL, and API nodes to connect to the management server:

    shell> ./ndb_config --config-file=usr/local/mysql/cluster-data/config.ini \ --query=hostname,portnumber --fields=: --rows=, --type=ndb_mgmd192.168.0.179:1186
  3. 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, IndexMemory, and DataDir parameters:

    shell> ./ndb_config --type=ndbd --query=id,host,datamemory,indexmemory,datadir -f ' : ' -r '\n'1 : 192.168.0.193 : 83886080 : 18874368 : /usr/local/mysql/cluster-data2 : 192.168.0.112 : 83886080 : 18874368 : /usr/local/mysql/cluster-data3 : 192.168.0.176 : 83886080 : 18874368 : /usr/local/mysql/cluster-data4 : 192.168.0.119 : 83886080 : 18874368 : /usr/local/mysql/cluster-data

    In this example, we used the short options -f and -r for setting the field delimiter and row separator, respectively.

  4. To exclude results from any host except one in particular, use the --host option:

    shell> ./ndb_config --host=192.168.0.176 -f : -r '\n' -q id,type3:ndbd5:ndb_mgmd

    In this example, we also used the short form -q to determine the attributes to be queried.

    Similarly, you can limit results to a node with a specific ID using the --id or --nodeid option.

17.4.7. ndb_cpcd - Automate Testing for NDB Development

A utility having this name was formerly part of an internal automated test framework used in testing and debugging MySQL Cluster. It was deprecated in MySQL Cluster NDB 7.0, and removed from MySQL Cluster distributions provided by Oracle beginning with MySQL Cluster NDB 7.2.1.

17.4.8. ndb_delete_all - Delete All Rows from an NDB Table

ndb_delete_all deletes all rows from the given NDB table. In some cases, this can be much faster than DELETE or even TRUNCATE TABLE.

Usage

ndb_delete_all -c connect_string tbl_name -d db_name

This deletes all rows from the table named tbl_name in the database named db_name. It is exactly equivalent to executing TRUNCATE db_name.tbl_name in MySQL.

The following table includes options that are specific to ndb_delete_all. Additional descriptions follow the table. For options common to most MySQL Cluster programs (including ndb_delete_all), see Section 17.4.24, "Options Common to MySQL Cluster Programs - Options Common to MySQL Cluster Programs".

Table 17.15. ndb_delete_all Options and Variables: MySQL 5.5

FormatDescriptionAdded / Removed

--database=dbname,

-d

Name of the database in which the table is found

All MySQL 5.5 based releases

--transactional,

-t

Perform the delete in a single transaction (may run out of operations)

All MySQL 5.5 based releases

--tupscan

Run tup scan

All MySQL 5.5 based releases

--diskscan

Run disk scan

All MySQL 5.5 based releases


  • --transactional, -t

    Use of this option causes the delete operation to be performed as a single transaction.

    Warning

    With very large tables, using this option may cause the number of operations available to the cluster to be exceeded.

17.4.9. ndb_desc - Describe NDB Tables

ndb_desc provides a detailed description of one or more NDB tables.

Usage

ndb_desc -c connect_string tbl_name -d db_name [-p]

Sample Output

MySQL table creation and population statements:

USE test;CREATE TABLE fish ( id INT(11) NOT NULL AUTO_INCREMENT, name VARCHAR(20) NOT NULL, length_mm INT(11) NOT NULL, weight_gm INT(11) NOT NULL, PRIMARY KEY pk (id), UNIQUE KEY uk (name)) ENGINE=NDB;INSERT INTO fish VALUES ('','guppy', 35, 2), ('','tuna', 2500, 150000), ('','shark', 3000, 110000), ('','manta ray', 1500, 50000), ('','grouper', 900, 125000), ('','puffer', 250, 2500);

Output from ndb_desc:

shell> ./ndb_desc -c localhost fish -d test -p-- fish --Version: 2Fragment type: 9K Value: 6Min load factor: 78Max load factor: 80Temporary table: noNumber of attributes: 4Number of primary keys: 1Length of frm data: 311Row Checksum: 1Row GCI: 1SingleUserMode: 0ForceVarPart: 1FragmentCount: 2TableStatus: Retrieved-- Attributes --id Int PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY AUTO_INCRname Varchar(20;latin1_swedish_ci) NOT NULL AT=SHORT_VAR ST=MEMORYlength_mm Int NOT NULL AT=FIXED ST=MEMORYweight_gm Int NOT NULL AT=FIXED ST=MEMORY-- Indexes --PRIMARY KEY(id) - UniqueHashIndexPRIMARY(id) - OrderedIndexuk$unique(name) - UniqueHashIndexuk(name) - OrderedIndex-- Per partition info --Partition  Row count  Commit count  Frag fixed memory ...0  2  2 32768 ...1  4  4 32768 ...... Frag varsized memory  Extent_space  Free extent_space... 32768 0 0... 32768 0 0NDBT_ProgramExit: 0 - OK

Information about multiple tables can be obtained in a single invocation of ndb_desc by using their names, separated by spaces. All of the tables must be in the same database.

The Version column in the output contains the table's schema object version. For information about interpreting this value, see NDB Schema Object Versions.

The Extent_space and Free extent_space columns are applicable only to NDB tables having columns on disk; for tables having only in-memory columns, these columns always contain the value 0.

To illustrate their use, we modify the previous example. First, we must create the necessary Disk Data objects, as shown here:

CREATE LOGFILE GROUP lg_1 ADD UNDOFILE 'undo_1.log' INITIAL_SIZE 16M UNDO_BUFFER_SIZE 2M ENGINE NDB;ALTER LOGFILE GROUP lg_1 ADD UNDOFILE 'undo_2.log' INITIAL_SIZE 12M ENGINE NDB;CREATE TABLESPACE ts_1 ADD DATAFILE 'data_1.dat' USE LOGFILE GROUP lg_1 INITIAL_SIZE 32M ENGINE NDB;ALTER TABLESPACE ts_1 ADD DATAFILE 'data_2.dat' INITIAL_SIZE 48M ENGINE NDB;

(For more information on the statements just shown and the objects created by them, see Section 17.5.12.1, "MySQL Cluster Disk Data Objects", as well as Section 13.1.14, "CREATE LOGFILE GROUP Syntax", and Section 13.1.18, "CREATE TABLESPACE Syntax".)

Now we can create and populate a version of the fish table that stores 2 of its columns on disk (deleting the previous version of the table first, if it already exists):

CREATE TABLE fish ( id INT(11) NOT NULL AUTO_INCREMENT, name VARCHAR(20) NOT NULL, length_mm INT(11) NOT NULL, weight_gm INT(11) NOT NULL, PRIMARY KEY pk (id), UNIQUE KEY uk (name)) TABLESPACE ts_1 STORAGE DISK ENGINE=NDB;INSERT INTO fish VALUES ('','guppy', 35, 2), ('','tuna', 2500, 150000), ('','shark', 3000, 110000), ('','manta ray', 1500, 50000), ('','grouper', 900, 125000), ('','puffer', 250, 2500);

When run against this version of the table, ndb_desc displays the following output:

shell> ./ndb_desc -c localhost fish -d test -p-- fish --Version: 3Fragment type: 9K Value: 6Min load factor: 78Max load factor: 80Temporary table: noNumber of attributes: 4Number of primary keys: 1Length of frm data: 321Row Checksum: 1Row GCI: 1SingleUserMode: 0ForceVarPart: 1FragmentCount: 2TableStatus: Retrieved-- Attributes --id Int PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY AUTO_INCRname Varchar(20;latin1_swedish_ci) NOT NULL AT=SHORT_VAR ST=MEMORYlength_mm Int NOT NULL AT=FIXED ST=DISKweight_gm Int NOT NULL AT=FIXED ST=DISK-- Indexes --PRIMARY KEY(id) - UniqueHashIndexPRIMARY(id) - OrderedIndexuk$unique(name) - UniqueHashIndexuk(name) - OrderedIndex-- Per partition info --Partition  Row count  Commit count  Frag fixed memory ...0  2  2 32768 ...1  4  4 32768 ...... Frag varsized memory  Extent_space  Free extent_space... 32768 0 0... 32768 0 0NDBT_ProgramExit: 0 - OK

This means that 1048576 bytes are allocated from the tablespace for this table on each partition, of which 1044440 bytes remain free for additional storage. In other words, 1048576 - 1044440 = 4136 bytes per partition is currently being used to store the data from this table's disk-based columns. The number of bytes shown as Free extent_space is available for storing on-disk column data from the fish table only; for this reason, it is not visible when selecting from the INFORMATION_SCHEMA.FILES table.

The following table includes options that are specific to ndb_desc. Additional descriptions follow the table. For options common to most MySQL Cluster programs (including ndb_desc), see Section 17.4.24, "Options Common to MySQL Cluster Programs - Options Common to MySQL Cluster Programs".

Table 17.16. ndb_desc Options and Variables: MySQL 5.5

FormatDescriptionAdded / Removed

--database=dbname,

-d

Name of database containing table

All MySQL 5.5 based releases

--unqualified,

-u

Use unqualified table names

All MySQL 5.5 based releases

--extra-partition-info,

-p

Display information about partitions

All MySQL 5.5 based releases

--retries=#,

-r

Number of times to retry the connection (once per second)

All MySQL 5.5 based releases

--blob-info,

-b

Include partition information for BLOB tables in output. Requires that the -p option also be used

All MySQL 5.5 based releases

--extra-node-info,

-n

Include partition-to-data-node mappings in output. Requires that the -p option also be used

All MySQL 5.5 based releases


  • --extra-partition-info, -p

    Print additional information about the table's partitions.

  • --blob-info, -b

    Include information about subordinate BLOB and TEXT columns.

    Use of this option also requires the use of the --extra-partition-info (-p) option.

  • --extra-node-info, -n

    Include information about the mappings between table partitions and the data nodes upon which they reside. This information can be useful for verifying distribution awareness mechanisms and supporting more efficient application access to the data stored in MySQL Cluster.

    Use of this option also requires the use of the --extra-partition-info (-p) option.

17.4.10. ndb_drop_index - Drop Index from an NDB Table

ndb_drop_index drops the specified index from an NDB table. It is recommended that you use this utility only as an example for writing NDB API applications-see the Warning later in this section for details.

Usage

ndb_drop_index -c connect_string table_name index -d db_name

The statement shown above drops the index named index from the table in the database.

The following table includes options that are specific to ndb_drop_index. Additional descriptions follow the table. For options common to most MySQL Cluster programs (including ndb_drop_index), see Section 17.4.24, "Options Common to MySQL Cluster Programs - Options Common to MySQL Cluster Programs".

Table 17.17. ndb_drop_index Options and Variables: MySQL 5.5

FormatDescriptionAdded / Removed

--database=dbname,

-d

Name of the database in which the table is found

All MySQL 5.5 based releases


Warning

Operations performed on Cluster table indexes using the NDB API are not visible to MySQL and make the table unusable by a MySQL server. If you use this program to drop an index, then try to access the table from an SQL node, an error results, as shown here:

shell> ./ndb_drop_index -c localhost dogs ix -d ctest1Dropping index dogs/idx...OKNDBT_ProgramExit: 0 - OKshell> ./mysql -u jon -p ctest1Enter password: *******Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -AWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 7 to server version: 5.5.29-ndb-7.2.10Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> SHOW TABLES;+------------------+| Tables_in_ctest1 |+------------------+| a || bt1  || bt2  || dogs || employees || fish |+------------------+6 rows in set (0.00 sec)mysql> SELECT * FROM dogs;ERROR 1296 (HY000): Got error 4243 'Index not found' from NDBCLUSTER

In such a case, your only option for making the table available to MySQL again is to drop the table and re-create it. You can use either the SQL statementDROP TABLE or the ndb_drop_table utility (see Section 17.4.11, "ndb_drop_table - Drop an NDB Table") to drop the table.

17.4.11. ndb_drop_table - Drop an NDB Table

ndb_drop_table drops the specified NDB table. (If you try to use this on a table created with a storage engine other than NDB, the attempt fails with the error 723: No such table exists.) This operation is extremely fast; in some cases, it can be an order of magnitude faster than using a MySQL DROP TABLE statement on an NDB table.

Usage

ndb_drop_table -c connect_string tbl_name -d db_name

The following table includes options that are specific to ndb_drop_table. Additional descriptions follow the table. For options common to most MySQL Cluster programs (including ndb_drop_table), see Section 17.4.24, "Options Common to MySQL Cluster Programs - Options Common to MySQL Cluster Programs".

Table 17.18. ndb_drop_table Options and Variables: MySQL 5.5

FormatDescriptionAdded / Removed

--database=dbname,

-d

Name of the database in which the table is found

All MySQL 5.5 based releases


17.4.12. ndb_error_reporter - NDB Error-Reporting Utility

ndb_error_reporter creates an archive from data node and management node log files that can be used to help diagnose bugs or other problems with a cluster. It is highly recommended that you make use of this utility when filing reports of bugs in MySQL Cluster.

The following table includes command options specific to the MySQL Cluster program ndb_error_reporter. Additional descriptions follow the table. For options common to most MySQL Cluster programs (including ndb_error_reporter), see Section 17.4.24, "Options Common to MySQL Cluster Programs - Options Common to MySQL Cluster Programs".

Table 17.19. ndb_error_reporter Options and Variables: MySQL 5.5

FormatDescriptionAdded / Removed

--fs

Include file system data in error report; can use a large amount of disk space

All MySQL 5.5 based releases


Usage

ndb_error_reporter path/to/config-file [username] [--fs]

This utility is intended for use on a management node host, and requires the path to the management host configuration file (config.ini). Optionally, you can supply the name of a user that is able to access the cluster's data nodes using SSH, to copy the data node log files. ndb_error_reporter then includes all of these files in archive that is created in the same directory in which it is run. The archive is named ndb_error_report_YYYYMMDDHHMMSS.tar.bz2, where YYYYMMDDHHMMSS is a datetime string.

If the --fs is used, then the data node file systems are also copied to the management host and included in the archive that is produced by this script. As data node file systems can be extremely large even after being compressed, we ask that you please do not send archives created using this option to Oracle unless you are specifically requested to do so.

Command-Line Format--fs
 Permitted Values
Typeboolean
DefaultFALSE

17.4.13. ndb_index_stat - NDB Index Statistics Utility

ndb_index_stat ...

Usage

To obtain basic index statistics about a given NDB table, invoke ndb_index_stat as shown here, with the name of the table as the first argument and the name of the database containing this table specified immediately following it, using the --database (-d) option:

ndb_index_stat table -d database

In this example, we use ndb_index_stat to obtain such information about an NDB table named mytable in the test database:

shell> ndb_index_stat -d test mytabletable:mytable index:PRIMARY fragCount:4sampleVersion:2 loadTime:1336751773 sampleCount:0 keyBytes:0query cache: valid:1 sampleCount:0 totalBytes:0times in ms: save: 12.380 sort: 0.001NDBT_ProgramExit: 0 - OK

The --verbose option provides some additional output, as shown here:

shell> ndb_index_stat -d test mytable --verboserandom seed 1337010518connectedloop 1 of 1table:mytable index:PRIMARY fragCount:4sampleVersion:2 loadTime:1336751773 sampleCount:0 keyBytes:0read statsquery cache createdquery cache: valid:1 sampleCount:0 totalBytes:0times in ms: save: 20.766 sort: 0.001disconnectedNDBT_ProgramExit: 0 - OKshell>

Options

The following table includes options that are specific to the MySQL Cluster ndb_index_stat utility. Additional descriptions are listed following the table. For options common to most MySQL Cluster programs (including ndb_index_stat), see Section 17.4.24, "Options Common to MySQL Cluster Programs - Options Common to MySQL Cluster Programs".

Table 17.20. ndb_index_stat Options and Variables: MySQL 5.5

FormatDescriptionAdded / Removed

--database=name,

-d

Name of the database containing the table.

All MySQL 5.5 based releases

--delete

Delete index statistics for the given table, stopping any auto-update previously configured.

All MySQL 5.5 based releases

--update

Update index statistics for the given table, restarting any auto-update previously configured.

All MySQL 5.5 based releases

--dump

Print the query cache.

All MySQL 5.5 based releases

--query=#

Perform a number of random range queries on first key attr (must be int unsigned).

All MySQL 5.5 based releases

--sys-drop

Drop any statistics tables and events in NDB kernel (all statistics are lost)

All MySQL 5.5 based releases

--sys-create

Create all statistics tables and events in NDB kernel, if none of them already exist

All MySQL 5.5 based releases

--sys-create-if-not-exist

Create any statistics tables and events in NDB kernel that do not already exist.

All MySQL 5.5 based releases

--sys-create-if-not-valid

Create any statistics tables or events that do not already exist in the NDB kernel. after dropping any that are invalid.

All MySQL 5.5 based releases

--sys-check

Verify that NDB system index statistics and event tables exist.

All MySQL 5.5 based releases

--sys-skip-tables

Do not apply sys-* options to tables.

All MySQL 5.5 based releases

--sys-skip-events

Do not apply sys-* options to events.

All MySQL 5.5 based releases

--verbose,

-v

Turn on verbose output

All MySQL 5.5 based releases

--loops=#

Set the number of times to perform a given command. Default is 0.

All MySQL 5.5 based releases


ndb_index_stat statistics options. The following options are used to generate index statistics. They work with a given table and database. They cannot be mixed with ndb_index_stat system options.

  • --database=name, -d name

    Command-Line Format--database=name
    -d
     Permitted Values
    Typestring
    Default[none]
    Range ..

    The name of the database that contains the table being queried.

  • --delete

    Command-Line Format--delete
     Permitted Values
    Typeboolean
    Defaulttrue
    Range ..

    Delete the index statistics for the given table, stopping any auto-update that was previously configured.

  • --update

    Command-Line Format--update
     Permitted Values
    Typeboolean
    Defaulttrue
    Range ..

    Update the index statistics for the given table, and restart any auto-update that previously configured.

  • --dump

    Command-Line Format--dump
     Permitted Values
    Typeboolean
    Defaulttrue
    Range ..

    Dump the contents of the query cache.

  • --query=#

    Command-Line Format--query=#
     Permitted Values
    Typenumeric
    Default0
    Range0 .. MAX_INT

    Perform random range queries on first key attribute (must be int unsigned).

ndb_index_stat system options. The following options are used to generate and update the statistics tables in the NDB kernel. They cannot be mixed with ndb_index_stat statistics options.

  • --sys-drop

    Command-Line Format--sys-drop
     Permitted Values
    Typeboolean
    Defaulttrue
    Range ..

    Drop all statistics tables and events in the NDB kernel. This causes all statistics to be lost.

  • --sys-create

    Command-Line Format--sys-create
     Permitted Values
    Typeboolean
    Defaulttrue
    Range ..

    Create all statistics tables and events in the NDB kernel. This works only if none of them exist previously.

  • sys-create-if-not-exist

    Command-Line Format--sys-create-if-not-exist
     Permitted Values
    Typeboolean
    Defaulttrue
    Range ..

    Create any NDB system statistics tables or events (or both) that do not already exist when the program is invoked.

  • --sys-create-if-not-valid

    Command-Line Format--sys-create-if-not-valid
     Permitted Values
    Typeboolean
    Defaulttrue
    Range ..

    Create any NDB system statistics tables or events that do not already exist, after dropping any that are invalid.

  • --sys-check

    Command-Line Format--sys-check
     Permitted Values
    Typeboolean
    Defaulttrue
    Range ..

    Verify that all required system statistics tables and events exist in the NDB kernel.

  • --sys-skip-tables

    Command-Line Format--sys-skip-tables
     Permitted Values
    Typeboolean
    Defaulttrue
    Range ..

    Do not apply any --sys-* options to any statistics tables.

  • --sys-skip-events

    Command-Line Format--sys-skip-events
     Permitted Values
    Typeboolean
    Defaulttrue
    Range ..

    Do not apply any --sys-* options to any events.

  • --verbose

    Command-Line Format--verbose
    -v
     Permitted Values
    Typeboolean
    Defaulttrue
    Range ..

    Turn on verbose output.

  • --loops=#

    Command-Line Format--loops=#
     Permitted Values
    Typenumeric
    Default0
    Range0 .. MAX_INT

    Repeat commands this number of times (for use in testing).

17.4.14. ndb_print_backup_file - Print NDB Backup File Contents

ndb_print_backup_file obtains diagnostic information from a cluster backup file.

Usage

ndb_print_backup_file file_name

file_name is the name of a cluster backup file. This can be any of the files (.Data, .ctl, or .log file) found in a cluster backup directory. These files are found in the data node's backup directory under the subdirectory BACKUP-#, where # is the sequence number for the backup. For more information about cluster backup files and their contents, see Section 17.5.3.1, "MySQL Cluster Backup Concepts".

Like ndb_print_schema_file and ndb_print_sys_file (and unlike most of the other NDB utilities that are intended to be run on a management server host or to connect to a management server) ndb_print_backup_file must be run on a cluster data node, since it accesses the data node file system directly. Because it does not make use of the management server, this utility can be used when the management server is not running, and even when the cluster has been completely shut down.

Additional Options

None.

17.4.15. ndb_print_schema_file - Print NDB Schema File Contents

ndb_print_schema_file obtains diagnostic information from a cluster schema file.

Usage

ndb_print_schema_file file_name

file_name is the name of a cluster schema file. For more information about cluster schema files, see MySQL Cluster Data Node FileSystemDir Files.

Like ndb_print_backup_file and ndb_print_sys_file (and unlike most of the other NDB utilities that are intended to be run on a management server host or to connect to a management server) ndb_schema_backup_file must be run on a cluster data node, since it accesses the data node file system directly. Because it does not make use of the management server, this utility can be used when the management server is not running, and even when the cluster has been completely shut down.

Additional Options

None.

17.4.16. ndb_print_sys_file - Print NDB System File Contents

ndb_print_sys_file obtains diagnostic information from a MySQL Cluster system file.

Usage

ndb_print_sys_file file_name

file_name is the name of a cluster system file (sysfile). Cluster system files are located in a data node's data directory (DataDir); the path under this directory to system files matches the pattern ndb_#_fs/D#/DBDIH/P#.sysfile. In each case, the # represents a number (not necessarily the same number). For more information, see MySQL Cluster Data Node FileSystemDir Files.

Like ndb_print_backup_file and ndb_print_schema_file (and unlike most of the other NDB utilities that are intended to be run on a management server host or to connect to a management server) ndb_print_backup_file must be run on a cluster data node, since it accesses the data node file system directly. Because it does not make use of the management server, this utility can be used when the management server is not running, and even when the cluster has been completely shut down.

Additional Options

None.

17.4.17. ndbd_redo_log_reader - Check and Print Content of Cluster Redo Log

Reads a redo log file, checking it for errors, printing its contents in a human-readable format, or both. ndbd_redo_log_reader is intended for use primarily by MySQL Cluster developers and Support personnel in debugging and diagnosing problems.

This utility remains under development, and its syntax and behavior are subject to change in future MySQL Cluster releases.

The C++ source files for ndbd_redo_log_reader can be found in the directory /storage/ndb/src/kernel/blocks/dblqh/redoLogReader.

The following table includes options that are specific to the MySQL Cluster program ndbd_redo_log_reader. Additional descriptions follow the table. For options common to most MySQL Cluster programs (including ndbd_redo_log_reader), see Section 17.4.24, "Options Common to MySQL Cluster Programs - Options Common to MySQL Cluster Programs".

Table 17.21. ndbd_redo_log_reader Options and Variables: MySQL 5.5

FormatDescriptionAdded / Removed

-noprint

Do not print records

All MySQL 5.5 based releases

-nocheck

Do not check records for errors

All MySQL 5.5 based releases


Usage

ndbd_redo_log_reader file_name [options]

file_name is the name of a cluster redo log file. redo log files are located in the numbered directories under the data node's data directory (DataDir); the path under this directory to the redo log files matches the pattern ndb_#_fs/D#/LCP/#/T#F#.Data. In each case, the # represents a number (not necessarily the same number). For more information, see MySQL Cluster Data Node FileSystemDir Files.

The name of the file to be read may be followed by one or more of the options listed here:

  • Command-Line Format-noprint
     Permitted Values
    Typeboolean
    DefaultFALSE

    -noprint: Do not print the contents of the log file.

  • Command-Line Format-nocheck
     Permitted Values
    Typeboolean
    DefaultFALSE

    -nocheck: Do not check the log file for errors.

Like ndb_print_backup_file and ndb_print_schema_file (and unlike most of the NDB utilities that are intended to be run on a management server host or to connect to a management server) ndbd_redo_log_reader must be run on a cluster data node, since it accesses the data node file system directly. Because it does not make use of the management server, this utility can be used when the management server is not running, and even when the cluster has been completely shut down.

17.4.18. ndb_restore - Restore a MySQL Cluster Backup

The cluster restoration program is implemented as a separate command-line utility ndb_restore, which can normally be found in the MySQL bin directory. This program reads the files created as a result of the backup and inserts the stored information into the database.

ndb_restore must be executed once for each of the backup files that were created by the START BACKUP command used to create the backup (see Section 17.5.3.2, "Using The MySQL Cluster Management Client to Create a Backup"). This is equal to the number of data nodes in the cluster at the time that the backup was created.

Note

Before using ndb_restore, it is recommended that the cluster be running in single user mode, unless you are restoring multiple data nodes in parallel. See Section 17.5.8, "MySQL Cluster Single User Mode", for more information.

The following table includes options that are specific to the MySQL Cluster native backup restoration program ndb_restore. Additional descriptions follow the table. For options common to most MySQL Cluster programs (including ndb_restore), see Section 17.4.24, "Options Common to MySQL Cluster Programs - Options Common to MySQL Cluster Programs".

Table 17.22. ndb_restore Options and Variables: MySQL 5.5

FormatDescriptionAdded / Removed

--connect,

-c

Same as connectstring

All MySQL 5.5 based releases

--nodeid=#,

-n

Back up files from node with this ID

All MySQL 5.5 based releases

--backupid=#,

-b

Restore from the backup with the given ID

All MySQL 5.5 based releases

--restore_data

Restore table data and logs into NDB Cluster using the NDB API

All MySQL 5.5 based releases

--restore_meta,

-m

Restore metadata to NDB Cluster using the NDB API

All MySQL 5.5 based releases

--no-upgrade,

-u

Do not upgrade array type for varsize attributes which do not already resize VAR data, and do not change column attributes

All MySQL 5.5 based releases

--promote-attributes,

-A

Allow attributes to be promoted when restoring data from backup

All MySQL 5.5 based releases

--preserve-trailing-spaces,

-P

Allow preservation of trailing spaces (including padding) when promoting fixed-width string types to variable-width types

All MySQL 5.5 based releases

--no-restore-disk-objects,

-d

Do not restore objects relating to Disk Data

All MySQL 5.5 based releases

--restore_epoch,

-e

Restore epoch info into the status table. Convenient on a MySQL Cluster replication slave for starting replication. The row in mysql.ndb_apply_status with id 0 will be updated/inserted.

All MySQL 5.5 based releases

--skip-table-check,

-s

Skip table structure check during restoring of data

All MySQL 5.5 based releases

--parallelism=#,

-p

Number of parallel transactions to use while restoring data

All MySQL 5.5 based releases

--print

Print metadata, data and log to stdout (equivalent to --print_meta --print_data --print_log)

All MySQL 5.5 based releases

--print_meta

Print metadata to stdout

All MySQL 5.5 based releases

--print_data

Print data to stdout

All MySQL 5.5 based releases

--print_log

Print to stdout

All MySQL 5.5 based releases

--backup_path=path

Path to backup files directory

All MySQL 5.5 based releases

--dont_ignore_systab_0,

-f

Do not ignore system table during restore. Experimental only; not for production use

All MySQL 5.5 based releases

--ndb-nodegroup-map=map,

-z

Nodegroup map for NDBCLUSTER storage engine. Syntax: list of (source_nodegroup, destination_nodegroup)

All MySQL 5.5 based releases

--fields-enclosed-by=char

Fields are enclosed with the indicated character

All MySQL 5.5 based releases

--fields-terminated-by=char

Fields are terminated by the indicated character

All MySQL 5.5 based releases

--fields-optionally-enclosed-by

Fields are optionally enclosed with the indicated character

All MySQL 5.5 based releases

--lines-terminated-by=char

Lines are terminated by the indicated character

All MySQL 5.5 based releases

--hex

Print binary types in hexadecimal format

All MySQL 5.5 based releases

--tab=path,

-T

Creates a tab-separated .txt file for each table in the given path

All MySQL 5.5 based releases

--append

Append data to a tab-delimited file

All MySQL 5.5 based releases

--progress-frequency=#

Print status of restoration each given number of seconds

All MySQL 5.5 based releases

--no-binlog

If a mysqld is connected and using binary logging, do not log the restored data

All MySQL 5.5 based releases

--verbose=#

Level of verbosity in output

All MySQL 5.5 based releases

--include-databases=db-list

List of one or more databases to restore (excludes those not named)

All MySQL 5.5 based releases

--exclude-databases=db-list

List of one or more databases to exclude (includes those not named)

All MySQL 5.5 based releases

--include-tables=table-list

List of one or more tables to restore (excludes those in same database that are not named); each table reference must include the database name

All MySQL 5.5 based releases

--exclude-tables=table-list

List of one or more tables to exclude (includes those in same database that are not not named); each table reference must include the database name

All MySQL 5.5 based releases

--exclude-missing-columns

Causes columns from the backup version of a table that are missing from the version of the table in the database to be ignored.

All MySQL 5.5 based releases

--disable-indexes

Causes indexes from a backup to be ignored; may decrease time needed to restore data.

All MySQL 5.5 based releases

--rebuild-indexes

Causes multi-threaded ordered index rebuilding of indexes found in the backup.

All MySQL 5.5 based releases

--skip-broken-objects

Causes missing blob tables in the backup file to be ignored.

All MySQL 5.5 based releases

--skip-unknown-objects

Causes schema objects not recognized by ndb_restore to be ignored when restoring a backup made from a newer MySQL Cluster version to an older version.

All MySQL 5.5 based releases

--rewrite-database=olddb,newdb

Restores to a database with a different name than the original

All MySQL 5.5 based releases

--lossy-conversions,

-L

Allow lossy conversions of column values (type demotions or changes in sign) when restoring data from backup

All MySQL 5.5 based releases

--restore-privilege-tables

Restore MySQL privilege tables that were previously moved to NDB.

All MySQL 5.5 based releases


Typical options for this utility are shown here:

ndb_restore [-c connectstring] -n node_id [-m] -b backup_id \ -r --backup_path=/path/to/backup/files

The -c option is used to specify a connectstring which tells ndb_restore where to locate the cluster management server. (See Section 17.3.2.3, "The MySQL Cluster Connectstring", for information on connectstrings.) If this option is not used, then ndb_restore attempts to connect to a management server on localhost:1186. This utility acts as a cluster API node, and so requires a free connection "slot" to connect to the cluster management server. This means that there must be at least one [api] or [mysqld] section that can be used by it in the cluster config.ini file. It is a good idea to keep at least one empty [api] or [mysqld] section in config.ini that is not being used for a MySQL server or other application for this reason (see Section 17.3.2.7, "Defining SQL and Other API Nodes in a MySQL Cluster").

You can verify that ndb_restore is connected to the cluster by using the SHOW command in the ndb_mgm management client. You can also accomplish this from a system shell, as shown here:

shell> ndb_mgm -e "SHOW"

-n is used to specify the node ID of the data node on which the backups were taken.

The first time you run the ndb_restore restoration program, you also need to restore the metadata. In other words, you must re-create the database tables-this can be done by running it with the -m option. Note that the cluster should have an empty database when starting to restore a backup. (In other words, you should start ndbd with --initial prior to performing the restore. You should also remove manually any Disk Data files present in the data node's DataDir.)

It is possible to restore data without restoring table metadata. The default behavior when doing this is for ndb_restore to fail with an error if table data do not match the table schema; this can be overridden using the --skip-table-check or -s option.

Some of the restrictions on mismatches in column definitions when restoring data using ndb_restore are relaxed; when one of these types of mismatches is encountered, ndb_restore does not stop with an error as it did previously, but rather accepts the data and inserts it into the target table while issuing a warning to the user that this is being done. This behavior occurs whether or not either of the options --skip-table-check or --promote-attributes is in use. These differences in column definitions are of the following types:

  • Different COLUMN_FORMAT settings (FIXED, DYNAMIC, DEFAULT)

  • Different STORAGE settings (MEMORY, DISK)

  • Different default values

  • Different distribution key settings

ndb_restore supports limited attribute promotion in much the same way that it is supported by MySQL replication; that is, data backed up from a column of a given type can generally be restored to a column using a "larger, similar" type. For example, data from a CHAR(20) column can be restored to a column declared as VARCHAR(20), VARCHAR(30), or CHAR(30); data from a MEDIUMINT column can be restored to a column of type INT or BIGINT. See Section 16.4.1.8.2, "Replication of Columns Having Different Data Types", for a table of type conversions currently supported by attribute promotion.

Attribute promotion by ndb_restore must be enabled explicitly, as follows:

  1. Prepare the table to which the backup is to be restored. ndb_restore cannot be used to re-create the table with a different definition from the original; this means that you must either create the table manually, or alter the columns which you wish to promote using ALTER TABLE after restoring the table metadata but before restoring the data.

  2. Invoke ndb_restore with the --promote-attributes option (short form -A) when restoring the table data. Attribute promotion does not occur if this option is not used; instead, the restore operation fails with an error.

--lossy-conversions, -L

Command-Line Format--lossy-conversions
-L
 Permitted Values
Typeboolean
DefaultFALSE

This option is intended to complement the --promote-attributes option. Using --lossy-conversions allows lossy conversions of column values (type demotions or changes in sign) when restoring data from backup. With some exceptions, the rules governing demotion are the same as for MySQL replication; see Section 16.4.1.8.2, "Replication of Columns Having Different Data Types", for information about specific type conversions currently supported by attribute demotion.

ndb_restore reports any truncation of data that it performs during lossy conversions once per attribute and column.

The --preserve-trailing-spaces option (short form -R) causes trailing spaces to be preserved when promoting a fixed-width character data type to its variable-width equivalent-that is, when promoting a CHAR column value to VARCHAR or a BINARY column value to VARBINARY. Otherwise, any trailing spaces are dropped from such column values when they are inserted into the new columns.

Note

Although you can promote CHAR columns to VARCHAR and BINARY columns to VARBINARY, you cannot promote VARCHAR columns to CHAR or VARBINARY columns to BINARY.

The -b option is used to specify the ID or sequence number of the backup, and is the same number shown by the management client in the Backup backup_id completed message displayed upon completion of a backup. (See Section 17.5.3.2, "Using The MySQL Cluster Management Client to Create a Backup".)

Important

When restoring cluster backups, you must be sure to restore all data nodes from backups having the same backup ID. Using files from different backups will at best result in restoring the cluster to an inconsistent state, and may fail altogether.

--restore_epoch (short form: -e) adds (or restores) epoch information to the cluster replication status table. This is useful for starting replication on a MySQL Cluster replication slave. When this option is used, the row in the mysql.ndb_apply_status having 0 in the id column is updated if it already exists; such a row is inserted if it does not already exist. (See Section 17.6.9, "MySQL Cluster Backups With MySQL Cluster Replication".)

--restore_data

This option causes ndb_restore to output NDB table data and logs.

--restore_meta

This option causes ndb_restore to print NDB table metadata.

--restore-privilege-tables

ndb_restore does not by default restore distributed MySQL privilege tables (MySQL Cluster NDB 7.2.0 and later). This option causes ndb_restore to restore the privilege tables.

This works only if the privilege tables were converted to NDB before the backup was taken. For more information, see Section 17.5.14, "Distributed MySQL Privileges for MySQL Cluster".

--backup_path

The path to the backup directory is required; this is supplied to ndb_restore using the --backup_path option, and must include the subdirectory corresponding to the ID backup of the backup to be restored. For example, if the data node's DataDir is /var/lib/mysql-cluster, then the backup directory is /var/lib/mysql-cluster/BACKUP, and the backup files for the backup with the ID 3 can be found in /var/lib/mysql-cluster/BACKUP/BACKUP-3. The path may be absolute or relative to the directory in which the ndb_restore executable is located, and may be optionally prefixed with backup_path=.

It is possible to restore a backup to a database with a different configuration than it was created from. For example, suppose that a backup with backup ID 12, created in a cluster with two database nodes having the node IDs 2 and 3, is to be restored to a cluster with four nodes. Then ndb_restore must be run twice-once for each database node in the cluster where the backup was taken. However, ndb_restore cannot always restore backups made from a cluster running one version of MySQL to a cluster running a different MySQL version. See Section 17.2.7, "Upgrading and Downgrading MySQL Cluster NDB 7.2", for more information.

Important

It is not possible to restore a backup made from a newer version of MySQL Cluster using an older version of ndb_restore. You can restore a backup made from a newer version of MySQL to an older cluster, but you must use a copy of ndb_restore from the newer MySQL Cluster version to do so.

For example, to restore a cluster backup taken from a cluster running MySQL Cluster NDB 7.2.5 to a cluster running MySQL Cluster NDB 7.1.21, you must use the ndb_restore that comes with the MySQL Cluster NDB 7.2.5 distribution.

For more rapid restoration, the data may be restored in parallel, provided that there is a sufficient number of cluster connections available. That is, when restoring to multiple nodes in parallel, you must have an [api] or [mysqld] section in the cluster config.ini file available for each concurrent ndb_restore process. However, the data files must always be applied before the logs.

--no-upgrade

When using ndb_restore to restore a backup, VARCHAR columns created using the old fixed format are resized and recreated using the variable-width format now employed. This behavior can be overridden using the --no-upgrade option (short form: -u) when running ndb_restore.

--print_data

The --print_data option causes ndb_restore to direct its output to stdout.

TEXT and BLOB column values are always truncated to the first 256 bytes in the output; this cannot currently be overridden when using --print_data.

Several additional options are available for use with the --print_data option in generating data dumps, either to stdout, or to a file. These are similar to some of the options used with mysqldump, and are shown in the following list:

  • --tab, -T

    Command-Line Format--tab=path
    -T

    This option causes --print_data to create dump files, one per table, each named tbl_name.txt. It requires as its argument the path to the directory where the files should be saved; use . for the current directory.

  • --fields-enclosed-by=string

    Command-Line Format--fields-enclosed-by=char
     Permitted Values
    Typestring
    Default

    Each column values are enclosed by the string passed to this option (regardless of data type; see next item).

  • --fields-optionally-enclosed-by=string

    Command-Line Format--fields-optionally-enclosed-by
     Permitted Values
    Typestring
    Default

    The string passed to this option is used to enclose column values containing character data (such as CHAR, VARCHAR, BINARY, TEXT, or ENUM).

  • --fields-terminated-by=string

    Command-Line Format--fields-terminated-by=char
     Permitted Values
    Typestring
    Default\t (tab)

    The string passed to this option is used to separate column values. The default value is a tab character (\t).

  • --hex

    Command-Line Format--hex

    If this option is used, all binary values are output in hexadecimal format.

  • --fields-terminated-by=string

    Command-Line Format--fields-terminated-by=char
     Permitted Values
    Typestring
    Default\t (tab)

    This option specifies the string used to end each line of output. The default is a linefeed character (\n).

  • --append

    Command-Line Format--append

    When used with the --tab and --print_data options, this causes the data to be appended to any existing files having the same names.

Note

If a table has no explicit primary key, then the output generated when using the --print_data option includes the table's hidden primary key.

--print_meta

This option causes ndb_restore to print all metadata to stdout.

--print_log

The --print_log option causes ndb_restore to output its log to stdout.

--print

Causes ndb_restore to print all data, metadata, and logs to stdout. Equivalent to using the --print_data, --print_meta, and --print_log options together.

Note

Use of --print or any of the --print_* options is in effect performing a dry run. Including one or more of these options causes any output to be redirected to stdout; in such cases, ndb_restore makes no attempt to restore data or metadata to a MySQL Cluster.

--dont_ignore_systab_0

Normally, when restoring table data and metadata, ndb_restore ignores the copy of the NDB system table that is present in the backup. --dont_ignore_systab_0 causes the system table to be restored. This option is intended for experimental and development use only, and is not recommended in a production environment.

--ndb-nodegroup-map, -z

This option can be used to restore a backup taken from one node group to a different node group. Its argument is a list of the form source_node_group, target_node_group.

--no-binlog

This option prevents any connected SQL nodes from writing data restored by ndb_restore to their binary logs.

--no-restore-disk-objects, -d

This option stops ndb_restore from restoring any MySQL Cluster Disk Data objects, such as tablespaces and log file groups; see Section 17.5.12, "MySQL Cluster Disk Data Tables", for more information about these.

--parallelism=#, -p

Determines the maximum number of parallel transactions that ndb_restore tries to use. By default, this is 128; the minimum is 1, and the maximum is 1024.

--progress-frequency=N

Print a status report each N seconds while the backup is in progress. 0 (the default) causes no status reports to be printed. The maximum is 65535.

--verbose=#

Sets the level for the verbosity of the output. The minimum is 0; the maximum is 255. The default value is 1.

It is possible to restore only selected databases, or selected tables from a single database, using the syntax shown here:

ndb_restore other_options db_name,[db_name[,...] | tbl_name[,tbl_name][,...]]

In other words, you can specify either of the following to be restored:

  • All tables from one or more databases

  • One or more tables from a single database

--include-databases=db_name[,db_name][,...]

Command-Line Format--include-databases=db-list
 Permitted Values
Typestring
Default

--include-tables=db_name.tbl_name[,db_name.tbl_name][,...]

Command-Line Format--include-tables=table-list
 Permitted Values
Typestring
Default

Use the --include-databases option or the --include-tables option for restoring only specific databases or tables, respectively. --include-databases takes a comma-delimited list of databases to be restored. --include-tables takes a comma-delimited list of tables (in database.table format) to be restored.

When --include-databases or --include-tables is used, only those databases or tables named by the option are restored; all other databases and tables are excluded by ndb_restore, and are not restored.

The following table shows several invocations of ndb_restore using --include-* options (other options possibly required have been omitted for clarity), and the effects these have on restoring from a MySQL Cluster backup:

Option UsedResult
--include-databases=db1Only tables in database db1 are restored; all tables in all other databases are ignored
--include-databases=db1,db2 (or --include-databases=db1 --include-databases=db2)Only tables in databases db1 and db2 are restored; all tables in all other databases are ignored
--include-tables=db1.t1Only table t1 in database db1 is restored; no other tables in db1 or in any other database are restored
--include-tables=db1.t2,db2.t1 (or --include-tables=db1.t2 --include-tables=db2.t1)Only the table t2 in database db1 and the table t1 in database db2 are restored; no other tables in db1, db2, or anyother database are restored

You can also use these two options together. For example, the following causes all tables in databases db1 and db2, together with the tables t1 and t2 in database db3, to be restored (and no other databases or tables):

shell> ndb_restore [...] --include-databases=db1,db2 --include-tables=db3.t1,db3.t2

(Again we have omitted other, possibly required, options in the example just shown.)

--exclude-databases=db_name[,db_name][,...]

Command-Line Format--exclude-databases=db-list
 Permitted Values
Typestring
Default

--exclude-tables=db_name.tbl_name[,db_name.tbl_name][,...]

Command-Line Format--exclude-tables=table-list
 Permitted Values
Typestring
Default

It is possible to prevent one or more databases or tables from being restored using the ndb_restore options --exclude-databases and --exclude-tables. --exclude-databases takes a comma-delimited list of one or more databases which should not be restored. --exclude-tables takes a comma-delimited list of one or more tables (using database.table format) which should not be restored.

When --exclude-databases or --exclude-tables is used, only those databases or tables named by the option are excluded; all other databases and tables are restored by ndb_restore.

This table shows several invocations of ndb_restore usng --exclude-* options (other options possibly required have been omitted for clarity), and the effects these options have on restoring from a MySQL Cluster backup:

Option UsedResult
--exclude-databases=db1All tables in all databases except db1 are restored; no tables in db1 are restored
--exclude-databases=db1,db2 (or --exclude-databases=db1 --exclude-databases=db2)All tables in all databases except db1 and db2 are restored; no tables in db1 or db2 are restored
--exclude-tables=db1.t1All tables except t1 in database db1 are restored; all other tables in db1 are restored; all tables in all other databases are restored
--exclude-tables=db1.t2,db2.t1 (or --exclude-tables=db1.t2 --exclude-tables=db2.t1)All tables in database db1 except for t2 and all tables in database db2 except for table t1 are restored; no other tables in db1 or db2 arerestored; all tables in all other databases are restored

You can use these two options together. For example, the following causes all tables in all databases except for databases db1 and db2, along with the tables t1 and t2 in database db3, not to be restored:

shell> ndb_restore [...] --exclude-databases=db1,db2 --exclude-tables=db3.t1,db3.t2

(Again, we have omitted other possibly necessary options in the interest of clarity and brevity from the example just shown.)

You can use --include-* and --exclude-* options together, subject to the following rules:

  • The actions of all --include-* and --exclude-* options are cumulative.

  • All --include-* and --exclude-* options are evaluated in the order passed to ndb_restore, from right to left.

  • In the event of conflicting options, the first (rightmost) option takes precedence. In other words, the first option (going from right to left) that matches against a given database or table "wins".

For example, the following set of options causes ndb_restore to restore all tables from database db1 except db1.t1, while restoring no other tables from any other databases:

  --include-databases=db1 --exclude-tables=db1.t1

However, reversing the order of the options just given simply causes all tables from database db1 to be restored (including db1.t1, but no tables from any other database), because the --include-databases option, being farthest to the right, is the first match against database db1 and thus takes precedence over any other option that matches db1 or any tables in db1:

  --exclude-tables=db1.t1 --include-databases=db1

--exclude-missing-columns

Command-Line Format--exclude-missing-columns

It is also possible to restore only selected table columns using the --exclude-missing-columns option. When this option is used, ndb_restore ignores any columns missing from tables being restored as compared to the versions of those tables found in the backup. This option applies to all tables being restored. If you wish to apply this option only to selected tables or databases, you can use it in combination with one or more of the options described in the previous paragraph to do so, then restore data to the remaining tables using a complementary set of these options.

--disable-indexes

Command-Line Format--disable-indexes

Disable restoration of indexes during restoration of the data from a native NDB backup. Afterwards, you can restore indexes for all tables at once with multi-threaded building of indexes using --rebuild-indexes, which should be faster than rebuilding indexes concurrently for very large tables.

--rebuild-indexes

Command-Line Format--rebuild-indexes

You can use this option with ndb_restore to cause multi-threaded rebuilding of the ordered indexes while restoring a native NDB backup.

--skip-broken-objects

Command-Line Format--skip-broken-objects

This option causes ndb_restore to ignore corrupt tables while reading a native NDB backup, and to continue restoring any remaining tables (that are not also corrupted). Currently, the --skip-broken-objects option works only in the case of missing blob parts tables.

--skip-unknown-objects

Command-Line Format--skip-unknown-objects

This option causes ndb_restore to ignore any schema objects it does not recognize while reading a native NDB backup. This can be used for restoring a backup made from a cluster running MySQL Cluster NDB 7.2 to a cluster running MySQL Cluster NDB 7.1.

--rewrite-database=old_dbname,new_dbname

Command-Line Format--rewrite-database=olddb,newdb
 Permitted Values
Typestring
Defaultnone

This option makes it possible to restore to a database having a different name from that used in the backup. For example, if a backup is made of a database named products, you can restore the data it contains to a database named inventory, use this option as shown here (omitting any other options that might be required):

shell> ndb_restore --rewrite-database=product,inventory

The option can be employed multiple times in a single invocation of ndb_restore. Thus it is possible to restore simultaneously from a database named db1 to a database named db2 and from a database named db3 to one named db4 using --rewrite-database=db1,db2 --rewrite-database=db3,db4. Other ndb_restore options may be used between multiple occurrences of --rewrite-database.

In the event of conflicts between multiple --rewrite-database options, the last --rewrite-database option used, reading from left to right, is the one that takes effect. For example, if --rewrite-database=db1,db2 --rewrite-database=db1,db3 is used, only --rewrite-database=db1,db3 is honored, and --rewrite-database=db1,db2 is ignored. It is also possible to restore from multiple databases to a single database, so that --rewrite-database=db1,db3 --rewrite-database=db2,db3 restores all tables and data from databases db1 and db2 into database db3.

Important

When restoring from multiple backup databases into a single target database using --rewrite-database, no check is made for collisions between table or other object names, and the order in which rows are restored is not guaranteed. This means that it is possible in such cases for rows to be overwritten and updates to be lost.

Error reporting. ndb_restore reports both temporary and permanent errors. In the case of temporary errors, it may able to recover from them, and reports Restore successful, but encountered temporary error, please look at configuration in such cases.

Important

After using ndb_restore to initialize a MySQL Cluster for use in circular replication, binary logs on the SQL node acting as the replication slave are not automatically created, and you must cause them to be created manually. To cause the binary logs to be created, issue a SHOW TABLES statement on that SQL node before running START SLAVE. This is a known issue in MySQL Cluster.

17.4.19. ndb_select_all - Print Rows from an NDB Table

ndb_select_all prints all rows from an NDB table to stdout.

Usage

ndb_select_all -c connect_string tbl_name -d db_name [> file_name]

The following table includes options that are specific to the MySQL Cluster native backup restoration program ndb_select_all. Additional descriptions follow the table. For options common to most MySQL Cluster programs (including ndb_select_all), see Section 17.4.24, "Options Common to MySQL Cluster Programs - Options Common to MySQL Cluster Programs".

Table 17.23. ndb_select_all Options and Variables: MySQL 5.5

FormatDescriptionAdded / Removed

--database=dbname,

-d

Name of the database in which the table is found

All MySQL 5.5 based releases

--parallelism=#,

-p

Degree of parallelism

All MySQL 5.5 based releases

--lock=#,

-l

Lock type

All MySQL 5.5 based releases

--order=index,

-o

Sort resultset according to index whose name is supplied

All MySQL 5.5 based releases

--descending,

-z

Sort resultset in descending order (requires order flag)

All MySQL 5.5 based releases

--header,

-h

Print header (set to 0|FALSE to disable headers in output)

All MySQL 5.5 based releases

--useHexFormat,

-x

Output numbers in hexadecimal format

All MySQL 5.5 based releases

--delimiter=char,

-D

Set a column delimiter

All MySQL 5.5 based releases

--disk

Print disk references (useful only for Disk Data tables having nonindexed columns)

All MySQL 5.5 based releases

--rowid

Print rowid

All MySQL 5.5 based releases

--gci

Include GCI in output

All MySQL 5.5 based releases

--tup,

-t

Scan in tup order

All MySQL 5.5 based releases

--nodata

Do not print table column data

All MySQL 5.5 based releases


  • --database=dbname, -d dbname

    Name of the database in which the table is found. The default value is TEST_DB.

  • parallelism=#, -p #

    Specifies the degree of parallelism.

  • --lock=lock_type, -l lock_type

    Employs a lock when reading the table. Possible values for lock_type are:

    • 0: Read lock

    • 1: Read lock with hold

    • 2: Exclusive read lock

    There is no default value for this option.

  • --order=index_name, -o index_name

    Orders the output according to the index named index_name. Note that this is the name of an index, not of a column, and that the index must have been explicitly named when created.

  • --descending, -z

    Sorts the output in descending order. This option can be used only in conjunction with the -o (--order) option.

  • --header=FALSE

    Excludes column headers from the output.

  • --useHexFormat -x

    Causes all numeric values to be displayed in hexadecimal format. This does not affect the output of numerals contained in strings or datetime values.

  • --delimiter=character, -D character

    Causes the character to be used as a column delimiter. Only table data columns are separated by this delimiter.

    The default delimiter is the tab character.

  • --disk

    Adds a disk reference column to the output. The column is nonempty only for Disk Data tables having nonindexed columns.

  • --rowid

    Adds a ROWID column providing information about the fragments in which rows are stored.

  • --gci

    Adds a column to the output showing the global checkpoint at which each row was last updated. See Section 17.1, "MySQL Cluster Overview", and Section 17.5.6.2, "MySQL Cluster Log Events", for more information about checkpoints.

  • --tupscan, -t

    Scan the table in the order of the tuples.

  • --nodata

    Causes any table data to be omitted.

Sample Output

Output from a MySQL SELECT statement:

mysql> SELECT * FROM ctest1.fish;+----+-----------+| id | name  |+----+-----------+|  3 | shark ||  6 | puffer ||  2 | tuna  ||  4 | manta ray ||  5 | grouper   ||  1 | guppy |+----+-----------+6 rows in set (0.04 sec)

Output from the equivalent invocation of ndb_select_all:

shell> ./ndb_select_all -c localhost fish -d ctest1id  name3   [shark]6   [puffer]2   [tuna]4   [manta ray]5   [grouper]1   [guppy]6 rows returnedNDBT_ProgramExit: 0 - OK

Note that all string values are enclosed by square brackets ("[...]") in the output of ndb_select_all. For a further example, consider the table created and populated as shown here:

CREATE TABLE dogs ( id INT(11) NOT NULL AUTO_INCREMENT, name VARCHAR(25) NOT NULL, breed VARCHAR(50) NOT NULL, PRIMARY KEY pk (id), KEY ix (name))TABLESPACE ts STORAGE DISKENGINE=NDBCLUSTER;INSERT INTO dogs VALUES ('', 'Lassie', 'collie'), ('', 'Scooby-Doo', 'Great Dane'), ('', 'Rin-Tin-Tin', 'Alsatian'), ('', 'Rosscoe', 'Mutt');

This demonstrates the use of several additional ndb_select_all options:

shell> ./ndb_select_all -d ctest1 dogs -o ix -z --gci --diskGCI id name  breed DISK_REF834461  2  [Scooby-Doo]  [Great Dane] [ m_file_no: 0 m_page: 98 m_page_idx: 0 ]834878  4  [Rosscoe] [Mutt]   [ m_file_no: 0 m_page: 98 m_page_idx: 16 ]834463  3  [Rin-Tin-Tin] [Alsatian]   [ m_file_no: 0 m_page: 34 m_page_idx: 0 ]835657  1  [Lassie]  [Collie] [ m_file_no: 0 m_page: 66 m_page_idx: 0 ]4 rows returnedNDBT_ProgramExit: 0 - OK

17.4.20. ndb_select_count - Print Row Counts for NDB Tables

ndb_select_count prints the number of rows in one or more NDB tables. With a single table, the result is equivalent to that obtained by using the MySQL statement SELECT COUNT(*) FROM tbl_name.

Usage

ndb_select_count [-c connect_string] -ddb_name tbl_name[, tbl_name2[, ...]]

The following table includes options that are specific to the MySQL Cluster native backup restoration program ndb_select_count. Additional descriptions follow the table. For options common to most MySQL Cluster programs (including ndb_select_count), see Section 17.4.24, "Options Common to MySQL Cluster Programs - Options Common to MySQL Cluster Programs".

Table 17.24. ndb_select_count Options and Variables: MySQL 5.5

FormatDescriptionAdded / Removed

--database=dbname,

-d

Name of the database in which the table is found

All MySQL 5.5 based releases

--parallelism=#,

-p

Degree of parallelism

All MySQL 5.5 based releases

--lock=#,

-l

Lock type

All MySQL 5.5 based releases


You can obtain row counts from multiple tables in the same database by listing the table names separated by spaces when invoking this command, as shown under Sample Output.

Sample Output

shell> ./ndb_select_count -c localhost -d ctest1 fish dogs6 records in table fish4 records in table dogsNDBT_ProgramExit: 0 - OK

17.4.21. ndb_show_tables - Display List of NDB Tables

ndb_show_tables displays a list of all NDB database objects in the cluster. By default, this includes not only both user-created tables and NDB system tables, but NDB-specific indexes, internal triggers, and MySQL Cluster Disk Data objects as well.

The following table includes options that are specific to the MySQL Cluster native backup restoration program ndb_show_tables. Additional descriptions follow the table. For options common to most MySQL Cluster programs (including ndb_show_tables), see Section 17.4.24, "Options Common to MySQL Cluster Programs - Options Common to MySQL Cluster Programs".

Table 17.25. ndb_show_tables Options and Variables: MySQL 5.5

FormatDescriptionAdded / Removed

--database=string,

-d

Specifies the database in which the table is found

All MySQL 5.5 based releases

--loops=#,

-l

Number of times to repeat output

All MySQL 5.5 based releases

--type=#,

-t

Limit output to objects of this type

All MySQL 5.5 based releases

--unqualified,

-u

Do not qualify table names

All MySQL 5.5 based releases

--parsable,

-p

Return output suitable for MySQL LOAD DATA INFILE statement

All MySQL 5.5 based releases

--show-temp-status

Show table temporary flag

All MySQL 5.5 based releases


Usage

ndb_show_tables [-c connect_string]
  • --database, -d

    Specifies the name of the database in which the tables are found.

  • --loops, -l

    Specifies the number of times the utility should execute. This is 1 when this option is not specified, but if you do use the option, you must supply an integer argument for it.

  • --parsable, -p

    Using this option causes the output to be in a format suitable for use with LOAD DATA INFILE.

  • --show-temp-status

    If specified, this causes temporary tables to be displayed.

  • --type, -t

    Can be used to restrict the output to one type of object, specified by an integer type code as shown here:

    • 1: System table

    • 2: User-created table

    • 3: Unique hash index

    Any other value causes all NDB database objects to be listed (the default).

  • --unqualified, -u

    If specified, this causes unqualified object names to be displayed.

Note

Only user-created MySQL Cluster tables may be accessed from MySQL; system tables such as SYSTAB_0 are not visible to mysqld. However, you can examine the contents of system tables using NDB API applications such as ndb_select_all (see Section 17.4.19, "ndb_select_all - Print Rows from an NDB Table").

17.4.22. ndb_size.pl - NDBCLUSTER Size Requirement Estimator

This is a Perl script that can be used to estimate the amount of space that would be required by a MySQL database if it were converted to use the NDBCLUSTER storage engine. Unlike the other utilities discussed in this section, it does not require access to a MySQL Cluster (in fact, there is no reason for it to do so). However, it does need to access the MySQL server on which the database to be tested resides.

Requirements

  • A running MySQL server. The server instance does not have to provide support for MySQL Cluster.

  • A working installation of Perl.

  • The DBI module, which can be obtained from CPAN if it is not already part of your Perl installation. (Many Linux and other operating system distributions provide their own packages for this library.)

  • A MySQL user account having the necessary privileges. If you do not wish to use an existing account, then creating one using GRANT USAGE ON db_name.*-where db_name is the name of the database to be examined-is sufficient for this purpose.

ndb_size.pl can also be found in the MySQL sources in storage/ndb/tools.

The following table includes options that are specific to the MySQL Cluster program ndb_size.pl. Additional descriptions follow the table. For options common to most MySQL Cluster programs (including ndb_size.pl), see Section 17.4.24, "Options Common to MySQL Cluster Programs - Options Common to MySQL Cluster Programs".

Table 17.26. ndb_size.pl Options and Variables: MySQL 5.5

FormatDescriptionAdded / Removed

--database=dbname

The database or databases to examine; accepts a comma-delimited list; the default is ALL (use all databases found on the server)

All MySQL 5.5 based releases

--hostname[:port]

Specify host and optional port as host[:port]

All MySQL 5.5 based releases

--socket=file

Specify a socket to connect to

All MySQL 5.5 based releases

--user=string

Specify a MySQL user name

All MySQL 5.5 based releases

--password=string

Specify a MySQL user password

All MySQL 5.5 based releases

--format=string

Set output format (text or HTML)

All MySQL 5.5 based releases

--excludetables=tbl_list

Skip any tables in a comma-separated list of tables

All MySQL 5.5 based releases

--excludedbs=db_list

Skip any databases in a comma-separated list of databases

All MySQL 5.5 based releases

--savequeries=file

Saves all queries to the database into the file specified

All MySQL 5.5 based releases

--loadqueries=file

Loads all queries from the file specified; does not connect to a database

All MySQL 5.5 based releases

--real_table_name=table

Designates a table to handle unique index size calculations

All MySQL 5.5 based releases


Usage

perl ndb_size.pl [--database={db_name|ALL}] [--hostname=host[:port]] [--socket=socket] \  [--user=user] [--password=password]  \   [--help|-h] [--format={html|text}] \   [--loadqueries=file_name] [--savequeries=file_name]

By default, this utility attempts to analyze all databases on the server. You can specify a single database using the --database option; the default behavior can be made explicit by using ALL for the name of the database. You can also exclude one or more databases by using the --excludedbs option with a comma-separated list of the names of the databases to be skipped. Similarly, you can cause specific tables to be skipped by listing their names, separated by commas, following the optional --excludetables option. A host name can be specified using --hostname; the default is localhost. In MySQL Cluster NDB 7.2.6 and later, you can specify a port in addition to the host using host:port format for the value of --hostname. The default port number is 3306. If necessary, you can also specify a socket; the default is /var/lib/mysql.sock. A MySQL user name and password can be specified the corresponding options shown. It also possible to control the format of the output using the --format option; this can take either of the values html or text, with text being the default. An example of the text output is shown here:

shell> ndb_size.pl --database=test --socket=/tmp/mysql.sockndb_size.pl report for database: 'test' (1 tables)--------------------------------------------------Connected to: DBI:mysql:host=localhost;mysql_socket=/tmp/mysql.sockIncluding information for versions: 4.1, 5.0, 5.1test.t1-------DataMemory for Columns (* means varsized DataMemory): Column Name Type  Varsized   Key  4.1  5.0   5.1 HIDDEN_NDB_PKEY  bigint PRI 8 8 8  c2 varchar(50) Y 52   52 4*  c1 int(11) 4 4 4   --   -- --Fixed Size Columns DM/Row  64   64 12   Varsize Columns DM/Row   0 0 4DataMemory for Indexes:   Index Name Type 4.1 5.0 5.1  PRIMARY BTREE 16 16 16   -- -- --   Total Index DM/Row  16 16 16IndexMemory for Indexes:   Index Name 4.1 5.0 5.1  PRIMARY 33 16 16  -- -- --   Indexes IM/Row 33 16 16Summary (for THIS table): 4.1 5.0 5.1 Fixed Overhead DM/Row 12 12 16   NULL Bytes/Row  4  4  4   DataMemory/Row 96 96 48  (Includes overhead, bitmap and indexes)  Varsize Overhead DM/Row  0  0  8   Varsize NULL Bytes/Row  0  0  4   Avg Varside DM/Row  0  0 16 No. Rows  0  0  0 Rows/32kb DM Page 340 340 680Fixedsize DataMemory (KB)  0  0  0Rows/32kb Varsize DM Page  0  0   2040  Varsize DataMemory (KB)  0  0  0 Rows/8kb IM Page 248 512 512 IndexMemory (KB)  0  0  0Parameter Minimum Requirements------------------------------* indicates greater than default Parameter Default 4.1 5.0 5.1  DataMemory (KB)   81920  0   0   0   NoOfOrderedIndexes 128  1   1   1   NoOfTables 128  1   1   1 IndexMemory (KB)   18432  0   0   0 NoOfUniqueHashIndexes  64  0   0   0   NoOfAttributes 1000  3   3   3 NoOfTriggers 768  5   5   5

For debugging purposes, the Perl arrays containing the queries run by this script can be read from the file specified using can be saved to a file using --savequeries; a file containing such arrays to be read in during script execution can be specified using --loadqueries. Neither of these options has a default value.

To produce output in HTML format, use the --format option and redirect the output to a file, as shown here:

shell> ndb_size.pl --database=test --socket=/tmp/mysql.sock --format=html > ndb_size.html

(Without the redirection, the output is sent to stdout.)

The output from this script includes the following information:

17.4.23. ndb_waiter - Wait for MySQL Cluster to Reach a Given Status

ndb_waiter repeatedly (each 100 milliseconds) prints out the status of all cluster data nodes until either the cluster reaches a given status or the --timeout limit is exceeded, then exits. By default, it waits for the cluster to achieve STARTED status, in which all nodes have started and connected to the cluster. This can be overridden using the --no-contact and --not-started options.

The node states reported by this utility are as follows:

  • NO_CONTACT: The node cannot be contacted.

  • UNKNOWN: The node can be contacted, but its status is not yet known. Usually, this means that the node has received a START or RESTART command from the management server, but has not yet acted on it.

  • NOT_STARTED: The node has stopped, but remains in contact with the cluster. This is seen when restarting the node using the management client's RESTART command.

  • STARTING: The node's ndbd process has started, but the node has not yet joined the cluster.

  • STARTED: The node is operational, and has joined the cluster.

  • SHUTTING_DOWN: The node is shutting down.

  • SINGLE USER MODE: This is shown for all cluster data nodes when the cluster is in single user mode.

The following table includes options that are specific to the MySQL Cluster native backup restoration program ndb_waiter. Additional descriptions follow the table. For options common to most MySQL Cluster programs (including ndb_waiter), see Section 17.4.24, "Options Common to MySQL Cluster Programs - Options Common to MySQL Cluster Programs".

Table 17.27. ndb_waiter Options and Variables: MySQL 5.5

FormatDescriptionAdded / Removed

--no-contact,

-n

Wait for cluster to reach NO CONTACT state

All MySQL 5.5 based releases

--not-started

Wait for cluster to reach NOT STARTED state

All MySQL 5.5 based releases

--single-user

Wait for cluster to enter single user mode

All MySQL 5.5 based releases

--timeout=#,

-t

Wait this many seconds, then exit whether or not cluster has reached desired state; default is 2 minutes (120 seconds)

All MySQL 5.5 based releases

--nowait-nodes=list

List of nodes not to be waited for.

All MySQL 5.5 based releases

--wait-nodes=list,

-w

List of nodes to be waited for.

All MySQL 5.5 based releases


Usage

ndb_waiter [-c connect_string]

Additional Options

  • --no-contact, -n

    Instead of waiting for the STARTED state, ndb_waiter continues running until the cluster reaches NO_CONTACT status before exiting.

  • --not-started

    Instead of waiting for the STARTED state, ndb_waiter continues running until the cluster reaches NOT_STARTED status before exiting.

  • --timeout=seconds, -t seconds

    Time to wait. The program exits if the desired state is not achieved within this number of seconds. The default is 120 seconds (1200 reporting cycles).

  • --single-user

    The program waits for the cluster to enter single user mode.

  • --nowait-nodes=list

    When this option is used, ndb_waiter does not wait for the nodes whose IDs are listed. The list is comma-delimited; ranges can be indicated by dashes, as shown here:

    shell> ndb_waiter --nowait-nodes=1,3,7-9
    Important

    Do not use this option together with the --wait-nodes option.

  • --wait-nodes=list, -w list

    When this option is used, ndb_waiter waits only for the nodes whose IDs are listed. The list is comma-delimited; ranges can be indicated by dashes, as shown here:

    shell> ndb_waiter --wait-nodes=2,4-6,10
    Important

    Do not use this option together with the --nowait-nodes option.

Sample Output. Shown here is the output from ndb_waiter when run against a 4-node cluster in which two nodes have been shut down and then started again manually. Duplicate reports (indicated by "...") are omitted.

shell> ./ndb_waiter -c localhostConnecting to mgmsrv at (localhost)State node 1 STARTEDState node 2 NO_CONTACTState node 3 STARTEDState node 4 NO_CONTACTWaiting for cluster enter state STARTED...State node 1 STARTEDState node 2 UNKNOWNState node 3 STARTEDState node 4 NO_CONTACTWaiting for cluster enter state STARTED...State node 1 STARTEDState node 2 STARTINGState node 3 STARTEDState node 4 NO_CONTACTWaiting for cluster enter state STARTED...State node 1 STARTEDState node 2 STARTINGState node 3 STARTEDState node 4 UNKNOWNWaiting for cluster enter state STARTED...State node 1 STARTEDState node 2 STARTINGState node 3 STARTEDState node 4 STARTINGWaiting for cluster enter state STARTED...State node 1 STARTEDState node 2 STARTEDState node 3 STARTEDState node 4 STARTINGWaiting for cluster enter state STARTED...State node 1 STARTEDState node 2 STARTEDState node 3 STARTEDState node 4 STARTEDWaiting for cluster enter state STARTEDNDBT_ProgramExit: 0 - OK
Note

If no connectstring is specified, then ndb_waiter tries to connect to a management on localhost, and reports Connecting to mgmsrv at (null).

17.4.24. Options Common to MySQL Cluster Programs - Options Common to MySQL Cluster Programs

All MySQL Cluster programs accept the options described in this section, with the following exceptions:

Users of earlier MySQL Cluster versions should note that some of these options have been changed to make them consistent with one another as well as with mysqld. You can use the --help option with any MySQL Cluster program-with the exception of ndb_print_backup_file, ndb_print_schema_file, and ndb_print_sys_file-to view a list of the options which the program supports.

The options in the following table are common to all MySQL Cluster executables (except those noted previously in this section).

Table 17.28. Common MySQL Cluster Program Options and Variables: MySQL 5.5

FormatDescriptionAdded / Removed

--help,

--usage,

-?

Display help message and exit

All MySQL 5.5 based releases

--ndb-connectstring=connectstring,

--connect-string=connectstring,

-c

Set connectstring for connecting to ndb_mgmd. Syntax: [nodeid=<id>][host=]<hostname>[:<port>]. Overrides entries specified in NDB_CONNECTSTRING or my.cnf.

All MySQL 5.5 based releases

--ndb-mgmd-host=host[:port]

Set the host (and port, if desired) for connecting to the management server

All MySQL 5.5 based releases

--ndb-nodeid=#

Set node id for this node

All MySQL 5.5 based releases

--ndb-optimized-node-selection

Select nodes for transactions in a more optimal way

All MySQL 5.5 based releases

--character-sets-dir=path

Directory where character sets are

All MySQL 5.5 based releases

--debug=options

Enable output from debug calls. Can be used only for versions compiled with debugging enabled

All MySQL 5.5 based releases

--core-file

Write core on errors (defaults to TRUE in debug builds)

All MySQL 5.5 based releases

--version,

-V

Output version information and exit

All MySQL 5.5 based releases


For options specific to individual MySQL Cluster programs, see Section 17.4, "MySQL Cluster Programs".

See Section 17.3.4.2, "MySQL Server Options for MySQL Cluster", for mysqld options relating to MySQL Cluster.

  • --help, --usage, -?

    Command-Line Format--help
    --usage
    -?

    Prints a short list with descriptions of the available command options.

  • --character-sets-dir=name

    Command-Line Format--character-sets-dir=path
     Permitted Values
    Typefile name
    Default

    Tells the program where to find character set information.

  • --ndb-connectstring=connect_string, --connect-string=connect_string, -c connect_string

    Command-Line Format--ndb-connectstring=connectstring
    --connect-string=connectstring
    -c
     Permitted Values
    Typestring
    Defaultlocalhost:1186

    This option takes a MySQL Cluster connectstring that specifies the management server for the application to connect to, as shown here:

    shell> ndbd --ndb-connectstring="nodeid=2;host=ndb_mgmd.mysql.com:1186"

    For more information, see Section 17.3.2.3, "The MySQL Cluster Connectstring".

  • --core-file

    Command-Line Format--core-file
     Permitted Values
    Typeboolean
    DefaultFALSE

    Write a core file if the program dies. The name and location of the core file are system-dependent. (For MySQL Cluster programs nodes running on Linux, the default location is the program's working directory-for a data node, this is the node's DataDir.) For some systems, there may be restrictions or limitations; for example, it might be necessary to execute ulimit -c unlimited before starting the server. Consult your system documentation for detailed information.

    If MySQL Cluster was built using the --debug option for configure, then --core-file is enabled by default. For regular builds, --core-file is disabled by default.

  • --debug[=options]

    Command-Line Format--debug=options
     Permitted Values
    Typestring
    Defaultd:t:O,/tmp/ndb_restore.trace

    This option can be used only for versions compiled with debugging enabled. It is used to enable output from debug calls in the same manner as for the mysqld process.

  • --ndb-mgmd-host=host[:port]

    Command-Line Format--ndb-mgmd-host=host[:port]
    Option-File Formatndb-mgmd-host
     Permitted Values
    Typestring
    Defaultlocalhost:1186

    Can be used to set the host and port number of a single management server for the program to connect to. If the program requires node IDs or references to multiple management servers (or both) in its connection information, use the --ndb-connectstring option instead.

  • --ndb-nodeid=#

    Command-Line Format--ndb-nodeid=#
     Permitted Values
    Typenumeric
    Default0

    Sets this node's MySQL Cluster node ID. The range of permitted values depends on the node's type (data, management, or API) and the MySQL Cluster software version. See Section 17.1.6.2, "Limits and Differences of MySQL Cluster from Standard MySQL Limits", for more information.

  • --ndb-optimized-node-selection

    Command-Line Format--ndb-optimized-node-selection
     Permitted Values
    Typeboolean
    DefaultTRUE

    Optimize selection of nodes for transactions. Enabled by default.

  • --version, -V

    Command-Line Format--version
    -V

    Prints the MySQL Cluster version number of the executable. The version number is relevant because not all versions can be used together, and the MySQL Cluster startup process verifies that the versions of the binaries being used can co-exist in the same cluster. This is also important when performing an online (rolling) software upgrade or downgrade of MySQL Cluster.

    See Section 17.5.5, "Performing a Rolling Restart of a MySQL Cluster"), for more information.

Copyright © 1997, 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices
(Sebelumnya) 17.3.3. Overview of MySQL Clus ...17.5. Management of MySQL Cluster (Berikutnya)