標籤:style color io os ar sp 資料 div on
Linux系統出現了效能問題,一般我們可以通過top.iostat,vmstat等命令來查看初步定位問題。其中iostat可以給我們提供豐富的IO狀態資料
$ iostat -x -1
avg-cpu: %user %nice %system %iowait %steal %idle
10.43 0.00 1.51 1.51 0.00 86.56
Device:rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
sda 4477.00 9.00 951.00 13.00 24288.00 2492.00 55.56 0.21 0.22 0.21 0.92 0.17 16.00
%user:Show the percentage of CPU utilization that occurred while executing at the user level(application).
%nice :Show the percentage of CPU utilization that occurred while executing at the user levelwith nice priority.
%system:Show the percentage of CPU utilization that occurred while executing at the system level (kernel).
%iowait:Show the percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request.
%steal:Show the percentage of time spent in involuntary wait by the virtual CPU or CPUs while thehypervisor was servicing another virtual processor.
%idle:Show the percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request.
rrqm/s:每秒進行merge的讀運算元目。即delta(rmerge)/s wrqm/s:每秒進行merge的寫運算元目。即delta(wmerge)/s r/s:每秒完成的讀I/O裝置次數。即delta(rio)/s w/s:每秒完成的寫I/0裝置次數。即delta(wio)/s rsec/s:每秒讀扇區數。即delta(rsect)/s wsec/s:每秒寫扇區數。即delta(wsect)/s rKB/s:每秒讀K位元組數。是rsec/s的一半,因為每扇區大小為512位元組 wKB/s:每秒寫K位元組數。是wsec/s的一半 avgrq-sz:平均每次裝置I/O操作的資料大小(扇區)。即delta(rsect+wsect)/delta(rio+wio) avgqu-sz:平均I/O隊列長度。即delta(aveq)/s/1000(因為aveq的單位為毫秒) await:平均每次裝置I/O操作的等待時間(毫秒)。即delta(ruse+wuse)/delta(rio+wio) svctm:平均每次裝置I/O操作的服務時間(毫秒)。即delta(use)/delta(rio+wio) %util:一秒中有百分之多少的時間用於I/O操作,或者說一秒中有多少時間I/O隊列是非空的。即delta(usr)/s/1000(因為use的單位為毫秒)
如果%util接近100%,表明I/O請求太多,I/O系統已經滿負荷,磁碟可能存在瓶頸,一般%util大於70%,I/O壓力就比較大.
svctm一般要小於await(因為同時等待的請求的等待時間被重複計算了),svctm的大小一般和磁碟效能有關,CPU/記憶體的負荷也會對其有影響,請求過多也會間接導致svctm的增加。await的大小一般取決於服務時間(svctm)以及I/O隊列的長度和I/O請求的發出模式。如果svctm比較接近await,說明I/O幾乎沒有等待時間;如果await遠大於svctm,說明I/O隊列太長,應用得到的回應時間變慢,如果回應時間超過了使用者可以容許的範圍,這時可以考慮更換更快的磁碟,調整核心elevator演算法,最佳化應用,或者升級CPU
隊列長度(avcqu-sz)也可作為衡量系統I/O負荷的指標,但由於avcqu-sz是按照單位時間的平均值,所以不能反映瞬間的I/O洪水。
iostat -x 1 查看磁碟的IO負載