Personal tools
You are here: Home Docs MySQL Cluster Excerpt 5.1 Chapter 6. MySQL Cluster Programs

Chapter 6. MySQL Cluster Programs

Chapter 6. MySQL Cluster Programs

Table of Contents

6.1. MySQL Server Usage for MySQL Cluster
6.2. ndbd — The MySQL Cluster Data Node Daemon
6.3. ndbmtd — The MySQL Cluster Data Node Daemon (Multi-Threaded)
6.4. ndb_mgmd — The MySQL Cluster Management Server Daemon
6.5. ndb_mgm — The MySQL Cluster Management Client
6.6. ndb_config — Extract MySQL Cluster Configuration Information
6.7. ndb_cpcd — Automate Testing for NDB Development
6.8. ndb_delete_all — Delete All Rows from an NDB Table
6.9. ndb_desc — Describe NDB Tables
6.10. ndb_drop_index — Drop Index from an NDB Table
6.11. ndb_drop_table — Drop an NDB Table
6.12. ndb_error_reporter — NDB Error-Reporting Utility
6.13. ndb_print_backup_file — Print NDB Backup File Contents
6.14. ndb_print_schema_file — Print NDB Schema File Contents
6.15. ndb_print_sys_file — Print NDB System File Contents
6.16. ndbd_redo_log_reader — Check and Print Content of Cluster Redo Log
6.17. ndb_restore — Restore a MySQL Cluster Backup
6.18. ndb_select_all — Print Rows from an NDB Table
6.19. ndb_select_count — Print Row Counts for NDB Tables
6.20. ndb_show_tables — Display List of NDB Tables
6.21. ndb_size.pl — NDBCLUSTER Size Requirement Estimator
6.22. ndb_waiter — Wait for MySQL Cluster to Reach a Given Status
6.23. Options Common to MySQL Cluster Programs
6.24. Summary Tables of NDB Program Options
6.24.1. Common Options for MySQL Cluster Programs
6.24.2. Program Options for ndbd and ndbmtd
6.24.3. Program Options for ndb_mgmd
6.24.4. Program Options for ndb_mgm
6.24.5. Program Options for ndbd_redo_log_reader
6.24.6. Program Options for ndb_config
6.24.7. Program Options for ndb_error_reporter
6.24.8. Program Options for ndb_restore
6.24.9. Program Options for ndb_show_tables
6.24.10. Program Options for ndb_size.pl

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 process daemons (ndbd, ndb_mgmd, and mysqld) and the management client (ndb_mgm).

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 covered later in this chapter.

The last two sections of this chapter contain tables of options used, respectively, with mysqld and with the various NDB programs.

6.1. MySQL Server Usage for MySQL Cluster

mysqld is the traditional MySQL server process. To be used with MySQL Cluster, mysqld needs to be built with support for the NDBCLUSTER storage engine, as it is in the precompiled binaries available from http://dev.mysql.com/downloads/. If you build MySQL from source, you must invoke configure with the --with-ndbcluster option to enable NDB Cluster storage engine support.

If the mysqld binary has been built with Cluster support, the NDBCLUSTER storage engine is still disabled by default. You can use either of two possible options to enable this engine:

  • Use --ndbcluster as a startup option on the command line when starting mysqld.

  • Insert a line containing NDBCLUSTER in the [mysqld] section of your my.cnf file.

An easy way to verify that your server is running with the NDBCLUSTER storage engine enabled is to issue the SHOW ENGINES statement in the MySQL Monitor (mysql). You should see the value YES as the Support value in the row for NDBCLUSTER. If you see NO in this row or if there is no such row displayed in the output, you are not running an NDB-enabled version of MySQL. If you see DISABLED in this row, you need to enable it in either one of the two ways just described.

To read cluster configuration data, the MySQL server requires at a minimum three pieces of information:

  • The MySQL server's own cluster node ID

  • The host name or IP address for the management server (MGM node)

  • The number of the TCP/IP port on which it can connect to the management server

Node IDs can be allocated dynamically, so it is not strictly necessary to specify them explicitly.

The mysqld parameter ndb-connectstring is used to specify the connectstring either on the command line when starting mysqld or in my.cnf. The connectstring contains the host name or IP address where the management server can be found, as well as the TCP/IP port it uses.

In the following example, ndb_mgmd.mysql.com is the host where the management server resides, and the management server listens for cluster messages on port 1186:

shell> mysqld --ndbcluster --ndb-connectstring=ndb_mgmd.mysql.com:1186

See Section 3.4.3, “The MySQL Cluster Connectstring”, for more information on connectstrings.

Given this information, the MySQL server will be a full participant in the cluster. (We often refer to a mysqld process running in this manner as an SQL node.) It will be fully aware of all cluster data nodes as well as their status, and will establish connections to all data nodes. In this case, it is able to use any data node as a transaction coordinator and to read and update node data.

You can see in the mysql client whether a MySQL server is connected to the cluster using SHOW PROCESSLIST. If the MySQL server is connected to the cluster, and you have the PROCESS privilege, then the first row of the output is as shown here:

mysql> SHOW PROCESSLIST \G
*************************** 1. row ***************************
     Id: 1
   User: system user
   Host:
     db:
Command: Daemon
   Time: 1
  State: Waiting for event from ndbcluster
   Info: NULL

Important

To participate in a MySQL Cluster, the mysqld process must be started with both the options --ndbcluster and --ndb-connectstring (or their equivalents in my.cnf). If mysqld is started with only the --ndbcluster option, or if it is unable to contact the cluster, it is not possible to work with NDB tables, nor is it possible to create any new tables regardless of storage engine. The latter restriction is a safety measure intended to prevent the creation of tables having the same names as NDB tables while the SQL node is not connected to the cluster. If you wish to create tables using a different storage engine while the mysqld process is not participating in a MySQL Cluster, you must restart the server without the --ndbcluster option.

