FIO是测试IOPS的非常好的工具,用来对硬件进行压力测试和验证,支持13种不同的I/O引擎,包括:sync,mmap, libaio, posixaio, SG v3, splice, null, network, syslet, guasi, solarisaio 等等。
fio 官网地址:http://freshmeat.net/projects/fio/
一,FIO安装
wget http://brick.kernel.dk/snaps/fio-2.2.5.tar.gz
yum install libaio-devel -y && tar -zxvf fio-2.2.5.tar.gz
cd fio-2.2.5
make && make install && echo $?
二,FIO用法:
随机读:(可直接用,向磁盘写一个2G文件,10线程,随机读1分钟,给出结果)
fio -filename=/tmp/test_randread -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=16k -size=2G -numjobs=10 -runtime=60 -group_reporting -name=mytest
说明:
filename=/dev/sdb1 测试文件名称,通常选择需要测试的盘的data目录。
direct=1 测试过程绕过机器自带的buffer。使测试结果更真实。
rw=randwrite 测试随机写的I/O
rw=randrw 测试随机写和读的I/O
bs=16k 单次io的块文件大小为16k
bsrange=512-2048 同上,提定数据块的大小范围
size=5g 本次的测试文件大小为5g,以每次4k的io进行测试。
numjobs=30 本次的测试线程为30.
runtime=1000 测试时间为1000秒,如果不写则一直将5g文件分4k每次写完为止。
ioengine=psync io引擎使用pync方式
rwmixwrite=30 在混合读写的模式下,写占30%
group_reporting 关于显示结果的,汇总每个进程的信息。
此外
lockmem=1g 只使用1g内存进行测试。
zero_buffers 用0初始化系统buffer。
nrfiles=8 每个进程生成文件的数量。
read 顺序读
write 顺序写
rw,readwrite 顺序混合读写
randwrite 随机写
randread 随机读
randrw 随机混合读写
io总的输入输出量
bw:带宽 KB/s
iops:每秒钟的IO数
runt:总运行时间
lat (msec):延迟(毫秒)
msec: 毫秒
usec: 微秒
顺序读:
fio -filename=/dev/sdb1 -direct=1 -iodepth 1 -thread -rw=read -ioengine=psync -bs=16k -size=2G -numjobs=10 -runtime=60 -group_reporting -name=mytest
随机写:
fio -filename=/dev/sdb1 -direct=1 -iodepth 1 -thread -rw=randwrite -ioengine=psync -bs=16k -size=2G -numjobs=10 -runtime=60 -group_reporting -name=mytest
顺序写:
fio -filename=/dev/sdb1 -direct=1 -iodepth 1 -thread -rw=write -ioengine=psync -bs=16k -size=2G -numjobs=10 -runtime=60 -group_reporting -name=mytest
混合随机读写:
fio -filename=/dev/sdb1 -direct=1 -iodepth 1 -thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=16k -size=2G -numjobs=10 -runtime=60 -group_reporting -name=mytest -ioscheduler=noop
三,实际测试范例:
[root@nginx fio-2.2.5]# fio -filename=/dev/sda2 -direct=1 -iodepth 1 -thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=16k -size=200G -numjobs=30 -runtime=100 -groupreporting -name=mytest1
mytest1: (g=0): rw=randrw, bs=16K-16K/16K-16K/16K-16K, ioengine=psync, iodepth=1
...
fio-2.2.5
Starting 30 threads
Jobs: 2 (f=2): [(3),m(1),(19),m(1),(6)] [3.5% done] [0KB/143KB/0KB /s] [0/8/0 iops] [eta 47m:06s] s]
mytest1: (groupid=0, jobs=30): err= 0: pid=4347: Mon Jun 8 18:24:21 2020
read : io=36432KB, bw=361572B/s, iops=22, runt=103178msec
clat (usec): min=22, max=526464, avg=3280.98, stdev=14214.11
lat (usec): min=22, max=526464, avg=3281.43, stdev=14214.12
clat percentiles (usec):
| 1.00th=[ 26], 5.00th=[ 33], 10.00th=[ 38], 20.00th=[ 50],
| 30.00th=[ 65], 40.00th=[ 85], 50.00th=[ 105], 60.00th=[ 121],
| 70.00th=[ 139], 80.00th=[ 177], 90.00th=[13888], 95.00th=[20608],
| 99.00th=[41728], 99.50th=[50432], 99.90th=[110080], 99.95th=[130560],
| 99.99th=[528384]
bw (KB /s): min= 2, max= 121, per=4.37%, avg=15.43, stdev=13.24
write: io=16416KB, bw=162922B/s, iops=9, runt=103178msec
clat (msec): min=14, max=6217, avg=2965.73, stdev=1323.21
lat (msec): min=14, max=6217, avg=2965.73, stdev=1323.21
clat percentiles (msec):
| 1.00th=[ 31], 5.00th=[ 41], 10.00th=[ 64], 20.00th=[ 2769],
| 30.00th=[ 3032], 40.00th=[ 3130], 50.00th=[ 3228], 60.00th=[ 3326],
| 70.00th=[ 3490], 80.00th=[ 3752], 90.00th=[ 4113], 95.00th=[ 4621],
| 99.00th=[ 5932], 99.50th=[ 5997], 99.90th=[ 6194], 99.95th=[ 6194],
| 99.99th=[ 6194]
bw (KB /s): min= 2, max= 30, per=3.21%, avg= 5.10, stdev= 2.59
lat (usec) : 50=13.50%, 100=19.26%, 250=24.83%, 500=1.06%, 750=0.18%
lat (usec) : 1000=0.09%
lat (msec) : 2=0.09%, 4=0.15%, 10=1.09%, 20=5.12%, 50=5.54%
lat (msec) : 100=2.06%, 250=0.27%, 500=0.06%, 750=0.06%, 1000=0.03%
lat (msec) : 2000=0.15%, >=2000=26.46%
cpu : usr=0.00%, sys=0.01%, ctx=3325, majf=0, minf=14
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 : total=r=2277/w=1026/d=0, short=r=0/w=0/d=0, drop=r=0/w=0/d=0
latency : target=0, window=0, percentile=100.00%, depth=1
Run status group 0 (all jobs):
READ: io=36432KB, aggrb=353KB/s, minb=353KB/s, maxb=353KB/s, mint=103178msec, maxt=103178msec
WRITE: io=16416KB, aggrb=159KB/s, minb=159KB/s, maxb=159KB/s, mint=103178msec, maxt=103178msec
Disk stats (read/write):
sda: ios=2314/1339, merge=0/48, ticks=7712/3080155, in_queue=3094038, util=100.00%