bin/mysqldumpslow -t10 -s /opt/mysql/var/slow.log
“mysqldumpslow.sh” is not currently compatible with Percona extended slow query
log format. Please use “pt-query-digest” from Percona Toolkit instead
(https://www.percona.com/doc/percona-toolkit/2.2/pt-query-digest.html).
使用mysqldumpslow分析percona mysql慢日志会提示使用 pt-query-digest
wget percona.com/get/percona-toolkit.tar.gz
tar zxf percona-toolkit.tar.gz
cd percona-toolkit-3.1.0
perl Makefile.PL PREFIX=/usr/local/percona-toolkit
make && make install
cd /usr/local/percona-toolkit
pt-query-digest /opt/mysql/var/slow.log
pt-query-digest –since=48h /opt/mysql/var/slow.log > slow_report.log
1.直接分析慢查询文件:
pt-query-digest slow.log > slow_report.log
2.分析最近12小时内的查询:
pt-query-digest –since=12h slow.log > slow_report2.log
3.分析指定时间范围内的查询:
pt-query-digest slow.log –since ‘2017-01-07 09:30:00’ –until ‘2017-01-07 10:00:00’> > slow_report3.log
4.分析指含有select语句的慢查询
pt-query-digest –filter ‘$event->{fingerprint} =~ m/^select/i’ slow.log> slow_report4.log
5.针对某个用户的慢查询
pt-query-digest –filter ‘($event->{user} || “”) =~ m/^root/i’ slow.log> slow_report5.log
6.查询所有所有的全表扫描或full join的慢查询
pt-query-digest –filter ‘(($event->{Full_scan} || “”) eq “yes”) ||(($event->{Full_join} || “”) eq “yes”)’ slow.log> slow_report6.log
参考:https://www.cnblogs.com/luyucheng/p/6265873.html
No Responses (yet)
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.