6.2. 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 list describes command options specific to the MySQL Cluster data node program ndbd.

Note

All of these options also apply to the multi-threaded version of this program — ndbmtd, which is available in MySQL Cluster NDB 7.0 — and you may substitute “ndbmtd” for “ndbd” wherever the latter occurs in this section.

For options common to all NDBCLUSTER programs, see Section 6.23, “Options Common to MySQL Cluster Programs”.

  • --bind-address

    Version Introduced5.1.12
    Command Line Format--bind-address=name
    Value Set
    Typestring
    Default

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

    This option was added in MySQL 5.1.12.

  • --daemon, -d

    Command Line Format--daemon
    Value Set
    Typeboolean
    DefaultTRUE

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

  • --initial

    Command Line Format--initial
    Value Set
    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 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.

    Important

    This option does not affect either of the following:

    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

    Version Introduced5.1.11
    Command Line Format--initial-start
    Value Set
    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.

    For example, suppose 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:

    ndbd --ndbd-nodeid=2 --nowait-nodes=3 --initial-start
    ndbd --ndbd-nodeid=4 --nowait-nodes=3 --initial-start
    ndbd --ndbd-nodeid=5 --nowait-nodes=3 --initial-start
    

    This option was added in MySQL 5.1.11.

    Important

    Prior to MySQL 5.1.19, it was not possible to perform DDL operations involving Disk Data tables on a partially started cluster. (See Bug#24631.)

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

    Version Introduced5.1.11
    Command Line Format--nowait-nodes=list
    Value Set
    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.

    This option was added in MySQL 5.1.9.

  • --nodaemon

    Command Line Format--nodaemon
    Value Set
    Typeboolean
    DefaultFALSE

    Instructs ndbd not to start as a daemon process. This is useful when ndbd is being debugged and you want output to be redirected to the screen.

  • --nostart, -n

    Command Line Format--nostart
    Value Set
    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 7.2, “Commands in the MySQL Cluster Management Client”).

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:01
    Type of error: error
    Message: Internal program error (failed ndbrequire)
    Fault ID: 2341
    Problem data: DbtupFixAlloc.cpp
    Object of reference: DBTUP (Line: 173)
    ProgramName: NDB Kernel
    ProcessID: 14909
    TraceFile: 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 3.4.3, “The MySQL Cluster Connectstring”, for additional information about this issue. Section 6.2, “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 via 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.1 in a production setting. See Chapter 12, Known Limitations of MySQL Cluster.

6.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 6.2, “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 6.24.2, “Program Options for ndbd and ndbmtd, and Section 3.4.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.

Important

