fio是測量磁盤IO性能的重要工具之一,可以很好的測試IOPS。在進行性能測試的時候建議使用裸盤的方式進行測試,會得到比較真實的數據。
fio安裝:
yum install fio
fio的卸載:
yum remove fio
使用命令fio判斷是否安裝成功,顯示報錯:
[root@localhost data]# fio
fio: error while loading shared libraries: libboost_thread-mt.so.1.53.0: cannot open shared object file: no such file or directory
使用下面指令解決報錯:
yum remove boost
yum install boost
yum install boost-devel
yum install boost-doc
sudo ln -s /usr/lib64/libboost_thread-mt.so libboost_thread-mt.so.1.53.0
然後報錯消失,顯示如下:
[root@localhost data]# fio
No job(s) defined
fio-3.7
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,
steadystate,helperthread
--parse-only Parse options only, don't start any IO
--output Write output to file
--bandwidth-log Generate aggregate bandwidth logs
--minimal Minimal (terse) output
--output-format=type Output format (terse,json,json+,normal)
--terse-version=type Set terse version output format (default 3, or 2 or 4)
--version Print version info and exit
--help Print this page
--cpuclock-test Perform test/validation of CPU clock
--crctest=[type] 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, multiple sections can be specified
--alloc-size=kb Set smalloc pool to this size in kb (def 16384)
--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(s) 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)
--inflate-log=log Inflate and output compressed log
--trigger-file=file Execute trigger cmd when file exists
--trigger-timeout=t Execute trigger at this time
--trigger=cmd Set this command as local trigger
--trigger-remote=cmd Set this command as remote trigger
--aux-path=path Use this path for fio state generated files
測試順序讀性能:
fio --filename=/home/test -iodepth=64 -ioengine=libaio --direct=1 --rw=read --bs=1m --size=2g --numjobs=4 --runtime=10 --group_reporting --name=test-read
測試順序寫性能:
fio -filename=/home/test -iodepth=64 -ioengine=libaio -direct=1 -rw=write -bs=1m -size=2g -numjobs=4 -runtime=20 -group_reporting -name=test-write
測試隨機讀性能:
fio -filename=/home/test -iodepth=64 -ioengine=libaio -direct=1 -rw=randread -bs=4k -size=2G -numjobs=64 -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
參數說明:
filename=/home/test 測試文件名稱,通常選擇需要測試的盤的data目錄。
direct=1 測試過程繞過機器自帶的buffer。使測試結果更真實。
rw=randwrite 測試隨機寫的I/O
rw=randrw 測試隨機寫和讀的I/O
bs=4k 單次io的塊文件大小爲4k
size=2g 本次的測試文件大小爲2g,以每次4k的io進行測試。
numjobs=64 本次的測試線程爲64
runtime=20 測試時間爲20秒,如果不寫則一直將2g文件分4k每次寫完爲止。