| 
 | 
 
原创出处:MySQLpub.com  ,作者:kider  ,转载请注明作者和出处,并不能用于商业用途,违者必究。 
 
介绍: 
一款帮助语句分析、过滤、分析和排序MySQL慢日志、查询日志、二进制日志和microslow patched日志的分析工具。整体来说, 功能非常强大. 数据报表,非常有利于分析慢查询的原因, 包括执行频率, 数据量, 查询消耗等。 
 
官方网站及向导: 
http://hackmysql.com/ 
http://hackmysql.com/mysqlsla_guide 
 
安装: 
[root@node01 mysqlsla]# tar -xzvf mysqlsla-2.03.tar.gz  
mysqlsla-2.03/ 
mysqlsla-2.03/Changes 
mysqlsla-2.03/INSTALL 
mysqlsla-2.03/README 
mysqlsla-2.03/Makefile.PL 
mysqlsla-2.03/bin/ 
mysqlsla-2.03/bin/mysqlsla 
mysqlsla-2.03/META.yml 
mysqlsla-2.03/lib/ 
mysqlsla-2.03/lib/mysqlsla.pm 
mysqlsla-2.03/MANIFEST 
 
[root@node01 tools]# cd mysqlsla-2.03/ 
 
[root@node01 mysqlsla-2.03]# perl Makefile.PL  
Checking if your kit is complete... 
Looks good 
Writing Makefile for mysqlsla 
 
[root@node01 mysqlsla-2.03]# make 
cp lib/mysqlsla.pm blib/lib/mysqlsla.pm 
cp bin/mysqlsla blib/script/mysqlsla 
/usr/bin/perl "-MExtUtils::MY" -e "MY->fixin(shift)" blib/script/mysqlsla 
Manifying blib/man3/mysqlsla.3pm 
 
[root@node01 mysqlsla-2.03]# make install 
Installing /usr/lib/perl5/site_perl/5.8.8/mysqlsla.pm 
Installing /usr/share/man/man3/mysqlsla.3pm 
Installing /usr/bin/mysqlsla 
Writing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/mysqlsla/.packlist 
Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/perllocal.pod 
 
注: 
需要Perl 
及perl-DBI-1.52-.....rpm 
  
安装完毕。 
 
使用: 
#mysqlsla LOG 
(2.03自动判断日志类型做日志分析) 
 
详细使用方法: 
# Basic operation: parse a MySQL slow or general log 
mysqlsla --log-type slow LOG 
mysqlsla --log-type general LOG 
 
# Parse output from mysqlbinlog 
# mysqlsla cannot directly parse binary logs 
mysqlbinlog LOG │ mysqlsla --log-type binary - 
 
# Parse a microslow patched slow log 
mysqlsla --log-type msl LOG 
 
# Replay a replay file 
mysqlsla --replay FILE 
 
# Parse a user-defined log specify its format 
mysqlsla --log-type udl --udl-format FILE 
 
# Let mysqlsla automatically determine the log type 
mysqlsla LOG 
 
报表: 
[root@node01 testing]# mysqlsla SRVR00-slow.log 
Auto-detected logs as slow logs 
Report for slow logs: SRVR00-slow.log 
1.65k queries total, 10 unique 
Sorted by 't_sum' 
Grand Totals: Time 36.20k s, Lock 0 s, Rows sent 41.59M, Rows Examined 2.70G 
 
 
______________________________________________________________________ 001 ___ 
Count 
: 1.62k 
(98.25%) 
Time 
: 34947 s total, 21.519089 s avg, 16 s to 42 s max 
(96.54%) 
 
95% of Time : 32271 s total, 20.928016 s avg, 16 s to 29 s max 
Lock Time (s) : 0 total, 0 avg, 0 to 0 max 
(0.00%) 
 
95% of Lock : 0 total, 0 avg, 0 to 0 max 
Rows sent 
: 4 avg, 4 to 4 max 
(0.02%) 
Rows examined : 1.64M avg, 1.07M to 2.13M max 
(98.32%) 
Database 
: teachingfile 
Users 
:  
 
tfile@SRVR00.localdomin 172.100.5.27 : 100.00% (1624) of query, 98.37% (1626) of all users 
 
Query abstract: 
SELECT DISTINCT ... |   
 
 
 
 |