We do not currently recommend using ndbmtd with MySQL Cluster Disk Data tables in production, due to known issues which we are working to fix in a future MySQL Cluster release. (Bug#41915, Bug#44915)

Using ndbmtd differs from using ndbd in two key respects:

  1. You must set an appropriate value for the MaxNoOfExecutionThreads configuration parameter in the config.ini file. If you do not do so, ndbmtd runs in single-threaded mode — that is, it behaves like ndbd.

  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.

Number of execution threads.  The MaxNoOfExecutionThreads configuration parameter is used to determine the number of local query handler (LQH) threads spawned by ndbmtd. Although this parameter is set in [ndbd] or [ndbd default] sections of the config.ini file, it is exclusive to ndbmtd and does not apply to ndbd.

This parameter takes an integer value from 2 to 8 inclusive. Generally, you should set this to the number of CPU cores on the data node host, as shown in the following table:

Number of CoresRecommended MaxNoOfExecutionThreads Value
22
44
8 or more8

(It is possible to set this parameter to other values within the permitted range, but these are automatically rounded as shown in the Value Used column of the next table in this section.)

The multi-threaded data node process always spawns at least 4 threads:

  • 1 local query handler (LQH) thread

  • 1 transaction coordinator (TC) thread

  • 1 transporter thread

  • 1 subscription manager (SUMA) thread

Setting this parameter to a value between 4 and 8 inclusive causes additional LQH threads to be used by ndbmtd (up to a maximum of 4 LQH threads), as shown in the following table:

config.ini ValueValue UsedNumber of LQH Threads Used
321
5 or 642
784

Setting this parameter outside the permitted range of values causes the management server to abort on startup with the error Error line number: Illegal value value for parameter MaxNoOfExecutionThreads.

Note

In MySQL Cluster NDB 6.4.0, it is not possible to set MaxNoOfExecutionThreads to 2. You can safely use the value 3 instead (it is treated as 2 internally). This issue is resolved in MySQL Cluster NDB 6.4.1.

In MySQL Cluster NDB 6.4.0 through 6.4.3, the default value for this parameter was undefined, although the default behavior for ndbmtd was to use 1 LQH thread, as though MaxNoOfExecutionThreads had been set to 2. Beginning with MySQL Cluster NDB 7.0.4, this parameter has an explcit default value of 2, thus guaranteeing this default behavior.

In MySQL Cluster NDB 7.0, it is not possible to cause ndbmtd to use more than 1 TC thread, although we plan to introduce this capability in a future MySQL Cluster release series.

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 follow the pattern ndb_node_id_trace.log.trace_id_tthread_id, where node_id is 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 not recommend doing so in a production setting at this time.

6.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 list includes options that are specific to ndb_mgmd. For options common to all NDB programs, see Section 6.23, “Options Common to MySQL Cluster Programs”.

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

    Version Introduced5.1.22-ndb-6.3.2
    Command Line Format--bind-address
    Value Set
    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.

    This option was added in MySQL Cluster NDB 6.2.5 and MySQL Cluster NDB 6.3.2.

  • --configdir=directory

    Version Introduced5.1.30-ndb-6.4.0
    Command Line Format--configdir=directory
    Value Set
    Typefilename
    Default$INSTALLDIR/mysql-cluster

    Beginning with MySQL Cluster NDB 6.4.0, configuration data is cached internally rather than being read from the cluster global configuration file each time the management server is started (see Section 3.4, “MySQL Cluster Configuration Files”). This option instructs the management server to its configuration cache in the directory indicated. By default, this is a directory named mysql-cluster in the MySQL installation directory — for example, if you compile and install MySQL Cluster on a Unix system using the default location, this is /usr/local/mysql-cluster.

    This behavior can be overridden using the --initial or --reload option for ndb_mgmd. Each of these options is described elsewhere in this section.

    This option is available beginning with MySQL Cluster NDB 6.4.0.

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

    Command Line Format-c
    Value Set
    Typefilename
    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.

    Beginning with MySQL Cluster NDB 6.4.0, 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. See Section 3.4, “MySQL Cluster Configuration Files”, for more information.

  • --daemon, -d

    Command Line Format--daemon
    Value Set
    Typeboolean
    DefaultTRUE

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

  • --initial

    Version Introduced5.1.30-ndb-6.4.0
    Command Line Format--initial
    Value Set
    Typeboolean
    DefaultFALSE

    Beginning with MySQL Cluster NDB 6.4.0, configuration data is cached internally rather than being read from the cluster global configuration file each time the management server is started (see Section 3.4, “MySQL Cluster Configuration Files”). Using this 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.

    This option was introduced in MySQL Cluster NDB 6.4.0.

  • --nodaemon

    Command Line Format--nodaemon
    Value Set
    Typeboolean
    DefaultFALSE

    Instructs ndb_mgmd not to start as a daemon process.

  • --print-full-config, -P

    Command Line Format--print-full-config
    Value Set
    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

    Version Introduced5.1.30-ndb-6.4.0
    Command Line Format--reload
    Value Set
    Typeboolean
    DefaultFALSE

    Beginning with MySQL Cluster NDB 6.4.0, configuration data is stored internally rather than being read from the cluster global configuration file each time the management server is started (see Section 3.4, “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.

    This option was introduced in MySQL Cluster NDB 6.4.0.

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 3.4.3, “The MySQL Cluster Connectstring”, for information about using connectstrings. Section 6.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. Chapter 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 Chapter 7, 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.

6.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 list includes options that are specific to ndb_mgm. For options common to all NDB programs, see Section 6.23, “Options Common to MySQL Cluster Programs”.

  • --try-reconnect=number

    Command Line Format--try-reconnect=#
    Value Set
    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 6.24.4, “Program Options for ndb_mgm, and Section 7.2, “Commands in the MySQL Cluster Management Client”.

6.6. ndb_config — Extract MySQL Cluster Configuration Information

This tool extracts current configuration information for data nodes, SQL nodes, and API nodes from a cluster management node (and possibly its config.ini file). Beginning with MySQL Cluster NDB 6.3.25 and MySQL Cluster NDB 7.0.6, it can also provide an offline dump (in text or XML format) of all configuration parameters which can be used, along with their default, maximum, and minimum values and other information (see the discussion of the --configinfo and --xml options later in this section).

Usage:

ndb_config options

The options available for this utility differ somewhat from those used with the other utilities, and so are listed in their entirety in the next section, followed by some examples.

Options:

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

    Command Line Format--help

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

  • --version, -V

    Command Line Format-V

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

  • --ndb-connectstring=connect_string

    Command Line Format--ndb-connectstring=name
    Value Set
    Typestring
    Defaultlocalhost:1186

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

    The use of -c as a short version for this option is supported for ndb_config beginning with MySQL 5.1.12.

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

    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.

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

    Command Line Format--query=string
    Value Set
    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 would return 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
    Value Set
    Typestring
    Default

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

  • --id=node_id, --nodeid=node_id

    Command Line Format--ndb-nodeid=#
    Value Set
    Typenumeric
    Default0

    Used to specify the node ID of the node for which configuration information is to be obtained.

  • --nodes

    Command Line Format--nodes
    Value Set
    Typeboolean
    DefaultFALSE

    (Tells ndb_config to print information from parameters defined in [ndbd] sections only. Currently, using this option has no affect, since these are the only values checked, but it may become possible in future to query parameters set in [tcp] and other sections of cluster configuration files.)

  • --type=node_type

    Command Line Format--type=name
    Value Set
    Typeenumeration
    Default
    Valid Valuesndbd, 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
    Value Set
    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
    Value Set
    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 [--xml]

    Version Introduced5.1.34-ndb-7.0.6
    Command Line Format--configinfo
    Value Set
    Typeboolean
    Defaultfalse
    Version Introduced5.1.34-ndb-7.0.6
    Command Line Format--configinfo --xml
    Value Set
    Typeboolean
    Defaultfalse

    The --configinfo option, added in MySQL Cluster NDB 6.3.25 and MySQL Cluster NDB 7.0.6, 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)
    MANDATORY
    PrimaryMGMNode (Non-negative Integer)
    Node id of Primary ndb_mgmd(MGM) node
    Default: 0 (Min: 0, Max: 4294967039)
    ConfigGenerationNumber (Non-negative Integer)
    Configuration generation number
    Default: 0 (Min: 0, Max: 4294967039)
    ****** DB ******
    MaxNoOfSubscriptions (Non-negative Integer)
    Max no of subscriptions (default 0 == MaxNoOfTables)
    Default: 0 (Min: 0, Max: 4294967039)
    MaxNoOfSubscribers (Non-negative Integer)
    Max no of subscribers (default 0 == 2 * MaxNoOfTables)
    Default: 0 (Min: 0, Max: 4294967039)
    …
    

    You can obtain the output as XML by using the --xml option (also available beginning with MySQL Cluster NDB 6.3.25 and MySQL Cluster NDB 7.0.6) in addition to --configinfo. A portion of the resulting output is shown in this example:

    shell> ndb_config --configinfo --xml
    <configvariables protocolversion="1" ndbversionstring="mysql-5.1.34 ndb-7.0.6"
                        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>
    

    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. If you attempt to do so, the usual (current) 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:ndbd
    2:ndbd
    3:ndbd
    4:ndbd
    5:ndb_mgmd
    6:mysqld
    7:mysqld
    8:mysqld
    9: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_mgmd
    192.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, and 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-data
    2 : 192.168.0.112 : 83886080 : 18874368 : /usr/local/mysql/cluster-data
    3 : 192.168.0.176 : 83886080 : 18874368 : /usr/local/mysql/cluster-data
    4 : 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,type
    3:ndbd
    5: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.

6.7. ndb_cpcd — Automate Testing for NDB Development

This utility is found in the libexec directory. It is part of an internal automated test framework used in testing and debugging MySQL Cluster. Because it can control processes on remote systems, it is not advisable to use ndb_cpcd in a production cluster.

The source files for ndb_cpcd may be found in the directory storage/ndb/src/cw/cpcd, in the MySQL Cluster source tree.

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

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.

Additional Options:

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

6.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),
    PRIMARY KEY pk (id),
    UNIQUE KEY uk (name)
) ENGINE=NDBCLUSTER;
INSERT INTO fish VALUES
    ('','guppy'), ('','tuna'), ('','shark'),
    ('','manta ray'), ('','grouper'), ('','puffer');

