FIO是測試IOPS的非常好的工具,用來對(duì)硬件進(jìn)行壓力測試和驗(yàn)證,支持19種不同的I/O引擎,包括:sync, mmap, libaio, posixaio, SG v3, splice, null, network, syslet, guasi, solarisaio 等等。
FIO官網(wǎng):http://freecode.com/projects/fio/
0x01 安裝
可以直接yum進(jìn)行安裝,也可以下載壓縮包進(jìn)行安裝
$ yum install fio
0x02 命令
- 隨機(jī)讀:
$ fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=4k -size=60G -numjobs=64 -runtime=10 -group_reporting -name=file
- 順序讀:
$ fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=read -ioengine=psync -bs=4k -size=60G -numjobs=64 -runtime=10 -group_reporting -name=file
- 隨機(jī)寫:
$ fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=randwrite -ioengine=psync -bs=4k -size=60G -numjobs=64 -runtime=10 -group_reporting -name=file
- 順序讀:
$ fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=write -ioengine=psync -bs=4k -size=60G -numjobs=64 -runtime=10 -group_reporting -name=file
- 混合隨機(jī)讀寫:
$ fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=randrw -rwmixread=30 -ioengine=psync -bs=4k -size=60G -numjobs=64 -runtime=10 -group_reporting -name=file -ioscheduler=noop
PS:
filename=/dev/sda1:測試文件名稱,通常選擇需要測試的盤的data目錄
direct=1:測試過程繞過機(jī)器自帶的buffer。使測試結(jié)果更真實(shí)
rw=randwrite:測試隨機(jī)寫的I/O
rw=randrw:測試隨機(jī)寫和讀的I/O
rw=randread:測試隨機(jī)讀的I/O
bs=4k:單次io的塊文件大小為4k
bsrange=512-2048:同上,提定數(shù)據(jù)塊的大小范圍
size=60g:本次的測試文件大小為60g,以每次4k的io進(jìn)行測試
numjobs=64:本次的測試線程為64
runtime=10:測試時(shí)間為10秒,如果不寫則一直將5g文件分4k每次寫完為止
ioengine=psync:io引擎使用pync方式
rwmixwrite=30:在混合讀寫的模式下,寫占30%
group_reporting:關(guān)于顯示結(jié)果的,匯總每個(gè)進(jìn)程的信息。
此外
lockmem=1g:只使用1g內(nèi)存進(jìn)行測試
zero_buffers:用0初始化系統(tǒng)buffer
nrfiles=8:每個(gè)進(jìn)程生成文件的數(shù)量。
0x03 實(shí)例測試
此例是測試隨機(jī)讀,文中bw=1532.2KB/s, iops=383即是測試出的iops
$ fio -filename=/dev/sda1 -direct=1 -rw=randread -bs=4k -size 60G -numjobs=64 -runtime=10 -group_reporting -name=file
file: (g=0): rw=randread, bs=4K-4K/4K-4K, ioengine=sync, iodepth=1
...
file: (g=0): rw=randread, bs=4K-4K/4K-4K, ioengine=sync, iodepth=1
fio 1.57
Starting 64 processes
Jobs: 4 (f=4): [______r_______________________r_r_______r_______________________] [3.5% done] [745K/0K /s] [181 /0 iops] [eta 12m:26s]s]
file: (groupid=0, jobs=64): err= 0: pid=8717
read : io=15792KB, bw=1532.2KB/s, iops=383, runt= 10307msec
clat (usec): min=78 , max=1303.3K, avg=99439.90, stdev=12973.11
lat (usec): min=78 , max=1303.3K, avg=99440.39, stdev=12973.10
bw (KB/s) : min= 3, max= 150, per=2.52%, avg=38.61, stdev= 2.45
cpu : usr=0.01%, sys=0.68%, ctx=4026, majf=0, minf=1961
IO depths : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
issued r/w/d: total=3948/0/0, short=0/0/0
lat (usec): 100=0.13%, 250=0.61%, 500=0.25%, 750=0.08%, 1000=0.03%
lat (msec): 2=0.03%, 4=0.10%, 10=0.76%, 20=1.85%, 50=10.61%
lat (msec): 100=18.90%, 250=47.21%, 500=19.02%, 750=0.28%, 1000=0.10%
lat (msec): 2000=0.05%
Run status group 0 (all jobs):
READ: io=15792KB, aggrb=1532KB/s, minb=1568KB/s, maxb=1568KB/s, mint=10307msec, maxt=10307msec
Disk stats (read/write):
sda: ios=3931/13, merge=0/13, ticks=584686/184, in_queue=584841, util=98.53%