Documentation Home
MySQL 8.4 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 39.8Mb
PDF (A4) - 39.9Mb
Man Pages (TGZ) - 257.9Kb
Man Pages (Zip) - 364.9Kb
Info (Gzip) - 4.0Mb
Info (Zip) - 4.0Mb


MySQL 8.4 Reference Manual  /  ...  /  NDB Cluster and the Performance Schema

25.6.19 NDB 集群和性能模式

NDB 提供了MySQL Performance Schema关于ndbcluster插件线程和事务批处理内存的测量信息。这些特性在以下部分中有更详细的描述。

ndbcluster插件线程在性能模式的threads表中可见,如下查询所示:

mysql> SELECT name, type, thread_id, thread_os_id
    -> FROM performance_schema.threads
    -> WHERE name LIKE '%ndbcluster%'\G
+----------------------------------+------------+-----------+--------------+
| name                             | type       | thread_id | thread_os_id |
+----------------------------------+------------+-----------+--------------+
| thread/ndbcluster/ndb_binlog     | BACKGROUND |        30 |        11980 |
| thread/ndbcluster/ndb_index_stat | BACKGROUND |        31 |        11981 |
| thread/ndbcluster/ndb_metadata   | BACKGROUND |        32 |        11982 |
+----------------------------------+------------+-----------+--------------+

threads表显示了以下三个线程中的所有内容:

  • ndb_binlog: 二进制日志线程

  • ndb_index_stat: 索引统计线程

  • ndb_metadata: 元数据线程

这些线程还以名称显示在setup_threads表中。

线程名称在threadssetup_threads表的name列中使用格式:prefix/plugin_name/thread_nameprefix,由performance_schema引擎确定的对象类型,为插件线程(见Thread Instrument Elements)是threadplugin_namendbclusterthread_name是线程的独立名称(ndb_binlogndb_index_statndb_metadata)。

使用线程ID或操作系统线程ID在threadssetup_threads表中给定线程,可以从Performance Schema获得关于插件执行和资源使用的相当详细信息。以下示例演示如何通过连接threadsmemory_summary_by_thread_by_event_name表来获得由ndbcluster插件创建的线程分配的内存量从mem_rootarena:

mysql> SELECT
    ->   t.name,
    ->   m.sum_number_of_bytes_alloc,
    ->   IF(m.sum_number_of_bytes_alloc > 0, "true", "false") AS 'Has allocated memory'
    -> FROM performance_schema.memory_summary_by_thread_by_event_name m
    -> JOIN performance_schema.threads t
    -> ON m.thread_id = t.thread_id
    -> WHERE t.name LIKE '%ndbcluster%'
    ->   AND event_name LIKE '%THD::main_mem_root%';
+----------------------------------+---------------------------+----------------------+
| name                             | sum_number_of_bytes_alloc | Has allocated memory |
+----------------------------------+---------------------------+----------------------+
| thread/ndbcluster/ndb_binlog     |                     20576 | true                 |
| thread/ndbcluster/ndb_index_stat |                         0 | false                |
| thread/ndbcluster/ndb_metadata   |                      8240 | true                 |
+----------------------------------+---------------------------+----------------------+

您可以通过查询Performance Schema的memory_summary_by_thread_by_event_name表来查看事务批处理所使用的内存量,类似于以下内容:

mysql> SELECT EVENT_NAME
    ->   FROM performance_schema.memory_summary_by_thread_by_event_name
    ->   WHERE THREAD_ID = PS_CURRENT_THREAD_ID()
    ->     AND EVENT_NAME LIKE 'memory/ndbcluster/%';
+-------------------------------------------+
| EVENT_NAME                                |
+-------------------------------------------+
| memory/ndbcluster/Thd_ndb::batch_mem_root |
+-------------------------------------------+
1 row in set (0.01 sec)

ndbcluster事务内存仪表也可在Performance Schema的setup_instruments表中看到,如下所示:

mysql> SELECT * from performance_schema.setup_instruments
    ->   WHERE NAME LIKE '%ndb%'\G
*************************** 1. row ***************************
         NAME: memory/ndbcluster/Thd_ndb::batch_mem_root
      ENABLED: YES
        TIMED: NULL
   PROPERTIES:
   VOLATILITY: 0
DOCUMENTATION: Memory used for transaction batching
1 row in set (0.01 sec)