Output from ndb_desc:

shell> ./ndb_desc -c localhost fish -d test -p
-- fish --
Version: 16777221
Fragment type: 5
K Value: 6
Min load factor: 78
Max load factor: 80
Temporary table: no
Number of attributes: 2
Number of primary keys: 1
Length of frm data: 268
Row Checksum: 1
Row GCI: 1
TableStatus: Retrieved
-- Attributes --
id Int PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY
name Varchar(20;latin1_swedish_ci) NULL AT=SHORT_VAR ST=MEMORY
-- Indexes --
PRIMARY KEY(id) - UniqueHashIndex
uk(name) - OrderedIndex
PRIMARY(id) - OrderedIndex
uk$unique(name) - UniqueHashIndex
-- Per partition info --
Partition  Row count  Commit count  Frag fixed memory  Frag varsized memory
2          2          2             65536              327680
1          2          2             65536              327680
3          2          2             65536              327680
NDBT_ProgramExit: 0 - OK

Additional Options:

  • --extra-partition-info, -p

    Prints additional information about the table's partitions.

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

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

Additional Options: None that are specific to this application.

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 ctest1
Dropping index dogs/idx...OK
NDBT_ProgramExit: 0 - OK
shell> ./mysql -u jon -p ctest1
Enter password: *******
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7 to server version: 5.1.12-beta-20060817
Type '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 6.11, “ndb_drop_table — Drop an NDB Table”) to drop the table.

6.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, it 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 DROP TABLE on an NDB table from MySQL.

Usage:

ndb_drop_table -c connect_string tbl_name -d db_name

Additional Options: None.

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

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 via SSH, in order 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 MySQL AB unless you are specifically requested to do so.

Command Line Format--fs
Value Set
Typeboolean
DefaultFALSE

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

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

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

6.16. 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 developers and support personnel in debugging and diagnosing problems.

This utility was made available as part of default builds beginning with MySQL Cluster NDB 6.1.3. It remains under development, and its syntax and behavior are subject to change in future releases. For this reason, it should be considered experimental at this time.

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

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 Cluster Data Node FileSystemDir Files.

Additional Options:

Command Line Format-noprint
Value Set
Typeboolean
DefaultFALSE
Command Line Format-nocheck
Value Set
Typeboolean
DefaultFALSE

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

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

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

6.17. 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 7.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 7.6, “MySQL Cluster Single User Mode”, for more information about single user mode.

Typical options for this utility are shown here:

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

The -c option is used to specify a connectstring which tells ndb_restore where to locate the cluster management server. (See Section 3.4.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 3.4.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. Prior to MySQL 5.1.17, ndb_restore did not perform any checks of table schemas; if a table was altered between the time the backup was taken and when ndb_restore was run, ndb_restore would still attempt to restore the data to the altered table.

Beginning with MySQL 5.1.17, the default behavior 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. Prior to MySQL 5.1.21, if this option is used, then ndb_restore attempts to fit data into the existing table schema, but the result of restoring a backup to a table schema that does not match the original is unspecified.

Beginning with MySQL Cluster NDB 6.3.8, 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 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.

In addition to --promote-attributes, a --preserve-trailing-spaces option is also available for use with ndb_restore beginning with MySQL Cluster NDB 6.3.8. This option (short form -R) causes trailing spaces to be preserved when promoting a CHAR column to VARCHAR or a BINARY column to VARBINARY. Otherwise, any trailing spaces are dropped from 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 7.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.

-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 9.9, “MySQL Cluster Backups With MySQL Cluster Replication”.)

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.

Note

Previous to MySQL 5.1.17 and MySQL Cluster NDB 6.1.5, the path to the backup directory was specified as shown here, with backup_path= being optional:

[backup_path=]/path/to/backup/files

Beginning with MySQL 5.1.17 and MySQL Cluster NDB 6.1.5, this syntax changed to --backup_path=/path/to/backup/files, to conform more closely with options used by other MySQL programs; --backup_id is required, and there is no short form for this option.

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 5.2, “MySQL Cluster 5.1 and MySQL Cluster NDB 6.x/7.x Upgrade and Downgrade Compatibility”, 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 6.2.15 to a cluster running MySQL 5.1.20, you must use a copy of ndb_restore from the MySQL Cluster NDB 6.2.15 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.

