当前位置:   article > 正文

MySQL CPU和内存飙高排查_mysqlcpu占用过高 排查

mysqlcpu占用过高 排查

一、查看数据库整体情况

二、CPU飙高

1、主机并发数 

排查数据库脚本1:

  1. select user,substring_index(host,':',1) host,db,command,count(*) from information_schema.PROCESSLIST
  2. where command<>'Sleep'
  3. group by user,substring_index(host,':',1),db,command
  4. order by 5 desc,3;

 

2、正在执行任务

 排查数据库脚本2:

select * from information_schema.processlist where command<>'Sleep'

添加索引解决部分问题:

ALTER TABLE `store_alarm_message_log` ADD INDEX `idx_status` (`status`);

3、查询表数据大小

 排查数据库脚本3:

  1. use information_schema;
  2. select table_name,table_rows, round(data_length/1024/1024,2) as DATA_SIZE_MB from tables
  3. where TABLE_SCHEMA = 'schema'
  4. order by table_rows desc;

4、查询指定schema中表大小

排查数据库脚本4:

  1. select TABLE_SCHEMA,table_name,format(data_length/1024/1024/1024,2) "table_size(GB)",
  2. format(index_length/1024/1024/1024,2) "index_size(GB)",
  3. format((data_length+index_length)/1024/1024/1024,2) "szie(GB)",
  4. table_rows from information_schema.tables
  5. where table_schema='xxx_033'
  6. order by (DATA_LENGTH+INDEX_LENGTH) desc;

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/583203
推荐阅读
相关标签
  

闽ICP备14008679号