工具準(zhǔn)備:
iotop: http://guichaz.free.fr/iotop/
pt-ioprofile:http://www.percona.com/downloads/percona-toolkit/2.2.1/
Step1 : iostat 查看IO情況
iostat -x 1 查看IO情況,從下圖可以看到dfa這個磁盤的IO負(fù)載較高,接下來我們就來定位具體的負(fù)載來源
Step2: iotop定位負(fù)載來源進(jìn)程
iotop的本質(zhì)是一個python腳本,從proc中獲取thread的IO信息,進(jìn)行匯總。
從下圖可以看出大部分的IO來源都來自于mysqld進(jìn)程。因此可以確定dfa的負(fù)載來源是數(shù)據(jù)庫
Step3 pt-ioprofile定位負(fù)載來源文件
pt-ioprofile的原理是對某個pid附加一個strace進(jìn)程進(jìn)行IO分析。
以下是摘自官網(wǎng)的一段警示:
However, it works by attaching strace to the process using ptrace(), which will make it run very slowly until strace detaches. In addition to freezing the server, there is also some risk of the process crashing or performing badly after strace detaches from it, or indeed of strace not detaching cleanly and leaving the process in a sleeping state. As a result, this should be considered an intrusive tool, and should not be used on production servers unless you are comfortable with that.
通過ps aux|grep mysqld 找到 mysqld進(jìn)程對應(yīng)的進(jìn)程號,通過pt-ioprofile查看哪個文件的IO占用時間最多。
默認(rèn)參數(shù)下該工具展示的是IO占用的時間。
對于定位問題更有用的是通過IO的吞吐量來進(jìn)行定位。使用參數(shù) --cell=sizes,該參數(shù)將結(jié)果已 B/s 的方式展示出來
從上圖可以看出IO負(fù)載的主要來源是sbtest (sysbench的IO bound OLTP測試)。
并且壓力主要集中在讀取上。
bitsCN.com聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com