FIO是测试IOPS的非常好的工具,用来对硬件进行压力测试和验证,支持19种不同的I/O引擎,包括:sync, mmap, libaio, posixaio, SG v3, splice, null, network, syslet, guasi, solarisaio 等等。
FIO官网:http://freecode.com/projects/fio/
0x01 安装
可以直接yum进行安装,也可以下载压缩包进行安装
$ yum install fio
0x02 命令
- 随机读:
$ 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
- 随机写:
$ 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
- 混合随机读写:
$ 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:测试过程绕过机器自带的buffer。使测试结果更真实
rw=randwrite:测试随机写的I/O
rw=randrw:测试随机写和读的I/O
rw=randread:测试随机读的I/O
bs=4k:单次io的块文件大小为4k
bsrange=512-2048:同上,提定数据块的大小范围
size=60g:本次的测试文件大小为60g,以每次4k的io进行测试
numjobs=64:本次的测试线程为64
runtime=10:测试时间为10秒,如果不写则一直将5g文件分4k每次写完为止
ioengine=psync:io引擎使用pync方式
rwmixwrite=30:在混合读写的模式下,写占30%
group_reporting:关于显示结果的,汇总每个进程的信息。
此外
lockmem=1g:只使用1g内存进行测试
zero_buffers:用0初始化系统buffer
nrfiles=8:每个进程生成文件的数量。
0x03 实例测试
此例是测试随机读,文中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%