[MySQL5.6]Innodb新的監控表INNODB_METRICS
除了Performance Schema外,在MySQL 5.6中還提供了一個新的information_schema表來監控Innodb的內部執行狀態——INNODB_METRICS;該表維護了一組計數器,使用者可以通過這些計數器,來監控Innodb內部執行是否健康。當前的MySQL5.6.12版本中,共有210個計數器:
mysql> select count(*) from INNODB_METRICS;
+———-+
| count(*) |
+———-+
| 210 |
+———-+
1 row in set (0.00 sec)
mysql> select count(*) from innodb_metrics where status = ‘disabled`;
+———-+
| count(*) |
+———-+
| 148 |
+———-+
1 row in set (0.00 sec)
mysql> select count(*) from innodb_metrics where status = ‘enabled`;
+———-+
| count(*) |
+———-+
| 62 |
+———-+
1 row in set (0.00 sec)
預設開啟62個計數器
這裡我們不討論相關的程式碼實現,因為其實現很簡單,所有的監控項,包括跟這些計數器相關的操作都在檔案srv/srv0mon.cc中,獨立成模組,外部我們經常看到類似如下程式碼的,就是插入的計數器:
buf_LRU_get_free_block:
MONITOR_INC(MONITOR_LRU_GET_FREE_SEARCH);
如果我們自己要新增新的counter,可以往srv/srv0mon.cc中自行新增。
以下只討論如何使用該表,以及其包含的內容。
INNODB_METRICS表包括如下列(摘自官方文件)
Column name |
Description |
NAME |
Unique name for the counter. |
SUBSYSTEM |
The aspect of InnoDB that the metric applies to. See the list following the table for the corresponding module names to use with the SET GLOBAL syntax. |
COUNT |
Value since the counter is enabled. |
MAX_COUNT |
Maximum value since the counter is enabled. |
MIN_COUNT |
Minimum value since the counter is enabled. |
AVG_COUNT |
Average value since the counter is enabled. |
COUNT_RESET |
Counter value since it was last reset. (The _RESET fields act like the lap counter on a stopwatch: you can measure the activity during some time interval, while the cumulative figures are still available in theCOUNT, MAX_COUNT, and so on fields.) |
MAX_COUNT_RESET |
Maximum counter value since it was last reset. |
MIN_COUNT_RESET |
Minimum counter value since it was last reset. |
AVG_COUNT_RESET |
Average counter value since it was last reset. |
TIME_ENABLED |
Timestamp of last start. |
TIME_DISABLED |
Timestamp of last stop. |
TIME_ELAPSED |
Elapsed time in seconds since the counter started. |
TIME_RESET |
Timestamp of last stop. |
STATUS |
Whether the counter is still running () or stopped (). |
TYPE |
Whether the item is a cumulative counter, or measures the current value of some resource. |
COMMENT |
Additional description. |
例如,我們要查詢DML的執行量:
mysql> select status, NAME, COUNT, SUBSYSTEM from INNODB_METRICS where name like ‘%dml%`;
+———-+———————-+——-+———–+
| status | NAME | COUNT | SUBSYSTEM |
+———-+———————-+——-+———–+
| disabled | purge_dml_delay_usec | 0 | purge |
| enabled | dml_reads | 942 | dml |
| enabled | dml_inserts | 0 | dml |
| enabled | dml_deletes | 0 | dml |
| enabled | dml_updates | 913 | dml |
+———-+———————-+——-+———–+
5 rows in set (0.00 sec)
我們可以通過以下幾個變數來控制計數器的設定:
mysql> show variables like ‘%monitor%`;
+————————–+——-+
| Variable_name | Value |
+————————–+——-+
| innodb_monitor_disable | |
| innodb_monitor_enable | |
| innodb_monitor_reset | |
| innodb_monitor_reset_all | |
+————————–+——-+
4 rows in set (0.00 sec)
我們以AHI相關的計數器為例,預設情況下他們是關閉的
mysql> select status, name, subsystem from INNODB_METRICS where status = ‘disabled’ and subsystem like ‘%adaptive_hash_index%`;
+———-+——————————————+———————+
| status | name | subsystem |
+———-+——————————————+———————+
| disabled | adaptive_hash_searches_btree | adaptive_hash_index |
| disabled | adaptive_hash_pages_added | adaptive_hash_index |
| disabled | adaptive_hash_pages_removed | adaptive_hash_index |
| disabled | adaptive_hash_rows_added | adaptive_hash_index |
| disabled | adaptive_hash_rows_removed | adaptive_hash_index |
| disabled | adaptive_hash_rows_deleted_no_hash_entry | adaptive_hash_index |
| disabled | adaptive_hash_rows_updated | adaptive_hash_index |
+———-+——————————————+———————+
7 rows in set (0.00 sec)
開啟計數器:
mysql> set global innodb_monitor_enable = ‘adaptive_hash_%`;
Query OK, 0 rows affected (0.00 sec)
關閉計數器:
mysql> set global innodb_monitor_disable = ‘adaptive_hash_%`;
Query OK, 0 rows affected (0.00 sec)
重置AHI所有列的值:
mysql> set global innodb_monitor_reset_all = “adaptive_hash_%”;
Query OK, 0 rows affected (0.00 sec)
只重置COUNTER的值:
mysql> set global innodb_monitor_reset = “adaptive_hash_%”;
Query OK, 0 rows affected (0.00 sec)
根據模組名開啟:
mysql> set global innodb_monitor_enable = module_adaptive_hash;
Query OK, 0 rows affected (0.00 sec)
開啟所有計數器:
mysql> set global innodb_monitor_enable = all;
Query OK, 0 rows affected (0.00 sec)
關閉所有計數器:
mysql> set global innodb_monitor_disable = all;
Query OK, 0 rows affected (0.00 sec)
我們既可以設定具體的某一個counter,或者通過萬用字元,或者通過模組名,或者all,來設定counter,配置還是相當靈活的。
模組名與subsystem的對應關係:
模組名 |
對應subsystem |
描述 |
module_metadata |
metadata |
表級別的開啟、關閉、引用次數等 |
module_lock |
lock |
鎖系統相關資訊,例如死鎖次數, 建立/移除/請求的記錄鎖,包括表鎖等統計資訊,鎖等待/持有時間等等。。 |
module_buffer |
buffer |
跟buffer pool相關的操作, |
module_buf_page |
buffer_page_io |
buffer pool做寫操作的計數 |
module_os |
os |
os層的資料讀寫等資訊 |
module_trx |
transaction |
事務量統計,例如只讀事務,寫事務,回滾事務,活躍事務,事務Undo資訊等。 |
module_purge |
purge |
purge操作統計,例如purge 標記刪除的記錄樹,Purge undo日誌的page數等 |
module_compress |
compression |
壓縮表相關統計資訊,例如壓縮,解壓,增加/減少padding的次數等。 |
module_file |
file_system |
只有一個counter:file_num_open_files 表示開啟的檔案數 |
module_index |
index |
索引分裂和合並的次數 |
module_adaptive_hash |
adaptive_hash_index |
自適應hash相關操作 |
module_ibuf_system |
change_buffer |
change buffer相關操作統計 |
module_srv |
server |
例項內部執行狀態,例如bp size , page size ,master執行緒資訊,spin 統計,讀寫鎖資訊,寫double write buffer的計數 |
module_ddl |
ddl |
DDL統計 |
module_dml |
dml |
讀/插入/刪除/更新的次數 |
module_log |
recovery |
跟redo log相關的資訊,例如reodo checkpoinr資訊,flush 資訊,同步/非同步刷日誌點,日誌寫入量,pending的日誌請求等。。 |
module_icp |
icp |
在Innodb層的index condition pushdown的相關資訊 |
相關文章
- mysql 5.6效能監控表innodb_metricsMySql
- 【TABLE】Oracle監控異常的表設計Oracle
- 歷史庫存監控表的設計
- mysql5.6在匯入時報innodb_table_stats不存在MySql
- APM效能監控軟體的監控型別服務及監控流程型別
- 黑盒監控、日誌監控
- 騰訊 SNG 監控資料的創新應用
- 如何監控分割槽表邊界溢位
- 6.prometheus監控--監控dockerPrometheusDocker
- TiDB監控實現--存活監控TiDB
- MySQL5.6新特性之Multi-Range ReadMySql
- 一種對雲主機進行效能監控的監控系統及其監控方法
- 監控
- upptime:使用GitHub Actions監控你的網站健康監控Github網站
- Configure innodb 表空間
- 聊聊前端監控——錯誤監控篇前端
- undrop-for-innodb恢復drop的表
- UAVStack功能上新:新增JVM監控分析工具JVM
- 11.prometheus監控之黑盒(blackbox)監控Prometheus
- 3-主機監控、應用監控
- 詳細瞭解INNODB_TRX、INNODB_LOCKs、INNODB_LOCK_waits、PROCESSLIST表AI
- Prometheus+Grafana實現服務效能監控:windows主機監控、Spring Boot監控、Spring Cloud Alibaba Seata監控PrometheusGrafanaWindowsSpring BootCloud
- 利用Grafana監控influxdb表中資料有效性GrafanaUX
- 大資料開發-資料表監控-實現大資料
- centos 監控CentOS
- openGauss 監控
- Linux 監控Linux
- nginx監控Nginx
- zabbix監控
- Innodb:Undo 表空間巨大
- MySQL InnoDB表空間加密MySql加密
- information_schema.innodb_metrics表ORM
- 監控索引的使用(轉)索引
- Python的監控功能示例Python
- zabbix的主動模式監控和zabbix-proxy分散式監控模式分散式
- 在監控中注視:監控題材遊戲的社交呈現遊戲
- MySQL:Innodb表 Data free 的計算概要MySql
- Innodb 下null '' ' '的儲存表現的不同Null
- 阿里雲容器Kubernetes監控(一)-資源監控阿里