工具準備:
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負載較高,接下來我們就來定位具體的負載來源
Step2: iotop定位負載來源進程
iotop的本質是一個python腳本,從proc中獲取thread的IO信息,進行匯總。
從下圖可以看出大部分的IO來源都來自于mysqld進程。因此可以確定dfa的負載來源是數據庫
Step3 pt-ioprofile定位負載來源文件
pt-ioprofile的原理是對某個pid附加一個strace進程進行IO分析。
以下是摘自官網的一段警示:
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進程對應的進程號,通過pt-ioprofile查看哪個文件的IO占用時間最多。
默認參數下該工具展示的是IO占用的時間。
對于定位問題更有用的是通過IO的吞吐量來進行定位。使用參數 --cell=sizes,該參數將結果已 B/s 的方式展示出來
從上圖可以看出IO負載的主要來源是sbtest (sysbench的IO bound OLTP測試)。
并且壓力主要集中在讀取上。
bitsCN.com聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com