Formerly, when using ndb_restore to restore a backup made from a MySQL 5.0 cluster to a 5.1 cluster, VARCHAR columns were not resized and were recreated using the 5.0 fixed format. Beginning with MySQL 5.1.19, ndb_restore recreates such VARCHAR columns using MySQL Cluster 5.1's variable-width format. Also beginning with MySQL 5.1.19, this behavior can be overridden using the --no-upgrade option (short form: -u) when running ndb_restore.

Most of the options available for this program are shown in the following table:

Long FormShort FormDescriptionDefault Value
--backup-id-bBackup sequence IDNone
--backup_path (added in MySQL 5.1.17 and MySQL Cluster NDB 6.1.5; previously this was backup_path — see Note in text)NonePath to backup filesNone
--character-sets-dirNoneSpecify the directory where character set information can be foundNone
--connect, --connectstring, or --ndb-connectstring-c or -CSet the connectstring in [nodeid=node_id;][host=]host[:port] formatlocalhost:1186
--core-fileNoneWrite a core file in the event of an errorTRUE
--debug-#Output debug logd:t:O,/tmp/ndb_restore.trace
--dont_ignore_systab_0-fDo not ignore system table during restore — EXPERIMENTAL; not for production useFALSE
--exclude-databases=db_listNoneDo not restore the indicated database or databases (added in MySQL Cluster NDB 6.3.22 and 6.4.3)[N/A]
--exclude-tables=tbl_listNoneDo not restore the indicated table or tables; each table must be specified using database.table format (added in MySQL Cluster NDB 6.3.22 and 6.4.3)[N/A]
--help or --usage-?Display help message with available options and current values, then exit[N/A]
--include-databases=db_listNoneRestore only the indicated database or databases (added in MySQL Cluster NDB 6.3.22 and 6.4.3)[N/A]
--include-tables=tbl_listNoneRestore only the indicated table or tables; each table must be specified using database.table format (added in MySQL Cluster NDB 6.3.22 and 6.4.3)[N/A]
--ndb-mgmd-hostNoneSet the host and port in host[:port] format for the management server to connect to; this is the same as --connect, --connectstring, or --ndb-connectstring, but without a way to specify the nodeidNone
--ndb-nodegroup-map-zSpecifies a nodegroup map — Syntax: list of (source_nodegroup, destination_nodegroup)None
--ndb-nodeidNoneSpecify a node ID for the ndb_restore process0
--ndb-optimized-node-selectionNoneOptimize selection of nodes for transactionsTRUE
--ndb-shmNoneUse shared memory connections when availableFALSE
--no-binlogNoneDo not write anything to mysqld binary logs (added in MySQL Cluster NDB 6.2.16 and 6.3.16)FALSE (in other words, write to binary logs unless this option is used)
--no-restore-disk-objects-dDo not restore Disk Data objects such as tablespaces and log file groupsFALSE (in other words, restore Disk Data objects unless this option is used)
--no-upgrade-uDo not re-create VARSIZE columns from a MySQL 5.0 Cluster backup as variable-width columns (added in MySQL 5.1.19)FALSE (in other words, re-create VARSIZE columns from a MySQL 5.0 Cluster backup as variable-width columns unless this option is used)
--nodeid-nUse backup files from node with the specified ID0
--parallelism-pSet from 1 to 1024 parallel transactions to be used during the restoration process128
--printNonePrint metadata, data, and log to stdoutFALSE
--print_dataNonePrint data to stdoutFALSE
--print_logNonePrint log to stdoutFALSE
--print_metaNonePrint metadata to stdoutFALSE
--restore_data-rRestore data and logsFALSE
--restore_epoch-eRestore epoch data into the status table; the row in the cluster.apply_status having the id 0 is inserted or updated as appropriate — this is convenient when starting up replication on a MySQL Cluster replication slaveFALSE
--restore_meta-mRestore table metadataFALSE
--skip-table-check-sDo not check table schemas (Added in MySQL 5.1.17)FALSE
--version-VOutput version information and exit[N/A]

Beginning with MySQL 5.1.18, 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 table:

Long FormShort FormDescriptionDefault Value
--tab-TCreates dumpfiles, one per table, each named tbl_name.txt. Takes as its argument the path to the directory where the files should be saved (required; use . for the current directory).None
--fields-enclosed-byNoneString used to enclose all column valuesNone
--fields-optionally-enclosed-byNoneString used to enclose column values containing character data (such as CHAR, VARCHAR, BINARY, TEXT, or ENUM)None
--fields-terminated-byNoneString used to separate column values\t (tab character)
--hexNoneUse hex format for binary values[N/A]
--lines-terminated-byNoneString used to terminate each line\n (linefeed character)
--appendNoneWhen used with --tab, causes the data to be appended to existing files of the same name[N/A]

Note

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

Beginning with MySQL 5.1.18, it is possible to restore selected databases, or to restore selected tables from a given database using the syntax shown here:

ndb_restore other_options db_name_1 [db_name_2[, db_name_3][, ...] | tbl_name_1[, tbl_name_2][, ...]]

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

Beginning with MySQL Cluster NDB 6.3.22 and 6.4.3, you can (and should) use instead the options --include-databases and --include-tables 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. You can 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

(For the sake of clarity and brevity, we have omitted other, possibly required, options in the example just shown.) When --include-databases, --include-tables, or both are used, only those databases or tables specified are restored; all other databases and tables are ignored by ndb_restore.

Also beginning with MySQL Cluster NDB 6.3.22 and 6.4.3, it is possible to exclude from being restored one or more databases, tables, or both 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. 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 should not use --include-databases or --include-tables together with --exclude-databases or --exclude-tables, since --include-databases and --include-tables exclude all databases and tables not explicitly named. Similarly, --exclude-databases and --exclude-tables include all databases and tables not listed in the arguments to these options.

Error reporting.  ndb_restore reports both temporary and permanent errors. In the case of temporary errors, it may able to recover from them. Beginning with MySQL 5.1.12, it 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. In order 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 with MySQL Cluster management, which we intend to address in a future release.

