MySQL Performance analysis System

Source: Internet
Author: User
Tags log mysql mysql slow query log percona

The MySQL slow query log analysis is now provided by a variety of tools, the most original Mysqldumpslow, full-featured Mysqlsla and Percona pt-query-digest; These tools greatly improve the DBA's ability to analyze the performance of the database, Reduce the excessive guessing process;

What if you can perform a timed analysis of SQL and visualize the presentation?

The application of Query-digest-ui-master this UI plug-in, in conjunction with Percona pt-query-digest Tools, is simply to achieve a visual result, if the analysis of multiple servers, this performance is very difficult;

For MySQL slow query analysis and visualization we can take advantage of open source software anemometer,

Function:

Can be analyzed for slow queries in multiple db;

Provide explain function;

Generate a picture of the usage of an SQL statement and generate a permanent link;

Support Performance_schema Performance collection;

Sort according to time or other metrics:

Wait

The use of Percona pt-query-digest can be referred to this blog: http://weipengfei.blog.51cto.com/1511707/953075 (the version used this time is 2.1)

Focus on the following two parameters:

--review: The collected results are stored in the database, and the next time the analysis is repeated without recording;

--review-history: Stores collected historical data and carries out SQL trend analysis;

(can be created using--create-review-table and--create-review-history-table two parameters if there is no corresponding table)

Simple example:

Pt-query-digest--filter ' (($event->{full_scan} | | "") eq "yes") | | (($event->{full_join} | | "") eq "yes") ' Slow.log

Anemometer is required for LNMP or lamp support (PHP 5.3+);

Pt-query-digest Execution Process:

$ pt-query-digest--user=anemometer--password=supersecurepass \--review H=db.example.com,d=slow_query_log,t=global _query_review \--review-history h=host,d=slow_query_log,t=global_query_review_history \
--no-report--limit=0% \

--filter= "\ $event->{bytes} = Length (\ $event->{arg}) and \ $event->{hostname}=\" $HOSTNAME \ "\/var/lib/mysql /db.example.com-slow.log

For $hostname parameters We can use flexibly, can be viewed for different hosts;

$ mysql-h db.example.com < Install.sql

Configuration file Modification:

$conf [' datasources '] [' localhost '] = array (    ' host '  => ' db.example.com ',    ' Port '  => 3306,    ' DB '    => ' slow_query_log ',    ' user '  => ' anemometer ',    ' password    ' => ' supersecurepass ', ' Tables ' => Array (        ' global_query_review ' => ' fact ',        ' global_query_review_history ' => ' dimension ')    ));

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.