当前位置:网站首页>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
边栏推荐
- Facebook等大厂超十亿用户数据遭泄露,早该关注DID了
- MySQL transaction isolation level
- 使用JS完成一个LRU缓存
- Ybtoj coloring plan [tree chain dissection, segment tree, tarjan]
- P2648 make money
- No qualifying bean of type ‘......‘ available
- Align items and align content in flex layout
- C#(三十)之C#comboBox ListView treeView
- Redis (replicate dictionary server) cache
- Global and Chinese markets for otolaryngology devices 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
math_极限&微分&导数&微商/对数函数的导函数推导(导数定义极限法)/指数函数求导公式推导(反函数求导法则/对数求导法)
Security xxE vulnerability recurrence (XXe Lab)
Ethernet port &arm & MOS &push-pull open drain &up and down &high and low sides &time domain and frequency domain Fourier
[disassembly] a visual air fryer. By the way, analyze the internal circuit
[optimization model] Monte Carlo method of optimization calculation
10個 Istio 流量管理 最常用的例子,你知道幾個?
Serial port-rs232-rs485-ttl
Proof of Stirling formula
mysql关于自增长增长问题
Error 1045 (28000): access denied for user 'root' @ 'localhost' (using password: no/yes
随机推荐
Yyds dry goods inventory hcie security Day11: preliminary study of firewall dual machine hot standby and vgmp concepts
MySql数据库root账户无法远程登陆解决办法
Le compte racine de la base de données MySQL ne peut pas se connecter à distance à la solution
Database, relational database and NoSQL non relational database
Custom event of C (31)
C#(二十九)之C#listBox checkedlistbox imagelist
ESP32(基于Arduino)连接EMQX的Mqtt服务器上传信息与命令控制
C form application of C (27)
Security xxE vulnerability recurrence (XXe Lab)
如何修改表中的字段约束条件(类型,default, null等)
Maxay paper latex template description
C language -- structs, unions, enumerations, and custom types
Global and Chinese market of plasma separator 2022-2028: Research Report on technology, participants, trends, market size and share
Detailed explanation of serialization and deserialization
使用JS完成一个LRU缓存
Record an excel xxE vulnerability
P2648 make money
关于进程、线程、协程、同步、异步、阻塞、非阻塞、并发、并行、串行的理解
10個 Istio 流量管理 最常用的例子,你知道幾個?
2/12 didn't learn anything