Download: http://hackmysql.com/mysqlsla
Tar xzvf mysqlsla-2.03.tar.gz
CD mysqlsla-2.03
Perl makefile. pl
Make
Make install
Install the command mysqlsla to the/usr/bin directory by default.
When you install the Perl module through CPAN for the first time, you need to configure the module. For most configurations, use the default value and press Enter.
# Perl-mcpan-e Shell
Then execute the following command to save
CPAN> reload Index
CPAN> reload CPAN
Install the DBI Module
CPAN> install DBI
Usage:
1. To connect to MySQL, you must have the root @ localhost permission and grant all on *. * to root @ localhost identified by '123'
2. Enable MySQL server's general log and slow log
/Etc/My. CNF:
[Mysqld]
Log = General-Log
Log-Slow-queries = slow-Log
3. Use mysqlsla to analyze log files
Mysqlsla is actually a Perl scripts, which is used in a very simple way. The syntax is as follows:
A. analyze the general log
Mysqlsla-lt slow. Log-r print-unique-MF "DB = foo"-SF "+ select"
Then you can understand what the server is processing.
B. Analyze slow log
Reference:
Mysqlsla -- user = root -- Password = XXXXX-ex -- socket =/tmp/MySQL. Sock-lt slow. Log
Mysqlsla -- user = root -- Password = XXXXX-ex -- socket =/tmp/MySQL. Sock-LT General/data/MySQL/test. Log
Reference:
-- Slow: indicates the slow log to be analyzed.
-- Ex: Use explain to analyze Query
-- DB database name: Slow log does not necessarily record the database to which the query belongs. In this way, when the server wants to explain, there will be a problem. Therefore, we will specify the database we use here.
Slow-Log: enter the name of the slow-log file. If multiple log files exist, separate them with commas (,), for example, log1, log2 ....
Sample reports generated: (mysqlsla only lists top 10 queries by default)