国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
十大MySQL性能分析工具匯總!專治MySQL性能瓶頸

前言

MySQL 數(shù)據(jù)庫最常見的兩個瓶頸是CPU和I/O的瓶頸。CPU在飽和的時候一般發(fā)生在數(shù)據(jù)裝入內(nèi)存或從磁盤上讀取數(shù)據(jù)時候,磁盤I/O瓶頸發(fā)生在裝入數(shù)據(jù)遠大于內(nèi)存容量的時候。

MySQL數(shù)據(jù)庫性能遇到瓶頸,如何快速定位問題的原因,是每個DBA或系統(tǒng)運維人員應該思考的問題。正確的借助一些性能分析工具,能夠幫助DBA或系統(tǒng)運維人員進行問題快速的定位。

下面小編匯總了一些 MySQL DBA工作中好用的性能分析工具,歡迎大家收藏轉(zhuǎn)發(fā)~

一、 Pt-qurey-digest

pt-query-digest主要用來分析mysql的慢日志,與mysqldumpshow工具相比,pt-querydigest 工具的分析結(jié)果更具體,更完善。pt-querydigest是PT工具集的子集。

1.1 安裝

yum install percona-toolkit-3.0.13-1.el7.x86_64.rpm

1.2 用法

1、直接分析慢查詢文件:

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

2、分析最近12小時內(nèi)的查詢:

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

3、分析指定時間范圍內(nèi)的查詢:

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

二、Innotop

innotop是一個MySQL和InnoDB事務/狀態(tài)監(jiān)視器,它顯示查詢、InnoDB事務、鎖等待、死鎖、外鍵錯誤,打開表,復制狀態(tài),緩沖區(qū)信息,行操作、日志、I/O操作、加載圖等等。你可以使用innotop同時監(jiān)控多個服務器。innotp可以綜合了解你的 MySQL。

2.1、安裝innotop

yum install innotop-1.11.4-1.el7.noarch 

2.2、使用方法

1、基本使用

innotop --host 192.168.1.181 --user admin --password 123456 --port 3306 --delay 1 -m Q

2、參數(shù)說明,如下圖:

注意::?可以切換至其他命令。

三、 Orzdba

是taobao開源出來一個數(shù)據(jù)庫實時性能查看工具,借助此工具你可以時刻了解的你的數(shù)據(jù)庫的性能情況。

3.1 使用方法:

./orzdba_remote --host=192.168.1.181 --user='admin' --password=123456 --port=3306 -mysql -sys 2>/dev/null 

參數(shù)說明:

  • --host:指定主機

  • --user:指定用戶名

  • --password:數(shù)據(jù)庫密碼

  • --port:數(shù)據(jù)庫的端口號

四、 Tcp抓包

4.1 安裝tcp包

yum install tcpdump-4.9.2-3.el7.x86_64 -y

4.2 使用

1、通過tcpdump抓包

tcpdump -i any port 3306 -l -s 0 -w - |strings |grep -A 5 select|less

2、tcpdump pt-query-digest

tcpdump -s 65535 -x -nn -q -tttt -i any -c 1000 port 3306 > mysql.tcp.txtpt-query-digest --type tcpdump mysql.tcp.txt> slow_report9.log

五、ioprofile

5.1 pt-ioprofile

pt-ioprofile定位負載來源文件,通過ps找出負載較高的進程。

5.2 使用

pt-ioprofile --profile-pid=12036 --cell=sizes 

參數(shù)說明:

  • --profile-pid:mysql進程的id

  • --cell-sizes:該參數(shù)將結(jié)果已 B/s 的方式展示出來

六、Tcprstat

通過響應時間判斷數(shù)據(jù)庫運行狀況

6.1 安裝tcprstat

如果是在64位操作系統(tǒng)中使用,可以直接下載二進制文件使用。步驟如下:

1)下載文件 http://github.com/downloads/Lowercases/tcprstat/tcprstat-static.v0.3.1.x86_64

2)把下載的文件移動到 /usr/bin

3)把文件名修改為 tcprstat

4)修改文件權(quán)限,增加執(zhí)行權(quán)限 chmod x /usr/bin/tcprstat 如果你想在32位操作系統(tǒng)中使用,那你只能自己編譯了。

代碼下載地址 https://github.com/Lowercases/tcprstat https://launchpad.net/tcprstat

6.2 使用

[root@localhost ~]# tcprstat --p 3306 -t 1 -n 10timestamp count max min avg med stddev 95_max 95_avg 95_std 99_max 99_avg 99_std1539760803 1 103 103 103 103 0 0 0 0 0 0 01539760804 1 108 108 108 108 0 0 0 0 0 0 01539760805 1 124 124 124 124 0 0 0 0 0 0 01539760806 1 115 115 115 115 0 0 0 0 0 0 01539760807 1 112 112 112 112 0 0 0 0 0 0 0

每個請求的時間在0.1ms~0.124ms

