当前位置:网站首页>Mysql数据库慢sql抓取与分析
Mysql数据库慢sql抓取与分析
2022-07-06 04:05:00 【春风化作秋雨】
1、修改mysql配置开启慢sql查询
修改配置文件/etc/my.cnf
slow_query_log=ON
slow_query_log_file=/usr/local/mysql/data/slow.log
long_query_time=5说明:long_query_time这个时间大家可以设置为1,不放过任何超过1秒的查询。
2、检查设置
show VARIABLES like '%slow_query_log%';
show VARIABLES like '%long_query_time%';


3、安装安装pt_query_digest
wget percona.com/get/pt-query-digest
mv pt-query-digest /usr/bin/
chmod +x /usr/bin/pt-query-digest
安装与Perl相关的模块
yum -y install 'perl(Data::Dumper)'
yum -y install perl-Digest-MD5
yum -y install perl-DBI
yum -y install perl-DBD-MySQL
4、分析慢sql日志文件
#全部
pt-query-digest slow.log > pt_slow_sql_report.log
#近30天的
pt-query-digest --since=30d mysql.log > pt_slow_sql_report.rtf
以下是分析结果截取示例,分析结果文档会给出每个慢sql的详细信息。
# 570.6s user time, 47s system time, 88.15M rss, 252.14M vsz
# Current date: Wed Jun 29 17:33:45 2022
# Hostname: izzm08qanynb5doqrznbeyz
# Files: mysql.log
# Overall: 722.25k total, 212 unique, 0.28 QPS, 2.88x concurrency ________
# Time range: 2022-05-30T17:25:05 to 2022-06-29T09:20:58
# Attribute total min max avg 95% stddev median
# ============ ======= ======= ======= ======= ======= ======= =======
# Exec time 7376702s 5s 122s 10s 24s 7s 7s
# Lock time 3079s 0 56s 4ms 204us 437ms 84us
# Rows sent 15.08M 0 32.56k 21.89 0.99 517.96 0.99
# Rows examine 3.11T 0 32.05M 4.52M 6.94M 2.51M 5.99M
# Query size 542.74M 27 5.86k 787.96 2.27k 907.02 299.03边栏推荐
- WPF effect Article 191 box selection listbox
- Unity中几个重要类
- 潘多拉 IOT 开发板学习(HAL 库)—— 实验9 PWM输出实验(学习笔记)
- 在 .NET 6 中使用 Startup.cs 更简洁的方法
- Facebook and other large companies have leaked more than one billion user data, and it is time to pay attention to did
- [001] [stm32] how to download STM32 original factory data
- Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
- The Research Report "2022 RPA supplier strength matrix analysis of China's banking industry" was officially launched
- KS008基于SSM的新闻发布系统
- [Key shake elimination] development of key shake elimination module based on FPGA
猜你喜欢

自动化测试的好处

绑定在游戏对象上的脚本的执行顺序
![[Zhao Yuqiang] deploy kubernetes cluster with binary package](/img/45/6777fa919386e526dbb0d2c808a7f2.jpg)
[Zhao Yuqiang] deploy kubernetes cluster with binary package

Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage

In Net 6 CS more concise method

Alibaba testers use UI automated testing to achieve element positioning

Path of class file generated by idea compiling JSP page

Web components series (VII) -- life cycle of custom components

Facebook等大廠超十億用戶數據遭泄露,早該關注DID了

Do you know cookies, sessions, tokens?
随机推荐
STC8H开发(十二): I2C驱动AT24C08,AT24C32系列EEPROM存储
Facebook等大厂超十亿用户数据遭泄露,早该关注DID了
math_ Derivative function derivation of limit & differential & derivative & derivative / logarithmic function (derivative definition limit method) / derivative formula derivation of exponential functi
Alibaba testers use UI automated testing to achieve element positioning
[Key shake elimination] development of key shake elimination module based on FPGA
Global and Chinese markets for medical gas manifolds 2022-2028: Research Report on technology, participants, trends, market size and share
10 exemples les plus courants de gestion du trafic istio, que savez - vous?
In Net 6 CS more concise method
80% of the diseases are caused by bad living habits. There are eight common bad habits, which are both physical and mental
Determine which week of the month the day is
软考 系统架构设计师 简明教程 | 总目录
图应用详解
Stack and queue
Global and Chinese markets for otolaryngology devices 2022-2028: Research Report on technology, participants, trends, market size and share
Viewing and verifying backup sets using dmrman
Database, relational database and NoSQL non relational database
Tips for using dm8huge table
lora网关以太网传输
Facebook等大廠超十億用戶數據遭泄露,早該關注DID了
[FPGA tutorial case 12] design and implementation of complex multiplier based on vivado core