当前位置:网站首页>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边栏推荐
- After five years of testing in byte, I was ruthlessly dismissed in July, hoping to wake up my brother who was paddling
- TCP/IP协议里面的网关地址和ip地址有什么区别?
- Benefits of automated testing
- 登录mysql输入密码时报错,ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO/YES
- 绑定在游戏对象上的脚本的执行顺序
- 【PSO】基于PSO粒子群优化的物料点货物运输成本最低值计算matlab仿真,包括运输费用、代理人转换费用、运输方式转化费用和时间惩罚费用
- [FPGA tutorial case 12] design and implementation of complex multiplier based on vivado core
- 【leetcode】22. bracket-generating
- [introduction to Django] 11 web page associated MySQL single field table (add, modify, delete)
- How does technology have the ability to solve problems perfectly
猜你喜欢

图应用详解

Yyds dry goods inventory hcie security Day11: preliminary study of firewall dual machine hot standby and vgmp concepts
![[FPGA tutorial case 11] design and implementation of divider based on vivado core](/img/39/f337510c2647d365603a8485583a20.png)
[FPGA tutorial case 11] design and implementation of divider based on vivado core

No qualifying bean of type ‘......‘ available

How many of the 10 most common examples of istio traffic management do you know?

Security xxE vulnerability recurrence (XXe Lab)

After five years of testing in byte, I was ruthlessly dismissed in July, hoping to wake up my brother who was paddling

C language -- structs, unions, enumerations, and custom types

C#(三十一)之自定义事件

KS008基于SSM的新闻发布系统
随机推荐
Blue Bridge Cup - day of week
阿里测试师用UI自动化测试实现元素定位
1291_Xshell日志中增加时间戳的功能
How to modify field constraints (type, default, null, etc.) in a table
判断当天是当月的第几周
Ks008 SSM based press release system
绑定在游戏对象上的脚本的执行顺序
Maxay paper latex template description
Redis (replicate dictionary server) cache
软考 系统架构设计师 简明教程 | 总目录
【leetcode】22. bracket-generating
Error 1045 (28000): access denied for user 'root' @ 'localhost' (using password: no/yes
【可调延时网络】基于FPGA的可调延时网络系统verilog开发
Global and Chinese markets for fire resistant conveyor belts 2022-2028: Research Report on technology, participants, trends, market size and share
[adjustable delay network] development of FPGA based adjustable delay network system Verilog
How can programmers resist the "three poisons" of "greed, anger and ignorance"?
Solution to the problem that the root account of MySQL database cannot be logged in remotely
SSTI template injection explanation and real problem practice
C mouse event and keyboard event of C (XXVIII)
Web components series (VII) -- life cycle of custom components