Documentation Home
MySQL 8.0 参考手册  / 第 23 章 MySQL NDB Cluster 8.0  / 23.6 NDB Cluster的管理  /  18.6.15 ndbinfo:NDB 集群信息数据库

18.6.15 ndbinfo:NDB 集群信息数据库

ndbinfo是一个包含 NDB Cluster 特定信息的数据库。

该数据库包含许多表,每个表提供有关 NDB Cluster 节点状态、资源使用情况和操作的不同类型的数据。您可以在接下来的几节中找到有关每个表的更多详细信息。

ndbinfo包含在 MySQL 服务器中的 NDB Cluster 支持中;不需要特殊的编译或配置步骤;这些表由 MySQL 服务器在连接到集群时创建。您可以验证 ndbinfo支持在给定的 MySQL 服务器实例中使用SHOW PLUGINS;如果ndbinfo启用了支持,您应该会看到包含ndbinfoName列中和列ACTIVE中的Status行,如下所示(强调文本):

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)

您还可以通过检查 SHOW ENGINES包含 ndbinfoEngine列中和列YES中的行的输出来执行此操作Support ,如此处所示(强调文本):

mysql> SHOW ENGINES\G
*************************** 1. row ***************************
      Engine: ndbcluster
     Support: YES
     Comment: Clustered, fault-tolerant tables
Transactions: YES
          XA: NO
  Savepoints: NO
*************************** 2. row ***************************
      Engine: MRG_MYISAM
     Support: YES
     Comment: Collection of identical MyISAM tables
Transactions: NO
          XA: NO
  Savepoints: NO
*************************** 3. row ***************************
      Engine: ndbinfo
     Support: YES
     Comment: NDB Cluster system information storage engine
Transactions: NO
          XA: NO
  Savepoints: NO
*************************** 4. row ***************************
      Engine: CSV
     Support: YES
     Comment: CSV storage engine
Transactions: NO
          XA: NO
  Savepoints: NO
*************************** 5. row ***************************
      Engine: MEMORY
     Support: YES
     Comment: Hash based, stored in memory, useful for temporary tables
Transactions: NO
          XA: NO
  Savepoints: NO
*************************** 6. row ***************************
      Engine: FEDERATED
     Support: NO
     Comment: Federated MySQL storage engine
Transactions: NULL
          XA: NULL
  Savepoints: NULL
*************************** 7. row ***************************
      Engine: ARCHIVE
     Support: YES
     Comment: Archive storage engine
Transactions: NO
          XA: NO
  Savepoints: NO
*************************** 8. row ***************************
      Engine: InnoDB
     Support: YES
     Comment: Supports transactions, row-level locking, and foreign keys
Transactions: YES
          XA: YES
  Savepoints: YES
*************************** 9. row ***************************
      Engine: MyISAM
     Support: DEFAULT
     Comment: Default engine as of MySQL 3.23 with great performance
Transactions: 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: NO
10 rows in set (0.00 sec)

如果ndbinfo启用了支持,那么您可以在mysql或其他 MySQL 客户端ndbinfo中使用 SQL 语句 访问。例如,您可以在 的输出中看到 listed ,如下所示(强调文本): ndbinfoSHOW DATABASES

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

如果mysqld进程未使用该 --ndbcluster选项启动, ndbinfo则不可用且不显示SHOW DATABASES。如果 mysqld以前连接到 NDB Cluster 但集群变得不可用(由于集群关闭、网络连接丢失等事件), ndbinfo并且其表仍然可见,但尝试访问任何表(除了blocksconfig_params) 失败并从 NDBINFO 得到错误 157 'Connection to NDB failed'

除了表blocksconfig_params表之外,我们所说的ndbinfo 实际上是从 NDB通常对 MySQL 服务器不可见的内部表生成的视图。ndbinfo_show_hidden您可以通过将系统变量设置为ON(或)使这些表可见 1,但这通常不是必需的。

所有ndbinfo表都是只读的,在查询时按需生成。因为它们中的许多是由数据节点并行生成的,而其他的则特定于给定的 SQL 节点,因此不能保证它们提供一致的快照。

此外,表不支持下推连接 ndbinfo;因此连接大型 ndbinfo表可能需要将大量数据传输到请求 API 节点,即使查询使用了WHERE子句也是如此。

ndbinfo表不包含在查询缓存中。(漏洞 #59831)

您可以使用语句选择ndbinfo数据库 USE,然后发出 SHOW TABLES语句以获取表列表,就像任何其他数据库一样,如下所示:

mysql> USE ndbinfo;
Database changed

mysql> SHOW TABLES;
+---------------------------------+
| Tables_in_ndbinfo               |
+---------------------------------+
| arbitrator_validity_detail      |
| arbitrator_validity_summary     |
| blocks                          |
| cluster_operations              |
| cluster_transactions            |
| config_params                   |
| counters                        |
| dict_obj_types                  |
| disk_write_speed_aggregate      |
| disk_write_speed_aggregate_node |
| disk_write_speed_base           |
| diskpagebuffer                  |
| logbuffers                      |
| logspaces                       |
| membership                      |
| memory_per_fragment             |
| memoryusage                     |
| nodes                           |
| operations_per_fragment         |
| resources                       |
| restart_info                    |
| server_operations               |
| server_transactions             |
| threadblocks                    |
| threadstat                      |
| transporters                    |
+---------------------------------+
26 rows in set (0.00 sec)

NDB 7.4 中添加了 , dict_obj_types, disk_write_speed_aggregate, disk_write_speed_aggregate_node, disk_write_speed_baserestart_info表 。operations_per_fragment

您可以对这些表执行SELECT语句,就像您通常期望的那样:

mysql> SELECT * FROM memoryusage;
+---------+---------------------+--------+------------+------------+-------------+
| node_id | memory_type         | used   | used_pages | total      | total_pages |
+---------+---------------------+--------+------------+------------+-------------+
|       5 | Data memory         | 753664 |         23 | 1073741824 |       32768 |
|       5 | Index memory        | 163840 |         20 | 1074003968 |      131104 |
|       5 | Long message buffer |   2304 |          9 |   67108864 |      262144 |
|       6 | Data memory         | 753664 |         23 | 1073741824 |       32768 |
|       6 | Index memory        | 163840 |         20 | 1074003968 |      131104 |
|       6 | Long message buffer |   2304 |          9 |   67108864 |      262144 |
+---------+---------------------+--------+------------+------------+-------------+
6 rows in set (0.02 sec)

更复杂的查询,例如以下两个 SELECT使用该 memoryusage表的语句,是可能的:

mysql> SELECT SUM(used) as 'Data Memory Used, All Nodes'
     >     FROM memoryusage
     >     WHERE memory_type = '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 memory_type = 'Index memory';
+-----------------------------+
| Total IndexMemory Available |
+-----------------------------+
|                       25664 |
+-----------------------------+
1 row in set (0.33 sec)

ndbinfo表名和列名区分大小写(ndbinfo 数据库本身的名称也是如此)。这些标识符是小写的。尝试使用错误的字母大小写会导致错误,如本例所示:

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完全忽略 ndbinfo数据库,并将其从任何输出中排除。即使使用 --databasesor --all-databases选项也是如此。

NDB Cluster 还在 INFORMATION_SCHEMA信息数据库中维护表,包括FILES包含有关用于 NDB Cluster 磁盘数据存储的文件信息的 ndb_transid_mysql_connection_map 表,以及显示事务、事务协调器和 NDB Cluster API 节点之间关系的表。有关更多信息,请参阅表的描述或 第 21.5 节,“INFORMATION_SCHEMA NDB 集群表”