參數(shù)說明:

  • --p:數(shù)據(jù)庫端口號

  • -t:刷新間隔時間

  • -n:輸出次數(shù)

七、 Nicstat

nicstat網(wǎng)絡利器,充分了解你的網(wǎng)卡運行狀況)

7.1、安裝nicstat

yum install http://rpmfind.net/linux/fedora/linux/releases/28/Everything/x8664/os/Packages/n/nicstat-1.95-7.fc27.x8664.rpm

7.2、使用方法

[root@lkjtest ~]# nicstat -z 1 Time Int rKB/s wKB/s rPk/s wPk/s rAvs wAvs %Util Sat15:29:14 ens160 4.03 0.91 43.18 1.60 95.61 581.8 0.00 0.0015:29:15 ens160 3.09 0.73 35.95 2.00 88.11 375.5 0.00 0.0015:29:16 ens160 3.93 0.66 43.99 2.00 91.52 335.5 0.00 0.0015:29:17 ens160 3.99 0.66 45.00 2.00 90.71 335.5 0.00 0.0015:29:18 ens160 4.04 0.66 46.99 2.00 88.04 335.5 0.00 0.0015:29:19 ens160 3.64 0.66 42.00 2.00 88.76 335.5 0.00 0.00

參數(shù)說明:

  • -z:跳過0行

輸出參數(shù)說明:

  • wKB/s,OutKB #每秒寫的千字節(jié)數(shù)(transmitted)

  • rMbps,RdMbps #每秒讀的百萬字節(jié)數(shù)K(received)

  • %Util #接口的利用率百分比

  • Sat #每秒的錯誤數(shù),接口接近飽和的一個指標

八、 Dstat

8.1 安裝dstat

yum install dstat -y

8.2 使用

[root@localhost ~]# dstat -tclmndy 1

參數(shù)說明:

  • -t:enable time/date output

  • -c:enable cpu stats

  • -l:enable load stats

  • -m:enable memory stats

  • -n:enable network stats

  • -d:enable disk stats

  • -y:enable system stats

九、 vmtouch

vmtouch是一個學習和控制unix和類unix系統(tǒng)的文件系統(tǒng)緩存的工具。

9.1、快速安裝

$ git clone https://github.com/hoytech/vmtouch.git$ cd vmtouch$ make$ sudo make install

9.2、使用方法

  • 顯示

$ vmtouch -v big-dataset.txt
  • 回收

vmtouch -ve a.txt

十、 oprofile

Oprofile 是一個開源的profiling工具,通過取樣來工作,是一個全局的抽樣統(tǒng)計工具。cpu無端占用高?應用程序響應慢?苦于沒有分析的工具?找它就對了!通過計數(shù)采樣,幫助我們從進程、函數(shù)、代碼層面找出占用cpu的'罪魁禍首'。

10.1 安裝

yum install http://www.rpmfind.net/linux/centos/7.5.1804/os/x86_64/Packages/oprofile-0.9.9-25.el7.x86_64.rpm -y

10.2 使用方法

1、使用

#加載oprofile內(nèi)核模塊 opcontrol --init #我們對內(nèi)核的取樣沒興趣 opcontrol --setup --no-vmlinux#在開始收集采樣數(shù)據(jù)前回顧下我們的設(shè)置 opcontrol --status#清除上一次采樣到的數(shù)據(jù) opcontrol --reset #運行我們的程序 opcontrol --start #收集采樣數(shù)據(jù) opcontrol --dump#關(guān)閉守護程序, 同時準備好采樣的數(shù)據(jù) opcontrol --shutdown

注意:如報Cannot find event CPUCLKUNHALTED,解決方法如下:

#解決步驟$sudo opcontrol --deinitDaemon not runningUnloading oprofile module $sudo modprobe oprofile timer=1 $dmesg|grep oprofile|tail -n 1oprofile: using timer interrupt.如果你看到上面的字說明你成功了。我們再試驗下:$sudo opcontrol --init && sudo opcontrol --reset && sudo opcontrol --startUsing 2.6 OProfile kernel interface.Using log file /var/lib/oprofile/samples/oprofiled.logDaemon started.Profiler running.

2、獲取采樣信息

#系統(tǒng)級別的 opreport --long-filenames#模塊級別的 opreport image:foo -l#源碼級別的 opannotate image:foo -s

3、使用樣例

opcontrol --deinitmodprobe oprofile timer=1$dmesg|grep oprofile|tail -n 1(oprofile: using timer interrupt.)opcontrol --resetpcontrol --separate=lib --no-vmlinux--start --image=/home/mysql_user/mysqlhome/bin/mysqldopcontrol --dumpopcontrol --shutdownopreport -l /home/mysql_user/mysqlhome/bin/mysqld
本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
利用Oprofile對多核多線程進行性能分析
Erlang非業(yè)余研究
linux 平臺性能分析工具
使用gprof和oprofile來分析 linux程序的性能
oprofile使用
使用 GNU profiler 來提高代碼運行速度
更多類似文章 >>
生活服務
分享 收藏 導長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服