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
表中。
线程名称在threads
和setup_threads
表的name
列中使用格式:
。prefix
/plugin_name
/thread_name
prefix
,由performance_schema
引擎确定的对象类型,为插件线程(见Thread Instrument Elements)是thread
。plugin_name
为ndbcluster
。thread_name
是线程的独立名称(ndb_binlog
,ndb_index_stat
或ndb_metadata
)。
使用线程ID或操作系统线程ID在threads
或setup_threads
表中给定线程,可以从Performance Schema获得关于插件执行和资源使用的相当详细信息。以下示例演示如何通过连接threads
和memory_summary_by_thread_by_event_name
表来获得由ndbcluster
插件创建的线程分配的内存量从mem_root
arena:
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)