ECS-CentOS使用FIO测试磁盘的iops
一、fio的安装(提供两种方式源码或者yum安装都可以)
1、源码安装方式
fio 官网地址:http://freshmeat.net/projects/fio/
wget http://brick.kernel.dk/snaps/fio-2.2.9.tar.gz
yum install libaio-devel
tar -zxvf fio-2.2.9.tar.gz && cd fio-2.2.9 && make && make install
2、yum方式安装
yum -y install fio.x86_64 libaio-devel
二、fio用法
说明:
filename=/dev/sdb1 测试的磁盘分区
direct=1 去除buffer,使测试结果更真实
iodepth 队列深度,只有使用libaio时才有意义。这是一个可以影响IOPS的参数。
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=libaio io引擎使用libaio方式
rwmixwrite=30 在混合读写的模式下,写占30%
group_reporting 关于显示结果的,汇总每个进程的信息。
此外
lockmem=1g 只使用1g内存进行测试。
zero_buffers 用0初始化系统buffer。
nrfiles=8 每个进程生成文件的数量。随机读:
fio-filename=/dev/sdb1 -direct=1 -iodepth 64 -thread -rw=randread-ioengine=libaio -bs=4k -size=10G -numjobs=1 -runtime=1000 -group_reporting -name=/path/testfile
顺序读:
fio-filename=/dev/sdb1 -direct=1 -iodepth 64 -thread -rw=read-ioengine=libaio -bs=4k -size=10G -numjobs=1 -runtime=1000 -group_reporting -name=/path/testfile
随机写:
fio-filename=/dev/sdb1 -direct=1 -iodepth 64 -thread -rw=randwrite-ioengine=libaio -bs=4k -size=10G -numjobs=1 -runtime=1000 -group_reporting -name=/path/testfile
顺序写:
fio-filename=/dev/sdb1 -direct=1 -iodepth 64 -thread -rw=write-ioengine=libaio -bs=4k -size=10G -numjobs=1 -runtime=1000 -group_reporting -name=/path/testfile
混合随机读写:
fio-filename=/dev/sdb1 -direct=1 -iodepth 64 -thread -rw=randrw-rwmixread=70 -ioengine=libaio -bs=16k -size=10G -numjobs=1-runtime=1000 -group_reporting -name=/path/testfileheduler=noop
三,实际测试范例:
[root@iZ2560jijrsZ~]# fio -filename=/dev/hda1 -direct=1 -iodepth 64 -thread -rw=randrw-rwmixread=70 -ioengine=libaio -bs=16k -size=10G -numjobs=1-runtime=1000 -group_reporting -name=mytest1
mytest1: (g=0): rw=randrw, bs=16K-16K/16K-16K/16K-16K, ioengine=libaio, iodepth=64
fio-2.0.14
Starting 1 thread
Jobs: 1 (f=1): [m] [100.0% done] [20480K/8484K/0K /s] [1280 /530 /0 iops] [eta 00m:00s]
mytest1: (groupid=0, jobs=1): err= 0: pid=1443: Sun Aug 23 07:03:05 2015
read : io=7168.4MB, bw=16062KB/s, iops=1003 , runt=456988msec
slat (usec): min=2 , max=1604 , avg= 7.46, stdev= 8.01
clat (msec): min=1 , max=1221 , avg=52.22, stdev=41.37
lat (msec): min=1 , max=1221 , avg=52.23, stdev=41.37
clat percentiles (msec):
| 1.00th=[ 11], 5.00th=[ 28], 10.00th=[ 33], 20.00th=[ 37],
| 30.00th=[ 40], 40.00th=[ 44], 50.00th=[ 48], 60.00th=[ 53],
| 70.00th=[ 59], 80.00th=[ 65], 90.00th=[ 74], 95.00th=[ 83],
| 99.00th=[ 116], 99.50th=[ 143], 99.90th=[ 947], 99.95th=[ 1037],
| 99.99th=[ 1172]
bw (KB/s) : min= 35, max=41184, per=100.00%, avg=16219.23, stdev=2531.62
write: io=3071.7MB, bw=6882.9KB/s, iops=430 , runt=456988msec
slat (usec): min=4 , max=20791 , avg=15.80, stdev=51.20
clat (usec): min=106 , max=1197.9K, avg=26859.39, stdev=30397.72
lat (msec): min=1 , max=1197 , avg=26.88, stdev=30.40
clat percentiles (msec):
| 1.00th=[ 5], 5.00th=[ 7], 10.00th=[ 9], 20.00th=[ 12],
| 30.00th=[ 16], 40.00th=[ 20], 50.00th=[ 24], 60.00th=[ 28],
| 70.00th=[ 33], 80.00th=[ 39], 90.00th=[ 47], 95.00th=[ 56],
| 99.00th=[ 79], 99.50th=[ 89], 99.90th=[ 388], 99.95th=[ 930],
| 99.99th=[ 1106]
bw (KB/s) : min= 52, max=17504, per=100.00%, avg=6948.33, stdev=1200.74
lat (usec) : 250=0.01%
lat (msec) : 2=0.01%, 4=0.12%, 10=4.62%, 20=10.44%, 50=50.46%
lat (msec) : 100=32.95%, 250=1.21%, 500=0.08%, 750=0.01%, 1000=0.05%
lat (msec) : 2000=0.05%
cpu : usr=0.69%, sys=1.56%, ctx=348174, majf=0, minf=5
IO depths : 1=0.1%, 2=0.1%, 4=0.1%, 8=0.1%, 16=0.1%, 32=0.1%, >=64=100.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.1%, >=64=0.0%
issued : total=r=458773/w=196587/d=0, short=r=0/w=0/d=0
Run status group 0 (all jobs):
READ: io=7168.4MB, aggrb=16062KB/s, minb=16062KB/s, maxb=16062KB/s, mint=456988msec, maxt=456988msec
WRITE: io=3071.7MB, aggrb=6882KB/s, minb=6882KB/s, maxb=6882KB/s, mint=456988msec, maxt=456988msec
Disk stats (read/write):
hda: ios=456900/196195, merge=1705/329, ticks=23848551/5263932, in_queue=29113419, util=100.00%