linux下硬盘性能(网络盘)测试工具fio使用

来源:互联网 发布:宇宙几维 知乎 编辑:程序博客网 时间:2024/05/17 09:15

FIO是测试IOPS的非常好的工具,用来对硬件进行压力测试和验证,支持13种不同的I/O引擎,包括:sync,mmap, libaio, posixaio, SG v3, splice, null, network, syslet, guasi, solarisaio 等等

查询是否安装过:
rpm -qa | grep fio

下载:
wget http://www.rpmfind.net/linux/dag/redhat/el6/en/x86_64/dag/RPMS/fio-2.0.9-1.el6.rf.x86_64.rpm

安装:
rpm -ivh fio-2.0.9-1.el6.rf.x86_64.rpm

典型应用:
fio -name=test -filename=/dev/sdb -ioengine=libaio -direct=1 -size=5g -thread -bs=1M -iodepth=128 -numjobs=8 -rw=write -group_reporting -runtime=30

5g内容,每次1M,写

二,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@localhost rpm]# fio -name=test -filename=/dev/sda -ioengine=libaio -direct=1 -size=5g -thread -bs=1M -iodepth=128 -numjobs=8 -rw=write -group_reporting -runtime=30test: (g=0): rw=write, bs=1M-1M/1M-1M, ioengine=libaio, iodepth=128...test: (g=0): rw=write, bs=1M-1M/1M-1M, ioengine=libaio, iodepth=128fio-2.0.9Starting 8 threadsJobs: 7 (f=7): [WWWWW_WW] [60.6% done] [0K/737.9M /s] [0 /737  iops] [eta 00m:26s]              test: (groupid=0, jobs=8): err= 0: pid=4713: Mon Dec 18 14:51:40 2017  write: io=25115MB, **bw=845395KB/s, iops=825 ,** runt= 30421msec    slat (usec): min=82 , max=767726 , avg=9577.80, stdev=41218.93    clat (msec): min=34 , max=3392 , avg=1205.98, stdev=523.79     lat (msec): min=133 , max=3393 , avg=1215.55, stdev=526.60    clat percentiles (msec):     |  1.00th=[  265],  5.00th=[  529], 10.00th=[  644], 20.00th=[  775],     | 30.00th=[  881], 40.00th=[  996], 50.00th=[ 1123], 60.00th=[ 1237],     | 70.00th=[ 1385], 80.00th=[ 1614], 90.00th=[ 1926], 95.00th=[ 2180],     | 99.00th=[ 2802], 99.50th=[ 3064], 99.90th=[ 3326], 99.95th=[ 3326],     | 99.99th=[ 3392]    bw (KB/s)  : min= 1041, max=453403, per=12.52%, avg=105871.80, stdev=56885.29    lat (msec) : 50=0.01%, 100=0.02%, 250=0.92%, 500=3.30%, 750=13.60%    lat (msec) : 1000=22.47%, 2000=51.27%, >=2000=8.43%  cpu          : usr=7.36%, sys=25.54%, ctx=45500, majf=0, minf=1119  IO depths    : 1=0.1%, 2=0.1%, 4=0.1%, 8=0.3%, 16=0.5%, 32=1.0%, >=64=98.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.1%     issued    : total=r=0/w=25115/d=0, short=r=0/w=0/d=0

主要查看以上加粗部分的bw , iops

原创粉丝点击