1.安裝:
方法一:直接用指令yum -y install fio
方法二:如果方法一不可行則,在官網http://freshmeat.net/projects/fio/下載fio的安裝包。安裝方法很簡單。解壓縮后,進入目錄輸入./configure make make install。
2.執行:
命令行:
fio -filename=/data/fiotest -direct=1 -ioengine=libaio -iodepth=16 -rw=randrw -rwmixwrite=70 -bs=64k -size=10G -numjobs=4 -runtime=60 -group_reporting -name=test_rw fio -filename=/data/fiotest -direct=1 -ioengine=libaio -iodepth=16 -rw=randrw -rwmixwrite=70 -bs=64k -size=10G -numjobs=4 -runtime=60 -group_reporting -name=test_rw
腳本:
vim /usr/local/src/fiotest.conf
[global] filename=/data/fiotest # the device/file name direct=1 # use raw io instead of buffered io ioengine=libaio # libaio is asynchronized io mode, sync is synchronized mode iodepth=16 # if use libaio, iodepth means the ios can be submitted at the same time. It is important! size=10G numjobs=5 # number of clones of processes/threads for each job runtime=60 # in seconds for each job name=test_read [rw64k-rand] stonewall # wait until the previous job is finished bs=64k rw=randrw rwmixwrite=70 group_reporting rw512k-rand] stonewall #wait until the previous job is finished bs=512k rw=randrw rwmixwrite=70 group_reporting
注意 fio測試指令需要在root權限下才能操作
第一個text是運行完后在/data 目錄下會生成一個5G的text文件。
第二個test_read是測試運行結果在屏幕上顯示的都是以test_read:。。。
3.關於參數:
-filename: 后可以直接加設備名 如-filename /dev/sdb1 ;也可以加設備的掛載點的文件名,如-filename=/data/testfile。
-directory: 設置filename的路徑前綴,入股filename有指定路徑,此項可以省略。
-direct: bool類型,如果設置成true (1),表示不使用io buffer,測試繞過機器自帶的buffer,測試結果更真實。
-ioengine=sync I/O引擎,現在fio支持19種ioengine。默認值是sync同步阻塞I/O,libaio是Linux的native異步I/O。
通常有同步和異步兩種方式。同步的io一次只能發出一個io請求,等待內核完成才返回,這樣對單線程來說iodepth總是小於1的,但多個線程並發可以使iodepth變大。異步方式就是一次提交一批請求,等待一批的完成,減少交互的次數
-iodepth: io隊列深度,當ioengine采用異步方式,該參數生效,表示一批提交保持的io單元數。
-rw有5種情況:
1.-rw=read
2.-rw=randread
3.-rw=write
4.-rw=randwrite
5.-rw=randrw -rwmixread=70 //混合模式下讀占百分之70
-bs: blocksize 每次讀寫的大小,默認是4k。
-size: 本次的測試文件的大小,默認以每次4k的io進行測試。
-numjobs: 指定job的克隆數(線程)。
-runtime: 指定在多少秒后停止進程。如果未指定該參數,fio將執行至指定的文件讀寫完全完成。
-group_reporting: 關於現實結果,匯總每個進程的信息,當同時指定了numjobs了時,輸出結果按組顯示。
-name: 指定job的名字,在命令行中表示新啟動一個job。
-time_based: 如果在runtime指定的時間還沒到時文件就被讀寫完成,將繼續重復直到runtime時間結束。
[THE END]