4 MySQL optimization tools AWR, to help you accurately locate the database bottleneck! (Reprint)

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, keep you from the overall grasp of your database performance situation.

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

 

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 [!!] ( brackets exclamation mark items) such as [!!] the Maximum Possible Memory Usage: 4.8G (244.13% of Installed RAM), indicates that the memory has been used over the grave.

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

 

2) concerns the final recommendations "Recommendations" give.

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

 

tuning-primer.sh

mysql的另一个优化工具,针于mysql的整体进行一个体检,对潜在的问题,给出优化的建议。

项目地址:https://github.com/BMDan/tuning-primer.sh

目前,支持检测和优化建议的内容如下:

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

 

2.1 下载

[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 报告分析

重点查看有红色告警的选项,根据建议结合自己系统的实际情况进行修改,例如:

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

 

pt-variable-advisor

pt-variable-advisor 可以分析MySQL变量并就可能出现的问题提出建议。

3.1 安装

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是pt工具集的一个子工具,主要用来诊断你的参数设置是否合理。

[root@localhost ~]# pt-variable-advisor localhost --socket /var/lib/mysql/mysql.sock

3.3 报告分析

重点关注有WARN的信息的条目,例如:

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

 

pt-qurey-digest

pt-query-digest 主要功能是从日志、进程列表和tcpdump分析MySQL查询。

4.1安装

具体参考3.1节

4.2使用

pt-query-digest主要用来分析mysql的慢日志,与mysqldumpshow工具相比,py-query_digest 工具的分析结果更具体,更完善。

[root@localhost ~]# pt-query-digest /var/lib/mysql/slowtest-slow.log 

4.3 常见用法分析

1)直接分析慢查询文件:

pt-query-digest /var/lib/mysql/slowtest-slow.log > slow_report.log

2)分析最近12小时内的查询:

pt-query-digest --since=12h /var/lib/mysql/slowtest-slow.log > slow_report2.log

3)分析指定时间范围内的查询:

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)分析指含有select语句的慢查询

pt-query-digest --filter '$event->{fingerprint} =~ m/^select/i' /var/lib/mysql/slowtest-slow.log> slow_report4.log

5)针对某个用户的慢查询

pt-query-digest --filter '($event->{user} || "") =~ m/^root/i' /var/lib/mysql/slowtest-slow.log> slow_report5.log

6)查询所有所有的全表扫描或full join的慢查询

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 报告分析

  • 第一部分:总体统计结果 Overall:总共有多少条查询 Time range:查询执行的时间范围 unique:唯一查询数量,即对查询条件进行参数化以后,总共有多少个不同的查询 total:总计 min:最小 max:最大 avg:平均 95%:把所有值从小到大排列,位置位于95%的那个数,这个数一般最具有参考价值 median:中位数,把所有值从小到大排列,位置位于中间那个数
  • 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

Reprinted from: https: //www.toutiao.com/a6691523026984370699/ tt_from = mobile_qq & utm_campaign = client_share & timestamp = 1575849515 & app = news_article & utm_source = mobile_qq & utm_medium = toutiao_ios & req_id = 20191209075835010129033015237F5DC6 & group_id = 6691523026984370699?

Guess you like

Origin www.cnblogs.com/xibuhaohao/p/12008994.html