First, download Mysqlsla
[Root@localhost tmp]# wget http://hackmysql.com/scripts/mysqlsla-2.03.tar.gz
--19:45:45--http://hackmysql.com/scripts/mysqlsla-2.03.tar.gz
Resolving hackmysql.com ... 64.13.232.157
connecting to hackmysql.com|64.13.232.157|:80 ... connected
. HTTP request sent, awaiting response ... OK
length:33674 (33K) [Application/x-tar]
saving to: ' mysqlsla-2.03.tar.gz.2 '
100%[================ ===========================================================================>] 33,674 50.2K/s in 0.7s
19:45:47 (50.2 kb/s)-' mysqlsla-2.03.tar.gz.2 ' saved [33674/33674]
Second, decompression
[Root@localhost tmp]# TAR-ZXVF 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@localhost tmp]# cd mysqlsla-2.03
[root@localhost mysqlsla-2.03]# ls
Bin Changes INSTALL Lib makefile.pl MANIFEST meta.yml README
Third, execute Perl script check package dependencies
[Root@localhost mysqlsla-2.03]# Perl makefile.pl
Checking If your kit is complete ...
Looks Good
writing Makefile for Mysqlsla
IV. Installation
[Root@localhost mysqlsla-2.03]# make && make install;
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
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
v. Basic use
1. Use parameter description
(1). --log-type (-LT) type logs:
This parameter is used to define the type of log, mainly with slow, general, binary, MSL, UDL, and slow log when analyzed by a slow.
(2). --sort:
Define what parameters to use to sort the analysis results, by default, by T_sum.
T_sum sorted by total time, c_sum by total number of times
(3). --top:
Displays the number of SQL, which defaults to 10, which indicates how many of the preceding bars are sorted by rule
(4). --statement-filter (-SF) [+-][type]:
Filter the types of SQL statements, such as SELECT, Update, Drop. [TYPE] has SELECT, CREATE, DROP, UPDATE, INSERT, such as "+select,insert", does not appear by default is-, that is not included.
(5). --databases DB:
Log of which library to process:
2. Statistical parameter description
(1). Queries total: Number of queries
(2). Unique: Number of SQL after heavy
(3). Sorted by: Output the contents of a report to sort the most significant slow SQL statistics, including average execution time, wait lock time, total number of resulting rows, total number of scanned rows.
(4). Count:sql the number of executions and the percentage of the total number of slow logs.
(5). Time: Execution times, including total time, average time, minimum, maximum time, percentage of total slow SQL time.
(6). 95% time: Get rid of the fastest and slowest SQL, with coverage accounting for up to one of SQL execution times.
(7). Lock time: Waits for a lock.
(8). The slow SQL wait-lock time for the lock:95%.
(9). Rows sent: Results row statistic quantity, including average, minimum, maximum quantity.
(10). Rows examined: Number of rows scanned.
(11). Database: Which databases belong to.
(12). Users: Which user, IP, represents the percentage of SQL executed by all users.
(13). Query Abstract: An abstract SQL statement.
(14). Query Sample:sql statement.
3. Use examples
(1). Slow query SQL for all select queries for Dowload_server1-slow.log, and display the longest execution time of 10 SQL, and write to Sql_time.sql
Mysqlsla-lt slow-sf "+select"-top dowload_server1-slow.log >test_time.log
(2). Statistical slow query file for Dowload_server1-slow.log database for Ultraxsmutf8 all select and update slow query SQL, and query the maximum number of 100 SQL, and write to Sql_num.sql
Mysqlsla-lt slow-sf "+select,update"-top 100-sort c_sum-db Ultraxsmutf8 dowload_server1-slow.log >num_time.log