Cari di MySQL 
    MySQL Manual
Daftar Isi
(Sebelumnya) 17.4. MySQL Cluster Programs17.6. MySQL Cluster Replication (Berikutnya)

17.5. Management of MySQL Cluster

Managing a MySQL Cluster involves a number of tasks, the first of which is to configure and start MySQL Cluster. This is covered in Section 17.3, "MySQL Cluster Configuration", and Section 17.4, "MySQL Cluster Programs".

The next few sections cover the management of a running MySQL Cluster.

For information about security issues relating to management and deployment of a MySQL Cluster, see Section 17.5.11, "MySQL Cluster Security Issues".

There are essentially two methods of actively managing a running MySQL Cluster. The first of these is through the use of commands entered into the management client whereby cluster status can be checked, log levels changed, backups started and stopped, and nodes stopped and started. The second method involves studying the contents of the cluster log ndb_node_id_cluster.log; this is usually found in the management server's DataDir directory, but this location can be overridden using the LogDestination option. (Recall that node_id represents the unique identifier of the node whose activity is being logged.) The cluster log contains event reports generated by ndbd. It is also possible to send cluster log entries to a Unix system log.

Some aspects of the cluster's operation can be also be monitored from an SQL node using the SHOW ENGINE NDB STATUS statement.

More detailed information about MySQL Cluster operations is available in real time through an SQL interface using the ndbinfo database. For more information, see Section 17.5.10, "The ndbinfo MySQL Cluster Information Database".

NDB statistics counters provide improved monitoring using the mysql client. These counters, implemented in the NDB kernel, relate to operations performed by or affecting Ndb objects, such as starting, closing, and aborting transactions; primary key and unique key operations; table, range, and pruned scans; blocked threads waiting for various operations to complete; and data and events sent and received by MySQL Cluster. The counters are incremented by the NDB kernel whenever NDB API calls are made or data is sent to or received by the data nodes.

mysqld exposes the NDB API statistics counters as system status variables, which can be identified from the prefix common to all of their names (Ndb_api_). The values of these variables can be read in the mysql client from the output of a SHOW STATUS statement, or by querying either the SESSION_STATUS table or the GLOBAL_STATUS table (in the INFORMATION_SCHEMA database). By comparing the values of the status variables before and after the execution of an SQL statement that acts on NDB tables, you can observe the actions taken on the NDB API level that correspond to this statement, which can be beneficial for monitoring and performance tuning of MySQL Cluster.

MySQL Enterprise Monitor can also be used to monitor MySQL Servers that are part of a MySQL Cluster deployment. MySQL Enterprise Monitor 2.3, added a MySQL Cluster advisor, including a set of graphs providing information on MySQL Cluster resources, and defining rules for alerts on key information from data nodes such as DataMemory usage. This information is made available to MySQL Enterprise Monitor 2.3 or later by any MySQL Server which is connected to the MySQL Cluster, using ndbinfo. The advisor could be run against a single MySQL Server in the Cluster, or against a pair in order to provide a higher level of availability for the monitoring service. For more information, see the MySQL Enterprise Monitor 2.3 Manual.

MySQL Cluster Manager provides an advanced command-line interface that simplifies many otherwise complex MySQL Cluster management tasks, such as starting, stopping, or restarting a MySQL Cluster with a large number of nodes. The MySQL Cluster Manager client also supports commands for getting and setting the values of most node configuration parameters as well as mysqld server options and variables relating to MySQL Cluster. MySQL Cluster Manager 1.1 provides support for adding data nodes online. See the MySQL Cluster Manager 1.1 User Manual, for more information.

17.5.1. Summary of MySQL Cluster Start Phases

This section provides a simplified outline of the steps involved when MySQL Cluster data nodes are started. More complete information can be found in MySQL Cluster Start Phases, in the NDB Internals Guide.

These phases are the same as those reported in the output from the node_id STATUS command in the management client (see Section 17.5.2, "Commands in the MySQL Cluster Management Client"). These start phases are also reported in the start_phase column of the ndbinfo.nodes table.

Start types. There are several different startup types and modes, as shown in the following list:

  • Initial start. The cluster starts with a clean file system on all data nodes. This occurs either when the cluster started for the very first time, or when all data nodes are restarted using the --initial option.

    Note

    Disk Data files are not removed when restarting a node using --initial.

  • System restart. The cluster starts and reads data stored in the data nodes. This occurs when the cluster has been shut down after having been in use, when it is desired for the cluster to resume operations from the point where it left off.

  • Node restart. This is the online restart of a cluster node while the cluster itself is running.

  • Initial node restart. This is the same as a node restart, except that the node is reinitialized and started with a clean file system.

Setup and initialization (phase -1). Prior to startup, each data node (ndbd process) must be initialized. Initialization consists of the following steps:

  1. Obtain a node ID

  2. Fetch configuration data

  3. Allocate ports to be used for inter-node communications

  4. Allocate memory according to settings obtained from the configuration file

When a data node or SQL node first connects to the management node, it reserves a cluster node ID. To make sure that no other node allocates the same node ID, this ID is retained until the node has managed to connect to the cluster and at least one ndbd reports that this node is connected. This retention of the node ID is guarded by the connection between the node in question and ndb_mgmd.

After each data node has been initialized, the cluster startup process can proceed. The stages which the cluster goes through during this process are listed here:

  • Phase 0. The NDBFS and NDBCNTR blocks start (see NDB Kernel Blocks). Data node file systems are cleared on those data nodes that were started with --initial option.

  • Phase 1. In this stage, all remaining NDB kernel blocks are started. MySQL Cluster connections are set up, inter-block communications are established, and heartbeats are started. In the case of a node restart, API node connections are also checked.

    Note

    When one or more nodes hang in Phase 1 while the remaining node or nodes hang in Phase 2, this often indicates network problems. One possible cause of such issues is one or more cluster hosts having multiple network interfaces. Another common source of problems causing this condition is the blocking of TCP/IP ports needed for communications between cluster nodes. In the latter case, this is often due to a misconfigured firewall.

  • Phase 2. The NDBCNTR kernel block checks the states of all existing nodes. The master node is chosen, and the cluster schema file is initialized.

  • Phase 3. The DBLQH and DBTC kernel blocks set up communications between them. The startup type is determined; if this is a restart, the DBDIH block obtains permission to perform the restart.

  • Phase 4. For an initial start or initial node restart, the redo log files are created. The number of these files is equal to NoOfFragmentLogFiles.

    For a system restart:

    • Read schema or schemas.

    • Read data from the local checkpoint.

    • Apply all redo information until the latest restorable global checkpoint has been reached.

    For a node restart, find the tail of the redo log.

  • Phase 5. Most of the database-related portion of a data node start is performed during this phase. For an initial start or system restart, a local checkpoint is executed, followed by a global checkpoint. Periodic checks of memory usage begin during this phase, and any required node takeovers are performed.

  • Phase 6. In this phase, node groups are defined and set up.

  • Phase 7. The arbitrator node is selected and begins to function. The next backup ID is set, as is the backup disk write speed. Nodes reaching this start phase are marked as Started. It is now possible for API nodes (including SQL nodes) to connect to the cluster.

  • Phase 8. If this is a system restart, all indexes are rebuilt (by DBDIH).

  • Phase 9. The node internal startup variables are reset.

  • Phase 100 (OBSOLETE). Formerly, it was at this point during a node restart or initial node restart that API nodes could connect to the node and begin to receive events. Currently, this phase is empty.

  • Phase 101. At this point in a node restart or initial node restart, event delivery is handed over to the node joining the cluster. The newly-joined node takes over responsibility for delivering its primary data to subscribers. This phase is also referred to as SUMA handover phase.

After this process is completed for an initial start or system restart, transaction handling is enabled. For a node restart or initial node restart, completion of the startup process means that the node may now act as a transaction coordinator.

17.5.2. Commands in the MySQL Cluster Management Client

In addition to the central configuration file, a cluster may also be controlled through a command-line interface available through the management client ndb_mgm. This is the primary administrative interface to a running cluster.

Commands for the event logs are given in Section 17.5.6, "Event Reports Generated in MySQL Cluster"; commands for creating backups and restoring from them are provided in Section 17.5.3, "Online Backup of MySQL Cluster".

