Use mysqlsla to analyze MySQL logs

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.