本节讨论几个 SQL 语句,这些语句可以证明在管理和监视连接到 NDB Cluster 的 MySQL 服务器方面很有用,并且在某些情况下提供有关集群本身的信息。
SHOW ENGINE NDB STATUS
,SHOW ENGINE NDBCLUSTER STATUS
此语句的输出包含有关服务器与集群的连接、NDB Cluster 对象的创建和使用以及 NDB Cluster 复制的二进制日志记录的信息。
有关用法示例和更多详细信息, 请参阅第 13.7.5.16 节,“SHOW ENGINE 语句” 。
此语句可用于确定是否在 MySQL 服务器中启用了集群支持,如果启用,则它是否处于活动状态。
有关更多详细信息, 请参阅第 13.7.5.17 节,“SHOW ENGINES 语句” 。
笔记此语句不支持
LIKE
子句。但是,您可以使用LIKE
该表来过滤查询INFORMATION_SCHEMA.ENGINES
,这将在下一项中讨论。SELECT * FROM INFORMATION_SCHEMA.ENGINES [WHERE ENGINE LIKE 'NDB%']
这相当于
SHOW ENGINES
,但使用数据库的ENGINES
表INFORMATION_SCHEMA
。与SHOW ENGINES
语句的情况不同,可以使用LIKE
子句过滤结果,并选择特定的列以获取可能在脚本中使用的信息。例如,以下查询显示服务器是否NDB
支持构建,如果是,是否启用:mysql> SELECT SUPPORT FROM INFORMATION_SCHEMA.ENGINES -> WHERE ENGINE LIKE 'NDB%'; +---------+ | support | +---------+ | ENABLED | +---------+
有关更多信息,请参阅第 21.3.7 节,“INFORMATION_SCHEMA ENGINES 表”。
该语句提供了与
NDB
存储引擎相关的大多数服务器系统变量及其值的列表,如下所示:mysql> SHOW VARIABLES LIKE 'NDB%'; +--------------------------------------+---------------------------------------+ | Variable_name | Value | +--------------------------------------+---------------------------------------+ | ndb_autoincrement_prefetch_sz | 1 | | ndb_batch_size | 32768 | | ndb_blob_read_batch_bytes | 65536 | | ndb_blob_write_batch_bytes | 65536 | | ndb_cache_check_time | 0 | | ndb_clear_apply_status | ON | | ndb_cluster_connection_pool | 1 | | ndb_connectstring | 127.0.0.1 | | ndb_deferred_constraints | 0 | | ndb_distribution | KEYHASH | | ndb_eventbuffer_free_percent | 20 | | ndb_eventbuffer_max_alloc | 0 | | ndb_extra_logging | 1 | | ndb_force_send | ON | | ndb_index_stat_enable | ON | | ndb_index_stat_option | loop_enable=1000ms,loop_idle=1000ms, loop_busy=100ms,update_batch=1,read_batch=4,idle_batch=32,check_batch=8, check_delay=10m,delete_batch=8,clean_delay=1m,error_batch=4,error_delay=1m, evict_batch=8,evict_delay=1m,cache_limit=32M,cache_lowpct=90,zero_total=0 | | ndb_join_pushdown | ON | | ndb_log_apply_status | OFF | | ndb_log_bin | ON | | ndb_log_binlog_index | ON | | ndb_log_empty_epochs | OFF | | ndb_log_empty_update | OFF | | ndb_log_exclusive_reads | OFF | | ndb_log_fail_terminate | OFF | | ndb_log_orig | OFF | | ndb_log_transaction_id | OFF | | ndb_log_update_as_write | ON | | ndb_log_update_minimal | OFF | | ndb_log_updated_only | ON | | ndb_mgmd_host | 127.0.0.1 | | ndb_nodeid | 0 | | ndb_optimization_delay | 10 | | ndb_optimized_node_selection | 3 | | ndb_recv_thread_activation_threshold | 8 | | ndb_recv_thread_cpu_mask | | | ndb_report_thresh_binlog_epoch_slip | 3 | | ndb_report_thresh_binlog_mem_usage | 10 | | ndb_show_foreign_key_mock_tables | OFF | | ndb_slave_conflict_role | NONE | | ndb_table_no_logging | OFF | | ndb_table_temporary | OFF | | ndb_use_copying_alter_table | OFF | | ndb_use_exact_count | OFF | | ndb_use_transactions | ON | | ndb_version | 459808 | | ndb_version_string | ndb-7.4.39 | | ndb_wait_connected | 30 | | ndb_wait_setup | 30 | | ndbinfo_database | ndbinfo | | ndbinfo_max_bytes | 0 | | ndbinfo_max_rows | 10 | | ndbinfo_offline | OFF | | ndbinfo_show_hidden | OFF | | ndbinfo_table_prefix | ndb$ | | ndbinfo_version | 459808 | +--------------------------------------+---------------------------------------+
有关详细信息,请参阅第 5.1.7 节,“服务器系统变量”。
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME LIKE 'NDB%';
此语句等同于
SHOW VARIABLES
上一项中描述的语句,并提供几乎相同的输出,如下所示:mysql> SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -> WHERE VARIABLE_NAME LIKE 'NDB%'; +--------------------------------------+---------------------------------------+ | VARIABLE_NAME | VARIABLE_VALUE | +--------------------------------------+---------------------------------------+ | NDB_CACHE_CHECK_TIME | 0 | | NDB_TABLE_TEMPORARY | OFF | | NDB_AUTOINCREMENT_PREFETCH_SZ | 1 | | NDB_LOG_BINLOG_INDEX | ON | | NDB_FORCE_SEND | ON | | NDB_WAIT_SETUP | 30 | | NDB_CLUSTER_CONNECTION_POOL | 1 | | NDB_WAIT_CONNECTED | 30 | | NDB_USE_EXACT_COUNT | OFF | | NDB_LOG_EMPTY_UPDATE | OFF | | NDB_RECV_THREAD_ACTIVATION_THRESHOLD | 8 | | NDB_EVENTBUFFER_MAX_ALLOC | 0 | | NDB_OPTIMIZED_NODE_SELECTION | 3 | | NDBINFO_DATABASE | ndbinfo | | NDB_LOG_APPLY_STATUS | OFF | | NDB_JOIN_PUSHDOWN | ON | | NDB_RECV_THREAD_CPU_MASK | | | NDBINFO_VERSION | 459808 | | NDB_CONNECTSTRING | 127.0.0.1 | | NDB_TABLE_NO_LOGGING | OFF | | NDB_LOG_UPDATED_ONLY | ON | | NDB_VERSION | 459808 | | NDB_LOG_UPDATE_MINIMAL | OFF | | NDB_OPTIMIZATION_DELAY | 10 | | NDB_LOG_UPDATE_AS_WRITE | ON | | NDB_SHOW_FOREIGN_KEY_MOCK_TABLES | OFF | | NDB_VERSION_STRING | ndb-7.4.39 | | NDBINFO_OFFLINE | OFF | | NDB_INDEX_STAT_OPTION | loop_enable=1000ms,loop_idle=1000ms, loop_busy=100ms,update_batch=1,read_batch=4,idle_batch=32,check_batch=8, check_delay=10m,delete_batch=8,clean_delay=1m,error_batch=4,error_delay=1m, evict_batch=8,evict_delay=1m,cache_limit=32M,cache_lowpct=90,zero_total=0 | | NDBINFO_MAX_ROWS | 10 | | NDB_BATCH_SIZE | 32768 | | NDB_USE_TRANSACTIONS | ON | | NDB_NODEID | 0 | | NDB_SLAVE_CONFLICT_ROLE | NONE | | NDB_REPORT_THRESH_BINLOG_MEM_USAGE | 10 | | NDB_MGMD_HOST | 127.0.0.1 | | NDB_REPORT_THRESH_BINLOG_EPOCH_SLIP | 3 | | NDBINFO_MAX_BYTES | 0 | | NDB_LOG_BIN | ON | | NDBINFO_TABLE_PREFIX | ndb$ | | NDB_LOG_EMPTY_EPOCHS | OFF | | NDB_LOG_ORIG | OFF | | NDB_LOG_EXCLUSIVE_READS | OFF | | NDB_LOG_TRANSACTION_ID | OFF | | NDB_LOG_FAIL_TERMINATE | OFF | | NDB_EVENTBUFFER_FREE_PERCENT | 20 | | NDB_CLEAR_APPLY_STATUS | ON | | NDBINFO_SHOW_HIDDEN | OFF | | NDB_INDEX_STAT_ENABLE | ON | | NDB_DISTRIBUTION | KEYHASH | | NDB_EXTRA_LOGGING | 1 | | NDB_BLOB_WRITE_BATCH_BYTES | 65536 | | NDB_USE_COPYING_ALTER_TABLE | OFF | | NDB_DEFERRED_CONSTRAINTS | 0 | | NDB_BLOB_READ_BATCH_BYTES | 65536 | +--------------------------------------+---------------------------------------+
与
SHOW VARIABLES
语句的情况不同,可以选择单独的列。例如:mysql> SELECT VARIABLE_VALUE -> FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -> WHERE VARIABLE_NAME = 'ndb_force_send'; +----------------+ | VARIABLE_VALUE | +----------------+ | ON | +----------------+
有关详细信息,请参阅第 21.3.10 节,“INFORMATION_SCHEMA GLOBAL_VARIABLES 和 SESSION_VARIABLES 表”和 第 5.1.7 节,“服务器系统变量”。
该语句一目了然地显示了MySQL服务器是否充当集群SQL节点,如果是,它提供了MySQL服务器的集群节点ID,它所连接的集群管理服务器的主机名和端口,以及集群中数据节点的数量,如下所示:
mysql> SHOW STATUS LIKE 'NDB%'; +----------------------------------------------+-------------------------------+ | Variable_name | Value | +----------------------------------------------+-------------------------------+ | Ndb_api_wait_exec_complete_count | 2 | | Ndb_api_wait_scan_result_count | 3 | | Ndb_api_wait_meta_request_count | 109 | | Ndb_api_wait_nanos_count | 830671169345 | | Ndb_api_bytes_sent_count | 13284 | | Ndb_api_bytes_received_count | 112672 | | 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_adaptive_send_forced_count | 0 | | Ndb_api_adaptive_send_unforced_count | 3 | | Ndb_api_adaptive_send_deferred_count | 0 | | Ndb_api_event_data_count | 0 | | Ndb_api_event_nondata_count | 0 | | Ndb_api_event_bytes_count | 3122560 | | Ndb_cluster_node_id | 100 | | Ndb_config_from_host | 127.0.0.1 | | Ndb_config_from_port | 1186 | | Ndb_number_of_data_nodes | 2 | | Ndb_number_of_ready_data_nodes | 2 | | Ndb_connect_count | 0 | | Ndb_execute_count | 0 | | Ndb_scan_count | 0 | | Ndb_pruned_scan_count | 0 | | Ndb_schema_locks_count | 0 | | 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_adaptive_send_forced_count_session | 0 | | Ndb_api_adaptive_send_unforced_count_session | 0 | | Ndb_api_adaptive_send_deferred_count_session | 0 | | Ndb_sorted_scan_count | 0 | | Ndb_pushed_queries_defined | 0 | | Ndb_pushed_queries_dropped | 0 | | Ndb_pushed_queries_executed | 0 | | Ndb_pushed_reads | 0 | | Ndb_last_commit_epoch_server | 73014444043 | | Ndb_last_commit_epoch_session | 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_adaptive_send_forced_count_slave | 0 | | Ndb_api_adaptive_send_unforced_count_slave | 0 | | Ndb_api_adaptive_send_deferred_count_slave | 0 | | Ndb_slave_max_replicated_epoch | 0 | | Ndb_api_event_data_count_injector | 0 | | Ndb_api_event_nondata_count_injector | 0 | | Ndb_api_event_bytes_count_injector | 2080768 | | Ndb_conflict_fn_max | 0 | | Ndb_conflict_fn_old | 0 | | Ndb_conflict_fn_max_del_win | 0 | | Ndb_conflict_fn_epoch | 0 | | Ndb_conflict_fn_epoch_trans | 0 | | Ndb_conflict_fn_epoch2 | 0 | | Ndb_conflict_fn_epoch2_trans | 0 | | Ndb_conflict_trans_row_conflict_count | 0 | | Ndb_conflict_trans_row_reject_count | 0 | | Ndb_conflict_trans_reject_count | 0 | | Ndb_conflict_trans_detect_iter_count | 0 | | Ndb_conflict_trans_conflict_commit_count | 0 | | Ndb_conflict_epoch_delete_delete_count | 0 | | Ndb_conflict_reflected_op_prepare_count | 0 | | Ndb_conflict_reflected_op_discard_count | 0 | | Ndb_conflict_refresh_op_count | 0 | | Ndb_conflict_last_conflict_epoch | 0 | | Ndb_conflict_last_stable_epoch | 0 | | Ndb_index_stat_status | allow:1,enable:1,busy:0, loop:1000,list:(new:0,update:0,read:0,idle:0,check:0,delete:0,error:0,total:0), analyze:(queue:0,wait:0),stats:(nostats:0,wait:0), total:(analyze:(all:0,error:0),query:(all:0,nostats:0,error:0), event:(act:0,skip:0,miss:0),cache:(refresh:0,clean:0,pinned:0,drop:0,evict:0)), cache:(query:0,clean:0,drop:0,evict:0,usedpct:0.00,highpct:0.00) | | Ndb_index_stat_cache_query | 0 | | Ndb_index_stat_cache_clean | 0 | +----------------------------------------------+-------------------------------+
如果 MySQL 服务器构建时支持集群,但未连接到集群,则此语句输出中的所有行都包含零或空字符串。
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE 'NDB%';
SHOW STATUS
此语句提供与上一项中讨论 的语句类似的输出 。但是,与 的情况不同SHOW STATUS
,可以使用SELECT
来提取 SQL 中的值,以便在脚本中用于监视和自动化目的。有关详细信息,请参阅第 21.3.9 节,“INFORMATION_SCHEMA GLOBAL_STATUS 和 SESSION_STATUS 表”。
您还可以查询
ndbinfo
信息数据库中的表以获取有关许多 NDB Cluster 操作的实时数据。请参阅
第 18.6.15 节,“ndbinfo:NDB Cluster 信息数据库”。