The management client has the following basic commands. In the listing that follows, node_id denotes either a database node ID or the keyword ALL, which indicates that the command should be applied to all of the cluster's data nodes.

  • HELP

    Displays information on all available commands.

  • SHOW

    Displays information on the cluster's status. Possible node status values include UNKNOWN, NO_CONTACT, NOT_STARTED, STARTING, STARTED, SHUTTING_DOWN, and RESTARTING. The output from this command also indicates when the cluster is in single user mode (status SINGLE USER MODE).

  • node_id START

    Brings online the data node identified by node_id (or all data nodes).

    ALL START works on all data nodes only, and does not affect management nodes.

    Important

    To use this command to bring a data node online, the data node must have been started using ndbd --nostart or ndbd -n.

  • node_id STOP [-a] [-f]

    Stops the data or management node identified by node_id. Note that ALL STOP works to stop all data nodes only, and does not affect management nodes.

    A node affected by this command disconnects from the cluster, and its associated ndbd or ndb_mgmd process terminates.

    The -a option causes the node to be stopped immediately, without waiting for the completion of any pending transactions.

    Normally, STOP fails if the result would cause an incomplete cluster. The -f option forces the node to shut down without checking for this. If this option is used and the result is an incomplete cluster, the cluster immediately shuts down.

    Warning

    Use of the -a option also disables the safety check otherwise performed when STOP is invoked to insure that stopping the node does not cause an incomplete cluster. In other words, you should exercise extreme care when using the -a option with the STOP command, due to the fact that this option makes it possible for the cluster to undergo a forced shutdown because it no longer has a complete copy of all data stored in NDB.

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

    Restarts the data node identified by node_id (or all data nodes).

    Using the -i option with RESTART causes the data node to perform an initial restart; that is, the node's file system is deleted and recreated. The effect is the same as that obtained from stopping the data node process and then starting it again using ndbd --initial from the system shell. Note that backup files and Disk Data files are not removed when this option is used.

    Using the -n option causes the data node process to be restarted, but the data node is not actually brought online until the appropriate START command is issued. The effect of this option is the same as that obtained from stopping the data node and then starting it again using ndbd --nostart or ndbd -n from the system shell.

    Using the -a causes all current transactions relying on this node to be aborted. No GCP check is done when the node rejoins the cluster.

    Normally, RESTART fails if taking the node offline would result in an incomplete cluster. The -f option forces the node to restart without checking for this. If this option is used and the result is an incomplete cluster, the entire cluster is restarted.

  • node_id STATUS

    Displays status information for the data node identified by node_id (or for all data nodes).

    The output from this command also indicates when the cluster is in single user mode.

  • node_id REPORT report-type

    Displays a report of type report-type for the data node identified by node_id, or for all data nodes using ALL.

    Currently, there are two accepted values for report-type:

    • BackupStatus provides a status report on a cluster backup in progress

    • MemoryUsage displays how much data memory and index memory is being used by each data node as shown in this example:

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

      This information is also available from the ndbinfo.memoryusage table.

    report-type is case-insensitive and "fuzzy"; for MemoryUsage, you can use MEMORY (as shown in the prior example), memory, or even simply MEM (or mem). You can abbreviate BackupStatus in a similar fashion.

    Prior to MySQL Cluster NDB 7.2.10, ALL REPORT BackupStatus did not work correctly with multithreaded data nodes. (Bug #15908907)

  • ENTER SINGLE USER MODE node_id

    Enters single user mode, whereby only the MySQL server identified by the node ID node_id is permitted to access the database.

    Currently, it is not possible for data nodes to join a MySQL Cluster while it is running in single user mode. (Bug #20395)

  • EXIT SINGLE USER MODE

    Exits single user mode, enabling all SQL nodes (that is, all running mysqld processes) to access the database.

    Note

    It is possible to use EXIT SINGLE USER MODE even when not in single user mode, although the command has no effect in this case.

  • QUIT, EXIT

    Terminates the management client.

    This command does not affect any nodes connected to the cluster.

  • SHUTDOWN

    Shuts down all cluster data nodes and management nodes. To exit the management client after this has been done, use EXIT or QUIT.

    This command does not shut down any SQL nodes or API nodes that are connected to the cluster.

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

    Creates a new MySQL Cluster node group and causes data nodes to join it.

    This command is used after adding new data nodes online to a MySQL Cluster, and causes them to join a new node group and thus to begin participating fully in the cluster. The command takes as its sole parameter a comma-separated list of node IDs-these are the IDs of the nodes just added and started that are to join the new node group. The number of nodes must be the same as the number of nodes in each node group that is already part of the cluster (each MySQL Cluster node group must have the same number of nodes). In other words, if the MySQL Cluster has 2 node groups of 2 data nodes each, then the new node group must also have 2 data nodes.

    The node group ID of the new node group created by this command is determined automatically, and always the next highest unused node group ID in the cluster; it is not possible to set it manually.

    For more information, see Section 17.5.13, "Adding MySQL Cluster Data Nodes Online".

  • DROP NODEGROUP nodegroup_id

    Drops the MySQL Cluster node group with the given nodegroup_id.

    This command can be used to drop a node group from a MySQL Cluster. DROP NODEGROUP takes as its sole argument the node group ID of the node group to be dropped.

    DROP NODEGROUP acts only to remove the data nodes in the effected node group from that node group. It does not stop data nodes, assign them to a different node group, or remove them from the cluster's configuration. A data node that does not belong to a node group is indicated in the output of the management client SHOW command with no nodegroup in place of the node group ID, like this (indicated using bold text):

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

    Prior to MySQL Cluster NDB 7.0.4, the SHOW output was not updated correctly following DROP NODEGROUP. (Bug #43413)

    DROP NODEGROUP works only when all data nodes in the node group to be dropped are completely empty of any table data and table definitions. Since there is currently no way using ndb_mgm or the mysql client to remove all data from a specific data node or node group, this means that the command succeeds only in the two following cases:

    1. After issuing CREATE NODEGROUP in the ndb_mgm client, but before issuing any ALTER ONLINE TABLE ... REORGANIZE PARTITION statements in the mysql client.

    2. After dropping all NDBCLUSTER tables using DROP TABLE.

      TRUNCATE TABLE does not work for this purpose because this removes only the table data; the data nodes continue to store an NDBCLUSTER table's definition until a DROP TABLE statement is issued that causes the table metadata to be dropped.

    For more information about DROP NODEGROUP, see Section 17.5.13, "Adding MySQL Cluster Data Nodes Online".

17.5.3. Online Backup of MySQL Cluster

The next few sections describe how to prepare for and then to create a MySQL Cluster backup using the functionality for this purpose found in the ndb_mgm management client. To distinguish this type of backup from a backup made using mysqldump, we sometimes refer to it as a "native" MySQL Cluster backup. (For information about the creation of backups with mysqldump, see Section 4.5.4, "mysqldump - A Database Backup Program".) Restoration of MySQL Cluster backups is done using the ndb_restore utility provided with the MySQL Cluster distribution; for information about ndb_restore and its use in restoring MySQL Cluster backups, see Section 17.4.18, "ndb_restore - Restore a MySQL Cluster Backup".

17.5.3.1. MySQL Cluster Backup Concepts

A backup is a snapshot of the database at a given time. The backup consists of three main parts:

  • Metadata. The names and definitions of all database tables

  • Table records. The data actually stored in the database tables at the time that the backup was made

  • Transaction log. A sequential record telling how and when data was stored in the database

Each of these parts is saved on all nodes participating in the backup. During backup, each node saves these three parts into three files on disk:

  • BACKUP-backup_id.node_id.ctl

    A control file containing control information and metadata. Each node saves the same table definitions (for all tables in the cluster) to its own version of this file.

  • BACKUP-backup_id-0.node_id.data

    A data file containing the table records, which are saved on a per-fragment basis. That is, different nodes save different fragments during the backup. The file saved by each node starts with a header that states the tables to which the records belong. Following the list of records there is a footer containing a checksum for all records.

  • BACKUP-backup_id.node_id.log

    A log file containing records of committed transactions. Only transactions on tables stored in the backup are stored in the log. Nodes involved in the backup save different records because different nodes host different database fragments.

In the listing above, backup_id stands for the backup identifier and node_id is the unique identifier for the node creating the file.

17.5.3.2. Using The MySQL Cluster Management Client to Create a Backup

Before starting a backup, make sure that the cluster is properly configured for performing one. (See Section 17.5.3.3, "Configuration for MySQL Cluster Backups".)

The START BACKUP command is used to create a backup:

START BACKUP [backup_id] [wait_option] [snapshot_option]wait_option:WAIT {STARTED | COMPLETED} | NOWAITsnapshot_option:SNAPSHOTSTART | SNAPSHOTEND

Successive backups are automatically identified sequentially, so the backup_id, an integer greater than or equal to 1, is optional; if it is omitted, the next available value is used. If an existing backup_id value is used, the backup fails with the error Backup failed: file already exists. If used, the backup_id must follow START BACKUP immediately, before any other options are used.

The wait_option can be used to determine when control is returned to the management client after a START BACKUP command is issued, as shown in the following list:

  • If NOWAIT is specified, the management client displays a prompt immediately, as seen here:

    ndb_mgm> START BACKUP NOWAITndb_mgm>

    In this case, the management client can be used even while it prints progress information from the backup process.

  • With WAIT STARTED the management client waits until the backup has started before returning control to the user, as shown here:

    ndb_mgm> START BACKUP WAIT STARTEDWaiting for started, this may take several minutesNode 2: Backup 3 started from node 1ndb_mgm>
  • WAIT COMPLETED causes the management client to wait until the backup process is complete before returning control to the user.

WAIT COMPLETED is the default.

A snapshot_option can be used to determine whether the backup matches the state of the cluster when START BACKUP was issued, or when it was completed. SNAPSHOTSTART causes the backup to match the state of the cluster when the backup began; SNAPSHOTEND causes the backup to reflect the state of the cluster when the backup was finished. SNAPSHOTEND is the default, and matches the behavior found in previous MySQL Cluster releases.

Note

If you use the SNAPSHOTSTART option with START BACKUP, and the CompressedBackup parameter is enabled, only the data and control files are compressed-the log file is not compressed.

If both a wait_option and a snapshot_option are used, they may be specified in either order. For example, all of the following commands are valid, assuming that there is no existing backup having 4 as its ID:

START BACKUP WAIT STARTED SNAPSHOTSTARTSTART BACKUP SNAPSHOTSTART WAIT STARTEDSTART BACKUP 4 WAIT COMPLETED SNAPSHOTSTARTSTART BACKUP SNAPSHOTEND WAIT COMPLETEDSTART BACKUP 4 NOWAIT SNAPSHOTSTART

The procedure for creating a backup consists of the following steps:

  1. Start the management client (ndb_mgm), if it not running already.

  2. Execute the START BACKUP command. This produces several lines of output indicating the progress of the backup, as shown here:

    ndb_mgm> START BACKUPWaiting for completed, this may take several minutesNode 2: Backup 1 started from node 1Node 2: Backup 1 started from node 1 completed StartGCP: 177 StopGCP: 180 #Records: 7362 #LogRecords: 0 Data: 453648 bytes Log: 0 bytesndb_mgm>
  3. When the backup has started the management client displays this message:

    Backup backup_id started from node node_id

    backup_id is the unique identifier for this particular backup. This identifier is saved in the cluster log, if it has not been configured otherwise. node_id is the identifier of the management server that is coordinating the backup with the data nodes. At this point in the backup process the cluster has received and processed the backup request. It does not mean that the backup has finished. An example of this statement is shown here:

    Node 2: Backup 1 started from node 1
  4. The management client indicates with a message like this one that the backup has started:

    Backup backup_id started from node node_id completed

    As is the case for the notification that the backup has started, backup_id is the unique identifier for this particular backup, and node_id is the node ID of the management server that is coordinating the backup with the data nodes. This output is accompanied by additional information including relevant global checkpoints, the number of records backed up, and the size of the data, as shown here:

    Node 2: Backup 1 started from node 1 completed StartGCP: 177 StopGCP: 180 #Records: 7362 #LogRecords: 0 Data: 453648 bytes Log: 0 bytes

It is also possible to perform a backup from the system shell by invoking ndb_mgm with the -e or --execute option, as shown in this example:

shell> ndb_mgm -e "START BACKUP 6 WAIT COMPLETED SNAPSHOTSTART"

When using START BACKUP in this way, you must specify the backup ID.

Cluster backups are created by default in the BACKUP subdirectory of the DataDir on each data node. This can be overridden for one or more data nodes individually, or for all cluster data nodes in the config.ini file using the BackupDataDir configuration parameter. The backup files created for a backup with a given backup_id are stored in a subdirectory named BACKUP-backup_id in the backup directory.

To abort a backup that is already in progress:

  1. Start the management client.

  2. Execute this command:

    ndb_mgm> ABORT BACKUP backup_id

    The number backup_id is the identifier of the backup that was included in the response of the management client when the backup was started (in the message Backup backup_id started from node management_node_id).

  3. The management client will acknowledge the abort request with Abort of backup backup_id ordered.

    Note

    At this point, the management client has not yet received a response from the cluster data nodes to this request, and the backup has not yet actually been aborted.

  4. After the backup has been aborted, the management client will report this fact in a manner similar to what is shown here:

    Node 1: Backup 3 started from 5 has been aborted.   Error: 1321 - Backup aborted by user request: Permanent error: User defined errorNode 3: Backup 3 started from 5 has been aborted.   Error: 1323 - 1323: Permanent error: Internal errorNode 2: Backup 3 started from 5 has been aborted.   Error: 1323 - 1323: Permanent error: Internal errorNode 4: Backup 3 started from 5 has been aborted.   Error: 1323 - 1323: Permanent error: Internal error

    In this example, we have shown sample output for a cluster with 4 data nodes, where the sequence number of the backup to be aborted is 3, and the management node to which the cluster management client is connected has the node ID 5. The first node to complete its part in aborting the backup reports that the reason for the abort was due to a request by the user. (The remaining nodes report that the backup was aborted due to an unspecified internal error.)

    Note

    There is no guarantee that the cluster nodes respond to an ABORT BACKUP command in any particular order.

    The Backup backup_id started from node management_node_id has been aborted messages mean that the backup has been terminated and that all files relating to this backup have been removed from the cluster file system.

It is also possible to abort a backup in progress from a system shell using this command:

shell> ndb_mgm -e "ABORT BACKUP backup_id"
Note

If there is no backup having the ID backup_id running when an ABORT BACKUP is issued, the management client makes no response, nor is it indicated in the cluster log that an invalid abort command was sent.

17.5.3.3. Configuration for MySQL Cluster Backups

Five configuration parameters are essential for backup:

  • BackupDataBufferSize

    The amount of memory used to buffer data before it is written to disk.

  • BackupLogBufferSize

    The amount of memory used to buffer log records before these are written to disk.

  • BackupMemory

    The total memory allocated in a data node for backups. This should be the sum of the memory allocated for the backup data buffer and the backup log buffer.

  • BackupWriteSize

    The default size of blocks written to disk. This applies for both the backup data buffer and the backup log buffer.

  • BackupMaxWriteSize

    The maximum size of blocks written to disk. This applies for both the backup data buffer and the backup log buffer.

More detailed information about these parameters can be found in Backup Parameters.

17.5.3.4. MySQL Cluster Backup Troubleshooting

If an error code is returned when issuing a backup request, the most likely cause is insufficient memory or disk space. You should check that there is enough memory allocated for the backup.

Important

If you have set BackupDataBufferSize and BackupLogBufferSize and their sum is greater than 4MB, then you must also set BackupMemory as well.

You should also make sure that there is sufficient space on the hard drive partition of the backup target.

NDB does not support repeatable reads, which can cause problems with the restoration process. Although the backup process is "hot", restoring a MySQL Cluster from backup is not a 100% "hot" process. This is due to the fact that, for the duration of the restore process, running transactions get nonrepeatable reads from the restored data. This means that the state of the data is inconsistent while the restore is in progress.

17.5.4. 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 one of the options to enable NDBCLUSTER storage engine support:

(--with-ndbcluster also works to enable NDBCLUSTER support, but is deprecated and so produces a configure warning as of MySQL 5.1.9.)

For information about other MySQL server options and variables relevant to MySQL Cluster in addition to those discussed in this section, see Section 17.3.4, "MySQL Server Options and Variables for MySQL Cluster".

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

17.5.5. Performing a Rolling Restart of a MySQL Cluster

This section discusses how to perform a rolling restart of a MySQL Cluster installation, so called because it involves stopping and starting (or restarting) each node in turn, so that the cluster itself remains operational. This is often done as part of a rolling upgrade or rolling downgrade, where high availability of the cluster is mandatory and no downtime of the cluster as a whole is permissible. Where we refer to upgrades, the information provided here also generally applies to downgrades as well.

There are a number of reasons why a rolling restart might be desirable. These are described in the next few paragraphs.

Configuration change. To make a change in the cluster's configuration, such as adding an SQL node to the cluster, or setting a configuration parameter to a new value.

MySQL Cluster software upgrade or downgrade. To upgrade the cluster to a newer version of the MySQL Cluster software (or to downgrade it to an older version). This is usually referred to as a "rolling upgrade" (or "rolling downgrade", when reverting to an older version of MySQL Cluster).

Change on node host. To make changes in the hardware or operating system on which one or more MySQL Cluster node processes are running.

System reset (cluster reset). To reset the cluster because it has reached an undesirable state. In such cases it is often desirable to reload the data and metadata of one or more data nodes. This can be done in any of three ways:

Resource Recovery. To free memory previously allocated to a table by successive INSERT and DELETE operations, for re-use by other MySQL Cluster tables.

The process for performing a rolling restart may be generalized as follows:

  1. Stop all cluster management nodes (ndb_mgmd processes), reconfigure them, then restart them. (See Rolling restarts with multiple management servers.)

  2. Stop, reconfigure, then restart each cluster data node (ndbd process) in turn.

  3. Stop, reconfigure, then restart each cluster SQL node (mysqld process) in turn.

The specifics for implementing a given rolling upgrade depend upon the changes being made. A more detailed view of the process is presented here:

MySQL Cluster Rolling Restarts (By Type)

In the previous diagram, the Stop and Start steps indicate that the process must be stopped completely using a shell command (such as kill on most Unix systems) or the management client STOP command, then started again from a system shell by invoking the ndbd or ndb_mgmd executable as appropriate. On Windows, you can also use the system NET START and NET STOP commands or the Windows Service Manager to start and stop nodes which have been installed as Windows services (see Section 17.2.2.4, "Installing MySQL Cluster Processes as Windows Services").

Restart indicates that the process may be restarted using the ndb_mgm management client RESTART command (see Section 17.5.2, "Commands in the MySQL Cluster Management Client").

MySQL Cluster supports a flexible order for upgrading nodes. When upgrading a MySQL Cluster, you may upgrade API nodes (including SQL nodes) before upgrading the management nodes, data nodes, or both. In other words, you are permitted to upgrade the API and SQL nodes in any order. This is subject to the following provisions:

  • This functionality is intended for use as part of an online upgrade only. A mix of node binaries from different MySQL Cluster releases is neither intended nor supported for continuous, long-term use in a production setting.

  • All management nodes must be upgraded before any data nodes are upgraded. This remains true regardless of the order in which you upgrade the cluster's API and SQL nodes.

  • Features specific to the "new" version must not be used until all management nodes and data nodes have been upgraded.

    This also applies to any MySQL Server version change that may apply, in addition to the NDB engine version change, so do not forget to take this into account when planning the upgrade. (This is true for online upgrades of MySQL Cluster in general.)

See also Bug #48528 and Bug #49163.

Rolling restarts with multiple management servers. When performing a rolling restart of a MySQL Cluster with multiple management nodes, you should keep in mind that ndb_mgmd checks to see if any other management node is running, and, if so, tries to use that node's configuration data. To keep this from occurring, and to force ndb_mgmd to reread its configuration file, perform the following steps:

  1. Stop all MySQL Cluster ndb_mgmd processes.

  2. Update all config.ini files.

  3. Start a single ndb_mgmd with --reload, --initial, or both options as desired.

  4. Start any remaining ndb_mgmd processes without using either of the --reload or --initial options.

  5. Complete the rolling restarts of the data nodes and API nodes as normal.

When performing a rolling restart to update the cluster's configuration, you can use the config_generation column of the ndbinfo.nodes table to keep track of which data nodes have been successfully restarted with the new configuration. See Section 17.5.10.13, "The ndbinfo nodes Table".

17.5.6. Event Reports Generated in MySQL Cluster

In this section, we discuss the types of event logs provided by MySQL Cluster, and the types of events that are logged.

MySQL Cluster provides two types of event log:

  • The cluster log, which includes events generated by all cluster nodes. The cluster log is the log recommended for most uses because it provides logging information for an entire cluster in a single location.

    By default, the cluster log is saved to a file named ndb_node_id_cluster.log, (where node_id is the node ID of the management server) in the same directory where the ndb_mgm binary resides.

    Cluster logging information can also be sent to stdout or a syslog facility in addition to or instead of being saved to a file, as determined by the values set for the DataDir and LogDestination configuration parameters. See Section 17.3.2.5, "Defining a MySQL Cluster Management Server", for more information about these parameters.

  • Node logs are local to each node.

    Output generated by node event logging is written to the file ndb_node_id_out.log (where node_id is the node's node ID) in the node's DataDir. Node event logs are generated for both management nodes and data nodes.

    Node logs are intended to be used only during application development, or for debugging application code.

Both types of event logs can be set to log different subsets of events.

Each reportable event can be distinguished according to three different criteria:

  • Category: This can be any one of the following values: STARTUP, SHUTDOWN, STATISTICS, CHECKPOINT, NODERESTART, CONNECTION, ERROR, or INFO.

  • Priority: This is represented by one of the numbers from 1 to 15 inclusive, where 1 indicates "most important" and 15 "least important."

  • Severity Level: This can be any one of the following values: ALERT, CRITICAL, ERROR, WARNING, INFO, or DEBUG.

Both the cluster log and the node log can be filtered on these properties.

The format used in the cluster log is as shown here:

2007-01-26 19:35:55 [MgmSrvr] INFO -- Node 1: Data usage is 2%(60 32K pages of total 2560)2007-01-26 19:35:55 [MgmSrvr] INFO -- Node 1: Index usage is 1%(24 8K pages of total 2336)2007-01-26 19:35:55 [MgmSrvr] INFO -- Node 1: Resource 0 min: 0 max: 639 curr: 02007-01-26 19:35:55 [MgmSrvr] INFO -- Node 2: Data usage is 2%(76 32K pages of total 2560)2007-01-26 19:35:55 [MgmSrvr] INFO -- Node 2: Index usage is 1%(24 8K pages of total 2336)2007-01-26 19:35:55 [MgmSrvr] INFO -- Node 2: Resource 0 min: 0 max: 639 curr: 02007-01-26 19:35:55 [MgmSrvr] INFO -- Node 3: Data usage is 2%(58 32K pages of total 2560)2007-01-26 19:35:55 [MgmSrvr] INFO -- Node 3: Index usage is 1%(25 8K pages of total 2336)2007-01-26 19:35:55 [MgmSrvr] INFO -- Node 3: Resource 0 min: 0 max: 639 curr: 02007-01-26 19:35:55 [MgmSrvr] INFO -- Node 4: Data usage is 2%(74 32K pages of total 2560)2007-01-26 19:35:55 [MgmSrvr] INFO -- Node 4: Index usage is 1%(25 8K pages of total 2336)2007-01-26 19:35:55 [MgmSrvr] INFO -- Node 4: Resource 0 min: 0 max: 639 curr: 02007-01-26 19:39:42 [MgmSrvr] INFO -- Node 4: Node 9 Connected2007-01-26 19:39:42 [MgmSrvr] INFO -- Node 1: Node 9 Connected2007-01-26 19:39:42 [MgmSrvr] INFO -- Node 1: Node 9: API 5.5.29-ndb-7.2.102007-01-26 19:39:42 [MgmSrvr] INFO -- Node 2: Node 9 Connected2007-01-26 19:39:42 [MgmSrvr] INFO -- Node 2: Node 9: API 5.5.29-ndb-7.2.102007-01-26 19:39:42 [MgmSrvr] INFO -- Node 3: Node 9 Connected2007-01-26 19:39:42 [MgmSrvr] INFO -- Node 3: Node 9: API 5.5.29-ndb-7.2.102007-01-26 19:39:42 [MgmSrvr] INFO -- Node 4: Node 9: API 5.5.29-ndb-7.2.102007-01-26 19:59:22 [MgmSrvr] ALERT -- Node 2: Node 7 Disconnected2007-01-26 19:59:22 [MgmSrvr] ALERT -- Node 2: Node 7 Disconnected

Each line in the cluster log contains the following information:

  • A timestamp in YYYY-MM-DD HH:MM:SS format.

  • The type of node which is performing the logging. In the cluster log, this is always [MgmSrvr].

  • The severity of the event.

  • The ID of the node reporting the event.

  • A description of the event. The most common types of events to appear in the log are connections and disconnections between different nodes in the cluster, and when checkpoints occur. In some cases, the description may contain status information.

17.5.6.1. MySQL Cluster Logging Management Commands

The following management commands are related to the cluster log:

  • CLUSTERLOG ON

    Turns the cluster log on.

  • CLUSTERLOG OFF

    Turns the cluster log off.

  • CLUSTERLOG INFO

    Provides information about cluster log settings.

  • node_id CLUSTERLOG category=threshold

    Logs category events with priority less than or equal to threshold in the cluster log.

  • CLUSTERLOG FILTER severity_level

    Toggles cluster logging of events of the specified severity_level.

The following table describes the default setting (for all data nodes) of the cluster log category threshold. If an event has a priority with a value lower than or equal to the priority threshold, it is reported in the cluster log.

Note that events are reported per data node, and that the threshold can be set to different values on different nodes.

CategoryDefault threshold (All data nodes)
STARTUP7
SHUTDOWN7
STATISTICS7
CHECKPOINT7
NODERESTART7
CONNECTION7
ERROR15
INFO7

The STATISTICS category can provide a great deal of useful data. See Section 17.5.6.3, "Using CLUSTERLOG STATISTICS in the MySQL Cluster Management Client", for more information.

Thresholds are used to filter events within each category. For example, a STARTUP event with a priority of 3 is not logged unless the threshold for STARTUP is set to 3 or higher. Only events with priority 3 or lower are sent if the threshold is 3.

The following table shows the event severity levels.

Note

These correspond to Unix syslog levels, except for LOG_EMERG and LOG_NOTICE, which are not used or mapped.

1ALERTA condition that should be corrected immediately, such as a corrupted system database
2CRITICALCritical conditions, such as device errors or insufficient resources
3ERRORConditions that should be corrected, such as configuration errors
4WARNINGConditions that are not errors, but that might require special handling
5INFOInformational messages
6DEBUGDebugging messages used for NDBCLUSTERdevelopment

Event severity levels can be turned on or off (using CLUSTERLOG FILTER-see above). If a severity level is turned on, then all events with a priority less than or equal to the category thresholds are logged. If the severity level is turned off then no events belonging to that severity level are logged.

Important

Cluster log levels are set on a per ndb_mgmd, per subscriber basis. This means that, in a MySQL Cluster with multiple management servers, using a CLUSTERLOG command in an instance of ndb_mgm connected to one management server affects only logs generated by that management server but not by any of the others. This also means that, should one of the management servers be restarted, only logs generated by that management server are affected by the resetting of log levels caused by the restart.

17.5.6.2. MySQL Cluster Log Events

An event report reported in the event logs has the following format:

datetime [string] severity -- message

For example:

09:19:30 2005-07-24 [NDB] INFO -- Node 4 Start phase 4 completed

This section discusses all reportable events, ordered by category and severity level within each category.

In the event descriptions, GCP and LCP mean "Global Checkpoint" and "Local Checkpoint", respectively.

CONNECTION Events

These events are associated with connections between Cluster nodes.

EventPrioritySeverity LevelDescription
data nodes connected8INFOData nodes connected
data nodes disconnected8INFOData nodes disconnected
Communication closed8INFOSQL node or data node connection closed
Communication opened8INFOSQL node or data node connection opened

CHECKPOINT Events

The logging messages shown here are associated with checkpoints.

EventPrioritySeverity LevelDescription
LCP stopped in calc keep GCI0ALERTLCP stopped
Local checkpoint fragment completed11INFOLCP on a fragment has been completed
Global checkpoint completed10INFOGCP finished
Global checkpoint started9INFOStart of GCP: REDO log is written to disk
Local checkpoint completed8INFOLCP completed normally
Local checkpoint started7INFOStart of LCP: data written to disk

STARTUP Events

The following events are generated in response to the startup of a node or of the cluster and of its success or failure. They also provide information relating to the progress of the startup process, including information concerning logging activities.

EventPrioritySeverity LevelDescription
Internal start signal received STTORRY15INFOBlocks received after completion of restart
New REDO log started10INFOGCI keep X, newest restorable GCI Y
New log started10INFOLog part X, start MB Y, stop MB Z
Node has been refused for inclusion in the cluster8INFONode cannot be included in cluster due to misconfiguration, inability toestablish communication, or other problem
data node neighbors8INFOShows neighboring data nodes
data node start phase X completed4INFOA data node start phase has been completed
Node has been successfully included into the cluster3INFODisplays the node, managing node, and dynamic ID
data node start phases initiated1INFONDB Cluster nodes starting
data node all start phases completed1INFONDB Cluster nodes started
data node shutdown initiated1INFOShutdown of data node has commenced
data node shutdown aborted1INFOUnable to shut down data node normally

NODERESTART Events

The following events are generated when restarting a node and relate to the success or failure of the node restart process.

EventPrioritySeverity LevelDescription
Node failure phase completed8ALERTReports completion of node failure phases
Node has failed, node state was X8ALERTReports that a node has failed
Report arbitrator results2ALERTThere are eight different possible results for arbitration attempts:
  • Arbitration check failed-less than 1/2 nodes left

  • Arbitration check succeeded-node group majority

  • Arbitration check failed-missing node group

  • Network partitioning-arbitration required

  • Arbitration succeeded-affirmative response from node X

  • Arbitration failed - negative response from node X

  • Network partitioning - no arbitrator available

  • Network partitioning - no arbitrator configured

Completed copying a fragment10INFO 
Completed copying of dictionary information8INFO 
Completed copying distribution information8INFO 
Starting to copy fragments8INFO 
Completed copying all fragments8INFO 
GCP takeover started7INFO 
GCP takeover completed7INFO 
LCP takeover started7INFO 
LCP takeover completed (state = X)7INFO 
Report whether an arbitrator is found or not6INFOThere are seven different possible outcomes when seeking an arbitrator:
  • Management server restarts arbitration thread [state=X]

  • Prepare arbitrator node X [ticket=Y]

  • Receive arbitrator node X [ticket=Y]

  • Started arbitrator node X [ticket=Y]

  • Lost arbitrator node X - process failure [state=Y]

  • Lost arbitrator node X - process exit [state=Y]

  • Lost arbitrator node X <error msg> [state=Y]

STATISTICS Events

The following events are of a statistical nature. They provide information such as numbers of transactions and other operations, amount of data sent or received by individual nodes, and memory usage.

EventPrioritySeverity LevelDescription
Report job scheduling statistics9INFOMean internal job scheduling statistics
Sent number of bytes9INFOMean number of bytes sent to node X
Received # of bytes9INFOMean number of bytes received from node X
Report transaction statistics8INFONumbers of: transactions, commits, reads, simple reads, writes,concurrent operations, attribute information, and aborts
Report operations8INFONumber of operations
Report table create7INFO 
Memory usage5INFOData and index memory usage (80%, 90%, and 100%)

ERROR Events

These events relate to Cluster errors and warnings. The presence of one or more of these generally indicates that a major malfunction or failure has occurred.

EventPrioritySeverityDescription
Dead due to missed heartbeat8ALERTNode X declared "dead" due to missed heartbeat
Transporter errors2ERROR 
Transporter warnings8WARNING 
Missed heartbeats8WARNINGNode X missed heartbeat#Y
General warning events2WARNING 

INFO Events

These events provide general information about the state of the cluster and activities associated with Cluster maintenance, such as logging and heartbeat transmission.

EventPrioritySeverityDescription
Sent heartbeat12INFOHeartbeat sent to node X
Create log bytes11INFOLog part, log file, MB
General information events2INFO 

17.5.6.3. Using CLUSTERLOG STATISTICS in the MySQL ClusterManagement Client

The NDB management client's CLUSTERLOG STATISTICS command can provide a number of useful statistics in its output. Counters providing information about the state of the cluster are updated at 5-second reporting intervals by the transaction coordinator (TC) and the local query handler (LQH), and written to the cluster log.

Transaction coordinator statistics. Each transaction has one transaction coordinator, which is chosen by one of the following methods:

  • In a round-robin fashion

  • By communication proximity

  • (Beginning with MySQL Cluster NDB 6.3.4:) By supplying a data placement hint when the transaction is started

Note

You can determine which TC selection method is used for transactions started from a given SQL node using the ndb_optimized_node_selection system variable.

All operations within the same transaction use the same transaction coordinator, which reports the following statistics:

  • Trans count. This is the number transactions started in the last interval using this TC as the transaction coordinator. Any of these transactions may have committed, have been aborted, or remain uncommitted at the end of the reporting interval.

    Note

    Transactions do not migrate between TCs.

  • Commit count. This is the number of transactions using this TC as the transaction coordinator that were committed in the last reporting interval. Because some transactions committed in this reporting interval may have started in a previous reporting interval, it is possible for Commit count to be greater than Trans count.

  • Read count. This is the number of primary key read operations using this TC as the transaction coordinator that were started in the last reporting interval, including simple reads. This count also includes reads performed as part of unique index operations. A unique index read operation generates 2 primary key read operations-1 for the hidden unique index table, and 1 for the table on which the read takes place.

  • Simple read count. This is the number of simple read operations using this TC as the transaction coordinator that were started in the last reporting interval. This is a subset of Read count. Because the value of Simple read count is incremented at a different point in time from Read count, it can lag behind Read count slightly, so it is conceivable that Simple read count is not equal to Read count for a given reporting interval, even if all reads made during that time were in fact simple reads.

  • Write count. This is the number of primary key write operations using this TC as the transaction coordinator that were started in the last reporting interval. This includes all inserts, updates, writes and deletes, as well as writes performed as part of unique index operations.

    Note

    A unique index update operation can generate multiple PK read and write operations on the index table and on the base table.

  • AttrInfoCount. This is the number of 32-bit data words received in the last reporting interval for primary key operations using this TC as the transaction coordinator. For reads, this is proportional to the number of columns requested. For inserts and updates, this is proportional to the number of columns written, and the size of their data. For delete operations, this is usually zero.

    Unique index operations generate multiple PK operations and so increase this count. However, data words sent to describe the PK operation itself, and the key information sent, are not counted here. Attribute information sent to describe columns to read for scans, or to describe ScanFilters, is also not counted in AttrInfoCount.

  • Concurrent Operations. This is the number of primary key or scan operations using this TC as the transaction coordinator that were started during the last reporting interval but that were not completed. Operations increment this counter when they are started and decrement it when they are completed; this occurs after the transaction commits. Dirty reads and writes-as well as failed operations-decrement this counter.

    The maximum value that Concurrent Operations can have is the maximum number of operations that a TC block can support; currently, this is (2 * MaxNoOfConcurrentOperations) + 16 + MaxNoOfConcurrentTransactions. (For more information about these configuration parameters, see the Transaction Parameters section of Section 17.3.2.6, "Defining MySQL Cluster Data Nodes".)

  • Abort count. This is the number of transactions using this TC as the transaction coordinator that were aborted during the last reporting interval. Because some transactions that were aborted in the last reporting interval may have started in a previous reporting interval, Abort count can sometimes be greater than Trans count.

  • Scans. This is the number of table scans using this TC as the transaction coordinator that were started during the last reporting interval. This does not include range scans (that is, ordered index scans).

  • Range scans. This is the number of ordered index scans using this TC as the transaction coordinator that were started in the last reporting interval.

Local query handler statistics (Operations). There is 1 cluster event per local query handler block (that is, 1 per data node process). Operations are recorded in the LQH where the data they are operating on resides.

Note

A single transaction may operate on data stored in multiple LQH blocks.

The Operations statistic provides the number of local operations performed by this LQH block in the last reporting interval, and includes all types of read and write operations (insert, update, write, and delete operations). This also includes operations used to replicate writes. For example, in a 2-replica cluster, the write to the primary replica is recorded in the primary LQH, and the write to the backup will be recorded in the backup LQH. Unique key operations may result in multiple local operations; however, this does not include local operations generated as a result of a table scan or ordered index scan, which are not counted.

Process scheduler statistics. In addition to the statistics reported by the transaction coordinator and local query handler, each ndbd process has a scheduler which also provides useful metrics relating to the performance of a MySQL Cluster. This scheduler runs in an infinite loop; during each loop the scheduler performs the following tasks:

  1. Read any incoming messages from sockets into a job buffer.

  2. Check whether there are any timed messages to be executed; if so, put these into the job buffer as well.

  3. Execute (in a loop) any messages in the job buffer.

  4. Send any distributed messages that were generated by executing the messages in the job buffer.

  5. Wait for any new incoming messages.

Process scheduler statistics include the following:

  • Mean Loop Counter. This is the number of loops executed in the third step from the preceding list. This statistic increases in size as the utilization of the TCP/IP buffer improves. You can use this to monitor changes in performance as you add new data node processes.

  • Mean send size and Mean receive size. These statistics enable you to gauge the efficiency of, respectively writes and reads between nodes. The values are given in bytes. Higher values mean a lower cost per byte sent or received; the maximum value is 64K.

To cause all cluster log statistics to be logged, you can use the following command in the NDB management client:

ndb_mgm> ALL CLUSTERLOG STATISTICS=15
Note

Setting the threshold for STATISTICS to 15 causes the cluster log to become very verbose, and to grow quite rapidly in size, in direct proportion to the number of cluster nodes and the amount of activity in the MySQL Cluster.

For more information about MySQL Cluster management client commands relating to logging and reporting, see Section 17.5.6.1, "MySQL Cluster Logging Management Commands".

17.5.7. MySQL Cluster Log Messages

This section contains information about the messages written to the cluster log in response to different cluster log events. It provides additional, more specific information on NDB transporter errors.

17.5.7.1. MySQL Cluster: Messages in the Cluster Log

The following table lists the most common NDB cluster log messages. For information about the cluster log, log events, and event types, see Section 17.5.6, "Event Reports Generated in MySQL Cluster". These log messages also correspond to log event types in the MGM API; see The Ndb_logevent_type Type, for related information of interest to Cluster API developers.

Log Message. Node mgm_node_id: Node data_node_id Connected

Description. The data node having node ID node_id has connected to the management server (node mgm_node_id).

Event Name. Connected

Event Type. Connection

Priority. 8

Severity. INFO

Log Message. Node mgm_node_id: Node data_node_id Disconnected

Description. The data node having node ID data_node_id has disconnected from the management server (node mgm_node_id).

Event Name. Disconnected

Event Type. Connection

Priority. 8

Severity. ALERT

Log Message. Node data_node_id: Communication to Node api_node_id closed

Description. The API node or SQL node having node ID api_node_id is no longer communicating with data node data_node_id.

Event Name. CommunicationClosed

Event Type. Connection

Priority. 8

Severity. INFO

Log Message. Node data_node_id: Communication to Node api_node_id opened

Description. The API node or SQL node having node ID api_node_id is now communicating with data node data_node_id.

Event Name. CommunicationOpened

Event Type. Connection

Priority. 8

Severity. INFO

Log Message. Node mgm_node_id: Node api_node_id: API version

Description. The API node having node ID api_node_id has connected to management node mgm_node_id using NDB API version version (generally the same as the MySQL version number).

Event Name. ConnectedApiVersion

Event Type. Connection

Priority. 8

Severity. INFO

Log Message. Node node_id: Global checkpoint gci started

Description. A global checkpoint with the ID gci has been started; node node_id is the master responsible for this global checkpoint.

Event Name. GlobalCheckpointStarted

Event Type. Checkpoint

Priority. 9

Severity. INFO

Log Message. Node node_id: Global checkpoint gci completed

Description. The global checkpoint having the ID gci has been completed; node node_id was the master responsible for this global checkpoint.

Event Name. GlobalCheckpointCompleted

Event Type. Checkpoint

Priority. 10

Severity. INFO

Log Message. Node node_id: Local checkpoint lcp started. Keep GCI = current_gci oldest restorable GCI = old_gci

Description. The local checkpoint having sequence ID lcp has been started on node node_id. The most recent GCI that can be used has the index current_gci, and the oldest GCI from which the cluster can be restored has the index old_gci.

Event Name. LocalCheckpointStarted

Event Type. Checkpoint

Priority. 7

Severity. INFO

Log Message. Node node_id: Local checkpoint lcp completed

Description. The local checkpoint having sequence ID lcp on node node_id has been completed.

Event Name. LocalCheckpointCompleted

Event Type. Checkpoint

Priority. 8

Severity. INFO

Log Message. Node node_id: Local Checkpoint stopped in CALCULATED_KEEP_GCI

Description. The node was unable to determine the most recent usable GCI.

Event Name. LCPStoppedInCalcKeepGci

Event Type. Checkpoint

Priority. 0

Severity. ALERT

Log Message. Node node_id: Table ID = table_id, fragment ID = fragment_id has completed LCP on Node node_id maxGciStarted: started_gci maxGciCompleted: completed_gci

Description. A table fragment has been checkpointed to disk on node node_id. The GCI in progress has the index started_gci, and the most recent GCI to have been completed has the index completed_gci.

Event Name. LCPFragmentCompleted

Event Type. Checkpoint

Priority. 11

Severity. INFO

Log Message. Node node_id: ACC Blocked num_1 and TUP Blocked num_2 times last second

Description. Undo logging is blocked because the log buffer is close to overflowing.

Event Name. UndoLogBlocked

Event Type. Checkpoint

Priority. 7

Severity. INFO

Log Message. Node node_id: Start initiated version

Description. Data node node_id, running NDB version version, is beginning its startup process.

Event Name. NDBStartStarted

Event Type. StartUp

Priority. 1

Severity. INFO

Log Message. Node node_id: Started version

Description. Data node node_id, running NDB version version, has started successfully.

Event Name. NDBStartCompleted

Event Type. StartUp

Priority. 1

Severity. INFO

Log Message. Node node_id: STTORRY received after restart finished

Description. The node has received a signal indicating that a cluster restart has completed.

Event Name. STTORRYRecieved

Event Type. StartUp

Priority. 15

Severity. INFO

Log Message. Node node_id: Start phase phase completed (type)

Description. The node has completed start phase phase of a type start. For a listing of start phases, see Section 17.5.1, "Summary of MySQL Cluster Start Phases". (type is one of initial, system, node, initial node, or <Unknown>.)

Event Name. StartPhaseCompleted

Event Type. StartUp

Priority. 4

Severity. INFO

Log Message. Node node_id: CM_REGCONF president = president_id, own Node = own_id, our dynamic id = dynamic_id

Description. Node president_id has been selected as "president". own_id and dynamic_id should always be the same as the ID (node_id) of the reporting node.

Event Name. CM_REGCONF

Event Type. StartUp

Priority. 3

Severity. INFO

Log Message. Node node_id: CM_REGREF from Node president_id to our Node node_id. Cause = cause

Description. The reporting node (ID node_id) was unable to accept node president_id as president. The cause of the problem is given as one of Busy, Election with wait = false, Not president, Election without selecting new candidate, or No such cause.

Event Name. CM_REGREF

Event Type. StartUp

Priority. 8

Severity. INFO

Log Message. Node node_id: We are Node own_id with dynamic ID dynamic_id, our left neighbor is Node id_1, our right is Node id_2

Description. The node has discovered its neighboring nodes in the cluster (node id_1 and node id_2). node_id, own_id, and dynamic_id should always be the same; if they are not, this indicates a serious misconfiguration of the cluster nodes.

Event Name. FIND_NEIGHBOURS

Event Type. StartUp

Priority. 8

Severity. INFO

Log Message. Node node_id: type shutdown initiated

Description. The node has received a shutdown signal. The type of shutdown is either Cluster or Node.

Event Name. NDBStopStarted

Event Type. StartUp

Priority. 1

Severity. INFO

Log Message. Node node_id: Node shutdown completed [, action] [Initiated by signal signal.]

Description. The node has been shut down. This report may include an action, which if present is one of restarting, no start, or initial. The report may also include a reference to an NDB Protocol signal; for possible signals, refer to Operations and Signals.

Event Name. NDBStopCompleted

Event Type. StartUp

Priority. 1

Severity. INFO

Log Message. Node node_id: Forced node shutdown completed [, action]. [Occured during startphase start_phase.] [ Initiated by signal.] [Caused by error error_code: 'error_message(error_classification). error_status'. [(extra info extra_code)]]

Description. The node has been forcibly shut down. The action (one of restarting, no start, or initial) subsequently being taken, if any, is also reported. If the shutdown occurred while the node was starting, the report includes the start_phase during which the node failed. If this was a result of a signal sent to the node, this information is also provided (see Operations and Signals, for more information). If the error causing the failure is known, this is also included; for more information about NDB error messages and classifications, see MySQL Cluster API Errors.

Event Name. NDBStopForced

Event Type. StartUp

Priority. 1

Severity. ALERT

Log Message. Node node_id: Node shutdown aborted

Description. The node shutdown process was aborted by the user.

Event Name. NDBStopAborted

Event Type. StartUp

Priority. 1

Severity. INFO

Log Message. Node node_id: StartLog: [GCI Keep: keep_pos LastCompleted: last_pos NewestRestorable: restore_pos]

Description. This reports global checkpoints referenced during a node start. The redo log prior to keep_pos is dropped. last_pos is the last global checkpoint in which data node the participated; restore_pos is the global checkpoint which is actually used to restore all data nodes.

Event Name. StartREDOLog

Event Type. StartUp

Priority. 4

Severity. INFO

Log Message. startup_message [Listed separately; see below.]

Description. There are a number of possible startup messages that can be logged under different circumstances.

Event Name. StartReport

Event Type. StartUp

Priority. 4

Severity. INFO

Log Message. Node node_id: Node restart completed copy of dictionary information

Description. Copying of data dictionary information to the restarted node has been completed.

Event Name. NR_CopyDict

Event Type. NodeRestart

Priority. 8

Severity. INFO

Log Message. Node node_id: Node restart completed copy of distribution information

Description. Copying of data distribution information to the restarted node has been completed.

Event Name. NR_CopyDistr

Event Type. NodeRestart

Priority. 8

Severity. INFO

Log Message. Node node_id: Node restart starting to copy the fragments to Node node_id

Description. Copy of fragments to starting data node node_id has begun

Event Name. NR_CopyFragsStarted

Event Type. NodeRestart

Priority. 8

Severity. INFO

Log Message. Node node_id: Table ID = table_id, fragment ID = fragment_id have been copied to Node node_id

Description. Fragment fragment_id from table table_id has been copied to data node node_id

Event Name. NR_CopyFragDone

Event Type. NodeRestart

Priority. 10

Severity. INFO

Log Message. Node node_id: Node restart completed copying the fragments to Node node_id

Description. Copying of all table fragments to restarting data node node_id has been completed

Event Name. NR_CopyFragsCompleted

Event Type. NodeRestart

Priority. 8

Severity. INFO

Log Message. Any of the following:

  1. Node node_id: Node node1_id completed failure of Node node2_id

  2. All nodes completed failure of Node node_id

  3. Node failure of node_idblock completed

Description. One of the following (each corresponding to the same-numbered message listed above):

  1. Data node node1_id has detected the failure of data node node2_id

  2. All (remaining) data nodes have detected the failure of data node node_id

  3. The failure of data node node_id has been detected in the blockNDB kernel block, where block is 1 of DBTC, DBDICT, DBDIH, or DBLQH; for more information, see NDB Kernel Blocks

Event Name. NodeFailCompleted

Event Type. NodeRestart

Priority. 8

Severity. ALERT

Log Message. Node mgm_node_id: Node data_node_id has failed. The Node state at failure was state_code

Description. A data node has failed. Its state at the time of failure is described by an arbitration state code state_code: possible state code values can be found in the file include/kernel/signaldata/ArbitSignalData.hpp.

Event Name. NODE_FAILREP

Event Type. NodeRestart

Priority. 8

Severity. ALERT

Log Message. President restarts arbitration thread [state=state_code] or Prepare arbitrator node node_id [ticket=ticket_id] or Receive arbitrator node node_id [ticket=ticket_id] or Started arbitrator node node_id [ticket=ticket_id] or Lost arbitrator node node_id - process failure [state=state_code] or Lost arbitrator node node_id - process exit [state=state_code] or Lost arbitrator node node_id - error_message [state=state_code]

Description. This is a report on the current state and progress of arbitration in the cluster. node_id is the node ID of the management node or SQL node selected as the arbitrator. state_code is an arbitration state code, as found in include/kernel/signaldata/ArbitSignalData.hpp. When an error has occurred, an error_message, also defined in ArbitSignalData.hpp, is provided. ticket_id is a unique identifier handed out by the arbitrator when it is selected to all the nodes that participated in its selection; this is used to ensure that each node requesting arbitration was one of the nodes that took part in the selection process.

Event Name. ArbitState

Event Type. NodeRestart

Priority. 6

Severity. INFO

Log Message. Arbitration check lost - less than 1/2 nodes left or Arbitration check won - all node groups and more than 1/2 nodes left or Arbitration check won - node group majority or Arbitration check lost - missing node group or Network partitioning - arbitration required or Arbitration won - positive reply from node node_id or Arbitration lost - negative reply from node node_id or Network partitioning - no arbitrator available or Network partitioning - no arbitrator configured or Arbitration failure - error_message [state=state_code]

Description. This message reports on the result of arbitration. In the event of arbitration failure, an error_message and an arbitration state_code are provided; definitions for both of these are found in include/kernel/signaldata/ArbitSignalData.hpp.

Event Name. ArbitResult

Event Type. NodeRestart

Priority. 2

Severity. ALERT

Log Message. Node node_id: GCP Take over started

Description. This node is attempting to assume responsibility for the next global checkpoint (that is, it is becoming the master node)

Event Name. GCP_TakeoverStarted

Event Type. NodeRestart

Priority. 7

Severity. INFO

Log Message. Node node_id: GCP Take over completed

Description. This node has become the master, and has assumed responsibility for the next global checkpoint

Event Name. GCP_TakeoverCompleted

Event Type. NodeRestart

Priority. 7

Severity. INFO

Log Message. Node node_id: LCP Take over started

Description. This node is attempting to assume responsibility for the next set of local checkpoints (that is, it is becoming the master node)

Event Name. LCP_TakeoverStarted

Event Type. NodeRestart

Priority. 7

Severity. INFO

Log Message. Node node_id: LCP Take over completed

Description. This node has become the master, and has assumed responsibility for the next set of local checkpoints

Event Name. LCP_TakeoverCompleted

Event Type. NodeRestart

Priority. 7

Severity. INFO

Log Message. Node node_id: Trans. Count = transactions, Commit Count = commits, Read Count = reads, Simple Read Count = simple_reads, Write Count = writes, AttrInfo Count = AttrInfo_objects, Concurrent Operations = concurrent_operations, Abort Count = aborts, Scans = scans, Range scans = range_scans

Description. This report of transaction activity is given approximately once every 10 seconds

Event Name. TransReportCounters

Event Type. Statistic

Priority. 8

Severity. INFO

Log Message. Node node_id: Operations=operations

Description. Number of operations performed by this node, provided approximately once every 10 seconds

Event Name. OperationReportCounters

Event Type. Statistic

Priority. 8

Severity. INFO

Log Message. Node node_id: Table with ID = table_id created

Description. A table having the table ID shown has been created

Event Name. TableCreated

Event Type. Statistic

Priority. 7

Severity. INFO

Log Message. Node node_id: Mean loop Counter in doJob last 8192 times = count

Description.

Event Name. JobStatistic

Event Type. Statistic

Priority. 9

Severity. INFO

Log Message. Mean send size to Node = node_id last 4096 sends = bytes bytes

Description. This node is sending an average of bytes bytes per send to node node_id

Event Name. SendBytesStatistic

Event Type. Statistic

Priority. 9

Severity. INFO

Log Message. Mean receive size to Node = node_id last 4096 sends = bytes bytes

Description. This node is receiving an average of bytes of data each time it receives data from node node_id

Event Name. ReceiveBytesStatistic

Event Type. Statistic

Priority. 9

Severity. INFO

Log Message. Node node_id: Data usage is data_memory_percentage% (data_pages_used 32K pages of total data_pages_total) / Node node_id: Index usage is index_memory_percentage% (index_pages_used 8K pages of total index_pages_total)

Description. This report is generated when a DUMP 1000 command is issued in the cluster management client; for more information, see DUMP 1000, in MySQL Cluster Internals

Event Name. MemoryUsage

Event Type. Statistic

Priority. 5

Severity. INFO

Log Message. Node node1_id: Transporter to node node2_id reported error error_code: error_message

Description. A transporter error occurred while communicating with node node2_id; for a listing of transporter error codes and messages, see NDB Transporter Errors, in MySQL Cluster Internals

Event Name. TransporterError

Event Type. Error

Priority. 2

Severity. ERROR

Log Message. Node node1_id: Transporter to node node2_id reported error error_code: error_message

Description. A warning of a potential transporter problem while communicating with node node2_id; for a listing of transporter error codes and messages, see NDB Transporter Errors, for more information

Event Name. TransporterWarning

Event Type. Error

Priority. 8

Severity. WARNING

Log Message. Node node1_id: Node node2_id missed heartbeat heartbeat_id

Description. This node missed a heartbeat from node node2_id

Event Name. MissedHeartbeat

Event Type. Error

Priority. 8

Severity. WARNING

Log Message. Node node1_id: Node node2_id declared dead due to missed heartbeat

Description. This node has missed at least 3 heartbeats from node node2_id, and so has declared that node "dead"

Event Name. DeadDueToHeartbeat

Event Type. Error

Priority. 8

Severity. ALERT

Log Message. Node node1_id: Node Sent Heartbeat to node = node2_id

Description. This node has sent a heartbeat to node node2_id

Event Name. SentHeartbeat

Event Type. Info

Priority. 12

Severity. INFO

Log Message. Node node_id: Event buffer status: used=bytes_used (percent_used%) alloc=bytes_allocated (percent_available%) max=bytes_available apply_gci=latest_restorable_GCI latest_gci=latest_GCI

Description. This report is seen during heavy event buffer usage, for example, when many updates are being applied in a relatively short period of time; the report shows the number of bytes and the percentage of event buffer memory used, the bytes allocated and percentage still available, and the latest and latest restorable global checkpoints

Event Name. EventBufferStatus

Event Type. Info

Priority. 7

Severity. INFO

Log Message. Node node_id: Entering single user mode, Node node_id: Entered single user mode Node API_node_id has exclusive access, Node node_id: Entering single user mode

Description. These reports are written to the cluster log when entering and exiting single user mode; API_node_id is the node ID of the API or SQL having exclusive access to the cluster (for more information, see Section 17.5.8, "MySQL Cluster Single User Mode"); the message Unknown single user report API_node_id indicates an error has taken place and should never be seen in normal operation

Event Name. SingleUser

Event Type. Info

Priority. 7

Severity. INFO

Log Message. Node node_id: Backup backup_id started from node mgm_node_id

Description. A backup has been started using the management node having mgm_node_id; this message is also displayed in the cluster management client when the START BACKUP command is issued; for more information, see Section 17.5.3.2, "Using The MySQL Cluster Management Client to Create a Backup"

Event Name. BackupStarted

Event Type. Backup

Priority. 7

Severity. INFO

Log Message. Node node_id: Backup backup_id started from node mgm_node_id completed. StartGCP: start_gcp StopGCP: stop_gcp #Records: records #LogRecords: log_records Data: data_bytes bytes Log: log_bytes bytes

Description. The backup having the ID backup_id has been completed; for more information, see Section 17.5.3.2, "Using The MySQL Cluster Management Client to Create a Backup"

Event Name. BackupCompleted

Event Type. Backup

Priority. 7

Severity. INFO

Log Message. Node node_id: Backup request from mgm_node_id failed to start. Error: error_code

Description. The backup failed to start; for error codes, see MGM API Errors

Event Name. BackupFailedToStart

Event Type. Backup

Priority. 7

Severity. ALERT

Log Message. Node node_id: Backup backup_id started from mgm_node_id has been aborted. Error: error_code

Description. The backup was terminated after starting, possibly due to user intervention

Event Name. BackupAborted

Event Type. Backup

Priority. 7

Severity. ALERT

17.5.7.2. MySQL Cluster: NDB Transporter Errors

This section lists error codes, names, and messages that are written to the cluster log in the event of transporter errors.

Error CodeError NameError Text
0x00TE_NO_ERRORNo error
0x01TE_ERROR_CLOSING_SOCKETError found during closing of socket
0x02TE_ERROR_IN_SELECT_BEFORE_ACCEPTError found before accept. The transporter will retry
0x03TE_INVALID_MESSAGE_LENGTHError found in message (invalid message length)
0x04TE_INVALID_CHECKSUMError found in message (checksum)
0x05TE_COULD_NOT_CREATE_SOCKETError found while creating socket(can't create socket)
0x06TE_COULD_NOT_BIND_SOCKETError found while binding server socket
0x07TE_LISTEN_FAILEDError found while listening to server socket
0x08TE_ACCEPT_RETURN_ERRORError found during accept(accept return error)
0x0bTE_SHM_DISCONNECTThe remote node has disconnected
0x0cTE_SHM_IPC_STATUnable to check shm segment
0x0dTE_SHM_UNABLE_TO_CREATE_SEGMENTUnable to create shm segment
0x0eTE_SHM_UNABLE_TO_ATTACH_SEGMENTUnable to attach shm segment
0x0fTE_SHM_UNABLE_TO_REMOVE_SEGMENTUnable to remove shm segment
0x10TE_TOO_SMALL_SIGIDSig ID too small
0x11TE_TOO_LARGE_SIGIDSig ID too large
0x12TE_WAIT_STACK_FULLWait stack was full
0x13TE_RECEIVE_BUFFER_FULLReceive buffer was full
0x14TE_SIGNAL_LOST_SEND_BUFFER_FULLSend buffer was full,and trying to force send fails
0x15TE_SIGNAL_LOSTSend failed for unknown reason(signal lost)
0x16TE_SEND_BUFFER_FULLThe send buffer was full, but sleeping for a while solved
0x0017TE_SCI_LINK_ERRORThere is no link from this node to the switch
0x18TE_SCI_UNABLE_TO_START_SEQUENCECould not start a sequence, because system resources are exumed or no sequence has been created
0x19TE_SCI_UNABLE_TO_REMOVE_SEQUENCECould not remove a sequence
0x1aTE_SCI_UNABLE_TO_CREATE_SEQUENCECould not create a sequence, because system resources are exempted. Must reboot
0x1bTE_SCI_UNRECOVERABLE_DATA_TFX_ERRORTried to send data on redundant link but failed
0x1cTE_SCI_CANNOT_INIT_LOCALSEGMENTCannot initialize local segment
0x1dTE_SCI_CANNOT_MAP_REMOTESEGMENTCannot map remote segment
0x1eTE_SCI_UNABLE_TO_UNMAP_SEGMENTCannot free the resources used by this segment (step 1)
0x1fTE_SCI_UNABLE_TO_REMOVE_SEGMENTCannot free the resources used by this segment (step 2)
0x20TE_SCI_UNABLE_TO_DISCONNECT_SEGMENTCannot disconnect from a remote segment
0x21TE_SHM_IPC_PERMANENTShm ipc Permanent error
0x22TE_SCI_UNABLE_TO_CLOSE_CHANNELUnable to close the sci channel and the resourcesallocated

17.5.8. MySQL Cluster Single User Mode

Single user mode enables the database administrator to restrict access to the database system to a single API node, such as a MySQL server (SQL node) or an instance of ndb_restore. When entering single user mode, connections to all other API nodes are closed gracefully and all running transactions are aborted. No new transactions are permitted to start.

Once the cluster has entered single user mode, only the designated API node is granted access to the database.

You can use the ALL STATUS command in the ndb_mgm client to see when the cluster has entered single user mode. You can also check the status column of the ndbinfo.nodes table (see Section 17.5.10.13, "The ndbinfo nodes Table", for more information).

Example:

ndb_mgm> ENTER SINGLE USER MODE 5

After this command has executed and the cluster has entered single user mode, the API node whose node ID is 5 becomes the cluster's only permitted user.

The node specified in the preceding command must be an API node; attempting to specify any other type of node will be rejected.

Note

When the preceding command is invoked, all transactions running on the designated node are aborted, the connection is closed, and the server must be restarted.

The command EXIT SINGLE USER MODE changes the state of the cluster's data nodes from single user mode to normal mode. API nodes-such as MySQL Servers-waiting for a connection (that is, waiting for the cluster to become ready and available), are again permitted to connect. The API node denoted as the single-user node continues to run (if still connected) during and after the state change.

Example:

ndb_mgm> EXIT SINGLE USER MODE

There are two recommended ways to handle a node failure when running in single user mode:

  • Method 1:

    1. Finish all single user mode transactions

    2. Issue the EXIT SINGLE USER MODE command

    3. Restart the cluster's data nodes

  • Method 2:

    Restart database nodes prior to entering single user mode.

17.5.9. Quick Reference: MySQL Cluster SQL Statements

This section discusses several SQL statements that can prove useful in managing and monitoring a MySQL server that is connected to a MySQL Cluster, and in some cases provide information about the cluster itself.

  • SHOW ENGINE NDB STATUS, SHOW ENGINE NDBCLUSTER STATUS

    The output of this statement contains information about the server's connection to the cluster, creation and usage of MySQL Cluster objects, and binary logging for MySQL Cluster replication.

    See Section 13.7.5.16, "SHOW ENGINE Syntax", for a usage example and more detailed information.

  • SHOW ENGINES

    This statement can be used to determine whether or not clustering support is enabled in the MySQL server, and if so, whether it is active.

    See Section 13.7.5.17, "SHOW ENGINES Syntax", for more detailed information.

    Note

    In MySQL 5.1 and later, this statement does not support a LIKE clause. However, you can use LIKE to filter queries against the INFORMATION_SCHEMA.ENGINES, as discussed in the next item.

  • SELECT * FROM INFORMATION_SCHEMA.ENGINES [WHERE ENGINE LIKE 'NDB%']

    This is the equivalent of SHOW ENGINES, but uses the ENGINES table of the INFORMATION_SCHEMA database. Unlike the case with the SHOW ENGINES statement, it is possible to filter the results using a LIKE clause, and to select specific columns to obtain information that may be of use in scripts. For example, the following query shows whether the server was built with NDB support and, if so, whether it is enabled:

    mysql> SELECT SUPPORT FROM INFORMATION_SCHEMA.ENGINES ->   WHERE ENGINE LIKE 'NDB%';+---------+| support |+---------+| ENABLED |+---------+

    See Section 20.6, "The INFORMATION_SCHEMA ENGINES Table", for more information.

  • SHOW VARIABLES LIKE 'NDB%'

    This statement provides a list of most server system variables relating to the NDB storage engine, and their values, as shown here:

    mysql> SHOW VARIABLES LIKE 'NDB%';+-------------------------------------+-------+| Variable_name   | Value |+-------------------------------------+-------+| ndb_autoincrement_prefetch_sz   | 32 || ndb_cache_check_time | 0 || ndb_extra_logging   | 0 || ndb_force_send  | ON || ndb_index_stat_cache_entries | 32 || ndb_index_stat_enable   | OFF   || ndb_index_stat_update_freq  | 20 || ndb_report_thresh_binlog_epoch_slip | 3 || ndb_report_thresh_binlog_mem_usage  | 10 || ndb_use_copying_alter_table | OFF   || ndb_use_exact_count | ON || ndb_use_transactions | ON |+-------------------------------------+-------+

    See Section 5.1.4, "Server System Variables", for more information.

  • SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME LIKE 'NDB%';

    This statement is the equivalent of the SHOW command described in the previous item, and provides almost identical output, as shown here:

    mysql> SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES ->   WHERE VARIABLE_NAME LIKE 'NDB%';+-------------------------------------+----------------+| VARIABLE_NAME   | VARIABLE_VALUE |+-------------------------------------+----------------+| NDB_AUTOINCREMENT_PREFETCH_SZ   | 32 || NDB_CACHE_CHECK_TIME | 0  || NDB_EXTRA_LOGGING   | 0  || NDB_FORCE_SEND  | ON || NDB_INDEX_STAT_CACHE_ENTRIES | 32 || NDB_INDEX_STAT_ENABLE   | OFF || NDB_INDEX_STAT_UPDATE_FREQ  | 20 || NDB_REPORT_THRESH_BINLOG_EPOCH_SLIP | 3  || NDB_REPORT_THRESH_BINLOG_MEM_USAGE  | 10 || NDB_USE_COPYING_ALTER_TABLE | OFF || NDB_USE_EXACT_COUNT | ON || NDB_USE_TRANSACTIONS | ON |+-------------------------------------+----------------+

    Unlike the case with the SHOW command, it is possible to select individual columns. For example:

    mysql> SELECT VARIABLE_VALUE  ->   FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES ->   WHERE VARIABLE_NAME = 'ndb_force_send';+----------------+| VARIABLE_VALUE |+----------------+| ON |+----------------+

    See Section 20.9, "The INFORMATION_SCHEMA GLOBAL_VARIABLES and SESSION_VARIABLES Tables", and Section 5.1.4, "Server System Variables", for more information.

  • SHOW STATUS LIKE 'NDB%'

    This statement shows at a glance whether or not the MySQL server is acting as a cluster SQL node, and if so, it provides the MySQL server's cluster node ID, the host name and port for the cluster management server to which it is connected, and the number of data nodes in the cluster, as shown here:

    mysql> SHOW STATUS LIKE 'NDB%';+--------------------------+---------------+| Variable_name | Value |+--------------------------+---------------+| Ndb_cluster_node_id  | 10 || Ndb_config_from_host | 192.168.0.103 || Ndb_config_from_port | 1186  || Ndb_number_of_data_nodes | 4 |+--------------------------+---------------+

    If the MySQL server was built with clustering support, but it is not connected to a cluster, all rows in the output of this statement contain a zero or an empty string:

    mysql> SHOW STATUS LIKE 'NDB%';+--------------------------+-------+| Variable_name | Value |+--------------------------+-------+| Ndb_cluster_node_id  | 0 || Ndb_config_from_host |   || Ndb_config_from_port | 0 || Ndb_number_of_data_nodes | 0 |+--------------------------+-------+

    See also Section 13.7.5.36, "SHOW STATUS Syntax".

  • SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE 'NDB%';

    This statement provides similar output to the SHOW command discussed in the previous item. However, unlike the case with SHOW STATUS, it is possible using the SELECT to extract values in SQL for use in scripts for monitoring and automation purposes.

    See Section 20.8, "The INFORMATION_SCHEMA GLOBAL_STATUS and SESSION_STATUS Tables", for more information.

You can also query the tables in the ndbinfo information database for real-time data about many MySQL Cluster operations. See Section 17.5.10, "The ndbinfo MySQL Cluster Information Database".

17.5.10. The ndbinfo MySQL Cluster Information Database

ndbinfo is a database storing containing information specific to MySQL Cluster.

This database contains a number of tables, each providing a different sort of data about MySQL Cluster node status, resource usage, and operations. You can find more detailed information about each of these tables in the next several sections.

ndbinfo is included with MySQL Cluster support in the MySQL Server; no special compilation or configuration steps are required; the tables are created by the MySQL Server when it connects to the cluster. You can verify that ndbinfo support is active in a given MySQL Server instance using SHOW PLUGINS; if ndbinfo support is enabled, you should see a row containing ndbinfo in the Name column and ACTIVE in the Status column, as shown here (emphasized text):

mysql> SHOW PLUGINS;+----------------------------------+--------+--------------------+---------+---------+| Name | Status | Type   | Library | License |+----------------------------------+--------+--------------------+---------+---------+| binlog   | ACTIVE | STORAGE ENGINE | NULL | GPL || mysql_native_password | ACTIVE | AUTHENTICATION | NULL | GPL || mysql_old_password   | ACTIVE | AUTHENTICATION | NULL | GPL || CSV  | ACTIVE | STORAGE ENGINE | NULL | GPL || MEMORY   | ACTIVE | STORAGE ENGINE | NULL | GPL || MRG_MYISAM   | ACTIVE | STORAGE ENGINE | NULL | GPL || MyISAM   | ACTIVE | STORAGE ENGINE | NULL | GPL || PERFORMANCE_SCHEMA   | ACTIVE | STORAGE ENGINE | NULL | GPL || BLACKHOLE | ACTIVE | STORAGE ENGINE | NULL | GPL || ARCHIVE  | ACTIVE | STORAGE ENGINE | NULL | GPL || ndbcluster   | ACTIVE | STORAGE ENGINE | NULL | GPL || ndbinfo  | ACTIVE | STORAGE ENGINE | NULL | GPL || ndb_transid_mysql_connection_map | ACTIVE | INFORMATION SCHEMA | NULL | GPL || InnoDB   | ACTIVE | STORAGE ENGINE | NULL | GPL || INNODB_TRX   | ACTIVE | INFORMATION SCHEMA | NULL | GPL || INNODB_LOCKS | ACTIVE | INFORMATION SCHEMA | NULL | GPL || INNODB_LOCK_WAITS | ACTIVE | INFORMATION SCHEMA | NULL | GPL || INNODB_CMP   | ACTIVE | INFORMATION SCHEMA | NULL | GPL || INNODB_CMP_RESET | ACTIVE | INFORMATION SCHEMA | NULL | GPL || INNODB_CMPMEM | ACTIVE | INFORMATION SCHEMA | NULL | GPL || INNODB_CMPMEM_RESET  | ACTIVE | INFORMATION SCHEMA | NULL | GPL || partition | ACTIVE | STORAGE ENGINE | NULL | GPL |+----------------------------------+--------+--------------------+---------+---------+22 rows in set (0.00 sec)

You can also do this by checking the output of SHOW ENGINES for a line including ndbinfo in the Engine column and YES in the Support column, as shown here (emphasized text):

mysql> SHOW ENGINES\G*************************** 1. row ***************************  Engine: ndbcluster Support: YES Comment: Clustered, fault-tolerant tablesTransactions: YES  XA: NO  Savepoints: NO*************************** 2. row ***************************  Engine: MRG_MYISAM Support: YES Comment: Collection of identical MyISAM tablesTransactions: NO  XA: NO  Savepoints: NO*************************** 3. row ***************************  Engine: ndbinfo Support: YES Comment: MySQL Cluster system information storage engineTransactions: NO  XA: NO  Savepoints: NO*************************** 4. row ***************************  Engine: CSV Support: YES Comment: CSV storage engineTransactions: NO  XA: NO  Savepoints: NO*************************** 5. row ***************************  Engine: MEMORY Support: YES Comment: Hash based, stored in memory, useful for temporary tablesTransactions: NO  XA: NO  Savepoints: NO*************************** 6. row ***************************  Engine: FEDERATED Support: NO Comment: Federated MySQL storage engineTransactions: NULL  XA: NULL  Savepoints: NULL*************************** 7. row ***************************  Engine: ARCHIVE Support: YES Comment: Archive storage engineTransactions: NO  XA: NO  Savepoints: NO*************************** 8. row ***************************  Engine: InnoDB Support: YES Comment: Supports transactions, row-level locking, and foreign keysTransactions: YES  XA: YES  Savepoints: YES*************************** 9. row ***************************  Engine: MyISAM Support: DEFAULT Comment: Default engine as of MySQL 3.23 with great performanceTransactions: NO  XA: NO  Savepoints: NO*************************** 10. row ***************************  Engine: BLACKHOLE Support: YES Comment: /dev/null storage engine (anything you write to it disappears)Transactions: NO  XA: NO  Savepoints: NO10 rows in set (0.00 sec)

If ndbinfo support is enabled, then you can access ndbinfo using SQL statements in mysql or another MySQL client. For example, you can see ndbinfo listed in the output of SHOW DATABASES, as shown here:

mysql> SHOW DATABASES;+--------------------+| Database   |+--------------------+| information_schema || mysql  || ndbinfo || test   |+--------------------+4 rows in set (0.00 sec)

If the mysqld process was not started with the --ndbcluster option, ndbinfo is not available and is not displayed by SHOW DATABASES. If mysqld was formerly connected to a MySQL Cluster but the cluster becomes unavailable (due to events such as cluster shutdown, loss of network connectivity, and so forth), ndbinfo and its tables remain visible, but an attempt to access any tables (other than blocks or config_params) fails with Got error 157 'Connection to NDB failed' from NDBINFO.

With the exception of the blocks and config_params tables, what we refer to as ndbinfo "tables" are actually views generated from internal NDB tables not normally visible to the MySQL Server.

All ndbinfo tables are read-only, and are generated on demand when queried. Because many of them are generated in parallel by the data nodes while other are specific to a given SQL node, they are not guaranteed to provide a consistent snapshot.

In addition, pushing down of joins is not supported on ndbinfo tables; so joining large ndbinfo tables can require transfer of a large amount of data to the requesting API node, even when the query makes use of a WHERE clause.

ndbinfo tables are not included in the query cache. (Bug #59831)

You can select the ndbinfo database with a USE statement, and then issue a SHOW TABLES statement to obtain a list of tables, just as for any other database, like this:

mysql> USE ndbinfo;Database changedmysql> SHOW TABLES;+----------------------+| Tables_in_ndbinfo |+----------------------+| blocks   || cluster_operations   || cluster_transactions || config_params || counters || diskpagebuffer   || logbuffers   || logspaces || memoryusage  || nodes || resources || server_operations || server_transactions  || threadblocks || threadstat   || transporters |+----------------------+16 rows in set (0.04 sec)

The cluster_operations, cluster_transactions, server_operations, server_transactions, threadblocks, and threadstat tables were added in MySQL Cluster NDB 7.2.2.

You can execute SELECT statements against these tables, just as you would normally expect:

mysql> SELECT * FROM memoryusage;+---------+--------------+------+-------+| node_id | DATA_MEMORY  | used | max   |+---------+--------------+------+-------+|   1 | DATA_MEMORY  | 3230 |  6408 ||   2 | DATA_MEMORY  | 3230 |  6408 ||   1 | INDEX_MEMORY |   16 | 12832 ||   2 | INDEX_MEMORY |   16 | 12832 |+---------+--------------+------+-------+4 rows in set (0.37 sec)

More complex queries, such as the two following SELECT statements using the memoryusage table, are possible:

mysql> SELECT SUM(used) as 'Data Memory Used, All Nodes'  > FROM memoryusage  > WHERE DATA_MEMORY = 'DATA_MEMORY';+-----------------------------+| Data Memory Used, All Nodes |+-----------------------------+| 6460 |+-----------------------------+1 row in set (0.37 sec)mysql> SELECT SUM(max) as 'Total IndexMemory Available'  > FROM memoryusage  > WHERE DATA_MEMORY = 'INDEX_MEMORY';+-----------------------------+| Total IndexMemory Available |+-----------------------------+|   25664 |+-----------------------------+1 row in set (0.33 sec)

ndbinfo table and column names are case sensitive (as is the name of the ndbinfo database itself). These identifiers are in lowercase. Trying to use the wrong lettercase results in an error, as shown in this example:

mysql> SELECT * FROM nodes;+---------+--------+---------+-------------+| node_id | uptime | status  | start_phase |+---------+--------+---------+-------------+|   1 |  13602 | STARTED |   0 ||   2 | 16 | STARTED |   0 |+---------+--------+---------+-------------+2 rows in set (0.04 sec)mysql> SELECT * FROM Nodes;ERROR 1146 (42S02): Table 'ndbinfo.Nodes' doesn't exist

mysqldump ignores the ndbinfo database entirely, and excludes it from any output. This is true even when using the --databases or --all-databases option.

MySQL Cluster also maintains tables in the INFORMATION_SCHEMA information database, including the FILES table which contains information about files used for MySQL Cluster Disk Data storage. For more information, see Section 20.29, "INFORMATION_SCHEMA Tables for MySQL Cluster".

17.5.10.1. The ndbinfo arbitrator_validity_detail Table

The arbitrator_validity_detail table shows the view that each data node in the cluster of the arbitrator. It is a subset of the membership table.

The following table provides information about the columns in the arbitrator_validity_detail table. For each column, the table shows the name, data type, and a brief description. Additional information can be found in the notes following the table.

Column NameTypeRemarks
node_idintegerThis node's node ID
arbitratorintegerNode ID of arbitrator
arb_ticketstringInternal identifier used to track arbitration
arb_connectedYes or NoWhather this node is connected to the arbitrator
arb_stateEnumeration (see text)Arbtitration state

The node ID is the same as that reported by ndb_mgm -e "SHOW".

All nodes should show the same arbitrator and arb_ticket values as well as the same arb_state value. Possible arb_state values are ARBIT_NULL, ARBIT_INIT, ARBIT_FIND, ARBIT_PREP1, ARBIT_PREP2, ARBIT_START, ARBIT_RUN, ARBIT_CHOOSE, ARBIT_CRASH, and UNKNOWN.

arb_connected shows whether the current node is connected to the arbitrator.

Like the membership and arbitrator_validity_summary tables, this table was added in MySQL Cluster NDB 7.2.10.

17.5.10.2. The ndbinfo arbitrator_validity_summary Table

The arbitrator_validity_summary table provides a composite view of the arbitrator with regard to the cluster's data nodes.

The following table provides information about the columns in the arbitrator_validity_detail table. For each column, the table shows the name, data type, and a brief description. Additional information can be found in the notes following the table.

Column NameTypeRemarks
arbitratorintegerNode ID of arbitrator
arb_ticketstringInternal identifier used to track arbitration
arb_connectedYes or NoWhether this arbitrator is connected to the cluster
consensus_countintegerNumber of data nodes that see this node as arbitrator

In normal operations, this table should have only 1 row for any appreciable length of time. If it has more than 1 row for longer than a few moments, then either not all nodes are connected to the arbitrator, or all nodes are connected, but do not agree on the same arbitrator.

The arbitrator column shows the arbitrator's node ID.

arb_ticket is the internal identifier used by this arbitrator.

arb_connected shows whether this node is connected to the cluster as an arbitrator.

Like the membership and arbitrator_validity_detail tables, this table was added in MySQL Cluster NDB 7.2.10.

17.5.10.3. The ndbinfo blocks Table

The blocks table is a static table which simply contains the names and internal IDs of all NDB kernel blocks (see NDB Kernel Blocks). It is for use by the other ndbinfo tables (most of which are actually views) in mapping block numbers to block names for producing human-readable output.

The following table provides information about the columns in the blocks table. For each column, the table shows the name, data type, and a brief description. Additional information can be found in the notes following the table.

Column NameTypeRemarks
block_numberintegerBlock number
block_namestringBlock name

To obtain a list of all block names, simply execute SELECT block_name FROM ndbinfo.blocks. Although this is a static table, its content can vary between different MySQL Cluster releases.

17.5.10.4. The ndbinfo cluster_operations Table

The cluster_operations table provides a per-operation (stateful primary key op) view of all activity in the MySQL Cluster from the point of view of the local data management (LQH) blocks (see The DBLQH Block).

The following table provides information about the columns in the cluster_operations table. For each column, the table shows the name, data type, and a brief description. Additional information can be found in the notes following the table.

Column NameTypeRemarks
node_idintegerNode ID of reporting LQH block
block_instanceintegerLQH block instance
transidintegerTransaction ID
operation_typestringOperation type (see text for possible values)
statestringOperation state (see text for possible values)
tableidintegerTable ID
fragmentidintegerFragment ID
client_node_idintegerClient node ID
client_block_refintegerClient block reference
tc_node_idintegerTransaction coordinator node ID
tc_block_nointegerTransaction coordinator block number
tc_block_instanceintegerTransaction coordinator block instance

The transaction ID is a unique 64-bit number which can be obtained using the NDB API's getTransactionId() method. (Currently, the MySQL Server does not expose the NDB API transaction ID of an ongoing transaction.)

The operation_type column can take any one of the values READ, READ-SH, READ-EX, INSERT, UPDATE, DELETE, WRITE, UNLOCK, REFRESH, SCAN, SCAN-SH, SCAN-EX, or <unknown>.

The state column can have any one of the values ABORT_QUEUED, ABORT_STOPPED, COMMITTED, COMMIT_QUEUED, COMMIT_STOPPED, COPY_CLOSE_STOPPED, COPY_FIRST_STOPPED, COPY_STOPPED, COPY_TUPKEY, IDLE, LOG_ABORT_QUEUED, LOG_COMMIT_QUEUED, LOG_COMMIT_QUEUED_WAIT_SIGNAL, LOG_COMMIT_WRITTEN, LOG_COMMIT_WRITTEN_WAIT_SIGNAL, LOG_QUEUED, PREPARED, PREPARED_RECEIVED_COMMIT, SCAN_CHECK_STOPPED, SCAN_CLOSE_STOPPED, SCAN_FIRST_STOPPED, SCAN_RELEASE_STOPPED, SCAN_STATE_USED, SCAN_STOPPED, SCAN_TUPKEY, STOPPED, TC_NOT_CONNECTED, WAIT_ACC, WAIT_ACC_ABORT, WAIT_AI_AFTER_ABORT, WAIT_ATTR, WAIT_SCAN_AI, WAIT_TUP, WAIT_TUPKEYINFO, WAIT_TUP_COMMIT, or WAIT_TUP_TO_ABORT. (If the MySQL Server is running with ndbinfo_show_hidden enabled, you can view this list of states by selecting from the ndb$dblqh_tcconnect_state table, which is normally hidden.)

You can obtain the name of an NDB table from its table ID by checking the output of ndb_show_tables.

The fragid is the same as the partition number seen in the output of ndb_desc --extra-partition-info (short form -p).

In client_node_id and client_block_ref, client refers to a MySQL Cluster API or SQL node (that is, an NDB API client or a MySQL Server attached to the cluster).

This table was added in MySQL Cluster NDB 7.2.2.

17.5.10.5. The ndbinfo cluster_transactions Table

The cluster_transactions table shows information about all ongoing transactions in a MySQL Cluster.

The following table provides information about the columns in the cluster_transactions table. For each column, the table shows the name, data type, and a brief description. Additional information can be found in the notes following the table.

Column NameTypeRemarks
node_idintegerNode ID of transaction coordinator
block_instanceintegerTC block instance
transidintegerTransaction ID
statestringOperation state (see text for possible values)
count_operationsintegerNumber of stateful primary key operations in transaction (includes readswith locks, as well as DML operations)
outstanding_operationsintegerOperations still being executed in local data management blocks
inactive_secondsintegerTime spent waiting for API
client_node_idintegerClient node ID
client_block_refintegerClient block reference

The transaction ID is a unique 64-bit number which can be obtained using the NDB API's getTransactionId() method. (Currently, the MySQL Server does not expose the NDB API transaction ID of an ongoing transaction.)

The state column can have any one of the values CS_ABORTING, CS_COMMITTING, CS_COMMIT_SENT, CS_COMPLETE_SENT, CS_COMPLETING, CS_CONNECTED, CS_DISCONNECTED, CS_FAIL_ABORTED, CS_FAIL_ABORTING, CS_FAIL_COMMITTED, CS_FAIL_COMMITTING, CS_FAIL_COMPLETED, CS_FAIL_PREPARED, CS_PREPARE_TO_COMMIT, CS_RECEIVING, CS_REC_COMMITTING, CS_RESTART, CS_SEND_FIRE_TRIG_REQ, CS_STARTED, CS_START_COMMITTING, CS_START_SCAN, CS_WAIT_ABORT_CONF, CS_WAIT_COMMIT_CONF, CS_WAIT_COMPLETE_CONF, CS_WAIT_FIRE_TRIG_REQ. (If the MySQL Server is running with ndbinfo_show_hidden enabled, you can view this list of states by selecting from the ndb$dbtc_apiconnect_state table, which is normally hidden.)

In client_node_id and client_block_ref, client refers to a MySQL Cluster API or SQL node (that is, an NDB API client or a MySQL Server attached to the cluster).

This table was added in MySQL Cluster NDB 7.2.2.

17.5.10.6. The ndbinfo config_params Table

The config_params table is a static table which provides the names and internal ID numbers of all MySQL Cluster configuration parameters.

The following table provides information about the columns in the config_params table. For each column, the table shows the name, data type, and a brief description. Additional information can be found in the notes following the table.

Column NameTypeRemarks
param_numberintegerThe parameter's internal ID number
param_namestringThe name of the parameter

Although this is a static table, its content can vary between MySQL Cluster installations, since supported parameters can vary due to differences between software releases, cluster hardware configurations, and other factors.

17.5.10.7. The ndbinfo counters Table

The counters table provides running totals of events such as reads and writes for specific kernel blocks and data nodes. Counts are kept from the most recent node start or restart; a node start or restart resets all counters on that node. Not all kernel blocks have all types of counters.

The following table provides information about the columns in the counters table. For each column, the table shows the name, data type, and a brief description. Additional information can be found in the notes following the table.

Column NameTypeRemarks
node_idintegerThe data node ID
block_namestringName of the associated NDB kernel block (see NDB Kernel Blocks).
block_instanceintegerBlock instance
counter_idintegerThe counter's internal ID number; normally an integer between 1 and 10, inclusive.
counter_namestringThe name of the counter. See text for names of individual counters and the NDB kernel block with which each counter isassociated.
valintegerThe counter's value

Each counter is associated with a particular NDB kernel block. Prior to MySQL Cluster NDB 7.2.0, this was limited to either the DBLQH kernel block or the DBTC kernel block.

The OPERATIONS counter is associated with the DBLQH (local query handler) kernel block (see The DBLQH Block).

The ATTRINFO, TRANSACTIONS, COMMITS, READS, SIMPLE_READS, WRITES, ABORTS, TABLE_SCANS, and RANGE_SCANS counters are associated with the DBTC (transaction co-ordinator) kernel block (see The DBTC Block).

MySQL Cluster NDB 7.2.0, as part of its implementation of distributed pushed-down joins, adds the LOCAL_TABLE_SCANS_SENT, READS_RECEIVED, PRUNED_RANGE_SCANS_RECEIVED, RANGE_SCANS_RECEIVED, LOCAL_READS_SENT, CONST_PRUNED_RANGE_SCANS_RECEIVED, LOCAL_RANGE_SCANS_SENT, REMOTE_READS_SENT, REMOTE_RANGE_SCANS_SENT, READS_NOT_FOUND, SCAN_BATCHES_RETURNED, TABLE_SCANS_RECEIVED, and SCAN_ROWS_RETURNED counters. These counters are associated with the DBSPJ (select push-down join) kernel block (see The DBSPJ Block).

A number of counters increasing the visibility of transporter overload and send buffer sizing when troubleshooting such issues were added in MySQL Cluster NDB 7.2.10. (Bug #15935206) For each LQH instance, there is one instance of each counter in the following list:

  • LQHKEY_OVERLOAD: Number of primary key requests rejected at the LQH block instance due to transporter overload

  • LQHKEY_OVERLOAD_TC: Count of instances of LQHKEY_OVERLOAD where the TC node transporter was overloaded

  • LQHKEY_OVERLOAD_READER: Count of instances of LQHKEY_OVERLOAD where the API reader (reads only) node was overloaded.

  • LQHKEY_OVERLOAD_NODE_PEER: Count of instances of LQHKEY_OVERLOAD where the next backup data node (writes only) was overloaded

  • LQHKEY_OVERLOAD_SUBSCRIBER: Count of instances of LQHKEY_OVERLOAD where a event subscriber (writes only) was overloaded.

  • LQHSCAN_SLOWDOWNS: Count of instances where a fragment scan batch size was reduced due to scanning API transporter overload.

17.5.10.8. The ndbinfo diskpagebuffer Table

The diskpagebuffer table provides statistics about disk page buffer usage by MySQL Cluster Disk Data tables.

The following table provides information about the columns in the diskpagebuffer table. For each column, the table shows the name, data type, and a brief description. Additional information can be found in the notes following the table.

Column NameTypeRemarks
node_idintegerThe data node ID
block_instanceintegerBlock instance
pages_writtenintegerNumber of pages written to disk.
pages_written_lcpintegerNumber of pages written by local checkpoints.
pages_readintegerNumber of pages read from disk
log_waitsintegerNumber of page writes waiting for log to be written to disk
page_requests_direct_returnintegerNumber of requests for pages that were available in buffer
page_requests_wait_queueintegerNumber of requests that had to wait for pages to become available in buffer
page_requests_wait_iointegerNumber of requests that had to be read from pages on disk (pages wereunavailable in buffer)

You can use this table with MySQL Cluster Disk Data tables to determine whether DiskPageBufferMemory is sufficiently large to allow data to be read from the buffer rather from disk; minimizing disk seeks can help improve performance of such tables.

You can determine the proportion of reads from DiskPageBufferMemory to the total number of reads using a query such as this one, which obtains this ratio as a percentage:

SELECT node_id,   100 * page_requests_direct_return / (page_requests_direct_return + page_requests_wait_io)   AS hit_ratio FROM ndbinfo.diskpagebuffer;

The result from this query should be similar to what is shown here, with one row for each data node in the cluster (in this example, the cluster has 4 data nodes):

+---------+-----------+| node_id | hit_ratio |+---------+-----------+|   5 |   97.6744 ||   6 |   97.6879 ||   7 |   98.1776 ||   8 |   98.1343 |+---------+-----------+4 rows in set (0.00 sec)

hit_ratio values approaching 100% indicate that only a very small number of reads are being made from disk rather than from the buffer, which means that Disk Data read performance is approaching an optimum level. If any of these values are less than 95%, this is a strong indicator that the setting for DiskPageBufferMemory needs to be increased in the config.ini file.

Note

A change in DiskPageBufferMemory requires a rolling restart of all of the cluster's data nodes before it takes effect.

17.5.10.9. The ndbinfo logbuffers Table

The logbuffer table provides information on MySQL Cluster log buffer usage.

The following table provides information about the columns in the logbuffers table. For each column, the table shows the name, data type, and a brief description.

Column NameTypeRemarks
node_idintegerThe ID of this data node.
log_typestringType of log; one of: REDO orDD-UNDO.
log_idintegerThe log ID.
log_partintegerThe log part number.
totalintegerTotal space available for this log.
usedintegerSpace used by this log.

17.5.10.10. The ndbinfo logspaces Table

This table provides information about MySQL Cluster log space usage.

The following table provides information about the columns in the logspaces table. For each column, the table shows the name, data type, and a brief description.

Column NameTypeRemarks
node_idintegerThe ID of this data node.
log_typestringType of log; one of: REDO orDD-UNDO.
log_idintegerThe log ID.
log_partintegerThe log part number.
totalintegerTotal space available for this log.
usedintegerSpace used by this log.

17.5.10.11. The ndbinfo membership Table

The membership table describes the view that each data node has of all the others in the cluster, including node group membership, president node, arbitrator, arbitrator successor, arbitrator connection states, and other information.

The following table provides information about the columns in the membership table. For each column, the table shows the name, data type, and a brief description. Additional information can be found in the notes following the table.

Column NameTypeRemarks
node_idintegerThis node's node ID
group_idintegerNode group to which this node belongs
left nodeintegerNode ID of the previous node
right_nodeintegerNode ID of the next node
presidentintegerPresident's node ID
successorintegerNode ID of successor to president
succession_orderintegerOrder in which this node succeeds to presidency
Conf_HB_orderinteger-
arbitratorintegerNode ID of arbitrator
arb_ticketstringInternal identifier used to track arbitration
arb_stateEnumeration (see text)Arbtitration state
arb_connectedYes or NoWhather this node is connected to the arbitrator
connected_rank1_arbsList of node IDsConnected arbitrators of rank 1
connected_rank2_arbsList of node IDsConnected arbitrators of rank 1

The node ID and node group ID are the same as reported by ndb_mgm -e "SHOW".

left_node and right_node are defined in terms of a model that connects all data nodes in a circle, in order of their node IDs, similar to the ordering of the numbers on a clock dial, as shown here:

Arrangement of nodes in a circle

In this example, we have 8 data nodes, numbered 5, 6, 7, 8, 12, 13, 14, and 15, ordered clockwise in a circle. We determine "left" and "right" from the interior of the circle. The node to the left of node 5 is node 15, and the node to the right of node 5 is node 6. You can see all these relationships by running the following query and observing the output:

mysql> SELECT node_id,left_node,right_node -> FROM ndbinfo.membership;+---------+-----------+------------+| node_id | left_node | right_node |+---------+-----------+------------+|   5 | 15 |  6 ||   6 | 5 |  7 ||   7 | 6 |  8 ||   8 | 7 | 12 ||  12 | 8 | 13 ||  13 | 12 | 14 ||  14 | 13 | 15 ||  15 | 14 |  5 |+---------+-----------+------------+8 rows in set (0.00 sec)

The designations "left" and "right" are used in the event log in the same way.

The president node is the node viewed by the current node as responsible for setting an arbitrator (see MySQL Cluster Start Phases). If the president fails or becomes disconnected, the current node expects the node whose ID is shown in the successor column to become the new president. The succession_order column shows the place in the succession queue that the current node views itself as having.

In a normal MySQL Cluster, all data nodes should see the same node as president, and the same node (other than the president) as its successor. In addition, the current president should see itself as 1 in the order of succession, the successor node should see itself as 2, and so on.

All nodes should show the same arb_ticket values as well as the same arb_state values. Possible arb_state values are ARBIT_NULL, ARBIT_INIT, ARBIT_FIND, ARBIT_PREP1, ARBIT_PREP2, ARBIT_START, ARBIT_RUN, ARBIT_CHOOSE, ARBIT_CRASH, and UNKNOWN.

arb_connected shows whether this node is connected to the node shown as this node's arbitrator.

The connected_rank1_arbs and connected_rank2_arbs columns each display a list of 0 or more arbitrators having an ArbitrationRank equal to 1, or to 2, respectively.

Note

Both management nodes and API nodes are eligible to become arbitrators.

Like the arbitrator_validity_detail and arbitrator_validity_summary tables, this table was added in MySQL Cluster NDB 7.2.10.

17.5.10.12. The ndbinfo memoryusage Table

Querying this table provides information similar to that provided by the ALL REPORT MemoryUsage command in the ndb_mgm client, or logged by ALL DUMP 1000.

The following table provides information about the columns in the memoryusage table. For each column, the table shows the name, data type, and a brief description. Additional information can be found in the notes following the table.

Column NameTypeRemarks
node_idintegerThe node ID of this data node.
memory_typestringOne of DATA_MEMORY or INDEX_MEMORY.
usedintegerNumber of bytes currently used for data memory or index memory by this data node.
used_pagesintegerNumber of pages currently used for data memory or index memory by this data node; see text.
totalintegerTotal number of bytes of data memory or index memory available for this data node; see text.
total_pagesintegerTotal number of memory pages available for data memory or index memoryon this data node; see text.

The total column represents the total amount of memory in bytes available for the given resource (data memory or index memory) on a particular data node. This number should be approximately equal to the setting of the corresponding configuration parameter in the config.ini file.

Suppose that the cluster has 2 data nodes having node IDs 1 and 2, and the config.ini file contains the following:

[ndbd default]DataMemory = 100MIndexMemory = 100M

The following query shows approximately the same values:

mysql> SELECT node_id, memory_type, total  > FROM ndbinfo.memoryusage;+---------+--------------+-----------+| node_id | memory_type  | total |+---------+--------------+-----------+|   1 | Data memory  | 104857600 ||   1 | Index memory | 105119744 ||   2 | Data memory  | 104857600 ||   2 | Index memory | 105119744 |+---------+--------------+-----------+4 rows in set (0.30 sec)

In this case, the total column values for index memory are slightly higher than the value set of IndexMemory due to internal rounding.

For the used_pages and total_pages columns, resources are measured in pages, which are 32K in size for DataMemory and 8K for IndexMemory.

17.5.10.13. The ndbinfo nodes Table

This table contains information on the status of data nodes. For each data node that is running in the cluster, a corresponding row in this table provides the node's node ID, status, and uptime. For nodes that are starting, it also shows the current start phase.

The following table provides information about the columns in the nodes table. For each column, the table shows the name, data type, and a brief description. Additional information can be found in the notes following the table.

Column NameTypeRemarks
node_idintegerThe data node's unique node ID in the cluster.
uptimeintegerTime since the node was last started, in seconds.
statusstringCurrent status of the data node; see text for possible values.
start_phaseintegerIf the data node is starting, the current start phase.
config_generationintegerThe version of the cluster configuration file in use on this data node.

The uptime column shows the time in seconds that this node has been running since it was last started or restarted. This is a BIGINT value. This figure includes the time actually needed to start the node; in other words, this counter starts running the moment that ndbd or ndbmtd is first invoked; thus, even for a node that has not yet finished starting, uptime may show a non-zero value.

The status column shows the node's current status. This is one of: NOTHING, CMVMI, STARTING, STARTED, SINGLEUSER, STOPPING_1, STOPPING_2, STOPPING_3, or STOPPING_4. When the status is STARTING, you can see the current start phase in the start_phase column (see later in this section). SINGLEUSER is displayed in the status column for all data nodes when the cluster is in single user mode (see Section 17.5.8, "MySQL Cluster Single User Mode"). Seeing one of the STOPPING states does not necessarily mean that the node is shutting down but can mean rather that it is entering a new state; for example, if you put the cluster in single user mode, you can sometimes see data nodes report their state briefly as STOPPING_2 before the status changes to SINGLEUSER.

The start_phase column uses the same range of values as those used in the output of the ndb_mgm client node_id STATUS command (see Section 17.5.2, "Commands in the MySQL Cluster Management Client"). If the node is not currently starting, then this column shows 0. For a listing of MySQL Cluster start phases with descriptions, see Section 17.5.1, "Summary of MySQL Cluster Start Phases".

The config_generation column shows which version of the cluster configuration is in effect on each data node. This can be useful when performing a rolling restart of the cluster in order to make changes in configuration parameters. For example, from the output of the following SELECT statement, you can see that node 3 is not yet using the latest version of the cluster configuration (6) although nodes 1, 2, and 4 are doing so:

mysql> USE ndbinfo;Database changedmysql> SELECT * FROM nodes;+---------+--------+---------+-------------+-------------------+| node_id | uptime | status  | start_phase | config_generation |+---------+--------+---------+-------------+-------------------+|   1 |  10462 | STARTED |   0 | 6 ||   2 |  10460 | STARTED |   0 | 6 ||   3 |  10457 | STARTED |   0 | 5 ||   4 |  10455 | STARTED |   0 | 6 |+---------+--------+---------+-------------+-------------------+2 rows in set (0.04 sec)

Therefore, for the case just shown, you should restart node 3 to complete the rolling restart of the cluster.

Nodes that are stopped are not accounted for in this table. Suppose that you have a MySQL Cluster with 4 data nodes (node IDs 1, 2, 3 and 4), and all nodes are running normally, then this table contains 4 rows, 1 for each data node:

mysql> USE ndbinfo;Database changedmysql> SELECT * FROM nodes;+---------+--------+---------+-------------+-------------------+| node_id | uptime | status  | start_phase | config_generation |+---------+--------+---------+-------------+-------------------+|   1 |  11776 | STARTED |   0 | 6 ||   2 |  11774 | STARTED |   0 | 6 ||   3 |  11771 | STARTED |   0 | 6 ||   4 |  11769 | STARTED |   0 | 6 |+---------+--------+---------+-------------+-------------------+4 rows in set (0.04 sec)

If you shut down one of the nodes, only the nodes that are still running are represented in the output of this SELECT statement, as shown here:

ndb_mgm> 2 STOPNode 2: Node shutdown initiatedNode 2: Node shutdown completed.Node 2 has shutdown.
mysql> SELECT * FROM nodes;+---------+--------+---------+-------------+-------------------+| node_id | uptime | status  | start_phase | config_generation |+---------+--------+---------+-------------+-------------------+|   1 |  11807 | STARTED |   0 | 6 ||   3 |  11802 | STARTED |   0 | 6 ||   4 |  11800 | STARTED |   0 | 6 |+---------+--------+---------+-------------+-------------------+3 rows in set (0.02 sec)

17.5.10.14. The ndbinfo resources Table

This table provides information about data node resource availability and usage.

These resources are sometimes known as super-pools.

The following table provides information about the columns in the resources table. For each column, the table shows the name, data type, and a brief description. Additional information can be found in the notes following the table.

Column NameTypeRemarks
node_idintegerThe unique node ID of this data node.
resource_namestringName of the resource; see text.
reservedintegerThe amount reserved for this resource.
usedintegerThe amount actually used by this resource.
maxintegerThe maximum amount of this resource used, since the node was laststarted.

The resource_name can be one of RESERVED, DISK_OPERATIONS, DISK_RECORDS, DATA_MEMORY, JOBBUFFER, FILE_BUFFERS, or TRANSPORTER_BUFFERS.

17.5.10.15. The ndbinfo server_operations Table

The server_operations table contains entries for all ongoing NDB operations that the current SQL node (MySQL Server) is currently involved in. It effectively is a subset of the the cluster_operations table, in which operations for other SQL and API nodes are not shown.

The following table provides information about the columns in the server_operations table. For each column, the table shows the name, data type, and a brief description. Additional information can be found in the notes following the table.

Column NameTypeRemarks
mysql_connection_idintegerMySQL Server connection ID
node_idintegerNode ID
block_instanceintegerBlock instance
transidintegerTransaction ID
operation_typestringOperation type (see text for possible values)
statestringOperation state (see text for possible values)
tableidintegerTable ID
fragmentidintegerFragment ID
client_node_idintegerClient node ID
client_block_refintegerClient block reference
tc_node_idintegerTransaction coordinator node ID
tc_block_nointegerTransaction coordinator block number
tc_block_instanceintegerTransaction coordinator block instance

The mysql_connection_id is the same as the connection or session ID shown in the output of SHOW PROCESSLIST. It is obtained from the INFORMATION_SCHEMA table NDB_TRANSID_MYSQL_CONNECTION_MAP.

The transaction ID is a unique 64-bit number which can be obtained using the NDB API's getTransactionId() method. (Currently, the MySQL Server does not expose the NDB API transaction ID of an ongoing transaction.)

The operation_type column can take any one of the values READ, READ-SH, READ-EX, INSERT, UPDATE, DELETE, WRITE, UNLOCK, REFRESH, SCAN, SCAN-SH, SCAN-EX, or <unknown>.

The state column can have any one of the values ABORT_QUEUED, ABORT_STOPPED, COMMITTED, COMMIT_QUEUED, COMMIT_STOPPED, COPY_CLOSE_STOPPED, COPY_FIRST_STOPPED, COPY_STOPPED, COPY_TUPKEY, IDLE, LOG_ABORT_QUEUED, LOG_COMMIT_QUEUED, LOG_COMMIT_QUEUED_WAIT_SIGNAL, LOG_COMMIT_WRITTEN, LOG_COMMIT_WRITTEN_WAIT_SIGNAL, LOG_QUEUED, PREPARED, PREPARED_RECEIVED_COMMIT, SCAN_CHECK_STOPPED, SCAN_CLOSE_STOPPED, SCAN_FIRST_STOPPED, SCAN_RELEASE_STOPPED, SCAN_STATE_USED, SCAN_STOPPED, SCAN_TUPKEY, STOPPED, TC_NOT_CONNECTED, WAIT_ACC, WAIT_ACC_ABORT, WAIT_AI_AFTER_ABORT, WAIT_ATTR, WAIT_SCAN_AI, WAIT_TUP, WAIT_TUPKEYINFO, WAIT_TUP_COMMIT, or WAIT_TUP_TO_ABORT. (If the MySQL Server is running with ndbinfo_show_hidden enabled, you can view this list of states by selecting from the ndb$dblqh_tcconnect_state table, which is normally hidden.)

You can obtain the name of an NDB table from its table ID by checking the output of ndb_show_tables.

The fragid is the same as the partition number seen in the output of ndb_desc --extra-partition-info (short form -p).

In client_node_id and client_block_ref, client refers to a MySQL Cluster API or SQL node (that is, an NDB API client or a MySQL Server attached to the cluster).

This table was added in MySQL Cluster NDB 7.2.2.

17.5.10.16. The ndbinfo server_transactions Table

The server_transactions table is subset of the cluster_transactions table, but includes only those transactions in which the current SQL node (MySQL Server) is a participant, while including the relevant connection IDs.

The following table provides information about the columns in the server_transactions table. For each column, the table shows the name, data type, and a brief description. Additional information can be found in the notes following the table.

Column NameTypeRemarks
mysql_connection_idintegerMySQL Server connection ID
node_idintegerTransaction coordinator node ID
block_instanceintegerTransaction coordinator block instance
transidintegerTransaction ID
statestringOperation state (see text for possible values)
count_operationsintegerNumber of stateful operations in the transaction
outstanding_operationsintegerOperations still being executed by local data management layer (LQHblocks)
inactive_secondsintegerTime spent waiting for API
client_node_idintegerClient node ID
client_block_refintegerClient block reference

The mysql_connection_id is the same as the connection or session ID shown in the output of SHOW PROCESSLIST. It is obtained from the INFORMATION_SCHEMA table NDB_TRANSID_MYSQL_CONNECTION_MAP.

The transaction ID is a unique 64-bit number which can be obtained using the NDB API's getTransactionId() method. (Currently, the MySQL Server does not expose the NDB API transaction ID of an ongoing transaction.)

The state column can have any one of the values CS_ABORTING, CS_COMMITTING, CS_COMMIT_SENT, CS_COMPLETE_SENT, CS_COMPLETING, CS_CONNECTED, CS_DISCONNECTED, CS_FAIL_ABORTED, CS_FAIL_ABORTING, CS_FAIL_COMMITTED, CS_FAIL_COMMITTING, CS_FAIL_COMPLETED, CS_FAIL_PREPARED, CS_PREPARE_TO_COMMIT, CS_RECEIVING, CS_REC_COMMITTING, CS_RESTART, CS_SEND_FIRE_TRIG_REQ, CS_STARTED, CS_START_COMMITTING, CS_START_SCAN, CS_WAIT_ABORT_CONF, CS_WAIT_COMMIT_CONF, CS_WAIT_COMPLETE_CONF, CS_WAIT_FIRE_TRIG_REQ. (If the MySQL Server is running with ndbinfo_show_hidden enabled, you can view this list of states by selecting from the ndb$dbtc_apiconnect_state table, which is normally hidden.)

In client_node_id and client_block_ref, client refers to a MySQL Cluster API or SQL node (that is, an NDB API client or a MySQL Server attached to the cluster).

This table was added in MySQL Cluster NDB 7.2.2.

17.5.10.17. The ndbinfo threadblocks Table

The threadblocks table associates data nodes, threads, and instances of NDB kernel blocks.

The following table provides information about the columns in the threadblocks table. For each column, the table shows the name, data type, and a brief description. Additional information can be found in the notes following the table.

Column NameTypeRemarks
node_idintegerNode ID
thr_nointegerThread ID
block_namestringBlock name
block_instanceintegerBlock instance number

The block_name is one of the values found in the block_name column when selecting from the ndbinfo.blocks table. Although the list of possible values is static for a given MySQL Cluster release, the list may vary between releases.

This table was added in MySQL Cluster NDB 7.2.2.

17.5.10.18. The ndbinfo threadstat Table

The threadstat table provides a rough snapshot of statistics for threads running in the NDB kernel.

The following table provides information about the columns in the threadstat table. For each column, the table shows the name, data type, and a brief description. Additional information can be found in the notes following the table.

Column NameTypeRemarks
node_idintegerNode ID
thr_nointegerThread ID
thr_nmstringThread name
c_loopstringNumber of loops in main loop
c_execstringNumber of signals executed
c_waitstringNumber of times waiting for additional input
c_l_sent_prioaintegerNumber of priority A signals sent to own node
c_l_sent_priobintegerNumber of priority B signals sent to own node
c_r_sent_prioaintegerNumber of priority A signals sent to remote node
c_r_sent_priobintegerNumber of priority B signals sent to remote node
os_tidintegerOS thread ID
os_nowintegerOS time (ms)
os_ru_utimeintegerOS user CPU time (�s)
os_ru_stimeintegerOS system CPU time (�s)
os_ru_minfltintegerOS page reclaims (soft page faults)
os_ru_majfltintegerOS page faults (hard page faults)
os_ru_nvcswintegerOS voluntary context switches
os_ru_nivcswintegerOS involuntary context switches

os_time uses the system gettimeofday() call.

The values of the os_ru_utime, os_ru_stime, os_ru_minflt, os_ru_majflt, os_ru_nvcsw, and os_ru_nivcsw columns are obtained using the system getrusage() call, or the equivalent.

Since this table contains counts taken at a given point in time, for best results it is necessary to query this table periodically and store the results in an intermediate table or tables. The MySQL Server's Event Scheduler can be employed to automate such monitoring. For more information, see Section 19.4, "Using the Event Scheduler".

This table was added in MySQL Cluster NDB 7.2.2.

17.5.10.19. The ndbinfo transporters Table

This table contains information about NDB transporters.

The following table provides information about the columns in the transporters table. For each column, the table shows the name, data type, and a brief description. Additional information can be found in the notes following the table.

Column NameTypeRemarks
node_idintegerThis data node's unique node ID in the cluster.
remote_node_idintegerThe remote data node's node ID.
statusstringStatus of the connection.
remote_addressstringName or IP address of the remote host
bytes_sentintegerNumber of bytes sent using this connection
bytes_received Number of bytes received using this connection
connect_count Number of times connection established on this transporter
overloaded 1 if this transporter is currently overloaded, otherwise 0
overload_count Number of times this transporter has entered overload state since connecting
slowdown 1 if this transporter is in scan slowndown state, otherwise 0
slowdown_count Number of times this transporter has entered scan slowdown state sinceconnecting

For each running data node in the cluster, the transporters table displays a row showing the status of each of that node's connections with all nodes in the cluster, including itself. This information is shown in the table's status column, which can have any one of the following values: CONNECTING, CONNECTED, DISCONNECTING, or DISCONNECTED.

Connections to API and management nodes which are configured but not currently connected to the cluster are shown with status DISCONNECTED. Rows where the node_id is that of a data nodes which is not currently connected are not shown in this table. (This is similar omission of disconnected nodes in the ndbinfo.nodes table.

The remote_address, bytes_sent, and bytes_received columns were added in MySQL Cluster NDB 7.2.9. The remote_address is the the host name or address for the node whose ID is shown in the remote_node_id column. The bytes_sent from this node and bytes_received by this node are the numbers, respectively, of bytes sent and received by the node using this connection since it was established; for nodes whose status is CONNECTING or DISCONNECTED, these columns always display 0.

The connect_count, overloaded, overload_count ,slowdown, and slowdown_count columns were added in MySQL Cluster NDB 7.2.10. These counters are reset on connection, and retain their values after the remote node disconnects. Also beginning with MySQL Cluster NDB 7.2.10, the bytes_send and bytes_received counters are reset on connection as well, and so retain their values following disconnection. (Previously, the values in these columns were reset on disconnection.) (Bug #15935206)

Assume you have a 5-node cluster consisting of 2 data nodes, 2 SQL nodes, and 1 management node, as shown in the output of the SHOW command in the ndb_mgm client:

ndb_mgm> SHOWConnected to Management Server at: localhost:1186Cluster Configuration---------------------[ndbd(NDB)] 2 node(s)id=1 @10.100.10.1  (5.5.29-ndb-7.2.10, Nodegroup: 0, Master)id=2 @10.100.10.2  (5.5.29-ndb-7.2.10, Nodegroup: 0)[ndb_mgmd(MGM)] 1 node(s)id=10   @10.100.10.10  (5.5.29-ndb-7.2.10)[mysqld(API)]   2 node(s)id=20   @10.100.10.20  (5.5.29-ndb-7.2.10)id=21   @10.100.10.21  (5.5.29-ndb-7.2.10)

There are 10 rows in the transporters table-5 for the first data node, and 5 for the second-assuming that all data nodes are running, as shown here:

mysql> SELECT node_id, remote_node_id, status ->   FROM ndbinfo.transporters;+---------+----------------+---------------+| node_id | remote_node_id | status |+---------+----------------+---------------+|   1 |  1 | CONNECTED ||   1 |  2 | CONNECTED ||   1 | 10 | CONNECTED ||   1 | 20 | CONNECTED ||   1 | 21 | CONNECTED ||   2 |  1 | CONNECTED ||   2 |  2 | CONNECTED ||   2 | 10 | CONNECTED ||   2 | 20 | CONNECTED ||   2 | 21 | CONNECTED |+---------+----------------+---------------+10 rows in set (0.04 sec)

If you shut down one of the data nodes in this cluster using the command 2 STOP in the ndb_mgm client, then repeat the previous query (again using the mysql client), this table now shows only 5 rows-1 row for each connection from the remaining management node to another node, including both itself and the data node that is currently offline-and displays CONNECTING for the status of each remaining connection to the data node that is currently offline, as shown here:

mysql> SELECT node_id, remote_node_id, status ->   FROM ndbinfo.transporters;+---------+----------------+---------------+| node_id | remote_node_id | status |+---------+----------------+---------------+|   1 |  1 | CONNECTED ||   1 |  2 | CONNECTING ||   1 | 10 | CONNECTED ||   1 | 20 | CONNECTED ||   1 | 21 | CONNECTED |+---------+----------------+---------------+5 rows in set (0.02 sec)

17.5.11. MySQL Cluster Security Issues

This section discusses security considerations to take into account when setting up and running MySQL Cluster.

Topics covered in this section include the following:

  • MySQL Cluster and network security issues

  • Configuration issues relating to running MySQL Cluster securely

  • MySQL Cluster and the MySQL privilege system

  • MySQL standard security procedures as applicable to MySQL Cluster

17.5.11.1. MySQL Cluster Security and Networking Issues

In this section, we discuss basic network security issues as they relate to MySQL Cluster. It is extremely important to remember that MySQL Cluster "out of the box" is not secure; you or your network administrator must take the proper steps to ensure that your cluster cannot be compromised over the network.

Cluster communication protocols are inherently insecure, and no encryption or similar security measures are used in communications between nodes in the cluster. Because network speed and latency have a direct impact on the cluster's efficiency, it is also not advisable to employ SSL or other encryption to network connections between nodes, as such schemes will effectively slow communications.

It is also true that no authentication is used for controlling API node access to a MySQL Cluster. As with encryption, the overhead of imposing authentication requirements would have an adverse impact on Cluster performance.

In addition, there is no checking of the source IP address for either of the following when accessing the cluster:

  • SQL or API nodes using "free slots" created by empty [mysqld] or [api] sections in the config.ini file

    This means that, if there are any empty [mysqld] or [api] sections in the config.ini file, then any API nodes (including SQL nodes) that know the management server's host name (or IP address) and port can connect to the cluster and access its data without restriction. (See Section 17.5.11.2, "MySQL Cluster and MySQL Privileges", for more information about this and related issues.)

    Note

    You can exercise some control over SQL and API node access to the cluster by specifying a HostName parameter for all [mysqld] and [api] sections in the config.ini file. However, this also means that, should you wish to connect an API node to the cluster from a previously unused host, you need to add an [api] section containing its host name to the config.ini file.

    More information is available elsewhere in this chapter about the HostName parameter. Also see Section 17.3.1, "Quick Test Setup of MySQL Cluster", for configuration examples using HostName with API nodes.

  • Any ndb_mgm client

    This means that any cluster management client that is given the management server's host name (or IP address) and port (if not the standard port) can connect to the cluster and execute any management client command. This includes commands such as ALL STOP and SHUTDOWN.

For these reasons, it is necessary to protect the cluster on the network level. The safest network configuration for Cluster is one which isolates connections between Cluster nodes from any other network communications. This can be accomplished by any of the following methods:

  1. Keeping Cluster nodes on a network that is physically separate from any public networks. This option is the most dependable; however, it is the most expensive to implement.

    We show an example of a MySQL Cluster setup using such a physically segregated network here:

    MySQL Cluster on a private network protected with a hardware firewall

    This setup has two networks, one private (solid box) for the Cluster management servers and data nodes, and one public (dotted box) where the SQL nodes reside. (We show the management and data nodes connected using a gigabit switch since this provides the best performance.) Both networks are protected from the outside by a hardware firewall, sometimes also known as a network-based firewall.

    This network setup is safest because no packets can reach the cluster's management or data nodes from outside the network-and none of the cluster's internal communications can reach the outside-without going through the SQL nodes, as long as the SQL nodes do not permit any packets to be forwarded. This means, of course, that all SQL nodes must be secured against hacking attempts.

    Important

    With regard to potential security vulnerabilities, an SQL node is no different from any other MySQL server. See Section 6.1.3, "Making MySQL Secure Against Attackers", for a description of techniques you can use to secure MySQL servers.

  2. Using one or more software firewalls (also known as host-based firewalls) to control which packets pass through to the cluster from portions of the network that do not require access to it. In this type of setup, a software firewall must be installed on every host in the cluster which might otherwise be accessible from outside the local network.

    The host-based option is the least expensive to implement, but relies purely on software to provide protection and so is the most difficult to keep secure.

    This type of network setup for MySQL Cluster is illustrated here:

    MySQL Cluster deployed on a network using software firewalls to create public and private zones

    Using this type of network setup means that there are two zones of MySQL Cluster hosts. Each cluster host must be able to communicate with all of the other machines in the cluster, but only those hosting SQL nodes (dotted box) can be permitted to have any contact with the outside, while those in the zone containing the data nodes and management nodes (solid box) must be isolated from any machines that are not part of the cluster. Applications using the cluster and user of those applications must not be permitted to have direct access to the management and data node hosts.

    To accomplish this, you must set up software firewalls that limit the traffic to the type or types shown in the following table, according to the type of node that is running on each cluster host computer:

    Type of Node to be AccessedTraffic to Permit
    SQL or API node
    • It originates from the IP address of a management or data node (using any TCP or UDP port).

    • It originates from within the network in which the cluster resides and is on the port that your application is using.

    Data node or Management node
    • It originates from the IP address of a management or data node (using any TCP or UDP port).

    • It originates from the IP address of an SQL or API node.

    Any traffic other than that shown in the table for a given node type should be denied.

    The specifics of configuring a firewall vary from firewall application to firewall application, and are beyond the scope of this Manual. iptables is a very common and reliable firewall application, which is often used with APF as a front end to make configuration easier. You can (and should) consult the documentation for the software firewall that you employ, should you choose to implement a MySQL Cluster network setup of this type, or of a "mixed" type as discussed under the next item.

  3. It is also possible to employ a combination of the first two methods, using both hardware and software to secure the cluster-that is, using both network-based and host-based firewalls. This is between the first two schemes in terms of both security level and cost. This type of network setup keeps the cluster behind the hardware firewall, but permits incoming packets to travel beyond the router connecting all cluster hosts to reach the SQL nodes.

    One possible network deployment of a MySQL Cluster using hardware and software firewalls in combination is shown here:

    Network setup for MySQL Cluster using a combination of hardware and software firewalls to provide protection

    In this case, you can set the rules in the hardware firewall to deny any external traffic except to SQL nodes and API nodes, and then permit traffic to them only on the ports required by your application.

Whatever network configuration you use, remember that your objective from the viewpoint of keeping the cluster secure remains the same-to prevent any unessential traffic from reaching the cluster while ensuring the most efficient communication between the nodes in the cluster.

Because MySQL Cluster requires large numbers of ports to be open for communications between nodes, the recommended option is to use a segregated network. This represents the simplest way to prevent unwanted traffic from reaching the cluster.

Note

If you wish to administer a MySQL Cluster remotely (that is, from outside the local network), the recommended way to do this is to use ssh or another secure login shell to access an SQL node host. From this host, you can then run the management client to access the management server safely, from within the Cluster's own local network.

Even though it is possible to do so in theory, it is not recommended to use ndb_mgm to manage a Cluster directly from outside the local network on which the Cluster is running. Since neither authentication nor encryption takes place between the management client and the management server, this represents an extremely insecure means of managing the cluster, and is almost certain to be compromised sooner or later.

17.5.11.2. MySQL Cluster and MySQL Privileges

In this section, we discuss how the MySQL privilege system works in relation to MySQL Cluster and the implications of this for keeping a MySQL Cluster secure.

Standard MySQL privileges apply to MySQL Cluster tables. This includes all MySQL privilege types (SELECT privilege, UPDATE privilege, DELETE privilege, and so on) granted on the database, table, and column level. As with any other MySQL Server, user and privilege information is stored in the mysql system database. The SQL statements used to grant and revoke privileges on NDB tables, databases containing such tables, and columns within such tables are identical in all respects with the GRANT and REVOKE statements used in connection with database objects involving any (other) MySQL storage engine. The same thing is true with respect to the CREATE USER and DROP USER statements.

It is important to keep in mind that, by default, the MySQL grant tables use the MyISAM storage engine. Because of this, those tables are not normally duplicated or shared among MySQL servers acting as SQL nodes in a MySQL Cluster. In other words, changes in users and their privileges do not automatically propagate between SQL nodes by default. In MySQL Cluster NDB 7.2 (and later), you can enable automatic distribution of MySQL users and privileges across MySQL Cluster SQL nodes; see Section 17.5.14, "Distributed MySQL Privileges for MySQL Cluster", for details.

Conversely, because there is no way in MySQL to deny privileges (privileges can either be revoked or not granted in the first place, but not denied as such), there is no special protection for NDB tables on one SQL node from users that have privileges on another SQL node; (This is true even if you are not using automatic distribution of user privileges. The definitive example of this is the MySQL root account, which can perform any action on any database object. In combination with empty [mysqld] or [api] sections of the config.ini file, this account can be especially dangerous. To understand why, consider the following scenario:

  • The config.ini file contains at least one empty [mysqld] or [api] section. This means that the MySQL Cluster management server performs no checking of the host from which a MySQL Server (or other API node) accesses the MySQL Cluster.

  • There is no firewall, or the firewall fails to protect against access to the MySQL Cluster from hosts external to the network.

  • The host name or IP address of the MySQL Cluster's management server is known or can be determined from outside the network.

If these conditions are true, then anyone, anywhere can start a MySQL Server with --ndbcluster --ndb-connectstring=management_host and access this MySQL Cluster. Using the MySQL root account, this person can then perform the following actions:

  • Execute metadata statements such as SHOW DATABASES statement (to obtain a list of all NDB databases on the server) or SHOW TABLES FROM some_ndb_database statement to obtain a list of all NDB tables in a given database

  • Run any legal MySQL statements on any of the discovered tables, such as:

    • SELECT * FROM some_table to read all the data from any table

    • DELETE FROM some_table to delete all the data from a table

    • DESCRIBE some_table or SHOW CREATE TABLE some_table to determine the table schema

    • UPDATE some_table SET column1 = some_value to fill a table column with "garbage" data; this could actually cause much greater damage than simply deleting all the data

      More insidious variations might include statements like these:

      UPDATE some_table SET an_int_column = an_int_column + 1

      or

      UPDATE some_table SET a_varchar_column = REVERSE(a_varchar_column)

      Such malicious statements are limited only by the imagination of the attacker.

    The only tables that would be safe from this sort of mayhem would be those tables that were created using storage engines other than NDB, and so not visible to a "rogue" SQL node.

    A user who can log in as root can also access the INFORMATION_SCHEMA database and its tables, and so obtain information about databases, tables, stored routines, scheduled events, and any other database objects for which metadata is stored in INFORMATION_SCHEMA.

    It is also a very good idea to use different passwords for the root accounts on different MySQL Cluster SQL nodes unless you are using distributed privileges.

In sum, you cannot have a safe MySQL Cluster if it is directly accessible from outside your local network.

Important

Never leave the MySQL root account password empty. This is just as true when running MySQL as a MySQL Cluster SQL node as it is when running it as a standalone (non-Cluster) MySQL Server, and should be done as part of the MySQL installation process before configuring the MySQL Server as an SQL node in a MySQL Cluster.

Prior to MySQL Cluster NDB 7.2, you should never convert the system tables in the mysql database to use the NDB storage engine. There are a number of reasons why you should not do this, but the most important reason is this: Many of the SQL statements that affect mysql tables storing information about user privileges, stored routines, scheduled events, and other database objects cease to function if these tables are changed to use any storage engine other than MyISAM. This is a consequence of various MySQL Server internals. Beginning with MySQL Cluster NDB 7.2, you can use a stored procedure provided for this purpose (see Section 17.5.14, "Distributed MySQL Privileges for MySQL Cluster"), but you are strongly advised not to attempt convert the system tables manually.

Otherwise, if you need to synchronize mysql system tables between SQL nodes, you can use standard MySQL replication to do so, or employ a script to copy table entries between the MySQL servers.

Summary. The most important points to remember regarding the MySQL privilege system with regard to MySQL Cluster are listed here:

  1. Users and privileges established on one SQL node do not automatically exist or take effect on other SQL nodes in the cluster. Conversely, removing a user or privilege on one SQL node in the cluster does not remove the user or privilege from any other SQL nodes.

  2. You can distribute MySQL users and privileges among SQL nodes using the SQL script, and the stored procedures it contains, that are supplied for this purpose in the MySQL Cluster distribution.

  3. Once a MySQL user is granted privileges on an NDB table from one SQL node in a MySQL Cluster, that user can "see" any data in that table regardless of the SQL node from which the data originated, even if you are not using privilege distribution.

17.5.11.3. MySQL Cluster and MySQL Security Procedures

In this section, we discuss MySQL standard security procedures as they apply to running MySQL Cluster.

In general, any standard procedure for running MySQL securely also applies to running a MySQL Server as part of a MySQL Cluster. First and foremost, you should always run a MySQL Server as the mysql system user; this is no different from running MySQL in a standard (non-Cluster) environment. The mysql system account should be uniquely and clearly defined. Fortunately, this is the default behavior for a new MySQL installation. You can verify that the mysqld process is running as the system user mysql by using the system command such as the one shown here:

shell> ps aux | grep mysqlroot 10467  0.0  0.1   3616  1380 pts/3 S 11:53   0:00 \  /bin/sh ./mysqld_safe --ndbcluster --ndb-connectstring=localhost:1186mysql 10512  0.2  2.5  58528 26636 pts/3 Sl   11:53   0:00 \  /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql \  --datadir=/usr/local/mysql/var --user=mysql --ndbcluster \  --ndb-connectstring=localhost:1186 --pid-file=/usr/local/mysql/var/mothra.pid \  --log-error=/usr/local/mysql/var/mothra.errjon  10579  0.0  0.0   2736   688 pts/0 S+   11:54   0:00 grep mysql

If the mysqld process is running as any other user than mysql, you should immediately shut it down and restart it as the mysql user. If this user does not exist on the system, the mysql user account should be created, and this user should be part of the mysql user group; in this case, you should also make sure that the MySQL data directory on this system (as set using the --datadir option for mysqld) is owned by the mysql user, and that the SQL node's my.cnf file includes user=mysql in the [mysqld] section. Alternatively, you can start the MySQL server process with --user=mysql on the command line, but it is preferable to use the my.cnf option, since you might forget to use the command-line option and so have mysqld running as another user unintentionally. The mysqld_safe startup script forces MySQL to run as the mysql user.

Important

Never run mysqld as the system root user. Doing so means that potentially any file on the system can be read by MySQL, and thus-should MySQL be compromised-by an attacker.

As mentioned in the previous section (see Section 17.5.11.2, "MySQL Cluster and MySQL Privileges"), you should always set a root password for the MySQL Server as soon as you have it running. You should also delete the anonymous user account that is installed by default. You can accomplish these tasks using the following statements:

shell> mysql -u rootmysql> UPDATE mysql.user -> SET Password=PASSWORD('secure_password') -> WHERE User='root';mysql> DELETE FROM mysql.user -> WHERE User='';mysql> FLUSH PRIVILEGES;

Be very careful when executing the DELETE statement not to omit the WHERE clause, or you risk deleting all MySQL users. Be sure to run the FLUSH PRIVILEGES statement as soon as you have modified the mysql.user table, so that the changes take immediate effect. Without FLUSH PRIVILEGES, the changes do not take effect until the next time that the server is restarted.

Note

Many of the MySQL Cluster utilities such as ndb_show_tables, ndb_desc, and ndb_select_all also work without authentication and can reveal table names, schemas, and data. By default these are installed on Unix-style systems with the permissions wxr-xr-x (755), which means they can be executed by any user that can access the mysql/bin directory.

See Section 17.4, "MySQL Cluster Programs", for more information about these utilities.

17.5.12. MySQL Cluster Disk Data Tables

It is possible to store the nonindexed columns of NDB tables on disk, rather than in RAM.

As part of implementing MySQL Cluster Disk Data work, a number of improvements were made in MySQL Cluster for the efficient handling of very large amounts (terabytes) of data during node recovery and restart. These include a "no-steal" algorithm for synchronizing a starting node with very large data sets. For more information, see the paper Recovery Principles of MySQL Cluster 5.1, by MySQL Cluster developers Mikael Ronstr�m and Jonas Oreland.

MySQL Cluster Disk Data performance can be influenced by a number of configuration parameters. For information about these parameters and their effects, see MySQL Cluster Disk Data configuration parameters and MySQL Cluster Disk Data storage and GCP Stop errors

The performance of a MySQL Cluster that uses Disk Data storage can also be greatly improved by separating data node file systems from undo log files and tablespace data files, which can be done using symbolic links. For more information, see Section 17.5.12.2, "Using Symbolic Links with Disk Data Objects".

17.5.12.1. MySQL Cluster Disk Data Objects

MySQL Cluster Disk Data storage is implemented using a number of Disk Data objects. These include the following:

  • Tablespaces act as containers for other Disk Data objects.

  • Undo log files undo information required for rolling back transactions.

  • One or more undo log files are assigned to a log file group, which is then assigned to a tablespace.

  • Data files store Disk Data table data. A data file is assigned directly to a tablespace.

Undo log files and data files are actual files in the file system of each data node; by default they are placed in ndb_node_id_fs in the DataDir specified in the MySQL Cluster config.ini file, and where node_id is the data node's node ID. It is possible to place these elsewhere by specifying either an absolute or relative path as part of the filename when creating the undo log or data file. Statements that create these files are shown later in this section.

MySQL Cluster tablespaces and log file groups are not implemented as files.

Important

Although not all Disk Data objects are implemented as files, they all share the same namespace. This means that each Disk Data object must be uniquely named (and not merely each Disk Data object of a given type). For example, you cannot have a tablespace and a log file group both named dd1.

Assuming that you have already set up a MySQL Cluster with all nodes (including management and SQL nodes), the basic steps for creating a MySQL Cluster table on disk are as follows:

  1. Create a log file group, and assign one or more undo log files to it (an undo log file is also sometimes referred to as an undofile).

    Note

    Undo log files are necessary only for Disk Data tables; they are not used for NDBCLUSTER tables that are stored only in memory.

  2. Create a tablespace; assign the log file group, as well as one or more data files, to the tablespace.

  3. Create a Disk Data table that uses this tablespace for data storage.

Each of these tasks can be accomplished using SQL statements in the mysql client or other MySQL client application, as shown in the example that follows.

  1. We create a log file group named lg_1 using CREATE LOGFILE GROUP. This log file group is to be made up of two undo log files, which we name undo_1.log and undo_2.log, whose initial sizes are 16 MB and 12 MB, respectively. (The default initial size for an undo log file is 128 MB.) Optionally, you can also specify a size for the log file group's undo buffer, or permit it to assume the default value of 8 MB. In this example, we set the UNDO buffer's size at 2 MB. A log file group must be created with an undo log file; so we add undo_1.log to lg_1 in this CREATE LOGFILE GROUP statement:

    CREATE LOGFILE GROUP lg_1 ADD UNDOFILE 'undo_1.log' INITIAL_SIZE 16M UNDO_BUFFER_SIZE 2M ENGINE NDBCLUSTER;

    To add undo_2.log to the log file group, use the following ALTER LOGFILE GROUP statement:

    ALTER LOGFILE GROUP lg_1 ADD UNDOFILE 'undo_2.log' INITIAL_SIZE 12M ENGINE NDBCLUSTER;

    Some items of note:

    • The .log file extension used here is not required. We use it merely to make the log files easily recognisable.

    • Every CREATE LOGFILE GROUP and ALTER LOGFILE GROUP statement must include an ENGINE clause. In MySQL Cluster NDB 7.2, the only permitted values for this clause are NDBCLUSTER and NDB.

      Important

      There can exist at most one log file group in the same MySQL Cluster at any given time.

    • When you add an undo log file to a log file group using ADD UNDOFILE 'filename', a file with the name filename is created in the ndb_node_id_fs directory within the DataDir of each data node in the cluster, where node_id is the node ID of the data node. Each undo log file is of the size specified in the SQL statement. For example, if a MySQL Cluster has 4 data nodes, then the ALTER LOGFILE GROUP statement just shown creates 4 undo log files, 1 each on in the data directory of each of the 4 data nodes; each of these files is named undo_2.log and each file is 12 MB in size.

    • UNDO_BUFFER_SIZE is limited by the amount of system memory available.

    • For more information about the CREATE LOGFILE GROUP statement, see Section 13.1.14, "CREATE LOGFILE GROUP Syntax". For more information about ALTER LOGFILE GROUP, see Section 13.1.3, "ALTER LOGFILE GROUP Syntax".

  2. Now we can create a tablespace, which contains files to be used by MySQL Cluster Disk Data tables for storing their data. A tablespace is also associated with a particular log file group. When creating a new tablespace, you must specify the log file group which it is to use for undo logging; you must also specify a data file. You can add more data files to the tablespace after the tablespace is created; it is also possible to drop data files from a tablespace (an example of dropping data files is provided later in this section).

    Assume that we wish to create a tablespace named ts_1 which uses lg_1 as its log file group. This tablespace is to contain two data files named data_1.dat and data_2.dat, whose initial sizes are 32 MB and 48 MB, respectively. (The default value for INITIAL_SIZE is 128 MB.) We can do this using two SQL statements, as shown here:

    CREATE TABLESPACE ts_1 ADD DATAFILE 'data_1.dat' USE LOGFILE GROUP lg_1 INITIAL_SIZE 32M ENGINE NDBCLUSTER;ALTER TABLESPACE ts_1 ADD DATAFILE 'data_2.dat' INITIAL_SIZE 48M ENGINE NDBCLUSTER;

    The CREATE TABLESPACE statement creates a tablespace ts_1 with the data file data_1.dat, and associates ts_1 with log file group lg_1. The ALTER TABLESPACE adds the second data file (data_2.dat).

    Some items of note:

    • As is the case with the .log file extension used in this example for undo log files, there is no special significance for the .dat file extension; it is used merely for easy recognition of data files.

    • When you add a data file to a tablespace using ADD DATAFILE 'filename', a file with the name filename is created in the ndb_node_id_fs directory within the DataDir of each data node in the cluster, where node_id is the node ID of the data node. Each undo log file is of the size specified in the SQL statement. For example, if a MySQL Cluster has 4 data nodes, then the ALTER TABLESPACE statement just shown creates 4 undo log files, 1 each on in the data directory of each of the 4 data nodes; each of these files is named data_2.dat and each file is 48 MB in size.

    • All CREATE TABLESPACE and ALTER TABLESPACE statements must contain an ENGINE clause; only tables using the same storage engine as the tablespace can be created in the tablespace. In MySQL MySQL Cluster NDB 7.2, the only permitted values for this clause are NDBCLUSTER and NDB.

    • For more information about the CREATE TABLESPACE and ALTER TABLESPACE statements, see Section 13.1.18, "CREATE TABLESPACE Syntax", and Section 13.1.8, "ALTER TABLESPACE Syntax".

  3. Now it is possible to create a table whose nonindexed columns are stored on disk in the tablespace ts_1:

    CREATE TABLE dt_1 ( member_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, last_name VARCHAR(50) NOT NULL, first_name VARCHAR(50) NOT NULL, dob DATE NOT NULL, joined DATE NOT NULL, INDEX(last_name, first_name) ) TABLESPACE ts_1 STORAGE DISK ENGINE NDBCLUSTER;

    The TABLESPACE ... STORAGE DISK option tells the NDBCLUSTER storage engine to use tablespace ts_1 for disk data storage.

    Note

    It is also possible to specify whether an individual column is stored on disk or in memory by using a STORAGE clause as part of the column's definition in a CREATE TABLE or ALTER TABLE statement. STORAGE DISK causes the column to be stored on disk, and STORAGE MEMORY causes in-memory storage to be used. See Section 13.1.17, "CREATE TABLE Syntax", for more information.

    Once table ts_1 has been created as shown, you can perform INSERT, SELECT, UPDATE, and DELETE statements on it just as you would with any other MySQL table.

    For table dt_1 as it has been defined here, only the dob and joined columns are stored on disk. This is because there are indexes on the id, last_name, and first_name columns, and so data belonging to these columns is stored in RAM. In MySQL Cluster NDB 7.2, only nonindexed columns can be held on disk; indexes and indexed column data continue to be stored in memory. This tradeoff between the use of indexes and conservation of RAM is something you must keep in mind as you design Disk Data tables.

Performance note. The performance of a cluster using Disk Data storage is greatly improved if Disk Data files are kept on a separate physical disk from the data node file system. This must be done for each data node in the cluster to derive any noticeable benefit.

You may use absolute and relative file system paths with ADD UNDOFILE and ADD DATAFILE. Relative paths are calculated relative to the data node's data directory. You may also use symbolic links; see Section 17.5.12.2, "Using Symbolic Links with Disk Data Objects", for more information and examples.

A log file group, a tablespace, and any Disk Data tables using these must be created in a particular order. The same is true for dropping any of these objects:

  • A log file group cannot be dropped as long as any tablespaces are using it.

  • A tablespace cannot be dropped as long as it contains any data files.

  • You cannot drop any data files from a tablespace as long as there remain any tables which are using the tablespace.

  • It is not possible to drop files created in association with a different tablespace than the one with which the files were created. (Bug #20053)

For example, to drop all the objects created so far in this section, you would use the following statements:

mysql> DROP TABLE dt_1;mysql> ALTER TABLESPACE ts_1 -> DROP DATAFILE 'data_2.dat' -> ENGINE NDBCLUSTER;mysql> ALTER TABLESPACE ts_1 -> DROP DATAFILE 'data_1.dat' -> ENGINE NDBCLUSTER;mysql> DROP TABLESPACE ts_1 -> ENGINE NDBCLUSTER;mysql> DROP LOGFILE GROUP lg_1 -> ENGINE NDBCLUSTER;

These statements must be performed in the order shown, except that the two ALTER TABLESPACE ... DROP DATAFILE statements may be executed in either order.

You can obtain information about data files used by Disk Data tables by querying the FILES table in the INFORMATION_SCHEMA database. An extra "NULL row" provides additional information about undo log files. For more information and examples, see Section 20.29.1, "The INFORMATION_SCHEMA FILES Table".

It is also possible to view information about allocated and free disk space for each Disk Data table or table partition using the ndb_desc utility. For more information, see Section 17.4.9, "ndb_desc - Describe NDB Tables".

17.5.12.2. Using Symbolic Links with Disk Data Objects

The performance of a MySQL Cluster that uses Disk Data storage can be greatly improved by separating data node file systems from undo log files and tablespace data files and placing these on different disks. In early versions of MySQL Cluster, there was no direct support for this in MySQL Cluster, but it was possible to achieve this separation using symbolic links as described in this section. MySQL Cluster NDB 7.2 supports the data node configuration parameters FileSystemPathDD, FileSystemPathDataFiles, and FileSystemPathUndoFiles, which make the use of symbolic links for this purpose unnecessary. For more information about these parameters, see Disk Data file system parameters.

Each data node in the cluster creates a file system in the directory named ndb_node_id_fs under the data node's DataDir as defined in the config.ini file. In this example, we assume that each data node host has 3 disks, aliased as /data0, /data1, and /data2, and that the cluster's config.ini includes the following:

[ndbd default]DataDir= /data0

Our objective is to place all Disk Data log files in /data1, and all Disk Data data files in /data2, on each data node host.

Note

In this example, we assume that the cluster's data node hosts are all using Linux operating systems. For other platforms, you may need to substitute you operating system's commands for those shown here.

To accomplish this, perform the following steps:

  • Under the data node file system create symbolic links pointing to the other drives:

    shell> cd /data0/ndb_2_fsshell> lsD1  D10  D11  D2  D8  D9  LCPshell> ln -s /data0 dnlogsshell> ln -s /data1 dndata

    You should now have two symbolic links:

    shell> ls -l --hide=D*lrwxrwxrwx 1 user group   30 2007-03-19 13:58 dndata -> /data1lrwxrwxrwx 1 user group   30 2007-03-19 13:59 dnlogs -> /data2

    We show this only for the data node with node ID 2; however, you must do this for each data node.

  • Now, in the mysql client, create a log file group and tablespace using the symbolic links, as shown here:

    mysql> CREATE LOGFILE GROUP lg1 -> ADD UNDOFILE 'dnlogs/undo1.log' -> INITIAL_SIZE 150M -> UNDO_BUFFER_SIZE = 1M -> ENGINE=NDBCLUSTER;mysql> CREATE TABLESPACE ts1 -> ADD DATAFILE 'dndata/data1.log' -> USE LOGFILE GROUP lg1 -> INITIAL_SIZE 1G -> ENGINE=NDBCLUSTER;

    Verify that the files were created and placed correctly as shown here:

    shell> cd /data1shell> ls -ltotal 2099304-rw-rw-r--  1 user group 157286400 2007-03-19 14:02 undo1.datshell> cd /data2shell> ls -ltotal 2099304-rw-rw-r--  1 user group 1073741824 2007-03-19 14:02 data1.dat
  • If you are running multiple data nodes on one host, you must take care to avoid having them try to use the same space for Disk Data files. You can make this easier by creating a symbolic link in each data node file system. Suppose you are using /data0 for both data node file systems, but you wish to have the Disk Data files for both nodes on /data1. In this case, you can do something similar to what is shown here:

    shell> cd /data0shell> ln -s /data1/dn2 ndb_2_fs/ddshell> ln -s /data1/dn3 ndb_3_fs/ddshell> ls -l --hide=D* ndb_2_fslrwxrwxrwx 1 user group   30 2007-03-19 14:22 dd -> /data1/dn2shell> ls -l --hide=D* ndb_3_fslrwxrwxrwx 1 user group   30 2007-03-19 14:22 dd -> /data1/dn3
  • Now you can create a logfile group and tablespace using the symbolic link, like this:

    mysql> CREATE LOGFILE GROUP lg1 -> ADD UNDOFILE 'dd/undo1.log' -> INITIAL_SIZE 150M -> UNDO_BUFFER_SIZE = 1M -> ENGINE=NDBCLUSTER;mysql> CREATE TABLESPACE ts1 -> ADD DATAFILE 'dd/data1.log' -> USE LOGFILE GROUP lg1 -> INITIAL_SIZE 1G -> ENGINE=NDBCLUSTER;

    Verify that the files were created and placed correctly as shown here:

    shell> cd /data1shell> lsdn2 dn3shell> ls dn2undo1.log data1.logshell> ls dn3undo1.log data1.log

17.5.12.3. MySQL Cluster Disk Data Storage Requirements

The following items apply to Disk Data storage requirements:

  • Variable-length columns of Disk Data tables take up a fixed amount of space. For each row, this is equal to the space required to store the largest possible value for that column.

    For general information about calculating these values, see Section 11.6, "Data Type Storage Requirements".

    You can obtain an estimate the amount of space available in data files and undo log files by querying the INFORMATION_SCHEMA.FILES table. For more information and examples, see Section 20.29.1, "The INFORMATION_SCHEMA FILES Table".

    Note

    The OPTIMIZE TABLE statement does not have any effect on Disk Data tables.

  • In a Disk Data table, the first 256 bytes of a TEXT or BLOB column are stored in memory; only the remainder is stored on disk.

  • Each row in a Disk Data table uses 8 bytes in memory to point to the data stored on disk. This means that, in some cases, converting an in-memory column to the disk-based format can actually result in greater memory usage. For example, converting a CHAR(4) column from memory-based to disk-based format increases the amount of DataMemory used per row from 4 to 8 bytes.

Important

Starting the cluster with the --initial option does not remove Disk Data files. You must remove these manually prior to performing an initial restart of the cluster.

Performance of Disk Data tables can be improved by minimizing the number of disk seeks by making sure that DiskPageBufferMemory is of sufficient size. You can query the diskpagebuffer table to help determine whether the value for this parameter needs to be increased.

17.5.13. Adding MySQL Cluster Data Nodes Online

This section describes how to add MySQL Cluster data nodes "online"-that is, without needing to shut down the cluster completely and restart it as part of the process.

Important

Currently, you must add new data nodes to a MySQL Cluster as part of a new node group. In addition, it is not possible to change the number of replicas (or the number of nodes per node group) online.

17.5.13.1. Adding MySQL Cluster Data Nodes Online: General Issues

This section provides general information about the behavior of and current limitations in adding MySQL Cluster nodes online.

Redistribution of Data. The ability to add new nodes online includes a means to reorganize NDBCLUSTER table data and indexes so that they are distributed across all data nodes, including the new ones. Table reorganization of both in-memory and Disk Data tables is supported. This redistribution does not currently include unique indexes (only ordered indexes are redistributed) or BLOB table data.

The redistribution for NDBCLUSTER tables already existing before the new data nodes were added is not automatic, but can be accomplished using simple SQL statements in mysql or another MySQL client application. However, all data and indexes added to tables created after a new node group has been added are distributed automatically among all cluster data nodes, including those added as part of the new node group.

Partial starts. It is possible to add a new node group without all of the new data nodes being started. It is also possible to add a new node group to a degraded cluster-that is, a cluster that is only partially started, or where one or more data nodes are not running. In the latter case, the cluster must have enough nodes running to be viable before the new node group can be added.

Effects on ongoing operations. Normal DML operations using MySQL Cluster data are not prevented by the creation or addition of a new node group, or by table reorganization. However, it is not possible to perform DDL concurrently with table reorganization-that is, no other DDL statements can be issued while an ALTER TABLE ... REORGANIZE PARTITION statement is executing. In addition, during the execution of ALTER TABLE ... REORGANIZE PARTITION (or the execution of any other DDL statement), it is not possible to restart cluster data nodes.

Failure handling. Failures of data nodes during node group creation and table reorganization are handled as hown in the following table:

Failure occurs during:Failure occurs in:
"Old" data nodes"New" data nodesSystem
Node group creation
  • If a node other than the master fails: The creation of the node group is always rolled forward.

  • If the master fails:

    • If the internal commit point has been reached: The creation of the node group is rolled forward.

    • If the internal commit point has not yet been reached. The creation of the node group is rolled back

  • If a node other than the master fails: The creation of the node group is always rolled forward.

  • If the master fails:

    • If the internal commit point has been reached: The creation of the node group is rolled forward.

    • If the internal commit point has not yet been reached. The creation of the node group is rolled back

  • If the execution of CREATE NODEGROUP has reached the internal commit point: When restarted, the cluster includes the new node group. Otherwise it without.

  • If the execution of CREATE NODEGROUP has not yet reached the internal commit point: When restarted, the cluster does not include the new node group.

Table reorganization
  • If a node other than the master fails: The table reorganization is always rolled forward.

  • If the master fails:

    • If the internal commit point has been reached: The table reorganization is rolled forward.

    • If the internal commit point has not yet been reached. The table reorganization is rolled back.

  • If a node other than the master fails: The table reorganization is always rolled forward.

  • If the master fails:

    • If the internal commit point has been reached: The table reorganization is rolled forward.

    • If the internal commit point has not yet been reached. The table reorganization is rolled back.

  • If the execution of an ALTER ONLINE TABLE table REORGANIZE PARTITION statement has reached the internal commit point: When the cluster is restarted, the data and indexes belonging to table are distributed using the "new" data nodes.

  • If the execution of an ALTER ONLINE TABLE table REORGANIZE PARTITION statement has not yet reached the internal commit point: When the cluster is restarted, the data and indexes belonging to table are distributed using only the "old" data nodes.

Dropping node groups. The ndb_mgm client supports a DROP NODEGROUP command, but it is possible to drop a node group only when no data nodes in the node group contain any data. Since there is currently no way to "empty" a specific data node or node group, this command works only the following two cases:

  1. After issuing CREATE NODEGROUP in the ndb_mgm client, but before issuing any ALTER ONLINE TABLE ... REORGANIZE PARTITION statements in the mysql client.

  2. After dropping all NDBCLUSTER tables using DROP TABLE.

    TRUNCATE TABLE does not work for this purpose because the data nodes continue to store the table definitions.

17.5.13.2. Adding MySQL Cluster Data Nodes Online: Basic procedure

In this section, we list the basic steps required to add new data nodes to a MySQL Cluster. This procedure applies whether you are using ndbd or ndbmtd binaries for the data node processes. For a more detailed example, see Section 17.5.13.3, "Adding MySQL Cluster Data Nodes Online: Detailed Example".

Assuming that you already have a running MySQL Cluster, adding data nodes online requires the following steps:

  1. Edit the cluster configuration config.ini file, adding new [ndbd] sections corresponding to the nodes to be added. In the case where the cluster uses multiple management servers, these changes need to be made to all config.ini files used by the management servers.

    You must be careful that node IDs for any new data nodes added in the config.ini file do not overlap node IDs used by existing nodes. In the event that you have API nodes using dynamically allocated node IDs and these IDs match node IDs that you want to use for new data nodes, it is possible to force any such API nodes to "migrate", as described later in this procedure.

  2. Perform a rolling restart of all MySQL Cluster management servers.

    Important

    All management servers must be restarted with the --reload or --initial option to force the reading of the new configuration.

  3. Perform a rolling restart of all existing MySQL Cluster data nodes. It is not necessary (or usually even desirable) to use --initial when restarting the existing data nodes.

    If you are using API nodes with dynamically allocated IDs matching any node IDs that you wish to assign to new data nodes, you must restart all API nodes (including SQL nodes) before restarting any of the data nodes processes in this step. This causes any API nodes with node IDs that were previously not explicitly assigned to relinquish those node IDs and acquire new ones.

  4. Perform a rolling restart of any SQL or API nodes connected to the MySQL Cluster.

  5. Start the new data nodes.

    The new data nodes may be started in any order. They can also be started concurrently, as long as they are started after the rolling restarts of all existing data nodes have been completed, and before proceeding to the next step.

  6. Execute one or more CREATE NODEGROUP commands in the MySQL Cluster management client to create the new node group or node groups to which the new data nodes will belong.

  7. Redistribute the cluster's data among all data nodes (including the new ones) by issuing an ALTER ONLINE TABLE ... REORGANIZE PARTITION statement in the mysql client for each NDBCLUSTER table.

    Note

    This needs to be done only for tables already existing at the time the new node group is added. Data in tables created after the new node group is added is distributed automatically; however, data added to any given table tbl that existed before the new nodes were added is not distributed using the new nodes until that table has been reorganized using ALTER ONLINE TABLE tbl REORGANIZE PARTITION.

  8. Reclaim the space freed on the "old" nodes by issuing, for each NDBCLUSTER table, an OPTIMIZE TABLE statement in the mysql client.

You can add all the nodes desired, then issue several CREATE NODEGROUP commands in succession to add the new node groups to the cluster.

17.5.13.3. Adding MySQL Cluster Data Nodes Online: Detailed Example

In this section we provide a detailed example illustrating how to add new MySQL Cluster data nodes online, starting with a MySQL Cluster having 2 data nodes in a single node group and concluding with a cluster having 4 data nodes in 2 node groups.

Starting configuration. For purposes of illustration, we assume a minimal configuration, and that the cluster uses a config.ini file containing only the following information:

[ndbd default]DataMemory = 100MIndexMemory = 100MNoOfReplicas = 2DataDir = /usr/local/mysql/var/mysql-cluster[ndbd]Id = 1HostName = 192.168.0.1[ndbd]Id = 2HostName = 192.168.0.2[mgm]HostName = 192.168.0.10Id = 10[api]Id=20HostName = 192.168.0.20[api]Id=21HostName = 192.168.0.21
Note

We have left a gap in the sequence between data node IDs and other nodes. This make it easier later to assign node IDs that are not already in use to data nodes which are newly added.

We also assume that you have already started the cluster using the appropriate command line or my.cnf options, and that running SHOW in the management client produces output similar to what is shown here:

-- NDB Cluster -- Management Client --ndb_mgm> SHOWConnected to Management Server at: 192.168.0.10:1186Cluster Configuration---------------------[ndbd(NDB)] 2 node(s)id=1 @192.168.0.1  (5.5.29-ndb-7.2.10, Nodegroup: 0, Master)id=2 @192.168.0.2  (5.5.29-ndb-7.2.10, Nodegroup: 0)[ndb_mgmd(MGM)] 1 node(s)id=10   @192.168.0.10  (5.5.29-ndb-7.2.10)[mysqld(API)]   2 node(s)id=20   @192.168.0.20  (5.5.29-ndb-7.2.10)id=21   @192.168.0.21  (5.5.29-ndb-7.2.10)

Finally, we assume that the cluster contains a single NDBCLUSTER table created as shown here:

USE n;CREATE TABLE ips ( id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, country_code CHAR(2) NOT NULL, type CHAR(4) NOT NULL, ip_address varchar(15) NOT NULL, addresses BIGINT UNSIGNED DEFAULT NULL, date BIGINT UNSIGNED DEFAULT NULL)   ENGINE NDBCLUSTER;

The memory usage and related information shown later in this section was generated after inserting approximately 50000 rows into this table.

Note

In this example, we show the single-threaded ndbd being used for the data node processes. However-beginning with MySQL Cluster NDB 7.0.4-you can also apply this example, if you are using the multi-threaded ndbmtd by substituting ndbmtd for ndbd wherever it appears in the steps that follow. (Bug #43108)

Step 1: Update configuration file. Open the cluster global configuration file in a text editor and add [ndbd] sections corresponding to the 2 new data nodes. (We give these data nodes IDs 3 and 4, and assume that they are to be run on host machines at addresses 192.168.0.3 and 192.168.0.4, respectively.) After you have added the new sections, the contents of the config.ini file should look like what is shown here, where the additions to the file are shown in bold type:

[ndbd default]DataMemory = 100MIndexMemory = 100MNoOfReplicas = 2DataDir = /usr/local/mysql/var/mysql-cluster[ndbd]Id = 1HostName = 192.168.0.1[ndbd]Id = 2HostName = 192.168.0.2[ndbd]Id = 3HostName = 192.168.0.3[ndbd]Id = 4HostName = 192.168.0.4[mgm]HostName = 192.168.0.10Id = 10[api]Id=20HostName = 192.168.0.20[api]Id=21HostName = 192.168.0.21

Once you have made the necessary changes, save the file.

Step 2: Restart the management server. Restarting the cluster management server requires that you issue separate commands to stop the management server and then to start it again, as follows:

  1. Stop the management server using the management client STOP command, as shown here:

    ndb_mgm> 10 STOPNode 10 has shut down.Disconnecting to allow Management Server to shutdownshell>
  2. Because shutting down the management server causes the management client to terminate, you must start the management server from the system shell. For simplicity, we assume that config.ini is in the same directory as the management server binary, but in practice, you must supply the correct path to the configuration file. You must also supply the --reload or --initial option so that the management server reads the new configuration from the file rather than its configuration cache. If your shell's current directory is also the same as the directory where the management server binary is located, then you can invoke the management server as shown here:

    shell> ndb_mgmd -f config.ini --reload2008-12-08 17:29:23 [MgmSrvr] INFO -- NDB Cluster Management Server. 5.5.29-ndb-7.2.102008-12-08 17:29:23 [MgmSrvr] INFO -- Reading cluster configuration from 'config.ini'

If you check the output of SHOW in the management client after restarting the ndb_mgm process, you should now see something like this:

-- NDB Cluster -- Management Client --ndb_mgm> SHOWConnected to Management Server at: 192.168.0.10:1186Cluster Configuration---------------------[ndbd(NDB)] 2 node(s)id=1 @192.168.0.1  (5.5.29-ndb-7.2.10, Nodegroup: 0, Master)id=2 @192.168.0.2  (5.5.29-ndb-7.2.10, Nodegroup: 0)id=3 (not connected, accepting connect from 192.168.0.3)id=4 (not connected, accepting connect from 192.168.0.4)[ndb_mgmd(MGM)] 1 node(s)id=10   @192.168.0.10  (5.5.29-ndb-7.2.10)[mysqld(API)]   2 node(s)id=20   @192.168.0.20  (5.5.29-ndb-7.2.10)id=21   @192.168.0.21  (5.5.29-ndb-7.2.10)

Step 3: Perform a rolling restart of the existing data nodes. This step can be accomplished entirely within the cluster management client using the RESTART command, as shown here:

ndb_mgm> 1 RESTARTNode 1: Node shutdown initiatedNode 1: Node shutdown completed, restarting, no start.Node 1 is being restartedndb_mgm> Node 1: Start initiated (version 7.2.10)Node 1: Started (version 7.1.26)ndb_mgm> 2 RESTARTNode 2: Node shutdown initiatedNode 2: Node shutdown completed, restarting, no start.Node 2 is being restartedndb_mgm> Node 2: Start initiated (version 7.2.10)ndb_mgm> Node 2: Started (version 7.2.10)
Important

After issuing each X RESTART command, wait until the management client reports Node X: Started (version ...) before proceeding any further.

You can verify that all existing data nodes were restarted using the updated configuration by checking the ndbinfo.nodes table in the mysql client.

Step 4: Perform a rolling restart of all cluster API nodes. Shut down and restart each MySQL server acting as an SQL node in the cluster using mysqladmin shutdown followed by mysqld_safe (or another startup script). This should be similar to what is shown here, where password is the MySQL root password for a given MySQL server instance:

shell> mysqladmin -uroot -ppassword shutdown081208 20:19:56 mysqld_safe mysqld from pid file/usr/local/mysql/var/tonfisk.pid endedshell> mysqld_safe --ndbcluster --ndb-connectstring=192.168.0.10 &081208 20:20:06 mysqld_safe Logging to '/usr/local/mysql/var/tonfisk.err'.081208 20:20:06 mysqld_safe Starting mysqld daemon with databasesfrom /usr/local/mysql/var

Of course, the exact input and output depend on how and where MySQL is installed on the system, as well as which options you choose to start it (and whether or not some or all of these options are specified in a my.cnf file).

Step 5: Perform an initial start of the new data nodes. From a system shell on each of the hosts for the new data nodes, start the data nodes as shown here, using the --initial option:

shell> ndbd -c 192.168.0.10 --initial
Note

Unlike the case with restarting the existing data nodes, you can start the new data nodes concurrently; you do not need to wait for one to finish starting before starting the other.

Wait until both of the new data nodes have started before proceeding with the next step. Once the new data nodes have started, you can see in the output of the management client SHOW command that they do not yet belong to any node group (as indicated with bold type here):

ndb_mgm> SHOWConnected to Management Server at: 192.168.0.10:1186Cluster Configuration---------------------[ndbd(NDB)] 2 node(s)id=1 @192.168.0.1  (5.5.29-ndb-7.2.10, Nodegroup: 0, Master)id=2 @192.168.0.2  (5.5.29-ndb-7.2.10, Nodegroup: 0)id=3 @192.168.0.3  (5.5.29-ndb-7.2.10, no nodegroup)id=4 @192.168.0.4  (5.5.29-ndb-7.2.10, no nodegroup)[ndb_mgmd(MGM)] 1 node(s)id=10   @192.168.0.10  (5.5.29-ndb-7.2.10)[mysqld(API)]   2 node(s)id=20   @192.168.0.20  (5.5.29-ndb-7.2.10)id=21   @192.168.0.21  (5.5.29-ndb-7.2.10)

Step 6: Create a new node group. You can do this by issuing a CREATE NODEGROUP command in the cluster management client. This command takes as its argument a comma-separated list of the node IDs of the data nodes to be included in the new node group, as shown here:

ndb_mgm> CREATE NODEGROUP 3,4Nodegroup 1 created

By issuing SHOW again, you can verify that data nodes 3 and 4 have joined the new node group (again indicated in bold type):

ndb_mgm> SHOWConnected to Management Server at: 192.168.0.10:1186Cluster Configuration---------------------[ndbd(NDB)] 2 node(s)id=1 @192.168.0.1  (5.5.29-ndb-7.2.10, Nodegroup: 0, Master)id=2 @192.168.0.2  (5.5.29-ndb-7.2.10, Nodegroup: 0)id=3 @192.168.0.3  (5.5.29-ndb-7.2.10, Nodegroup: 1)id=4 @192.168.0.4  (5.5.29-ndb-7.2.10, Nodegroup: 1)[ndb_mgmd(MGM)] 1 node(s)id=10   @192.168.0.10  (5.5.29-ndb-7.2.10)[mysqld(API)]   2 node(s)id=20   @192.168.0.20  (5.5.29-ndb-7.2.10)id=21   @192.168.0.21  (5.5.29-ndb-7.2.10)

Step 7: Redistribute cluster data. When a node group is created, existing data and indexes are not automatically distributed to the new node group's data nodes, as you can see by issuing the appropriate REPORT command in the management client:

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

By using ndb_desc with the -p option, which causes the output to include partitioning information, you can see that the table still uses only 2 partitions (in the Per partition info section of the output, shown here in bold text):

shell> ndb_desc -c 192.168.0.10 -d n ips -p-- ips --Version: 1Fragment type: 9K Value: 6Min load factor: 78Max load factor: 80Temporary table: noNumber of attributes: 6Number of primary keys: 1Length of frm data: 340Row Checksum: 1Row GCI: 1SingleUserMode: 0ForceVarPart: 1FragmentCount: 2TableStatus: Retrieved-- Attributes --id Bigint PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY AUTO_INCRcountry_code Char(2;latin1_swedish_ci) NOT NULL AT=FIXED ST=MEMORYtype Char(4;latin1_swedish_ci) NOT NULL AT=FIXED ST=MEMORYip_address Varchar(15;latin1_swedish_ci) NOT NULL AT=SHORT_VAR ST=MEMORYaddresses Bigunsigned NULL AT=FIXED ST=MEMORYdate Bigunsigned NULL AT=FIXED ST=MEMORY-- Indexes --PRIMARY KEY(id) - UniqueHashIndexPRIMARY(id) - OrderedIndex-- Per partition info --Partition   Row count   Commit count  Frag fixed memory   Frag varsized memory0   26086   26086 1572864 5570561   26329   26329 1605632 557056NDBT_ProgramExit: 0 - OK

You can cause the data to be redistributed among all of the data nodes by performing, for each NDBCLUSTER table, an ALTER ONLINE TABLE ... REORGANIZE PARTITION statement in the mysql client. After issuing the statement ALTER ONLINE TABLE ips REORGANIZE PARTITION, you can see using ndb_desc that the data for this table is now stored using 4 partitions, as shown here (with the relevant portions of the output in bold type):

shell> ndb_desc -c 192.168.0.10 -d n ips -p-- ips --Version: 16777217Fragment type: 9K Value: 6Min load factor: 78Max load factor: 80Temporary table: noNumber of attributes: 6Number of primary keys: 1Length of frm data: 341Row Checksum: 1Row GCI: 1SingleUserMode: 0ForceVarPart: 1FragmentCount: 4TableStatus: Retrieved-- Attributes --id Bigint PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY AUTO_INCRcountry_code Char(2;latin1_swedish_ci) NOT NULL AT=FIXED ST=MEMORYtype Char(4;latin1_swedish_ci) NOT NULL AT=FIXED ST=MEMORYip_address Varchar(15;latin1_swedish_ci) NOT NULL AT=SHORT_VAR ST=MEMORYaddresses Bigunsigned NULL AT=FIXED ST=MEMORYdate Bigunsigned NULL AT=FIXED ST=MEMORY-- Indexes --PRIMARY KEY(id) - UniqueHashIndexPRIMARY(id) - OrderedIndex-- Per partition info --Partition   Row count   Commit count  Frag fixed memory   Frag varsized memory0   12981   52296 1572864 5570561   13236   52515 1605632 5570562   13105   13105 819200  2949123   13093   13093 819200  294912NDBT_ProgramExit: 0 - OK
Note

Normally, ALTER [ONLINE] TABLE table_name REORGANIZE PARTITION is used with a list of partition identifiers and a set of partition definitions to create a new partitioning scheme for a table that has already been explicitly partitioned. Its use here to redistribute data onto a new MySQL Cluster node group is an exception in this regard; when used in this way, only the name of the table is used following the TABLE keyword, and no other keywords or identifiers follow REORGANIZE PARTITION.

For more information, see Section 13.1.7, "ALTER TABLE Syntax".

In addition, for each table, the ALTER ONLINE TABLE statement should be followed by an OPTIMIZE TABLE to reclaim wasted space. You can obtain a list of all NDBCLUSTER tables using the following query against the INFORMATION_SCHEMA.TABLES table:

SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE ENGINE = 'NDBCLUSTER';
Note

The INFORMATION_SCHEMA.TABLES.ENGINE value for a MySQL Cluster table is always NDBCLUSTER, regardless of whether the CREATE TABLE statement used to create the table (or ALTER TABLE statement used to convert an existing table from a different storage engine) used NDB or NDBCLUSTER in its ENGINE option.

You can see after performing these statements in the output of ALL REPORT MEMORY that the data and indexes are now redistributed between all cluster data nodes, as shown here:

ndb_mgm> ALL REPORT MEMORYNode 1: Data usage is 5%(176 32K pages of total 3200)Node 1: Index usage is 0%(76 8K pages of total 12832)Node 2: Data usage is 5%(176 32K pages of total 3200)Node 2: Index usage is 0%(76 8K pages of total 12832)Node 3: Data usage is 2%(80 32K pages of total 3200)Node 3: Index usage is 0%(51 8K pages of total 12832)Node 4: Data usage is 2%(80 32K pages of total 3200)Node 4: Index usage is 0%(50 8K pages of total 12832)
Note

Since only one DDL operation on NDBCLUSTER tables can be executed at a time, you must wait for each ALTER ONLINE TABLE ... REORGANIZE PARTITION statement to finish before issuing the next one.

It is not necessary to issue ALTER ONLINE TABLE ... REORGANIZE PARTITION statements for NDBCLUSTER tables created after the new data nodes have been added; data added to such tables is distributed among all data nodes automatically. However, in NDBCLUSTER tables that existed prior to the addition of the new nodes, neither existing nor new data is distributed using the new nodes until these tables have been reorganized using ALTER ONLINE TABLE ... REORGANIZE PARTITION.

Alternative procedure, without rolling restart. It is possible to avoid the need for a rolling restart by configuring the extra data nodes, but not starting them, when first starting the cluster. We assume, as before, that you wish to start with two data nodes-nodes 1 and 2-in one node group and later to expand the cluster to four data nodes, by adding a second node group consisting of nodes 3 and 4:

[ndbd default]DataMemory = 100MIndexMemory = 100MNoOfReplicas = 2DataDir = /usr/local/mysql/var/mysql-cluster[ndbd]Id = 1HostName = 192.168.0.1[ndbd]Id = 2HostName = 192.168.0.2[ndbd]Id = 3HostName = 192.168.0.3Nodegroup = 65536   [ndbd]Id = 4HostName = 192.168.0.4Nodegroup = 65536   [mgm]HostName = 192.168.0.10Id = 10[api]Id=20HostName = 192.168.0.20[api]Id=21HostName = 192.168.0.21
Note

In MySQL Cluster NDB 7.2, it is no longer necessary to perform the initial start of the cluster using --nowait-nodes option with ndbd or ndbmtd as it was in some earlier versions of MySQL Cluster.

The data nodes to be brought online at a later time (nodes 3 and 4) can be configured with NodeGroup = 65536, in which case nodes 1 and 2 can each be started as shown here:

shell> ndbd -c 192.168.0.10 --initial

The data nodes configured with NodeGroup = 65536 are treated by the management server as though you had started nodes 1 and 2 using --nowait-nodes=3,4 after waiting for a period of time determined by the setting for the StartNoNodeGroupTimeout data node configuration parameter. By default, this is 15 seconds (15000 milliseconds).

Note

StartNoNodegroupTimeout must be the same for all data nodes in the cluster; for this reason, you should always set it in the [ndbd default] section of the config.ini file, rather than for individual data nodes.

When you are ready to add the second node group, you need only perform the following additional steps:

  1. Start data nodes 3 and 4, invoking the data node process once for each new node:

    shell> ndbd -c 192.168.0.10 --initial
  2. Issue the appropriate CREATE NODEGROUP command in the management client:

    ndb_mgm> CREATE NODEGROUP 3,4
  3. In the mysql client, issue ALTER ONLINE TABLE ... REORGANIZE PARTITION and OPTIMIZE TABLE statements for each existing NDBCLUSTER table. (As noted elsewhere in this section, existing MySQL Cluster tables cannot use the new nodes for data distribution until this has been done.)

17.5.14. Distributed MySQL Privileges for MySQL Cluster

MySQL Cluster NDB 7.2 introduces support for distributing MySQL users and privileges across all SQL nodes in a MySQL Cluster. This support is not enabled by default; you should follow the procedure outlined in this section in order to do so.

Normally, each MySQL server's user privilege tables in the mysql database must use the MyISAM storage engine, which means that a user account and its associated privileges created on one SQL node are not available on the cluster's other SQL nodes. In MySQL Cluster NDB 7.2 and later, an SQL file ndb_dist_priv.sql is provided with the MySQL Cluster distribution. This file can be found in the share directory in the MySQL installation directory.

The first step in enabling distributed privileges is to load this script into a MySQL Server that functions as an SQL node (which we refer to after this as the target SQL node or MySQL Server). You can do this by executing the following command from the system shell on the target SQL node after changing to its MySQL installation directory (where options stands for any additional options needed to connect to this SQL node):

shell> mysql options -uroot < share/ndb_dist_priv.sql

Importing ndb_dist_priv.sql creates a number of stored routines (six stored procedures and one stored function) in the mysql database on the target SQL node. After connecting to the SQL node in the mysql client (as the MySQL root user), you can verify that these were created as shown here:

mysql> SELECT ROUTINE_NAME, ROUTINE_SCHEMA, ROUTINE_TYPE -> FROM INFORMATION_SCHEMA.ROUTINES -> WHERE ROUTINE_NAME LIKE 'mysql_cluster%' -> ORDER BY ROUTINE_TYPE;+---------------------------------------------+----------------+--------------+| ROUTINE_NAME | ROUTINE_SCHEMA | ROUTINE_TYPE |+---------------------------------------------+----------------+--------------+| mysql_cluster_privileges_are_distributed | mysql  | FUNCTION || mysql_cluster_backup_privileges | mysql  | PROCEDURE || mysql_cluster_move_grant_tables | mysql  | PROCEDURE || mysql_cluster_move_privileges   | mysql  | PROCEDURE || mysql_cluster_restore_local_privileges  | mysql  | PROCEDURE || mysql_cluster_restore_privileges | mysql  | PROCEDURE || mysql_cluster_restore_privileges_from_local | mysql  | PROCEDURE |+---------------------------------------------+----------------+--------------+7 rows in set (0.01 sec)

The stored procedure named mysql_cluster_move_privileges creates backup copies of the existing privilege tables, then converts them to NDB. Two sets of copies are created in the mysql database:

  • A set of local copies that use the MyISAM storage engine, and named by adding the suffix _backup to the original privilege table names.

  • A set of distributed copies (using NDBCLUSTER). These tables are named by prefixing ndb_ and appending _backup to the names of the original tables.

Although the original privilege tables are backed up automatically, it is always a good idea to create backups manually of the existing privilege tables on all affected SQL nodes before proceeding. You can do this using mysqldump in a manner similar to what is shown here:

shell> mysqldump options -uroot \ mysql host user db tables_priv columns_priv procs_priv proxies_priv > backup_file

To perform the conversion, you must be connected to the target SQL node using the mysql client (again, as the MySQL root user). Invoke the stored procedure like this:

mysql> CALL mysql.mysql_cluster_move_privileges();Query OK, 0 rows affected (22.32 sec)

Depending on the number of rows in the privilege tables, this procedure may take some time to execute. If some of the privilege tables are empty, you may see one or more No data - zero rows fetched, selected, or processed warnings when mysql_cluster_move_privileges returns. In such cases, the warnings may be safely ignored. To verify that the conversion was successful, you can use the stored function mysql_cluster_privileges_are_distributed as shown here:

mysql> SELECT CONCAT( -> 'Conversion ', -> IF(mysql.mysql_cluster_privileges_are_distributed(), 'succeeded', 'failed'), -> '.') -> AS Result;+-----------------------+| Result |+-----------------------+| Conversion succeeded. |+-----------------------+1 row in set (0.00 sec)

mysql_cluster_privileges_are_distributed checks for the existence of the distributed privilege tables and returns 1 if all of the privilege tables are distributed; otherwise, it returns 0.

You can verify that the backups have been created using a query such as this one:

mysql> SELECT TABLE_NAME, ENGINE FROM INFORMATION_SCHEMA.TABLES -> WHERE TABLE_SCHEMA = 'mysql' AND TABLE_NAME LIKE '%backup' -> ORDER BY ENGINE;+-------------------------+------------+| TABLE_NAME  | ENGINE |+-------------------------+------------+| host_backup | MyISAM || db_backup   | MyISAM || columns_priv_backup | MyISAM || user_backup | MyISAM || tables_priv_backup  | MyISAM || proxies_priv_backup | MyISAM || procs_priv_backup   | MyISAM || ndb_user_backup | ndbcluster || ndb_tables_priv_backup  | ndbcluster || ndb_proxies_priv_backup | ndbcluster || ndb_procs_priv_backup   | ndbcluster || ndb_host_backup | ndbcluster || ndb_db_backup   | ndbcluster || ndb_columns_priv_backup | ndbcluster |+-------------------------+------------+14 rows in set (0.00 sec)

Once the conversion to distributed privileges has been made, any time a MySQL user account is created, dropped, or has its privileges updated on any SQL node, the changes take effect immediately on all other MySQL servers attached to the cluster. Once privileges are distributed, any new MySQL Servers that connect to the cluster automatically participate in the distribution.

Note

Formerly, after mysql_cluster_move_privileges was executed, you sometimes needed to execute FLUSH PRIVILEGES on those SQL nodes, or to disconnect and then reconnect the clients, in order for those clients to be able to see the changes in privileges. In MySQL Cluster NDB 7.2.4 and later, this is no longer necessary, as SQL nodes automatically execute a FLUSH PRIVILEGES statement when joining a MySQL Cluster where distributed privileges are in use.

All MySQL user privileges are distributed across all connected MySQL Servers. This includes privileges associated with views and stored routines. While automatic distribution of views and stored routines is not currently supported, you can attempt to distribute stored routines by issuing a statement such as ALTER TABLE mysql.proc ENGINE = NDB, but you must verify manually that any tables referenced by the stored routines exist on all SQL nodes, since MySQL Cluster has no support at the present time for doing this automatically. There is currently no way to distribute views among MySQL Cluster SQL nodes, other than by creating them manually on each SQL node. If you do this, you must make certain that all base tables referenced by the views use the NDB storage engine; otherwise, the views are likely to diverge very quickly.

In the event that an SQL node becomes disconnected from the cluster while mysql_cluster_move_privileges is running, you must drop its privilege tables after reconnecting to the cluster, using a statement such as DROP TABLE IF EXISTS mysql.user mysql.db mysql.tables_priv mysql.columns_priv mysql.procs_priv. This causes the SQL node to use the shared privilege tables rather than its own local versions of them. This is not needed when connecting a new SQL node to the cluster for the first time.

In the event of an initial restart of the entire cluster (all data nodes shut down, then started again with --initial), the shared privilege tables are lost. If this happens, you can restore them using the original target SQL node either from the backups made by mysql_cluster_move_privileges or from a dump file created with mysqldump. If you need to use a new MySQL Server to perform the restoration, you should start it with --skip-grant-tables when connecting to the cluster for the first time; after this, you can restore the privilege tables locally, then distribute them again using mysql_cluster_move_privileges. After restoring and distributing the tables, you should restart this MySQL Server without the --skip-grant-tables option.

You can also restore the distributed tables using ndb_restore --restore-privilege-tables from a backup made using START BACKUP in the ndb_mgm client. (The MyISAM tables created by mysql_cluster_move_privileges are not backed up by the START BACKUP command.) ndb_restore does not restore the privilege tables by default; the --restore-privilege-tables option causes it to do so.

Important

Applications that access MySQL Cluster data directly, including NDB API and ClusterJ applications, are not subject to the MySQL privilege system. This means that, once you have distributed the grant tables, they can be freely accessed by such applications, just as they can any other NDB tables. In particular, you should keep in mind that NDB API and ClusterJ applications can read and write user names, host names, password hashes, and any other contents of the distributed grant tables without any restrictions.

17.5.15. NDB API Statistics Counters and Variables

A number of types of statistical counters relating to actions performed by or affecting Ndb objects are available. Such actions include starting and closing (or aborting) transactions; primary key and unique key operations; table, range, and pruned scans; threads blocked while waiting for the completion of various operations; and data and events sent and received by NDBCLUSTER. The counters are incremented inside the NDB kernel whenever NDB API calls are made or data is sent to or received by the data nodes. mysqld exposes these counters as system status variables; their values can be read in the output of SHOW STATUS, or by querying the INFORMATION_SCHEMA.SESSION_STATUS or INFORMATION_SCHEMA.GLOBAL_STATUS table. By comparing the values before and after statements operating on NDB tables, you can observe the corresponding actions taken on the API level, and thus the cost of performing the statement.

You can list all of these status variables using the following SHOW STATUS statement:

mysql> SHOW STATUS LIKE 'ndb_api%';+--------------------------------------------+----------+| Variable_name  | Value |+--------------------------------------------+----------+| Ndb_api_wait_exec_complete_count_session   | 0 || Ndb_api_wait_scan_result_count_session | 0 || Ndb_api_wait_meta_request_count_session | 0 || Ndb_api_wait_nanos_count_session   | 0 || Ndb_api_bytes_sent_count_session   | 0 || Ndb_api_bytes_received_count_session   | 0 || Ndb_api_trans_start_count_session  | 0 || Ndb_api_trans_commit_count_session | 0 || Ndb_api_trans_abort_count_session  | 0 || Ndb_api_trans_close_count_session  | 0 || Ndb_api_pk_op_count_session | 0 || Ndb_api_uk_op_count_session | 0 || Ndb_api_table_scan_count_session   | 0 || Ndb_api_range_scan_count_session   | 0 || Ndb_api_pruned_scan_count_session  | 0 || Ndb_api_scan_batch_count_session   | 0 || Ndb_api_read_row_count_session | 0 || Ndb_api_trans_local_read_row_count_session | 0 || Ndb_api_event_data_count_injector  | 0 || Ndb_api_event_nondata_count_injector   | 0 || Ndb_api_event_bytes_count_injector | 0 || Ndb_api_wait_exec_complete_count_slave | 0 || Ndb_api_wait_scan_result_count_slave   | 0 || Ndb_api_wait_meta_request_count_slave  | 0 || Ndb_api_wait_nanos_count_slave | 0 || Ndb_api_bytes_sent_count_slave | 0 || Ndb_api_bytes_received_count_slave | 0 || Ndb_api_trans_start_count_slave | 0 || Ndb_api_trans_commit_count_slave   | 0 || Ndb_api_trans_abort_count_slave | 0 || Ndb_api_trans_close_count_slave | 0 || Ndb_api_pk_op_count_slave  | 0 || Ndb_api_uk_op_count_slave  | 0 || Ndb_api_table_scan_count_slave | 0 || Ndb_api_range_scan_count_slave | 0 || Ndb_api_pruned_scan_count_slave | 0 || Ndb_api_scan_batch_count_slave | 0 || Ndb_api_read_row_count_slave   | 0 || Ndb_api_trans_local_read_row_count_slave   | 0 || Ndb_api_wait_exec_complete_count   | 2 || Ndb_api_wait_scan_result_count | 3 || Ndb_api_wait_meta_request_count | 27   || Ndb_api_wait_nanos_count   | 45612023 || Ndb_api_bytes_sent_count   | 992  || Ndb_api_bytes_received_count   | 9640 || Ndb_api_trans_start_count  | 2 || Ndb_api_trans_commit_count | 1 || Ndb_api_trans_abort_count  | 0 || Ndb_api_trans_close_count  | 2 || Ndb_api_pk_op_count | 1 || Ndb_api_uk_op_count | 0 || Ndb_api_table_scan_count   | 1 || Ndb_api_range_scan_count   | 0 || Ndb_api_pruned_scan_count  | 0 || Ndb_api_scan_batch_count   | 0 || Ndb_api_read_row_count | 1 || Ndb_api_trans_local_read_row_count | 1 || Ndb_api_event_data_count   | 0 || Ndb_api_event_nondata_count | 0 || Ndb_api_event_bytes_count  | 0 |+--------------------------------------------+----------+60 rows in set (0.02 sec)

These status variables are also available from the SESSION_STATUS and GLOBAL_STATUS tables of the INFORMATION_SCHEMA database, as shown here:

mysql> SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS  ->   WHERE VARIABLE_NAME LIKE 'ndb_api%';+--------------------------------------------+----------------+| VARIABLE_NAME  | VARIABLE_VALUE |+--------------------------------------------+----------------+| NDB_API_WAIT_EXEC_COMPLETE_COUNT_SESSION   | 2  || NDB_API_WAIT_SCAN_RESULT_COUNT_SESSION | 0  || NDB_API_WAIT_META_REQUEST_COUNT_SESSION | 1  || NDB_API_WAIT_NANOS_COUNT_SESSION   | 8144375 || NDB_API_BYTES_SENT_COUNT_SESSION   | 68 || NDB_API_BYTES_RECEIVED_COUNT_SESSION   | 84 || NDB_API_TRANS_START_COUNT_SESSION  | 1  || NDB_API_TRANS_COMMIT_COUNT_SESSION | 1  || NDB_API_TRANS_ABORT_COUNT_SESSION  | 0  || NDB_API_TRANS_CLOSE_COUNT_SESSION  | 1  || NDB_API_PK_OP_COUNT_SESSION | 1  || NDB_API_UK_OP_COUNT_SESSION | 0  || NDB_API_TABLE_SCAN_COUNT_SESSION   | 0  || NDB_API_RANGE_SCAN_COUNT_SESSION   | 0  || NDB_API_PRUNED_SCAN_COUNT_SESSION  | 0  || NDB_API_SCAN_BATCH_COUNT_SESSION   | 0  || NDB_API_READ_ROW_COUNT_SESSION | 1  || NDB_API_TRANS_LOCAL_READ_ROW_COUNT_SESSION | 1  || NDB_API_EVENT_DATA_COUNT_INJECTOR  | 0  || NDB_API_EVENT_NONDATA_COUNT_INJECTOR   | 0  || NDB_API_EVENT_BYTES_COUNT_INJECTOR | 0  || NDB_API_WAIT_EXEC_COMPLETE_COUNT_SLAVE | 0  || NDB_API_WAIT_SCAN_RESULT_COUNT_SLAVE   | 0  || NDB_API_WAIT_META_REQUEST_COUNT_SLAVE  | 0  || NDB_API_WAIT_NANOS_COUNT_SLAVE | 0  || NDB_API_BYTES_SENT_COUNT_SLAVE | 0  || NDB_API_BYTES_RECEIVED_COUNT_SLAVE | 0  || NDB_API_TRANS_START_COUNT_SLAVE | 0  || NDB_API_TRANS_COMMIT_COUNT_SLAVE   | 0  || NDB_API_TRANS_ABORT_COUNT_SLAVE | 0  || NDB_API_TRANS_CLOSE_COUNT_SLAVE | 0  || NDB_API_PK_OP_COUNT_SLAVE  | 0  || NDB_API_UK_OP_COUNT_SLAVE  | 0  || NDB_API_TABLE_SCAN_COUNT_SLAVE | 0  || NDB_API_RANGE_SCAN_COUNT_SLAVE | 0  || NDB_API_PRUNED_SCAN_COUNT_SLAVE | 0  || NDB_API_SCAN_BATCH_COUNT_SLAVE | 0  || NDB_API_READ_ROW_COUNT_SLAVE   | 0  || NDB_API_TRANS_LOCAL_READ_ROW_COUNT_SLAVE   | 0  || NDB_API_WAIT_EXEC_COMPLETE_COUNT   | 4  || NDB_API_WAIT_SCAN_RESULT_COUNT | 3  || NDB_API_WAIT_META_REQUEST_COUNT | 28 || NDB_API_WAIT_NANOS_COUNT   | 53756398   || NDB_API_BYTES_SENT_COUNT   | 1060   || NDB_API_BYTES_RECEIVED_COUNT   | 9724   || NDB_API_TRANS_START_COUNT  | 3  || NDB_API_TRANS_COMMIT_COUNT | 2  || NDB_API_TRANS_ABORT_COUNT  | 0  || NDB_API_TRANS_CLOSE_COUNT  | 3  || NDB_API_PK_OP_COUNT | 2  || NDB_API_UK_OP_COUNT | 0  || NDB_API_TABLE_SCAN_COUNT   | 1  || NDB_API_RANGE_SCAN_COUNT   | 0  || NDB_API_PRUNED_SCAN_COUNT  | 0  || NDB_API_SCAN_BATCH_COUNT   | 0  || NDB_API_READ_ROW_COUNT | 2  || NDB_API_TRANS_LOCAL_READ_ROW_COUNT | 2  || NDB_API_EVENT_DATA_COUNT   | 0  || NDB_API_EVENT_NONDATA_COUNT | 0  || NDB_API_EVENT_BYTES_COUNT  | 0  |+--------------------------------------------+----------------+60 rows in set (0.00 sec)mysql> SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS -> WHERE VARIABLE_NAME LIKE 'ndb_api%';+--------------------------------------------+----------------+| VARIABLE_NAME  | VARIABLE_VALUE |+--------------------------------------------+----------------+| NDB_API_WAIT_EXEC_COMPLETE_COUNT_SESSION   | 2  || NDB_API_WAIT_SCAN_RESULT_COUNT_SESSION | 0  || NDB_API_WAIT_META_REQUEST_COUNT_SESSION | 1  || NDB_API_WAIT_NANOS_COUNT_SESSION   | 8144375 || NDB_API_BYTES_SENT_COUNT_SESSION   | 68 || NDB_API_BYTES_RECEIVED_COUNT_SESSION   | 84 || NDB_API_TRANS_START_COUNT_SESSION  | 1  || NDB_API_TRANS_COMMIT_COUNT_SESSION | 1  || NDB_API_TRANS_ABORT_COUNT_SESSION  | 0  || NDB_API_TRANS_CLOSE_COUNT_SESSION  | 1  || NDB_API_PK_OP_COUNT_SESSION | 1  || NDB_API_UK_OP_COUNT_SESSION | 0  || NDB_API_TABLE_SCAN_COUNT_SESSION   | 0  || NDB_API_RANGE_SCAN_COUNT_SESSION   | 0  || NDB_API_PRUNED_SCAN_COUNT_SESSION  | 0  || NDB_API_SCAN_BATCH_COUNT_SESSION   | 0  || NDB_API_READ_ROW_COUNT_SESSION | 1  || NDB_API_TRANS_LOCAL_READ_ROW_COUNT_SESSION | 1  || NDB_API_EVENT_DATA_COUNT_INJECTOR  | 0  || NDB_API_EVENT_NONDATA_COUNT_INJECTOR   | 0  || NDB_API_EVENT_BYTES_COUNT_INJECTOR | 0  || NDB_API_WAIT_EXEC_COMPLETE_COUNT_SLAVE | 0  || NDB_API_WAIT_SCAN_RESULT_COUNT_SLAVE   | 0  || NDB_API_WAIT_META_REQUEST_COUNT_SLAVE  | 0  || NDB_API_WAIT_NANOS_COUNT_SLAVE | 0  || NDB_API_BYTES_SENT_COUNT_SLAVE | 0  || NDB_API_BYTES_RECEIVED_COUNT_SLAVE | 0  || NDB_API_TRANS_START_COUNT_SLAVE | 0  || NDB_API_TRANS_COMMIT_COUNT_SLAVE   | 0  || NDB_API_TRANS_ABORT_COUNT_SLAVE | 0  || NDB_API_TRANS_CLOSE_COUNT_SLAVE | 0  || NDB_API_PK_OP_COUNT_SLAVE  | 0  || NDB_API_UK_OP_COUNT_SLAVE  | 0  || NDB_API_TABLE_SCAN_COUNT_SLAVE | 0  || NDB_API_RANGE_SCAN_COUNT_SLAVE | 0  || NDB_API_PRUNED_SCAN_COUNT_SLAVE | 0  || NDB_API_SCAN_BATCH_COUNT_SLAVE | 0  || NDB_API_READ_ROW_COUNT_SLAVE   | 0  || NDB_API_TRANS_LOCAL_READ_ROW_COUNT_SLAVE   | 0  || NDB_API_WAIT_EXEC_COMPLETE_COUNT   | 4  || NDB_API_WAIT_SCAN_RESULT_COUNT | 3  || NDB_API_WAIT_META_REQUEST_COUNT | 28 || NDB_API_WAIT_NANOS_COUNT   | 53756398   || NDB_API_BYTES_SENT_COUNT   | 1060   || NDB_API_BYTES_RECEIVED_COUNT   | 9724   || NDB_API_TRANS_START_COUNT  | 3  || NDB_API_TRANS_COMMIT_COUNT | 2  || NDB_API_TRANS_ABORT_COUNT  | 0  || NDB_API_TRANS_CLOSE_COUNT  | 3  || NDB_API_PK_OP_COUNT | 2  || NDB_API_UK_OP_COUNT | 0  || NDB_API_TABLE_SCAN_COUNT   | 1  || NDB_API_RANGE_SCAN_COUNT   | 0  || NDB_API_PRUNED_SCAN_COUNT  | 0  || NDB_API_SCAN_BATCH_COUNT   | 0  || NDB_API_READ_ROW_COUNT | 2  || NDB_API_TRANS_LOCAL_READ_ROW_COUNT | 2  || NDB_API_EVENT_DATA_COUNT   | 0  || NDB_API_EVENT_NONDATA_COUNT | 0  || NDB_API_EVENT_BYTES_COUNT  | 0  |+--------------------------------------------+----------------+60 rows in set (0.00 sec)

Each Ndb object has its own counters. NDB API applications can read the values of the counters for use in optimization or monitoring. For multithreaded clients which use more than one Ndb object concurrently, it is also possible to obtain a summed view of counters from all Ndb objects belonging to a given Ndb_cluster_connection.

Four sets of these counters are exposed. One set applies to the current session only; the other 3 are global. This is in spite of the fact that their values can be obtained as either session or global status variables in the mysql client. This means that specifying the SESSION or GLOBAL keyword with SHOW STATUS has no effect on the values reported for NDB API statistics status variables, and the value for each of these variables is the same whether the value is obtained from the equivalent column of the SESSION_STATUS or the GLOBAL_STATUS table.

  • Session counters (session specific)

    Session counters relate to the Ndb objects in use by (only) the current session. Use of such objects by other MySQL clients does not influence these counts.

    In order to minimize confusion with standard MySQL session variables, we refer to the variables that correspond to these NDB API session counters as "_session variables", with a leading underscore.

  • Slave counters (global)

    This set of counters relates to the Ndb objects used by the replication slave SQL thread, if any. If this mysqld does not act as a replication slave, or does not use NDB tables, then all of these counts are 0.

    We refer to the related status variables as "_slave variables" (with a leading underscore).

  • Injector counters (global)

    Injector counters relate to the Ndb object used to listen to cluster events by the binlog injector thread. Even when not writing a binary log, mysqld processes attached to a MySQL Cluster continue to listen for some events, such as schema changes.

    We refer to the status variables that correspond to NDB API injector counters as "_injector variables" (with a leading underscore).

  • Server (Global) counters (global)

    This set of counters relates to all Ndb objects currently used by this mysqld. This includes all MySQL client applications, the slave SQL thread (if any), the binlog injector, and the NDB utility thread.

    We refer to the status variables that correspond to these counters as "global variables" or "mysqld-level variables".

You can obtain values for a particular set of variables by additionally filtering for the substring session, slave, or injector in the variable name (along with the common prefix Ndb_api). For _session variables, this can be done as shown here:

mysql> SHOW STATUS LIKE 'ndb_api%session';+--------------------------------------------+---------+| Variable_name  | Value   |+--------------------------------------------+---------+| Ndb_api_wait_exec_complete_count_session   | 2   || Ndb_api_wait_scan_result_count_session | 0   || Ndb_api_wait_meta_request_count_session | 1   || Ndb_api_wait_nanos_count_session   | 8144375 || Ndb_api_bytes_sent_count_session   | 68  || Ndb_api_bytes_received_count_session   | 84  || Ndb_api_trans_start_count_session  | 1   || Ndb_api_trans_commit_count_session | 1   || Ndb_api_trans_abort_count_session  | 0   || Ndb_api_trans_close_count_session  | 1   || Ndb_api_pk_op_count_session | 1   || Ndb_api_uk_op_count_session | 0   || Ndb_api_table_scan_count_session   | 0   || Ndb_api_range_scan_count_session   | 0   || Ndb_api_pruned_scan_count_session  | 0   || Ndb_api_scan_batch_count_session   | 0   || Ndb_api_read_row_count_session | 1   || Ndb_api_trans_local_read_row_count_session | 1   |+--------------------------------------------+---------+18 rows in set (0.50 sec)

To obtain a listing of the NDB API mysqld-level status variables, filter for variable names beginning with ndb_api and ending in _count, like this:

mysql> SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS -> WHERE VARIABLE_NAME LIKE 'ndb_api%count';+------------------------------------+----------------+| VARIABLE_NAME  | VARIABLE_VALUE |+------------------------------------+----------------+| NDB_API_WAIT_EXEC_COMPLETE_COUNT   | 4  || NDB_API_WAIT_SCAN_RESULT_COUNT | 3  || NDB_API_WAIT_META_REQUEST_COUNT | 28 || NDB_API_WAIT_NANOS_COUNT   | 53756398   || NDB_API_BYTES_SENT_COUNT   | 1060   || NDB_API_BYTES_RECEIVED_COUNT   | 9724   || NDB_API_TRANS_START_COUNT  | 3  || NDB_API_TRANS_COMMIT_COUNT | 2  || NDB_API_TRANS_ABORT_COUNT  | 0  || NDB_API_TRANS_CLOSE_COUNT  | 3  || NDB_API_PK_OP_COUNT | 2  || NDB_API_UK_OP_COUNT | 0  || NDB_API_TABLE_SCAN_COUNT   | 1  || NDB_API_RANGE_SCAN_COUNT   | 0  || NDB_API_PRUNED_SCAN_COUNT  | 0  || NDB_API_SCAN_BATCH_COUNT   | 0  || NDB_API_READ_ROW_COUNT | 2  || NDB_API_TRANS_LOCAL_READ_ROW_COUNT | 2  || NDB_API_EVENT_DATA_COUNT   | 0  || NDB_API_EVENT_NONDATA_COUNT | 0  || NDB_API_EVENT_BYTES_COUNT  | 0  |+------------------------------------+----------------+21 rows in set (0.09 sec)

Not all counters are reflected in all 4 sets of status variables. For the event counters DataEventsRecvdCount, NondataEventsRecvdCount, and EventBytesRecvdCount, only _injector and mysqld-level NDB API status variables are available:

mysql> SHOW STATUS LIKE 'ndb_api%event%';+--------------------------------------+-------+| Variable_name | Value |+--------------------------------------+-------+| Ndb_api_event_data_count_injector | 0 || Ndb_api_event_nondata_count_injector | 0 || Ndb_api_event_bytes_count_injector   | 0 || Ndb_api_event_data_count | 0 || Ndb_api_event_nondata_count  | 0 || Ndb_api_event_bytes_count | 0 |+--------------------------------------+-------+6 rows in set (0.00 sec)

_injector status variables are not implemented for any other NDB API counters, as shown here:

mysql> SHOW STATUS LIKE 'ndb_api%injector%';+--------------------------------------+-------+| Variable_name | Value |+--------------------------------------+-------+| Ndb_api_event_data_count_injector | 0 || Ndb_api_event_nondata_count_injector | 0 || Ndb_api_event_bytes_count_injector   | 0 |+--------------------------------------+-------+3 rows in set (0.00 sec)

The names of the status variables can easily be associated with the names of the corresponding counters. Each NDB API statistics counter is listed in the following table with a description as well as the names of any MySQL server status variables corresponding to this counter.

Counter NameDescription
Status Variables (by statistic type):
  • Session

  • Slave

  • Injector

  • Server

WaitExecCompleteCountNumber of times thread has been blocked while waiting for execution of an operation to complete. Includes all execute() calls as well as implicit executes for blob operations andauto-increment not visible to clients.
WaitScanResultCountNumber of times thread has been blocked while waiting for a scan-based signal, such waiting for additional results, or for a scanto close.
WaitMetaRequestCountNumber of times thread has been blocked waiting for a metadata-based signal; this can occur when waiting for a DDL operation orfor an epoch to be started (or ended).
WaitNanosCountTotal time (in nanoseconds) spent waiting for some type of signal fromthe data nodes.
BytesSentCountAmount of data (in bytes) sent to the data nodes
BytesRecvdCountAmount of data (in bytes) received from the data nodes
TransStartCountNumber of transactions started.
TransCommitCountNumber of transactions committed.
TransAbortCountNumber of transactions aborted.
TransCloseCountNumber of transactions aborted. (This value may be greater than the sum of TransCommitCount andTransAbortCount.)
PkOpCountNumber of operations based on or using primary keys. This count includes blob-part table operations, implicit unlocking operations, and auto-increment operations, as well as primary keyoperations normally visible to MySQL clients.
UkOpCountNumber of operations based on or using unique keys.
TableScanCountNumber of table scans that have been started. This includes scans ofinternal tables.
RangeScanCountNumber of range scans that have been started.
PrunedScanCountNumber of scans that have been pruned to a single partition.
ScanBatchCountNumber of batches of rows received. (A batch in this context is a set of scan results from a singlefragment.)
ReadRowCountTotal number of rows that have been read. Includes rows read usingprimary key, unique key, and scan operations.
TransLocalReadRowCountNumber of rows read from the data same node on which the transaction wasbeing run.
DataEventsRecvdCountNumber of row change events received.
NondataEventsRecvdCountNumber of events received, other than row change events.
EventBytesRecvdCountNumber of bytes of events received.

To see all counts of committed transactions-that is, all TransCommitCount counter status variables-you can filter the results of SHOW STATUS for the substring trans_commit_count, like this:

mysql> SHOW STATUS LIKE '%trans_commit_count%';+------------------------------------+-------+| Variable_name  | Value |+------------------------------------+-------+| Ndb_api_trans_commit_count_session | 1 || Ndb_api_trans_commit_count_slave   | 0 || Ndb_api_trans_commit_count | 2 |+------------------------------------+-------+3 rows in set (0.00 sec)

From this you can determine that 1 transaction has been committed in the current mysql client session, and 2 transactions have been committed on this mysqld since it was last restarted.

You can see how various NDB API counters are incremented by a given SQL statement by comparing the values of the corresponding _session status variables immediately before and after performing the statement. In this example, after getting the initial values from SHOW STATUS, we create in the test database an NDB table, named t, that has a single column:

mysql> SHOW STATUS LIKE 'ndb_api%session%';+--------------------------------------------+--------+| Variable_name  | Value  |+--------------------------------------------+--------+| Ndb_api_wait_exec_complete_count_session   | 2  || Ndb_api_wait_scan_result_count_session | 0  || Ndb_api_wait_meta_request_count_session | 3  || Ndb_api_wait_nanos_count_session   | 820705 || Ndb_api_bytes_sent_count_session   | 132 || Ndb_api_bytes_received_count_session   | 372 || Ndb_api_trans_start_count_session  | 1  || Ndb_api_trans_commit_count_session | 1  || Ndb_api_trans_abort_count_session  | 0  || Ndb_api_trans_close_count_session  | 1  || Ndb_api_pk_op_count_session | 1  || Ndb_api_uk_op_count_session | 0  || Ndb_api_table_scan_count_session   | 0  || Ndb_api_range_scan_count_session   | 0  || Ndb_api_pruned_scan_count_session  | 0  || Ndb_api_scan_batch_count_session   | 0  || Ndb_api_read_row_count_session | 1  || Ndb_api_trans_local_read_row_count_session | 1  |+--------------------------------------------+--------+18 rows in set (0.00 sec)mysql> USE test;Database changedmysql> CREATE TABLE t (c INT) ENGINE NDBCLUSTER;Query OK, 0 rows affected (0.85 sec)

Now you can execute a new SHOW STATUS statement and observe the changes, as shown here (with the changed rows highlighted in the output):

mysql> SHOW STATUS LIKE 'ndb_api%session%';+--------------------------------------------+-----------+| Variable_name  | Value |+--------------------------------------------+-----------+| Ndb_api_wait_exec_complete_count_session   | 8 || Ndb_api_wait_scan_result_count_session | 0 || Ndb_api_wait_meta_request_count_session | 17 || Ndb_api_wait_nanos_count_session   | 706871709 || Ndb_api_bytes_sent_count_session   | 2376  || Ndb_api_bytes_received_count_session   | 3844  || Ndb_api_trans_start_count_session  | 4 || Ndb_api_trans_commit_count_session | 4 || Ndb_api_trans_abort_count_session  | 0 || Ndb_api_trans_close_count_session  | 4 || Ndb_api_pk_op_count_session | 6 || Ndb_api_uk_op_count_session | 0 || Ndb_api_table_scan_count_session   | 0 || Ndb_api_range_scan_count_session   | 0 || Ndb_api_pruned_scan_count_session  | 0 || Ndb_api_scan_batch_count_session   | 0 || Ndb_api_read_row_count_session | 2 || Ndb_api_trans_local_read_row_count_session | 1 |+--------------------------------------------+-----------+18 rows in set (0.00 sec)

Similarly, you can see the changes in the NDB API statistics counters caused by inserting a row into t: Insert the row, then run the same SHOW STATUS statement used in the previous example, as shown here:

mysql> INSERT INTO t VALUES (100);Query OK, 1 row affected (0.00 sec)mysql> SHOW STATUS LIKE 'ndb_api%session%';+--------------------------------------------+-----------+| Variable_name  | Value |+--------------------------------------------+-----------+| Ndb_api_wait_exec_complete_count_session   | 11 || Ndb_api_wait_scan_result_count_session | 6 || Ndb_api_wait_meta_request_count_session | 20 || Ndb_api_wait_nanos_count_session   | 707370418 || Ndb_api_bytes_sent_count_session   | 2724  || Ndb_api_bytes_received_count_session   | 4116  || Ndb_api_trans_start_count_session  | 7 || Ndb_api_trans_commit_count_session | 6 || Ndb_api_trans_abort_count_session  | 0 || Ndb_api_trans_close_count_session  | 7 || Ndb_api_pk_op_count_session | 8 || Ndb_api_uk_op_count_session | 0 || Ndb_api_table_scan_count_session   | 1 || Ndb_api_range_scan_count_session   | 0 || Ndb_api_pruned_scan_count_session  | 0 || Ndb_api_scan_batch_count_session   | 0 || Ndb_api_read_row_count_session | 3 || Ndb_api_trans_local_read_row_count_session | 2 |+--------------------------------------------+-----------+18 rows in set (0.00 sec)

We can make a number of observations from these results:

  • Although we created t with no explicit primary key, 5 primary key operations were performed in doing so (the difference in the "before" and "after" values of Ndb_api_pk_op_count_session, or 6 minus 1). This reflects the creation of the hidden primary key that is a feature of all tables using the NDB storage engine.

  • By comparing successive values for Ndb_api_wait_nanos_count_session, we can see that the NDB API operations implementing the CREATE TABLE statement waited much longer (706871709 - 820705 = 706051004 nanoseconds, or approximately 0.7 second) for responses from the data nodes than those executed by the INSERT (707370418 - 706871709 = 498709 ns or roughly .0005 second). The execution times reported for these statements in the mysql client correlate roughly with these figures.

    On platforms with without sufficient (nanosecond) time resolution, small changes in the value of the WaitNanosCount NDB API counter due to SQL statements that execute very quickly may not always be visible in the values of Ndb_api_wait_nanos_count_session, Ndb_api_wait_nanos_count_slave, or Ndb_api_wait_nanos_count.

  • The INSERT statement incremented both the ReadRowCount and TransLocalReadRowCount NDB API statistics counters, as reflected by the increased values of Ndb_api_read_row_count_session and Ndb_api_trans_local_read_row_count_session.

Copyright © 1997, 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices
(Sebelumnya) 17.4. MySQL Cluster Programs17.6. MySQL Cluster Replication (Berikutnya)