• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • ndbinfo:NDB群集信息数据库

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

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

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

    mysql> SHOW PLUGINS;
    +----------------------------------	+--------	+--------------------	+---------	+---------	+
    | Name	| Status	| Type	| Library	| License	|
    +----------------------------------	+--------	+--------------------	+---------	+---------	+
    | binlog	| ACTIVE	| STORAGE ENGINE	| NULL	| GPL	|
    | mysql_native_password	| ACTIVE	| AUTHENTICATION	| NULL	| GPL	|
    | sha256_password	| ACTIVE	| AUTHENTICATION	| NULL	| GPL	|
    | MRG_MYISAM	| ACTIVE	| STORAGE ENGINE	| NULL	| GPL	|
    | MEMORY	| ACTIVE	| STORAGE ENGINE	| NULL	| GPL	|
    | CSV	| ACTIVE	| STORAGE ENGINE	| NULL	| GPL	|
    | MyISAM	| ACTIVE	| STORAGE ENGINE	| 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	|
    | INNODB_CMP_PER_INDEX	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_CMP_PER_INDEX_RESET	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_BUFFER_PAGE	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_BUFFER_PAGE_LRU	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_BUFFER_POOL_STATS	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_TEMP_TABLE_INFO	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_METRICS	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_FT_DEFAULT_STOPWORD	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_FT_DELETED	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_FT_BEING_DELETED	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_FT_CONFIG	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_FT_INDEX_CACHE	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_FT_INDEX_TABLE	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_SYS_TABLES	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_SYS_TABLESTATS	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_SYS_INDEXES	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_SYS_COLUMNS	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_SYS_FIELDS	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_SYS_FOREIGN	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_SYS_FOREIGN_COLS	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_SYS_TABLESPACES	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_SYS_DATAFILES	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | INNODB_SYS_VIRTUAL	| ACTIVE	| INFORMATION SCHEMA	| NULL	| GPL	|
    | PERFORMANCE_SCHEMA	| 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	|
    | BLACKHOLE	| ACTIVE	| STORAGE ENGINE	| NULL	| GPL	|
    | ARCHIVE	| ACTIVE	| STORAGE ENGINE	| NULL	| GPL	|
    | partition	| ACTIVE	| STORAGE ENGINE	| NULL	| GPL	|
    | ngram	| ACTIVE	| FTPARSER	| NULL	| GPL	|
    +----------------------------------	+--------	+--------------------	+---------	+---------	+
    46 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: CSV
         Support: YES
         Comment: CSV storage engine
    Transactions: NO
              XA: NO
      Savepoints: NO
    *************************** 3. row***************************
          Engine: InnoDB
         Support: DEFAULT
         Comment: Supports transactions, row-level locking, and foreign keys
    Transactions: YES
              XA: YES
      Savepoints: YES
    *************************** 4. row***************************
          Engine: BLACKHOLE
         Support: YES
         Comment: /dev/null storage engine (anything you write to it disappears)
    Transactions: NO
              XA: NO
      Savepoints: NO
    *************************** 5. row***************************
          Engine: MyISAM
         Support: YES
         Comment: MyISAM storage engine
    Transactions: NO
              XA: NO
      Savepoints: NO
    *************************** 6. row***************************
          Engine: MRG_MYISAM
         Support: YES
         Comment: Collection of identical MyISAM tables
    Transactions: NO
              XA: NO
      Savepoints: NO
    *************************** 7. row***************************
          Engine: ARCHIVE
         Support: YES
         Comment: Archive storage engine
    Transactions: NO
              XA: NO
      Savepoints: NO
    *************************** 8. row***************************
          Engine: ndbinfo
         Support: YES
         Comment: NDB Cluster system information storage engine
    Transactions: NO
              XA: NO
      Savepoints: NO
    *************************** 9. row***************************
          Engine: PERFORMANCE_SCHEMA
         Support: YES
         Comment: Performance Schema
    Transactions: NO
              XA: NO
      Savepoints: NO
    *************************** 10. row***************************
          Engine: MEMORY
         Support: YES
         Comment: Hash based, stored in memory, useful for temporary tables
    Transactions: NO
              XA: NO
      Savepoints: NO
    10 rows in set (0.00 sec)
    

    如果ndbinfo启用了支持,则可以ndbinfomysql或另一个MySQL客户端中使用SQL语句进行访问。例如,您可以ndbinfo在的输出中看到列出的内容SHOW DATABASES,如下所示(强调的文字):

    mysql> SHOW DATABASES;
    +--------------------	+
    | Database	|
    +--------------------	+
    | information_schema	|
    | mysql	|
    
    | ndbinfo	|
    | performance_schema	|
    | sys	|
    +--------------------	+
    5 rows in set (0.04 sec)
    

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

    除了blocksconfig_params表,我们所谓的ndbinfo“表”实际上是从内部NDB表生成的视图,这些内部表通常是MySQL Server不可见的。

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

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

    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_locks	|
    | cluster_operations	|
    | cluster_transactions	|
    | config_nodes	|
    | config_params	|
    | config_values	|
    | counters	|
    | cpustat	|
    | cpustat_1sec	|
    | cpustat_20sec	|
    | cpustat_50ms	|
    | dict_obj_info	|
    | dict_obj_types	|
    | disk_write_speed_aggregate	|
    | disk_write_speed_aggregate_node	|
    | disk_write_speed_base	|
    | diskpagebuffer	|
    | error_messages	|
    | locks_per_fragment	|
    | logbuffers	|
    | logspaces	|
    | membership	|
    | memory_per_fragment	|
    | memoryusage	|
    | nodes	|
    | operations_per_fragment	|
    | processes	|
    | resources	|
    | restart_info	|
    | server_locks	|
    | server_operations	|
    | server_transactions	|
    | table_distribution_status	|
    | table_fragments	|
    | table_info	|
    | table_replicas	|
    | tc_time_track_stats	|
    | threadblocks	|
    | threads	|
    | threadstat	|
    | transporters	|
    +---------------------------------	+
    44 rows in set (0.00 sec)
    

    在NDB 8.0中,所有ndbinfo表都使用NDB存储引擎。但是,ndbinfo条目仍然出现在和的输出中SHOW ENGINESSHOW PLUGINS如前所述。

    您可以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
    

    mysqldumpndbinfo完全忽略数据库,并将其从任何输出中排除。即使使用--databases--all-databases选项,也是如此。

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