GreatSQL社区

搜索

chongzh

Mysql如何使用sys模式来监控InnoDB?

chongzh 已有 297 次阅读2023-9-9 18:20 |个人分类:Mysql 原理|系统分类:原理&产品解读

MySQL sys模式是视图、存储过程和存储函数的集合,帮助MySQL数据库管理员了解MySQL正在做什么,信息采集来自 Performance Schema and  Information Schema

注意:Sys模式本身不会添加任何信息模式或性能模式中没有的新度量。

通用指标  General Metrics

sys模式的视图是InnoDB指标的一个好的观测点。其中包括以下指标:

为了能够充分利用这些信息,请将以下内容添加到MySQL配置文件中:

[mysqld]
innodb_monitor_enable = '%'

And to enable dynamically:

mysql> SET GLOBAL innodb_monitor_enable = '%';

这样做的开销非常小。

进度信息 Progress Information

动态启用事件阶段记录功能

update performance_schema.setup_instruments set enabled='YES' where name like 'stage/innodb/alter%';
update performance_schema.setup_consumers set enabled='YES' where name like '%stage%';

为了能够充分利用这些信息,请将以下内容添加到MySQL配置文件中持久化配置:

performance_schema=1
performance_schema_instrument = '%stage/innodb/alter%=on'
performance_schema_consumer_events_stages_current=on         
performance_schema_consumer_events_stages_history=on            
performance_schema_consumer_events_stages_history_long=on  

processlist and session  视图中提供了进度信息。

对大表进行DDL后,可以查看进展

select event_name,work_completed,work_estimated from performance_schema.events_stages_current;
select event_name,work_completed,work_estimated from performance_schema.events_stages_history;

缓冲池使用和锁等待  Buffer Pool Usage and Lock Waits

三个特定于InnoDB系统视图:

innodb_buffer_stats_by_schema   -每个模式的InnoDB缓冲池使用情况
innodb_buffer_stats_by_table   -每个表的InnoDB缓冲池使用情况 
innodb_lock_waits   -查找当前正在等待另一个事务持有的锁的事务


评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 立即注册

合作电话:010-64087828

社区邮箱:greatsql@greatdb.com

社区公众号
社区小助手
QQ群
GMT+8, 2024-4-29 03:50 , Processed in 0.013228 second(s), 8 queries , Redis On.
返回顶部