磁盤IO是檢查磁盤性能的重要指標,能夠按照負載狀況分紅照順序讀寫,隨機讀寫兩大類。linux
fio 是測試磁盤性能的最佳工具:bash
ddif=/dev/zero of=/root/test bs=4kcount=524288 (建立2G文件)ide
1、測試順序讀性能工具
fio --filename=/root/test -iodepth=64 -ioengine=libaio --direct=1 --rw=read --bs=1m --size=2g --numjobs=4 --runtime=10 --group_reporting --name=test-read
2、測試順序寫性能性能
fio -filename=/root/test -iodepth=64 -ioengine=libaio -direct=1 -rw=write -bs=1m -size=2g -numjobs=4 -runtime=20 -group_reporting -name=test-write
3、測試隨機讀性能測試
fio -filename=/root/test -iodepth=64 -ioengine=libaio -direct=1 -rw=randread -bs=4k -size=2G -numjobs=64 -runtime=20 -group_reporting -name=test-rand-read
4、測試隨機寫性能spa
fio -filename=/root/test -iodepth=64 -ioengine=libaio-direct=1 -rw=randwrite -bs=4k -size=2G -numjobs=64 -runtime=20-group_reporting -name=test-rand-write
參數說明:
.net
filename=/root/test 測試文件名稱,一般選擇須要測試的盤的data目錄。
direct=1 測試過程繞過機器自帶的buffer。使測試結果更真實。
rw=randwrite 測試隨機寫的I/O
rw=randrw 測試隨機寫和讀的I/O
bs=4k 單次io的塊文件大小爲4k
size=2g 本次的測試文件大小爲2g,以每次4k的io進行測試。
numjobs=64 本次的測試線程爲64.
runtime=20 測試時間爲20秒,若是不寫則一直將2g文件分4k每次寫完爲止。線程
報告如何查看:
fio的結果報告內容豐富,咱們主要關心的是兩項:blog
磁盤的吞吐量bw,這個是順序讀寫考察的重點
磁盤的每秒讀寫次數iops,這個是隨機讀寫考察的重點
好比,下面是4個測試的結果部分截取:
test-read:(groupid=0, jobs=4): err= 0: pid=4752
read : io=839680KB, bw=76823KB/s, iops=75 , runt= 10930msec
順序讀,帶寬76823KB/s,iops 75
test-write:(groupid=0, jobs=4): err= 0: pid=4758
write: io=899072KB, bw=42854KB/s, iops=41 , runt= 20980msec
順序寫,帶寬42854KB/s, iops=41
test-rand-read:(groupid=0, jobs=64): err= 0: pid=4619
read : io=72556KB, bw=3457.4KB/s, iops=864 , runt= 20986msec
隨機讀,帶寬3457.4KB/s, iops=864
test-rand-write:(groupid=0, jobs=64): err= 0: pid=4685
write: io=129264KB, bw=6432.4KB/s, iops=1608 , runt= 20097msec
隨機寫,帶寬6432.4KB/s, iops=1608
引用: