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

2023年 9月 9日 22.8k 0

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

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

通用指标  General Metrics

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

  • The information_schema.INNODB_METRICS table
  • The information_schema.GLOBAL_STATUS (MySQL 5.6) or performance_schema.global_status (MySQL 5.7 and later) table.
  • Some memory usage information not specific to 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 -查找当前正在等待另一个事务持有的锁的事务

相关文章

pt-kill工具的使用
pt-ioprofile工具包的使用
数据库管理-第216期 Oracle的高可用-01(20240703)
DBMS_REPAIR EXAMPLE SCRIPT WITH PARTITION
数据库事务的四大特性: ACID 
使用BBED修复损坏的SYSTEM文件头

发布评论