6.18. 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]

Additional Options:

  • --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 Chapter 14, MySQL Cluster Glossary, and Section 7.4.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 ctest1
id      name
3       [shark]
6       [puffer]
2       [tuna]
4       [manta ray]
5       [grouper]
1       [guppy]
6 rows returned
NDBT_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 DISK
ENGINE=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 --disk
GCI     id name          breed        DISK_REF
834461  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 returned
NDBT_ProgramExit: 0 - OK

6.19. 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[, ...]]

Additional Options: None that are specific to this application. However, 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 dogs
6 records in table fish
4 records in table dogs
NDBT_ProgramExit: 0 - OK

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

Usage:

ndb_show_tables [-c connect_string]

Additional Options:

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

  • --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 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 6.18, “ndb_select_all — Print Rows from an NDB Table”).

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

  • Previous to MySQL 5.1.18, ndb_size.pl also required the HTML::Template module and an associated template file share/mysql/ndb_size.tmpl. Beginning with MySQL 5.1.18, ndb_size.tmpl is no longer needed (or included).

  • 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. If this file is not present in your MySQL installation, you can obtain it from the MySQL Forge project page.

Usage:

perl ndb_size.pl 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 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 (and possibly a port as well) can be specified using --hostname; the default is localhost:3306. If necessary, you can 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.sock
ndb_size.pl report for database: 'test' (1 tables)
--------------------------------------------------
Connected to: DBI:mysql:host=localhost;mysql_socket=/tmp/mysql.sock
Including information for versions: 4.1, 5.0, 5.1
test.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          4
DataMemory for Indexes:
               Index Name                 Type        4.1        5.0        5.1
                  PRIMARY                BTREE         16         16         16
                                                       --         --         --
       Total Index DM/Row                              16         16         16
IndexMemory for Indexes:
               Index Name        4.1        5.0        5.1
                  PRIMARY         33         16         16
                                  --         --         --
           Indexes IM/Row         33         16         16
Summary (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        680
Fixedsize DataMemory (KB)          0          0          0
Rows/32kb Varsize DM Page          0          0       2040
  Varsize DataMemory (KB)          0          0          0
         Rows/8kb IM Page        248        512        512
         IndexMemory (KB)          0          0          0
Parameter 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 in this example:

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

(Without the redirection, the output is sent to stdout.) This figure shows a portion of the generated ndb_size.html output file, as viewed in a Web browser:

Partial sample output from
            ndb_size.pl as viewed in a Web
            browser.

The output from this script includes:

  • Minimum values for the DataMemory, IndexMemory, MaxNoOfTables, MaxNoOfAttributes, MaxNoOfOrderedIndexes, MaxNoOfUniqueHashIndexes, and MaxNoOfTriggers configuration parameters required to accommodate the tables analyzed.

  • Memory requirements for all of the tables, attributes, ordered indexes, and unique hash indexes defined in the database.

  • The IndexMemory and DataMemory required per table and table row.

Note

Prior to MySQL 5.1.23, MySQL Cluster NDB 6.2.5, and MySQL Cluster NDB 6.3.7, ndb_size.pl was invoked as shown here:

perl ndb_size.pl db_name hostname username password > file_name.html

For more information about this change, see Bug#28683 and Bug#28253.

6.22. 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 (see Additional 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.

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

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 localhost
Connecting to mgmsrv at (localhost)
State node 1 STARTED
State node 2 NO_CONTACT
State node 3 STARTED
State node 4 NO_CONTACT
Waiting for cluster enter state STARTED
...
State node 1 STARTED
State node 2 UNKNOWN
State node 3 STARTED
State node 4 NO_CONTACT
Waiting for cluster enter state STARTED
...
State node 1 STARTED
State node 2 STARTING
State node 3 STARTED
State node 4 NO_CONTACT
Waiting for cluster enter state STARTED
...
State node 1 STARTED
State node 2 STARTING
State node 3 STARTED
State node 4 UNKNOWN
Waiting for cluster enter state STARTED
...
State node 1 STARTED
State node 2 STARTING
State node 3 STARTED
State node 4 STARTING
Waiting for cluster enter state STARTED
...
State node 1 STARTED
State node 2 STARTED
State node 3 STARTED
State node 4 STARTING
Waiting for cluster enter state STARTED
...
State node 1 STARTED
State node 2 STARTED
State node 3 STARTED
State node 4 STARTED
Waiting for cluster enter state STARTED
NDBT_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).

6.23. Options Common to MySQL Cluster Programs

All MySQL Cluster programs (except for mysqld) take the options described in this section. 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 to view a list of the options which it supports.

The options in the following list are common to all MySQL Cluster executables.

For options specific to individual NDB programs, see Chapter 6, MySQL Cluster Programs.

See Section 4.2, “mysqld Command Options for MySQL Cluster”, for mysqld options relating to MySQL Cluster.

  • --help --usage, -?

    Command Line Format--help

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

  • --character-sets-dir=name

    Command Line Format--character-sets-dir=name
    Value Set
    Typefilename
    Default

    Tells the program where to find character set information.

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

    Command Line Format--ndb-connectstring=name
    Value Set
    Typestring
    Defaultlocalhost:1186

    connect_string sets the connectstring to the management server as a command option.

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

    For more information, see Section 3.4.3, “The MySQL Cluster Connectstring”.

  • --core-file

    Command Line Format--core-file
    Value Set
    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

    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.

  • --execute=command, -e command

    Command Line Format--execute=name

    Can be used to send a command to a Cluster executable from the system shell. For example, either of the following:

    shell> ndb_mgm -e "SHOW"
    

    or

    shell> ndb_mgm --execute="SHOW"
    

    is equivalent to

    ndb_mgm> SHOW
    

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

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

    Can be used to set the host and port number of the management server to connect to.

  • --ndb-nodeid=#

    Sets this node's MySQL Cluster node ID. The range of permitted values depends on the type of the node (data, management, or API) and the version of the MySQL Cluster software which is running on it. See Section 12.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
    Value Set
    Typeboolean
    DefaultTRUE

    Optimize selection of nodes for transactions. Enabled by default.

  • --version, -V

    Command Line Format-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 5.1, “Performing a Rolling Restart of a MySQL Cluster”).

