How performance for mysql running? Whether reasonable parameter settings? Account settings if there is a security risk if the gains?
The saying goes, it 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.
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.
1、mysqltuner-pl
This is a common mysql 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 scriptPlease enter your MySQL administrative login: rootPlease 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.
2, tuning-primer.sh
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:
3、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:
4、pt-qurey-digest
pt-query-digest main function is to query from the log, analyze tcpdump process list and MySQL. Focus on micro-channel public number: Java technology stack in the background reply: mysql, I can get sort of dry N papers 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 statistical results
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: The minimum max: maximum avg: Average 95 %: all of the values in ascending order, the position is 95% of the number, this number is typically the most valuable median: median, all of the values in ascending order, the number of positions in the middle
The second part: the query packet statistics
Rank: Rank all statements, the default query time by descending order, designated by Query ID --order-by: ID statement (text characters and remove extra spaces, calculated hash value) Response: the response time of the total time: the query in this analysis, the proportion of the total time Calls: execution times, i.e., this analysis a total of how many of this type of query R / Call: response time V / M average per execution: response time Variance-to- the mean ratio Item: query object
Part III: detailed statistics for 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, the length of the interval reflects proportion. Tables: tables involved in the query to Explain: SQL statement.
Author: Wang talk about the operation and maintenance
https://www.toutiao.com/a6691523026984370699/