備注:
使用的是yum 進行的安裝,大家可以使用源碼編譯安裝(centos 7)
安裝
yum install -y fio
命令行參數
fio-2.2.8
fio [options] [job options] <job file(s)>
--debug=options Enable debug logging. May be one/more of:
process,file,io,mem,blktrace,verify,random,parse,
diskutil,job,mutex,profile,time,net,rate,compress
--parse-only Parse options only, don't start any IO
--output Write output to file
--runtime Runtime in seconds
--bandwidth-log Generate per-job bandwidth logs
--minimal Minimal (terse) output
--output-format=x Output format (terse,json,normal)
--terse-version=x Set terse version output format to 'x'
--version Print version info and exit
--help Print this page
--cpuclock-test Perform test/validation of CPU clock
--crctest Test speed of checksum functions
--cmdhelp=cmd Print command help, "all" for all of them
--enghelp=engine Print ioengine help, or list available ioengines
--enghelp=engine,cmd Print help for an ioengine cmd
--showcmd Turn a job file into command line options
--eta=when When ETA estimate should be printed
May be "always", "never" or "auto"
--eta-newline=time Force a new line for every 'time' period passed
--status-interval=t Force full status dump every 't' period passed
--readonly Turn on safety read-only checks, preventing writes
--section=name Only run specified section in job file
--alloc-size=kb Set smalloc pool to this size in kb (def 1024)
--warnings-fatal Fio parser warnings are fatal
--max-jobs=nr Maximum number of threads/processes to support
--server=args Start a backend fio server
--daemonize=pidfile Background fio server, write pid to file
--client=hostname Talk to remote backend fio server at hostname
--remote-config=file Tell fio server to load this local job file
--idle-prof=option Report cpu idleness on a system or percpu basis
(option=system,percpu) or run unit work
calibration only (option=calibrate)
--trigger-file=file Execute trigger cmd when file exists
--trigger-timeout=t Execute trigger af this time
--trigger=cmd Set this command as local trigger
--trigger-remote=cmd Set this command as remote trigger
使用
filename: 指定文件(設備)的名稱。可以通過冒號分割同時指定多個文件,如filename=/dev/sda:/dev/sdb。
directory: 設置filename的路徑前綴。在后面的基准測試中,采用這種方式來指定設備。
name: 指定job的名字,在命令行中表示新啟動一個job。
direct: bool類型,如果設置成true (1),表示不使用io buffer。
ioengine: I/O引擎,現在fio支持19種ioengine。默認值是sync同步阻塞I/O,libaio是Linux的native異步I/O。關於同步異步,阻塞和非阻塞模型可以參考文章“使用異步 I/O 大大提高應用程序的性能”。
http://www.ibm.com/developerworks/cn/linux/l-async/
iodepth: 如果ioengine采用異步方式,該參數表示一批提交保持的io單元數。該參數可參考文章“Fio壓測工具和io隊列深度理解和誤區”。
http://blog.yufeng.info/archives/2104
rw: I/O模式,隨機讀寫,順序讀寫等等。
bs: I/O block大小,默認是4k。
size: 指定job處理的文件的大小。
numjobs: 指定job的克隆數(線程)。
time_based: 如果在runtime指定的時間還沒到時文件就被讀寫完成,將繼續重復知道runtime時間結束。
runtime: 指定在多少秒后停止進程。如果未指定該參數,fio將執行至指定的文件讀寫完全完成。
group_reporting: 當同時指定了numjobs了時,輸出結果按組顯示。
參考說明
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引擎使用psync方式
rwmixwrite=30 #在混合讀寫的模式下,寫占30%
group_reporting #關於顯示結果的,匯總每個進程的信息
lockmem=1G #只使用1g內存進行測試
zero_buffers #用0初始化系統buffer
nrfiles=8 #每個進程生成文件的數量
#順序讀
fio -filename=/dev/sda -direct=1 -iodepth 1 -thread -rw=read -ioengine=psync -bs=16k -size=200G -numjobs=30 -runtime=1000 -group_reporting -name=mytest
#順序寫
fio -filename=/dev/sda -direct=1 -iodepth 1 -thread -rw=write -ioengine=psync -bs=16k -size=200G -numjobs=30 -runtime=1000 -group_reporting -name=mytest
#隨機讀
fio -filename=/dev/sda -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=16k -size=200G -numjobs=30 -runtime=1000 -group_reporting -name=mytest
#隨機寫
fio -filename=/dev/sda -direct=1 -iodepth 1 -thread -rw=randwrite -ioengine=psync -bs=16k -size=200G -numjobs=30 -runtime=1000 -group_reporting -name=mytest
#混合隨機讀寫
fio -filename=/dev/sda -direct=1 -iodepth 1 -thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=16k -size=200G -numjobs=30 -runtime=100 -group_reporting -name=mytest -ioscheduler=noop
#復制下面的配置內容,將directory=/path/to/test修改為你測試硬盤掛載目錄的地址,並另存為fio.conf
[global]
ioengine=libaio
direct=1
thread=1
norandommap=1
randrepeat=0
runtime=60
ramp_time=6
size=1g
directory=/path/to/test
[read4k-rand]
stonewall
group_reporting
bs=4k
rw=randread
numjobs=8
iodepth=32
[read64k-seq]
stonewall
group_reporting
bs=64k
rw=read
numjobs=4
iodepth=8
[write4k-rand]
stonewall
group_reporting
bs=4k
rw=randwrite
numjobs=2
iodepth=4
[write64k-seq]
stonewall
group_reporting
bs=64k
rw=write
numjobs=2
iodepth=4
#測試
fio fio.conf