6.24. Summary Tables of NDB Program Options

The next few sections contain summary tables providing basic information about command-line options used with MySQL Cluster programs.

6.24.1. Common Options for MySQL Cluster Programs

Table 6.1. ndb_common Option Reference

FormatDescriptionIntroductionDeprecatedRemoved
--character-sets-dir=nameDirectory where character sets are   
--ndb-connectstring=nameSet connect string for connecting to ndb_mgmd. Syntax: [nodeid=<id>;][host=]<hostname>[:<port>]. Overrides specifying entries in NDB_CONNECTSTRING and my.cnf   
--core-fileWrite core on errors (defaults to TRUE in debug builds)   
--debug=optionsEnable output from debug calls. Can be used only for versions compiled with debugging enabled   
--execute=nameExecute command and exit   
--helpDisplay help message and exit   
--ndb-mgmd-host=nameSet host and port for connecting to ndb_mgmd. Syntax: <hostname>[:<port>]. Overrides specifying entries in NDB_CONNECTSTRING and my.cnf   
--ndb-optimized-node-selectionSelect nodes for transactions in a more optimal way   
--ndb-nodeid=#Set node id for this node   
-VOutput version information and exit   

For options specific to individual MySQL Cluster programs, see Section 6.23, “Options Common to MySQL Cluster Programs”.

6.24.2. Program Options for ndbd and ndbmtd

Table 6.2. ndbd Option Reference

FormatDescriptionIntroductionDeprecatedRemoved
--bind-address=nameLocal bind address5.1.12  
--daemonStart ndbd as daemon (default); override with --nodaemon   
--foregroundRun ndbd in foreground, provided for debugging purposes (implies --nodaemon)   
--initialPerform initial start of ndbd, including cleaning the file system. Consult the documentation before using this option   
--initial-startPerform partial initial start (requires --nowait-nodes)5.1.11  
--nodaemonDo not start ndbd as daemon; provided for testing purposes   
--nostartDon't start ndbd immediately; ndbd waits for command to start from ndb_mgmd   
--nowait-nodes=listNodes that will not be waited for during start (comma-deparated list of node IDs)5.1.11  

For more information about ndbd, see Section 6.2, “ndbd — The MySQL Cluster Data Node Daemon”. For options common to all MySQL Cluster programs, see Section 6.23, “Options Common to MySQL Cluster Programs”.

6.24.3. Program Options for ndb_mgmd

Table 6.3. ndb_mgmd Option Reference

FormatDescriptionIntroductionDeprecatedRemoved
--bind-addressLocal bind address5.1.22-ndb-6.3.2  
-cSpecify the cluster configuration file; in NDB-6.4.0 and later, needs --reload or --initial to override configuration cache if present   
--configdir=directorySpecify the cluster management server's configuration cache directory5.1.30-ndb-6.4.0  
--daemonRun ndb_mgmd in daemon mode (default)   
--initialCauses the management server reload its configuration data from the configuration file, bypassing the configuration cache5.1.30-ndb-6.4.0  
--interactiveRun ndb_mgmd in interactive mode (not officially supported in production; for testing purposes only)   
--mycnfRead cluster configuration data from the my.cnf file   
--no-nodeid-checksDo not provide any node id checks   
--nodaemonDo not run ndb_mgmd as a daemon   
--print-full-configPrint full configuration and exit   
--reloadCauses the management server to compare the configuration file with its configuration cache5.1.30-ndb-6.4.0  

For more information about ndb_mgmd, see Section 6.4, “ndb_mgmd — The MySQL Cluster Management Server Daemon”. For options common to all MySQL Cluster programs, see Section 6.23, “Options Common to MySQL Cluster Programs”.

6.24.4. Program Options for ndb_mgm

Table 6.4. ndb_mgm Option Reference

FormatDescriptionIntroductionDeprecatedRemoved
--try-reconnect=#Specify number of tries for connecting to ndb_mgmd (0 = infinite)   

For more information about ndb_mgm, see Section 6.5, “ndb_mgm — The MySQL Cluster Management Client”. For options common to all MySQL Cluster programs, see Section 6.23, “Options Common to MySQL Cluster Programs”.

6.24.5. Program Options for ndbd_redo_log_reader

Table 6.5. ndbd_redo_log_reader Option Reference

FormatDescriptionIntroductionDeprecatedRemoved
-nocheckDo not check records for errors   
-noprintDo not print records   

For more information about ndbd_redo_log_reader, see Section 6.16, “ndbd_redo_log_reader — Check and Print Content of Cluster Redo Log”. For options common to all MySQL Cluster programs, see Section 6.23, “Options Common to MySQL Cluster Programs”.

6.24.6. Program Options for ndb_config

Table 6.6. ndb_config Option Reference

FormatDescriptionIntroductionDeprecatedRemoved
--configinfoDumps information about all NDB configuration parameters in text format with default, maximum, and minimum values. Use with --xml to obtain XML output.5.1.34-ndb-7.0.6  
--connectionsPrint connection information only   
--fields=stringField separator   
--host=nameSpecify host   
--mycnfRead configuration data from my.cnf file   
--nodeidGet configuration of node with this ID   
--nodesPrint node information only   
 Short form for --ndb-connectstring5.1.12  
