4 MySQL optimization tools to help you accurately locate the database bottleneck!

Original: https: //www.toutiao.com/a6691523026984370699/

Foreword

For mysql running, how performance is reasonable parameter settings, whether there are security risks account settings, if you are clear in the chest it?

The saying goes, we must first of its profits, on a regular basis to your MYSQL database a physical examination is an important means to ensure the safe operation of the database, because a good tool to make your work efficiency doubled!
Today to share a few tool mysql optimization, you can use them to perform a physical examination of your mysql, generate reports awr, let you grasp your database performance situation as a whole.


mysqltuner.pl

Mysql is a common database performance diagnostic tools, including rationality log files, storage engine performance analysis of safety recommendations and the main check parameter settings. Against potential problems, make recommendations for improvement. Mysql optimization is a good helper.
In the previous version, MySQLTuner support about 300 indicators MySQL / MariaDB / Percona Server's.
Project address: https: //github.com/major/MySQLTuner-perl

1.1 Download

[root@localhost ~]#wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl复制代码

1.2

[root@localhost ~]# ./mysqltuner.pl --socket /var/lib/mysql/mysql.sock
 >> MySQLTuner 1.7.4 - Major Hayden <[email protected]>
 >> Bug reports, feature requests, and downloads at http://mysqltuner.com/
 >> Run with '--help' for additional options and output filtering
[--] Skipped version check for MySQLTuner script
Please enter your MySQL administrative login: root
Please enter your MySQL administrative password: [OK] Currently running supported MySQL version 5.7.23
[OK] Operating on 64-bit architecture 

复制代码

1.3, the report analyzes

1) important concern [!!] (exclamation mark in brackets items) such as [!!] Maximum possible memory usage: 4.8G (244.13% of installed RAM), indicates that the memory has been used over the grave.


2) concerns the final recommendations "Recommendations" give.


tuning-primer.sh

Another optimization tool mysql, the needle of a medical examination on the overall mysql, potential problems, give advice optimization.
Project address: https: //github.com/BMDan/tuning-primer.sh
Currently, support for testing and optimization recommendations reads as follows:


2.1 Download

[root@localhost ~]#wget https://launchpad.net/mysql-tuning-primer/trunk/1.6-r1/+download/tuning-primer.sh

复制代码

2.2

[root@localhost ~]# [root@localhost dba]# ./tuning-primer.sh 
 
 -- MYSQL PERFORMANCE TUNING PRIMER --
 - By: Matthew Montgomery -

复制代码

2.3 Analysis Report

Focus your red alarm options, according to the proposed combination of the actual situation of their own system be modified, for example:


pt-variable-advisor

pt-variable-advisor MySQL variables can analyze problems and to make recommendations that may arise.

3.1 Installation

https://www.percona.com/downloads/percona-toolkit/LATEST/
[root@localhost ~]#wget https://www.percona.com/downloads/percona-toolkit/3.0.13/binary/redhat/7/x86_64/percona-toolkit-3.0.13-re85ce15-el7-x86_64-bundle.tar
[root@localhost ~]#yum install percona-toolkit-3.0.13-1.el7.x86_64.rpm 

复制代码

3.2

pt-variable-advisor tool is a sub-pt toolset, mainly used to diagnose your parameter settings are reasonable.
[root@localhost ~]# pt-variable-advisor localhost --socket /var/lib/mysql/mysql.sock

复制代码

3.3 Analysis Report

Focus has WARN entry information, for example:


pt-qurey-digest

pt-query-digest main function is to query from the log, analyze tcpdump process list and MySQL.

4.1 Installation

With specific reference to 3.1

4.2

pt-query-digest is mainly used to analyze the log mysql slow, compared with mysqldumpshow tools, analysis tools py-query_digest more specific and better.
[root@localhost ~]# pt-query-digest /var/lib/mysql/slowtest-slow.log 

复制代码

4.3 common usage analysis

1) direct analysis of slow query file:
pt-query-digest /var/lib/mysql/slowtest-slow.log > slow_report.log

复制代码
2) analytical queries within the last 12 hours:
pt-query-digest --since=12h /var/lib/mysql/slowtest-slow.log > slow_report2.log

复制代码
3) analytical queries within a specified time range:
pt-query-digest /var/lib/mysql/slowtest-slow.log --since '2017-01-07 09:30:00' --until '2017-01-07 10:00:00'> > slow_report3.log

复制代码
4) analysis refers to the slow query contains a select statement
pt-query-digest --filter '$event->{fingerprint} =~ m/^select/i' /var/lib/mysql/slowtest-slow.log> slow_report4.log

复制代码
5) slow query for a user's
pt-query-digest --filter '($event->{user} || "") =~ m/^root/i' /var/lib/mysql/slowtest-slow.log> slow_report5.log

复制代码
6) All queries slow query all of the full table scan or full join the
pt-query-digest --filter '(($event->{Full_scan} || "") eq "yes") ||(($event->{Full_join} || "") eq "yes")' /var/lib/mysql/slowtest-slow.log> slow_report6.log

复制代码

4.4 Analysis Report

  • Part 1: General statistics Overall: Total number of queries Time range: Time range query execution unique: the number of unique queries that the query conditions after parameterization, a total of how many different queries total: Total min: minimum max : Max avg: average 95%: all of the values ​​in ascending order, located the 95% of the number, this number is generally the most valuable median: median, all of the values ​​in ascending order, location in the middle of that number
  • Part II: inquiry packet statistics Rank: Rank all statements, query time descending order by default, Query ID specified by --order-by: ID statement (remove extra spaces and text characters, calculated hash value) Response: the total response time of time: the query in the proportion of the total time of calls in this analysis: execution times, i.e., this analysis a total of how many of this type of query R / Call: average response time per execution V / M: response time Variance-to-mean ratio of Item: query object
  • Part III: Detailed statistical results of each query ID: ID number of the query, the Query ID, and corresponding FIG Databases: database name Users: number (proportion) of each user to perform Query_time distribution: the distribution of the query time, reflect the length interval accounting. Tables: tables involved in the query to Explain: SQL statement

At last

Welcome to public concern number: Programmer Herd, 66 replies, receive a 300 Java core knowledge pdf document summary!

When the content of these materials are the interview the interviewer will ask knowledge points, chapter points, including a lot of knowledge, including basic knowledge, Java collections, JVM, multi-threaded, spring principle, micro-services, Netty and RPC, Kafka , diary, design patterns, Java algorithms, databases, Zookeeper, distributed caching, data structures, and so on.


Guess you like

Origin juejin.im/post/5e807a10e51d4546b3564227