ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Mysql如何使用sys模式来监控InnoDB?

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

原创 Linux操作系统 作者:张冲andy 时间:2023-09-10 18:10:56 0 删除 编辑

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   -查找当前正在等待另一个事务持有的锁的事务


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31383567/viewspace-2982184/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
支持就关注我个人公众号:DBA烂笔头 。专注数据库领域,熟悉oracle、mysql、redis、mongodb,clickhouse等相关技术

注册时间:2016-08-11

  • 博文量
    626
  • 访问量
    286291