--config-file=pathSet the path to config.ini file   
--query=stringOne or more query options (attributes)   
--rows=stringRow separator   
--type=nameSpecify node type   
--configinfo --xmlUse with --configinfo to obtain a dump of all NDB configuration parameters in XML format with default, maximum, and minimum values.5.1.34-ndb-7.0.6  

For more information about ndb_config, see Section 6.6, “ndb_config — Extract MySQL Cluster Configuration Information”. For options common to all MySQL Cluster programs, see Section 6.23, “Options Common to MySQL Cluster Programs”.

6.24.7. Program Options for ndb_error_reporter

Table 6.7. ndb_error_reporter Option Reference

FormatDescriptionIntroductionDeprecatedRemoved
--fsInclude file system data in error report; can use a large amount of disk space   

For more information about ndb_error_reporter, see Section 6.12, “ndb_error_reporter — NDB Error-Reporting Utility”. For options common to all MySQL Cluster programs, see Section 6.23, “Options Common to MySQL Cluster Programs”.

6.24.8. Program Options for ndb_restore

Table 6.8. ndb_restore Option Reference

FormatDescriptionIntroductionDeprecatedRemoved
--appendAppend data to a tab-delimited file5.1.18  
--backup_path=pathPath to backup files directory   
--backupid=#Restore from the backup with the given ID   
--connectSame as connectstring   
--restore_dataRestore table data and logs into NDB Cluster using the NDB API   
--dont_ignore_systab_0Do not ignore system table during restore. Experimental only; not for production use   
--exclude-databases=db-listList of one or more databases to exclude (includes those not named)5.1.32-ndb-6.4.3  
--exclude-tables=table-listList of one or more tables to exclude (includes those not named)5.1.32-ndb-6.4.3  
--fields-enclosed-by=charFields are enclosed with the indicated character5.1.18  
--fields-optionally-enclosed-byFields are optionally enclosed with the indicated character5.1.18  
--fields-terminated-by=charFields are terminated by the indicated character5.1.18  
--hexPrint binary types in hexadecimal format5.1.18  
--include-databases=db-listList of one or more databases to restore (excludes those not named)5.1.32-ndb-6.4.3  
--include-tables=table-listList of one or more tables to restore (excludes those not named)5.1.32-ndb-6.4.3  
--lines-terminated-by=charLines are terminated by the indicated character5.1.18  
--restore_metaRestore metadata to NDB Cluster using the NDB API   
--ndb-nodegroup-map=mapNodegroup map for NDBCLUSTER storage engine. Syntax: list of (source_nodegroup, destination_nodegroup)   
--no-binlogIf a mysqld is connected and using binary logging, do not log the restored data5.1.24-ndb-6.3.16  
--no-restore-disk-objectsDo not restore Disk Data objects such as tablespaces and log file groups   
--no-upgradeDo not upgrade array type for varsize attributes which do not already resize VAR data, and do not change column attributes5.1.19  
--nodeid=#Back up files from node with this ID   
--parallelism=#Number of parallel transactions during restoration of data   
--preserve-trailing-spacesAllow preservation of tailing spaces (including padding) when CHAR is promoted to VARCHAR or BINARY is promoted to VARBINARY5.1.23-ndb-6.3.8  
--printPrint metadata, data and log to stdout (equivalent to --print_meta --print_data --print_log)   
--print_dataPrint data to stdout   
--print_logPrint to stdout   
--print_metadataPrint metadata to stdout   
--progress-frequency=#Print status of restoration each given number of seconds5.1.?  
--promote-attributesAllow attributes to be promoted when restoring data from backup5.1.23-ndb-6.3.8  
--restore_epochRestore 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.   
--skip-table-checkSkip table structure check during restoring of data5.1.17  
--tab=pathCreates tab separated a .txt file for each table in the given path5.1.18  
--verbose=#Control level of verbosity in output   

For more information about ndb_restore, see Section 6.17, “ndb_restore — Restore a MySQL Cluster Backup”. For options common to all NDB programs, see Section 6.23, “Options Common to MySQL Cluster Programs”.

6.24.9. Program Options for ndb_show_tables

Table 6.9. ndb_show_tables Option Reference

FormatDescriptionIntroductionDeprecatedRemoved
--database=stringSpecifies the database in which the table is found   
--loops=#Number of times to repeat output   
--show-temp-statusShow table temporary flag   
--parsableReturn output suitable for MySQL LOAD DATA INFILE statement   
--type=#Limit output to objects of this type   
--unqualifiedDo not qualify table names   

For more information about ndb_show_tables, see Section 6.20, “ndb_show_tables — Display List of NDB Tables”. For options common to all MySQL Cluster programs, see Section 6.23, “Options Common to MySQL Cluster Programs”.

6.24.10. Program Options for ndb_size.pl

Table 6.10. ndb_size_pl Option Reference

FormatDescriptionIntroductionDeprecatedRemoved
--database=dbnameThe databae or databases to examine; accepts a comma-delimited list; the default is ALL (use all databases found on the server)   
--excludedbs=db-listSkip any databases in a comma-separated list of databases   
--excludetables=tbl-listSkip any tables in a comma-separated list of tables   
--format=stringSet output format (text or HTML)   
--hostname[:port]Specify host and optional port as host[:port]   
--loadqueries=fileLoads all queries from the file specified; does not connect to a database   
--password=stringSpecify a MySQL user password   
--real_table_name=tableDesignates a table to handle unique index size calculations5.1.22-ndb-6.2.5  
--savequeries=fileSaves all queries to the database into the file specified   
--socket=fileSpecify a socket to connect to5.1.22-ndb-6.2.5  
--user=stringSpecify a MySQL user name   

For more information about ndb_size.pl, see Section 6.21, “ndb_size.pl — NDBCLUSTER Size Requirement Estimator”. For options common to all MySQL Cluster programs, see Section 6.23, “Options Common to MySQL Cluster Programs”.

Document Actions