1FIO安装
FIO 工具用来测试裸盘的IO性能,直接操作存储设备,当然,在测试的时候,对会整个设备进行读写。如果不想对整盘进行操作,可以先用dd 命令,创建出一个文件,放在存储设备上,然后使用该文件进行测试。FIO 工具非常小巧,使用也很简单。
fio is an I/O tool meant to be used both for benchmark and stress/hardware verification. It has support for 19 different types of I/O engines (sync, mmap, libaio, posixaio, SG v3, splice, null, network, syslet, guasi, solarisaio, and more), I/O priorities (for newer Linux kernels), rate I/O, forked or threaded jobs, and much more. It can work on block devices as well as files. fio accepts job descriptions in a simple-to-understand text format. Several example job files are included. fio displays all sorts of I/O performance information, including complete IO latencies and percentiles. Fio is in wide use in many places, for both benchmarking, QA, and verification purposes. It supports Linux, FreeBSD, NetBSD, OpenBSD, OS X, OpenSolaris, AIX, HP-UX, Android, and Windows.
可以同github上下载:
安装FIO 依赖如下2个包
/dave/article/104
yuminstalllibaiolibaio-devel-y
[root@dave~]#ls
anaconda-ks.cfgDocumentsfio-2.1.10install.logMusicPublicVideos
DesktopDownloadsfio-2.1.10.tar.gzinstall.log.syslogPicturesTemplates
[root@dave~]#
[root@dave~]#tarxzvffio-2.1.10.tar.gz
[root@dave~]#cdfio-2.1.10
[root@davefio-2.1.10]#ls
archerr.hgclient.hHOWTOmemalign.cSERVER-TODO
backend.ceta.cgcompat.cidletime.cmemalign.hsmalloc.c
blktrace_api.hexamplesgcompat.hidletime.hmemory.csmalloc.h
blktrace.cfifo.cgerror.cinit.cminmax.hstat.c
cairo_text_helpers.cfifo.hgerror.hio_ddir.hmutex.cstat.h
cairo_text_helpers.hfile.hgettime.cioengine.hmutex.ht
cconv.cfilehash.cgettime.hioengines.coptions.ctd_error.c
cgroup.cfilehash.hgettime-thread.ciolog.coptions.htd_error.h
cgroup.hfilelock.cgfio.ciolog.hosthread_options.h
client.cfilelock.hgfio.hio_u.cparse.ctickmarks.c
client.hfilesetup.cGFIO-TODOio_u_queue.cparse.htickmarks.h
compilerfio.1ghelpers.cio_u_queue.hprinting.ctime.c
configurefio.cghelpers.hjson.cprinting.htools
COPYINGfio.hgoptions.cjson.hprofile.ctrim.c
crcfio_time.hgoptions.hlibprofile.htrim.h
debug.cFIO-VERSION-GENgraph.clibfio.cprofilesverify.c
debug.hflist.hgraph.hLICENSEREADMEverify.h
diskutil.cflow.chash.hlog.cREPORTING-BUGS
diskutil.hflow.hhelpers.clog.hserver.c
enginesgclient.chelpers.hMakefileserver.h
--安装
[root@davefio-2.1.10]#makeall
[root@davefio-2.1.10]#makeinstall
install-m755-d/usr/local/bin
installfiotools/fio_generate_plotstools/plot/fio2gnuplottools/genfio/usr/local/bin
install-m755-d/usr/local/man/man1
install-m644fio.1/usr/local/man/man1
install-m644tools/fio_generate_plots.1/usr/local/man/man1
install-m644tools/plot/fio2gnuplot.1/usr/local/man/man1
install-m755-d/usr/local/share/fio
install-m644tools/plot/*gpm/usr/local/share/fio/
2语法说明
[root@rac1~]#fio
Nojobs(s)defined
fio-2.1.10
fio[options][joboptions]
--debug=optionsEnabledebuglogging.Maybeone/moreof:
process,file,io,mem,blktrace,verify,random,parse,
diskutil,job,mutex,profile,time,net,rate
--parse-onlyParseoptionsonly,don'tstartanyIO
--outputWriteoutputtofile
--runtimeRuntimeinseconds
--latency-logGenerateper-joblatencylogs
--bandwidth-logGenerateper-jobbandwidthlogs
--minimalMinimal(terse)output
--output-format=xOutputformat(terse,json,normal)
--terse-version=xSetterseversionoutputformatto'x'
--versionPrintversioninfoandexit
--helpPrintthispage
--cpuclock-testPerformtest/validationofCPUclock
--crctestTestspeedofchecksumfunctions
--cmdhelp=cmdPrintcommandhelp,"all"forallofthem
--enghelp=enginePrintioenginehelp,orlistavailableioengines
--enghelp=engine,cmdPrinthelpforanioenginecmd
--showcmdTurnajobfileintocommandlineoptions
--eta=whenWhenETAestimateshouldbeprinted
Maybe"always","never"or"auto"
--eta-newline=timeForceanewlineforevery'time'periodpassed
--status-interval=tForcefullstatusdumpevery't'periodpassed
--readonlyTurnonsafetyread-onlychecks,preventingwrites
--section=nameOnlyrunspecifiedsectioninjobfile
--alloc-size=kbSetsmallocpooltothissizeinkb(def1024)
--warnings-fatalFioparserwarningsarefatal
--max-jobs=nrMaximumnumberofthreads/processestosupport
--server=argsStartabackendfioserver
--daemonize=pidfileBackgroundfioserver,writepidtofile
--client=hostnameTalktoremotebackendfioserverathostname
--idle-prof=optionReportcpuidlenessonasystemorpercpubasis
(option=system,percpu)orrununitwork
calibrationonly(option=calibrate)
FiowaswrittenbyJensAxboe
JensAxboe
JensAxboeaxboe@
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 每个进程生成文件的数量。
bw:磁盘的吞吐量,这个是顺序读写考察的重点
iops:磁盘的每秒读写次数,这个是随机读写考察的重点
--测试随机写带宽
fio--name=wbw--filename=/dev/dfa--numjobs=4--bs=128k--ioengine=libaio--direct=1--randrepeat=0--norandommap/
--rw=randwrite--group_reporting--iodepth=512--iodepth_batch=128--iodepth_batch_complete=128/
--gtod_reduce=1--runtime=30
fio--name=wlat--filename=/dev/dfa--numjobs=1--runtime=30--bs=4k--ioengine=libaio--direct=1--norandommap/
--randrepeat=0--rw=randwrite--group_reporting--iodepth=1--iodepth_batch_complete=0
--测试4k 随机写IOPS:
/dave/article/104
fio--name=wiops--filename=/dev/dfa--numjobs=4--bs=4k--ioengine=libaio--direct=1--randrepeat=0--norandommap/
--rw=randwrite--group_reporting--iodepth=512--iodepth_batch=128--iodepth_batch_complete=128/
--gtod_reduce=1--runtime=30
--测试4k 读带宽:
fio--name=rbw--filename=/dev/dfa--numjobs=4--bs=128k--ioengine=libaio--direct=1--randrepeat=0--norandommap/
--rw=randread--group_reporting--iodepth=512--iodepth_batch=128--iodepth_batch_complete=128/
--gtod_reduce=1--runtime=30
/dave/article/104/dave/article/104
--测试4k 随机读延迟:
fio--name=rlat--filename=/dev/dfa--numjobs=1--runtime=30--bs=4k--ioengine=libaio--direct=1--randrepeat=0/
--rw=randread--group_reporting--iodepth=1--iodepth_batch_complete=0
--测试4k 随机读IOPS:
fio--name=riops--filename=/dev/dfa--numjobs=4--bs=4k--ioengine=libaio--direct=1--randrepeat=0--norandommap/
--rw=randread--group_reporting--iodepth=512--iodepth_batch=128--iodepth_batch_complete=128/
--gtod_reduce=1--runtime=30
--随机读:
fio-filename=/dev/dfa-iodepth=1-ioengine=libaio-direct=1-rw=randread-bs=4k-size=1G-numjobs=10-runtime=20-group_reporting-name=test-rand-read
--随机写:
fio-filename=/home/test-iodepth=64-ioengine=libaio-direct=1-rw=randwrite-bs=4k-size=2G-numjobs=64-runtime=20-group_reporting-name=test-rand-write
--顺序读:
fio-filename=/dev/sdb1-direct=1-iodepth1-thread-rw=read-ioengine=psync-bs=16k-size=200G-numjobs=30-runtime=1000-group_reporting-name=mytest
--顺序写:
fio-filename=/dev/sdb1-direct=1-iodepth1-thread-rw=write-ioengine=psync-bs=16k-size=200G-numjobs=30-runtime=1000-group_reporting-name=mytest
--混合随机读写:
fio-filename=/dev/sdb1-direct=1-iodepth1-thread-rw=randrw-rwmixread=70-ioengine=psync-bs=16k-size=200G-numjobs=30-runtime=100-group_reporting-name=mytest-ioscheduler=noop
3实测示例
3.1 测试随机写带宽
[root@rac1~]#fio--name=wbw--filename=/dev/dfa--numjobs=4--bs=128k--ioengine=libaio--direct=1--randrepeat=0--norandommap/
>--rw=randwrite--group_reporting--iodepth=512--iodepth_batch=128--iodepth_batch_complete=128/
>--gtod_reduce=1--runtime=30
wbw:(g=0):rw=randwrite,bs=128K-128K/128K-128K/128K-128K,ioengine=libaio,iodepth=512
...
wbw:(g=0):rw=randwrite,bs=128K-128K/128K-128K/128K-128K,ioengine=libaio,iodepth=512
fio-2.0.13
Starting4processes
Jobs:4(f=4):[wwww][100.0%done][0K/1872M/0K/s][0/14.1K/0iops][eta00m:00s]
wbw:(groupid=0,jobs=4):err=0:pid=63788:MonDec2122:02:34
write:io=55887MB,bw=1858.2MB/s,iops=14865,runt=30076msec
cpu:usr=9.76%,sys=8.17%,ctx=12461,majf=0,minf=86
IOdepths:1=0.0%,2=0.0%,4=0.0%,8=0.0%,16=0.0%,32=0.0%,>=64=99.9%
submit:0=0.0%,4=0.0%,8=0.0%,16=0.0%,32=0.0%,64=0.1%,>=64=99.9%
complete:0=0.0%,4=0.0%,8=0.0%,16=0.0%,32=0.0%,64=0.0%,>=64=100.0%
issued:total=r=0/w=447096/d=0,short=r=0/w=0/d=0
Runstatusgroup0(alljobs):
WRITE:io=55887MB,aggrb=1858.2MB/s,minb=1858.2MB/s,maxb=1858.2MB/s,mint=30076msec,maxt=30076msec
Diskstats(read/write):
dfa:ios=0/444800,merge=0/0,ticks=0/16680784,in_queue=16760571,util=99.76%
[root@rac1~]#
/dave/article/104
3.2 测试4K 随机写延迟
[root@rac1~]#fio--name=wlat--filename=/dev/dfa--numjobs=1--runtime=30--bs=4k--ioengine=libaio--direct=1--norandommap/
>--randrepeat=0--rw=randwrite--group_reporting--iodepth=1--iodepth_batch_complete=0
wlat:(g=0):rw=randwrite,bs=4K-4K/4K-4K/4K-4K,ioengine=libaio,iodepth=1
fio-2.0.13
Starting1process
Jobs:1(f=1):[w][100.0%done][0K/351.6M/0K/s][0/89.1K/0iops][eta00m:00s]
wlat:(groupid=0,jobs=1):err=0:pid=66726:MonDec2122:10:48
write:io=10624MB,bw=362634KB/s,iops=90658,runt=30001msec
slat(usec):min=2,max=808,avg=3.92,stdev=1.20
clat(usec):min=0,max=960,avg=6.81,stdev=1.81
lat(usec):min=7,max=965,avg=10.79,stdev=2.16
clatpercentiles(usec):
|1.00th=[5],5.00th=[6],10.00th=[6],20.00th=[6],
|30.00th=[6],40.00th=[7],50.00th=[7],60.00th=[7],
|70.00th=[7],80.00th=[7],90.00th=[8],95.00th=[8],
|99.00th=[10],99.50th=[10],99.90th=[12],99.95th=[26],
|99.99th=[39]
bw(KB/s):min=355360,max=457536,per=100.00%,avg=362687.73,stdev=16744.99
lat(usec):2=0.01%,4=0.01%,10=98.14%,20=1.79%,50=0.05%
lat(usec):250=0.01%,500=0.01%,1000=0.01%
cpu:usr=14.04%,sys=86.05%,ctx=130,majf=0,minf=22
IOdepths: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=0/w=2719843/d=0,short=r=0/w=0/d=0
Runstatusgroup0(alljobs):
WRITE:io=10624MB,aggrb=362633KB/s,minb=362633KB/s,maxb=362633KB/s,mint=30001msec,maxt=30001msec
Diskstats(read/write):
dfa:ios=0/2711308,merge=0/0,ticks=0/18630,in_queue=18509,util=61.71%
[root@rac1~]#
3.3 测试4k 随机写IOPS
fio--name=wiops--filename=/dev/dfa--numjobs=4--bs=4k--ioengine=libaio--direct=1--randrepeat=0--norandommap/
--rw=randwrite--group_reporting--iodepth=512--iodepth_batch=128--iodepth_batch_complete=128/
--gtod_reduce=1--runtime=30
[root@rac1~]#fio--name=wiops--filename=/dev/dfa--numjobs=4--bs=4k--ioengine=libaio--direct=1--randrepeat=0--norandommap/
>--rw=randwrite--group_reporting--iodepth=512--iodepth_batch=128--iodepth_batch_complete=128/
>--gtod_reduce=1--runtime=30
wiops:(g=0):rw=randwrite,bs=4K-4K/4K-4K/4K-4K,ioengine=libaio,iodepth=512
...
wiops:(g=0):rw=randwrite,bs=4K-4K/4K-4K/4K-4K,ioengine=libaio,iodepth=512
fio-2.0.13
Starting4processes
Jobs:4(f=4):[wwww][100.0%done][0K/1856M/0K/s][0/475K/0iops][eta00m:00s]
wiops:(groupid=0,jobs=4):err=0:pid=65083:MonDec2122:06:03
write:io=55594MB,bw=1852.1MB/s,iops=474338,runt=30004msec
cpu:usr=6.03%,sys=36.80%,ctx=5450027,majf=0,minf=86
IOdepths:1=0.0%,2=0.0%,4=0.0%,8=0.0%,16=0.0%,32=0.0%,>=64=100.0%
submit:0=0.0%,4=0.0%,8=0.0%,16=0.0%,32=0.0%,64=0.1%,>=64=100.0%
complete:0=0.0%,4=0.0%,8=0.0%,16=0.0%,32=0.0%,64=0.0%,>=64=100.0%
issued:total=r=0/w=14232056/d=0,short=r=0/w=0/d=0
Runstatusgroup0(alljobs):
WRITE:io=55594MB,aggrb=1852.1MB/s,minb=1852.1MB/s,maxb=1852.1MB/s,mint=30004msec,maxt=30004msec
Diskstats(read/write):
dfa:ios=0/14187613,merge=0/0,ticks=0/50514448,in_queue=53271406,util=100.00%
[root@rac1~]#
3.4 测试4k 读带宽
[root@rac1~]#fio--name=rbw--filename=/dev/dfa--numjobs=4--bs=128k--ioengine=libaio--direct=1--randrepeat=0--norandommap--rw=randread--group_reporting--iodepth=512--iodepth_batch=128--iodepth_batch_complete=128--gtod_reduce=1--runtime=30
rbw:(g=0):rw=randread,bs=128K-128K/128K-128K/128K-128K,ioengine=libaio,iodepth=512
...
rbw:(g=0):rw=randread,bs=128K-128K/128K-128K/128K-128K,ioengine=libaio,iodepth=512
fio-2.0.13
Starting4processes
Jobs:4(f=4):[rrrr][100.0%done][12064M/0K/0K/s][96.6K/0/0iops][eta00m:00s]
rbw:(groupid=0,jobs=4):err=0:pid=67769:MonDec2122:14:10
read:io=362047MB,bw=12065MB/s,iops=96520,runt=30008msec
cpu:usr=0.78%,sys=99.30%,ctx=151,majf=0,minf=2262
IOdepths:1=0.0%,2=0.0%,4=0.0%,8=0.0%,16=0.0%,32=0.0%,>=64=100.0%
submit:0=0.0%,4=0.0%,8=0.0%,16=0.0%,32=0.0%,64=0.1%,>=64=100.0%
complete:0=0.0%,4=0.0%,8=0.0%,16=0.0%,32=0.0%,64=0.0%,>=64=100.0%
issued:total=r=2896376/w=0/d=0,short=r=0/w=0/d=0
Runstatusgroup0(alljobs):
READ:io=362047MB,aggrb=12065MB/s,minb=12065MB/s,maxb=12065MB/s,mint=30008msec,maxt=30008msec
Diskstats(read/write):
dfa:ios=2887839/0,merge=0/0,ticks=163897/0,in_queue=166373,util=100.00%
3.5 测试4k 随机读延迟
[root@rac1~]#fio--name=rlat--filename=/dev/dfa--numjobs=1--runtime=30--bs=4k--ioengine=libaio--direct=1--randrepeat=0/
>--rw=randread--group_reporting--iodepth=1--iodepth_batch_complete=0
rlat:(g=0):rw=randread,bs=4K-4K/4K-4K/4K-4K,ioengine=libaio,iodepth=1
fio-2.0.13
Starting1process
Jobs:1(f=1):[r][100.0%done][779.2M/0K/0K/s][199K/0/0iops][eta00m:00s]
rlat:(groupid=0,jobs=1):err=0:pid=68757:MonDec2122:16:43
read:io=23251MB,bw=793604KB/s,iops=198401,runt=30001msec
slat(usec):min=1,max=65,avg=2.14,stdev=0.55
clat(usec):min=0,max=86,avg=2.47,stdev=11.08
lat(usec):min=2,max=88,avg=4.67,stdev=11.16
clatpercentiles(usec):
|1.00th=[0],5.00th=[0],10.00th=[0],20.00th=[0],
|30.00th=[0],40.00th=[0],50.00th=[0],60.00th=[0],
|70.00th=[1],80.00th=[1],90.00th=[1],95.00th=[1],
|99.00th=[64],99.50th=[65],99.90th=[68],99.95th=[69],
|99.99th=[69]
bw(KB/s):min=779168,max=809720,per=99.98%,avg=793466.98,stdev=7401.14
lat(usec):2=96.18%,4=0.02%,10=0.01%,20=0.01%,50=0.13%
lat(usec):100=3.66%
cpu:usr=17.58%,sys=82.52%,ctx=32,majf=0,minf=24
IOdepths: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=5952229/w=0/d=0,short=r=0/w=0/d=0
Runstatusgroup0(alljobs):
READ:io=23251MB,aggrb=793604KB/s,minb=793604KB/s,maxb=793604KB/s,mint=30001msec,maxt=30001msec
Diskstats(read/write):
dfa:ios=5908454/0,merge=0/0,ticks=24555/0,in_queue=24571,util=81.92%
/dave/article/104
3.6 测试4k 随机读IOPS
[root@rac1~]#fio--name=riops--filename=/dev/dfa--numjobs=4--bs=4k--ioengine=libaio--direct=1--randrepeat=0--norandommap/
>--rw=randread--group_reporting--iodepth=512--iodepth_batch=128--iodepth_batch_complete=128/
>--gtod_reduce=1--runtime=30
riops:(g=0):rw=randread,bs=4K-4K/4K-4K/4K-4K,ioengine=libaio,iodepth=512
...
riops:(g=0):rw=randread,bs=4K-4K/4K-4K/4K-4K,ioengine=libaio,iodepth=512
fio-2.0.13
Starting4processes
Jobs:4(f=4):[rrrr][100.0%done][7001M/0K/0K/s][1792K/0/0iops][eta00m:00s]
riops:(groupid=0,jobs=4):err=0:pid=69105:MonDec2122:17:59
read:io=209962MB,bw=6998.6MB/s,iops=1791.7K,runt=30001msec
cpu:usr=8.08%,sys=92.01%,ctx=241,majf=0,minf=2138
IOdepths:1=0.0%,2=0.0%,4=0.0%,8=0.0%,16=0.0%,32=0.0%,>=64=100.0%
submit:0=0.0%,4=0.0%,8=0.0%,16=0.0%,32=0.0%,64=0.1%,>=64=100.0%
complete:0=0.0%,4=0.0%,8=0.0%,16=0.0%,32=0.0%,64=0.0%,>=64=100.0%
issued:total=r=53750392/w=0/d=0,short=r=0/w=0/d=0
Runstatusgroup0(alljobs):
READ:io=209962MB,aggrb=6998.6MB/s,minb=6998.6MB/s,maxb=6998.6MB/s,mint=30001msec,maxt=30001msec
Diskstats(read/write):
dfa:ios=53591338/0,merge=0/0,ticks=164668/0,in_queue=210358,util=100.00%
[root@rac1~]#
/dave/article/104
版权声明:本文为博主原创文章,未经博主允许。
如果觉得《fio模拟mysql写入速度_IO压力测试工具 -- FIO 使用说明》对你有帮助,请点赞、收藏,并留下你的观点哦!