4 款 MySQL 調優工具,公司大神都在用!

工具1:mysqltuner.pl

是mysql一個常用的資料庫效能診斷工具,主要檢查引數設定的合理性包括日誌檔案、儲存引擎、安全建議及效能分析。針對潛在的問題,給出改進的建議。是mysql最佳化的好幫手。

[root@localhost ~]#wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl
[root@localhost ~]# ./mysqltuner.pl --socket /var/lib/mysql/mysql.sock
>> MySQLTuner 1.7.4 - Major Hayden <major@mhtx.net>
>> 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

工具2:tuning-primer.sh

mysql的另一個最佳化工具,針於mysql的整體進行一個體檢,對潛在的問題,給出最佳化的建議。

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

-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -

工具3:pt-variable-advisor

pt-variable-advisor 可以分析MySQL變數並就可能出現的問題提出建議。

[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
[root@localhost ~]# pt-variable-advisor localhost --socket /var/lib/mysql/mysql.sock

工具4:pt-qurey-digest

pt-query-digest 主要功能是從日誌、程序列表和tcpdump分析MySQL查詢。

[root@localhost ~]# pt-query-digest /var/lib/mysql/slowtest-slow.log
pt-query-digest /var/lib/mysql/slowtest-slow.log > slow_report.log
pt-query-digest — since=12h /var/lib/mysql/slowtest-slow.log > slow_report2.log
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
pt-query-digest — filter ‘$event->{fingerprint} =~ m/^select/i’ /var/lib/mysql/slowtest-slow.log> slow_report4.log
pt-query-digest — filter ‘($event->{user} || “”) =~ m/^root/i’ /var/lib/mysql/slowtest-slow.log> slow_report5.log
pt-query-digest — filter ‘(($event->{Full_scan} || “”) eq “yes”) ||(($event->{Full_join} || “”) eq “yes”)’ /var/lib/mysql/slowtest-slow.log> slow_report6.log

文章推選

資料分析師的SQL要學到什麼程度?

--

--

這是一個專注於數據分析職場的內容部落格,聚焦一批數據分析愛好者,在這裡,我會分享數據分析相關知識點推送、(工具/書籍)等推薦、職場心得、熱點資訊剖析以及資源大盤點,希望同樣熱愛數據的我們一同進步! 臉書會有更多互動喔:https://www.facebook.com/shujvfenxi/

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
數據分析那些事

數據分析那些事

這是一個專注於數據分析職場的內容部落格,聚焦一批數據分析愛好者,在這裡,我會分享數據分析相關知識點推送、(工具/書籍)等推薦、職場心得、熱點資訊剖析以及資源大盤點,希望同樣熱愛數據的我們一同進步! 臉書會有更多互動喔:https://www.facebook.com/shujvfenxi/