MySQL5.6监控表之INNODB_METRICS
在MySQL5.6的Information_Schema引入新的INNODB_METRICS,此表用来监控InnoDB运行是否正常,并且该表包括很多计数器
mysql> select version();
+------------------+
| version() |
+------------------+
| 5.6.28-debug-log |
+------------------+
1 row in set (0.00 sec)
此表的结构:
mysql> desc INNODB_METRICS;
+-----------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+-------+
| NAME | varchar(193) | NO | | | |
| SUBSYSTEM | varchar(193) | NO | | | |
| COUNT | bigint(21) | NO | | 0 | |
| MAX_COUNT | bigint(21) | YES | | NULL | |
| MIN_COUNT | bigint(21) | YES | | NULL | |
| AVG_COUNT | double | YES | | NULL | |
| COUNT_RESET | bigint(21) | NO | | 0 | |
| MAX_COUNT_RESET | bigint(21) | YES | | NULL | |
| MIN_COUNT_RESET | bigint(21) | YES | | NULL | |
| AVG_COUNT_RESET | double | YES | | NULL | |
| TIME_ENABLED | datetime | YES | | NULL | |
| TIME_DISABLED | datetime | YES | | NULL | |
| TIME_ELAPSED | bigint(21) | YES | | NULL | |
| TIME_RESET | datetime | YES | | NULL | |
| STATUS | varchar(193) | NO | | | |
| TYPE | varchar(193) | NO | | | |
| COMMENT | varchar(193) | NO | | | |
+-----------------+--------------+------+-----+---------+-------+
17 rows in set (0.19 sec)
总计数器:
mysql> select count(*) from INNODB_METRICS;
+----------+
| count(*) |
+----------+
| 214 |
+----------+
1 row in set (0.19 sec)
默认开启的计数器
mysql> select count(*) from innodb_metrics where status = 'enabled';
+----------+
| count(*) |
+----------+
| 63 |
+----------+
1 row in set (0.18 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)
我们以metadata相关的计数器为例,演示开启、关闭、重置.默认此计数器是关闭状态.
mysql> select status, name, subsystem from INNODB_METRICS where status = 'disabled' and subsystem='metadata';
+----------+--------------------------------+-----------+
| status | name | subsystem |
+----------+--------------------------------+-----------+
| disabled | metadata_table_handles_opened | metadata |
| disabled | metadata_table_handles_closed | metadata |
| disabled | metadata_table_reference_count | metadata |
+----------+--------------------------------+-----------+
3 rows in set (0.01 sec)
开启:
mysql> set global innodb_monitor_enable = 'metadata_%';
Query OK, 0 rows affected (0.01 sec)
mysql> select status, name, subsystem from INNODB_METRICS where subsystem='metadata';
+---------+--------------------------------+-----------+
| status | name | subsystem |
+---------+--------------------------------+-----------+
| enabled | metadata_table_handles_opened | metadata |
| enabled | metadata_table_handles_closed | metadata |
| enabled | metadata_table_reference_count | metadata |
| enabled | metadata_mem_pool_size | metadata |
+---------+--------------------------------+-----------+
4 rows in set (0.01 sec)
关闭:
mysql> set global innodb_monitor_disable = 'metadata_%';
Query OK, 0 rows affected (0.00 sec)
重置所有metadata的所有值:
mysql> set global innodb_monitor_reset_all = 'metadata_%';
Query OK, 0 rows affected (0.00 sec)
重置计数器值:
mysql> set global innodb_monitor_reset = 'metadata_%';
Query OK, 0 rows affected (0.00 sec)
打开与关闭所有计数器
mysql> set global innodb_monitor_disable = all;
Query OK, 0 rows affected (0.18 sec) mysql> set global innodb_monitor_enable = all;
Query OK, 0 rows affected (0.00 sec)
计数器既支持单个开启也支持模糊匹配,所以配置起来还是非常灵活多变的.
模块对应的子系统(此翻译为个人理解,如有错误请指出.)
module_metadata (subsystem = metadata) 表计数器开启、关闭
module_lock (subsystem = lock) 锁监控死锁、表锁,锁统计信息等等.
module_buffer (subsystem = buffer) buffer_pool
module_buf_page (subsystem = buffer_page_io) buffer的写操作
module_os (subsystem = os) 操作系统信息
module_trx (subsystem = transaction) 事务信息监控回滚、只读事务等等信息
module_purge (subsystem = purge) purge删除信息
module_compress (subsystem = compression) 表压缩相关信息
module_file (subsystem = file_system) 打开文件数
module_index (subsystem = index) 索引相关信息,统计索引信息、索引分裂等等
module_adaptive_hash (subsystem = adaptive_hash_index) 自适应哈希
module_ibuf_system (subsystem = change_buffer) '这个还不知道'囧
module_srv (subsystem = server) server运行状态信息
module_ddl (subsystem = ddl) ddl信息
module_dml (subsystem = dml) 读、写、更新、删除信息
module_log (subsystem = recovery) flush,同步异步刷日志等等信息
module_icp (subsystem = icp) icp通信? 囧,'这个不知道怎么理解'
这里举个例子以dml_insert为例
mysql> select name,subsystem,status,count from information_schema.innodb_metrics where name like "dml%";
+-------------+-----------+----------+-------+
| name | subsystem | status | count |
+-------------+-----------+----------+-------+
| dml_reads | dml | disabled | 0 |
| dml_inserts | dml | disabled | 0 |
| dml_deletes | dml | disabled | 0 |
| dml_updates | dml | disabled | 0 |
+-------------+-----------+----------+-------+
mysql> set global innodb_monitor_enable = 'dml_inserts';
Query OK, 0 rows affected (0.00 sec)
mysql> select status, name, subsystem from INNODB_METRICS where status = 'enabled' and subsystem='dml';
+---------+-------------+-----------+
| status | name | subsystem |
+---------+-------------+-----------+
| enabled | dml_inserts | dml |
+---------+-------------+-----------+
1 row in set (0.00 sec)
mysql> select * from information_schema.innodb_metrics where name='dml_inserts'\G;
*************************** 1. row ***************************
NAME: dml_inserts
SUBSYSTEM: dml
COUNT: 0
MAX_COUNT: 0
MIN_COUNT: NULL
AVG_COUNT: 0
COUNT_RESET: 0
MAX_COUNT_RESET: 0
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: NULL
TIME_ENABLED: 2016-06-27 21:30:56
TIME_DISABLED: NULL
TIME_ELAPSED: 138
TIME_RESET: NULL
STATUS: enabled
TYPE: status_counter
COMMENT: Number of rows inserted
1 row in set (0.21 sec)
测试:
mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
mysql> create table test (id int);
Query OK, 0 rows affected (0.24 sec) mysql> insert into test values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
Query OK, 10 rows affected (0.21 sec)
Records: 10 Duplicates: 0 Warnings: 0 mysql> insert into test values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
Query OK, 10 rows affected (0.18 sec)
Records: 10 Duplicates: 0 Warnings: 0 mysql> insert into test values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
Query OK, 10 rows affected (0.01 sec)
Records: 10 Duplicates: 0 Warnings: 0 mysql> insert into test values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
Query OK, 10 rows affected (0.01 sec)
Records: 10 Duplicates: 0 Warnings: 0 mysql> insert into test values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
Query OK, 10 rows affected (0.01 sec)
Records: 10 Duplicates: 0 Warnings: 0 mysql> select * from information_schema.innodb_metrics where name='dml_inserts'\G;
*************************** 1. row ***************************
NAME: dml_inserts
SUBSYSTEM: dml
COUNT: 50
MAX_COUNT: 50
MIN_COUNT: NULL
AVG_COUNT: 0.04950495049504951
COUNT_RESET: 50
MAX_COUNT_RESET: 50
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: NULL
TIME_ENABLED: 2016-06-27 21:30:56
TIME_DISABLED: NULL
TIME_ELAPSED: 1010
TIME_RESET: NULL
STATUS: enabled
TYPE: status_counter
COMMENT: Number of rows inserted
1 row in set (0.19 sec)
这时我们重置计数器
mysql> set global innodb_monitor_reset = module_dml;
Query OK, 0 rows affected (0.00 sec) mysql> select * from information_schema.innodb_metrics where name='dml_inserts'\G;
*************************** 1. row ***************************
NAME: dml_inserts
SUBSYSTEM: dml
COUNT: 50
MAX_COUNT: 50
MIN_COUNT: NULL
AVG_COUNT: 0.04428697962798937
COUNT_RESET: 0
MAX_COUNT_RESET: 0
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: 0
TIME_ENABLED: 2016-06-27 21:30:56
TIME_DISABLED: NULL
TIME_ELAPSED: 1129
TIME_RESET: 2016-06-27 21:49:34
STATUS: enabled
TYPE: status_counter
COMMENT: Number of rows inserted
1 row in set (0.01 sec)
当我们重置计数器的时候,只会影响count_reset、max_count_reset.(不知道会不会影响avg_count_reset)
那么如果我们重置所有,那么它会把所有值全部重置
mysql> set global innodb_monitor_disable = module_dml;
Query OK, 0 rows affected (0.00 sec) mysql> set global innodb_monitor_reset_all = module_dml;
Query OK, 0 rows affected (0.00 sec) mysql> select * from information_schema.innodb_metrics where name='dml_inserts'\G
*************************** 1. row ***************************
NAME: dml_inserts
SUBSYSTEM: dml
COUNT: 0
MAX_COUNT: NULL
MIN_COUNT: NULL
AVG_COUNT: NULL
COUNT_RESET: 0
MAX_COUNT_RESET: NULL
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: NULL
TIME_ENABLED: NULL
TIME_DISABLED: NULL
TIME_ELAPSED: NULL
TIME_RESET: NULL
STATUS: disabled
TYPE: status_counter
COMMENT: Number of rows inserted
1 row in set (0.00 sec)
此文章部分内容参考MySQL官方文档和Oracle英文Blog,地址如下:
https://blogs.oracle.com/mysqlinnodb/entry/get_started_with_innodb_metrics
MySQL5.6监控表之INNODB_METRICS的更多相关文章
- SQL Server 更改跟踪(Chang Tracking)监控表数据
一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 主要区别与对比(Compare) 实现监控表数据步骤(Process) 参考文献(Refere ...
- 利用__index和__newindex实现默认值表、监控表、只读表
__index和__newindex实际上相当于是在读写表的时候分别加了一道过滤的逻辑,让读写表的操作可以被监控或说回调,利用这个特性可以实现一些带有特殊功能的表. 带有默认值的表: setdefau ...
- 利用__index和__newindex实现默认值表、监控表、只读表(转)
__index和__newindex实际上相当于是在读写表的时候分别加了一道过滤的逻辑,让读写表的操作可以被监控或说回调,利用这个特性可以实现一些带有特殊功能的表. 带有默认值的表: setdefau ...
- 【转载,备忘】SQL Server 更改跟踪(Chang Tracking)监控表数据
一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 主要区别与对比(Compare) 实现监控表数据步骤(Process) 参考文献(Refere ...
- 光年数据分析表(seo数据监控表和爬虫数据监控表)
http://www.wocaoseo.com/thread-307-1-1.html 光年seo培训想必很多人都知道,他们提出的数据化操作影响了很多的seo从业者,下面是他们的2个数据表,搜集于网络 ...
- SQL Server 变更数据捕获(CDC)监控表数据
一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 实现过程(Realization) 补充说明(Addon) 参考文献(References) ...
- SQL Server ---(CDC)监控表数据(转译)
一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 实现过程(Realization) 补充说明(Addon) 参考文献(References) ...
- MySQL5.7 import表结构报错超出表空间界限
事后测试了一下,一下方法就是垃圾,看看可以,别跟着学!!! 数据库重启后,问题依然暴露出来了,参数什么的都是扯,擦 记录一个困扰我好几天的问题.先贴上报错: space name jxtms/Cost ...
- Mysql5.7 单表 500万数据迁移到新表的快速实现方案
开发过程中需要把一个已有500万条记录的表数据同步到另一个新表中,刚好体验下Mysql官方推荐的大数据迁移的方案:SELECT INTO OUTFILE,LOAD DATA INFILE Mysql ...
随机推荐
- log的6种等级
在Java中,log有6种等级,从低到高为: (1)TRACE:用于展现程序执行的轨迹 (2)DEBUG:用于协助低层次的调试 (3)INFO:用于基本高层次的诊断信息,在长时间运行的代码段开始运行及 ...
- [原博客] POJ 2975 Nim 统计必胜走法个数
题目链接题意介绍了一遍Nim取石子游戏,可以看上一篇文章详细介绍.问当前状态的必胜走法个数,也就是走到必败状态的方法数. 我们设sg为所有个数的Xor值.首先如果sg==0,它不可能有必胜走法,输出0 ...
- Json 返回日期格式转换
//日期转换 function ChangeDateFormat(time) { if (time != null) { var date = new Date(parseInt(time.repla ...
- ANDROID_MARS学习笔记_S03_008_GOOGLEMAP2
一.简介 二.代码1.xml(1)main.xml <?xml version="1.0" encoding="utf-8"?> <Linea ...
- Linux平台下Java调用C函数
JNI是Java native interface的简写,可以译作Java原生接口.Java可以通过JNI调用C/C++的库,这对于那些对性能要求比较高的Java程序无疑是一个 福音. 使用JNI也是 ...
- 如何让windows版Safari支持H5 audio/video?
今天在windows版Safari上看效果的时候惊奇地发现它竟然不支持HTML5的audio/video, 这样的话就无法复现不少ios上出现的问题. 在同事提醒下, 发现Safari HTML5 A ...
- linux上怎么切换不同版本的arm-linux-gcc?只需改一行函数
linux上怎么切换不同版本的arm-linux-gcc?只需改一行函数 ln -s /usr/local/arm/3.4.1/bin/arm-linux-gcc /usr/bin/arm-linux ...
- java httpclient post 文件到server
public void sendFileToServer (String url, File logFiles) { HttpURLConnection connection = nul ...
- BZOJ_1002_[FJOI2007]_轮状病毒_(递推+高精)
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1002 )*&*(^&*^&*^**()*) 1002: [FJOI20 ...
- How many ways
How many ways Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...