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 SHOW ENGINE
Syntax, for a usage example and
more detailed information.
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 SHOW ENGINES
Syntax, for more detailed
information.
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 (available
beginning with MySQL 5.1.5). 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 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 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 The INFORMATION_SCHEMA GLOBAL_VARIABLES
and SESSION_VARIABLES
Tables, and
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 SHOW STATUS
Syntax.
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE
VARIABLE_NAME LIKE 'NDB%';
Beginning with MySQL 5.1.12, 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 The INFORMATION_SCHEMA GLOBAL_STATUS
and SESSION_STATUS
Tables, for more information.
Beginning with MySQL Cluster NDB 7.1.1, you can also query the
tables in the ndbinfo
information database for
real-time data about many MySQL Cluster operations. See
Section 5.8, “The ndbinfo
MySQL Cluster Information Database”.