Linux下硬盤性能測試

1、使用dd命令讀寫數據。

[root@centos7-1605 ~]# dd  --help
用法:dd [操作數] ...
 或:dd 選項
Copy a file, converting and formatting according to the operands.

  bs=BYTES        read and write up to BYTES bytes at a time
  cbs=BYTES       convert BYTES bytes at a time
  conv=CONVS      convert the file as per the comma separated symbol list
  count=N         copy only N input blocks
  ibs=BYTES       read up to BYTES bytes at a time (default: 512)
  if=FILE         read from FILE instead of stdin
  iflag=FLAGS     read as per the comma separated symbol list
  obs=BYTES       write BYTES bytes at a time (default: 512)
  of=FILE         write to FILE instead of stdout
  oflag=FLAGS     write as per the comma separated symbol list
  seek=N          skip N obs-sized blocks at start of output
  skip=N          skip N ibs-sized blocks at start of input
  status=LEVEL    The LEVEL of information to print to stderr;
                  'none' suppresses everything but error messages,
                  'noxfer' suppresses the final transfer statistics,
                  'progress' shows periodic transfer statistics

N and BYTES may be followed by the following multiplicative suffixes:
c =1, w =2, b =512, kB =1000, K =1024, MB =1000*1000, M =1024*1024, xM =M
GB =1000*1000*1000, G =1024*1024*1024, and so on for T, P, E, Z, Y.

Each CONV symbol may be:

  ascii     from EBCDIC to ASCII
  ebcdic    from ASCII to EBCDIC
  ibm       from ASCII to alternate EBCDIC
  block     pad newline-terminated records with spaces to cbs-size
  unblock   replace trailing spaces in cbs-size records with newline
  lcase     change upper case to lower case
  ucase     change lower case to upper case
  sparse    try to seek rather than write the output for NUL input blocks
  swab      swap every pair of input bytes
  sync      pad every input block with NULs to ibs-size; when used
            with block or unblock, pad with spaces rather than NULs
  excl          fail if the output file already exists
  nocreat       do not create the output file
  notrunc       不截斷輸出文件
  noerror       讀取數據發生錯誤後仍然繼續
  fdatasync     結束前將輸出文件數據寫入磁盤
  fsync 類似上面,但是元數據也一同寫入

FLAG 符號可以是:

  append        追加模式(僅對輸出有意義;隱含了conv=notrunc)
  direct        使用直接I/O 存取模式
  directory     除非是目錄,否則 directory 失敗
  dsync         使用同步I/O 存取模式
  sync          與上者類似,但同時也對元數據生效
  fullblock     爲輸入積累完整塊(僅iflag)
  nonblock      使用無阻塞I/O 存取模式
  noatime       不更新存取時間
  nocache       丟棄緩存數據
  noctty        不根據文件指派控制終端
  nofollow      不跟隨鏈接文件
  count_bytes  treat 'count=N' as a byte count (iflag only)
  skip_bytes  treat 'skip=N' as a byte count (iflag only)
  seek_bytes  treat 'seek=N' as a byte count (oflag only)

Sending a USR1 signal to a running 'dd' process makes it
print I/O statistics to standard error and then resume copying.

  $ dd if=/dev/zero of=/dev/null& pid=$!
  $ kill -USR1 $pid; sleep 1; kill $pid
  18335302+0 records in
  18335302+0 records out
  9387674624 bytes (9.4 GB) copied, 34.6279 seconds, 271 MB/s

示例一、
[root@centos7-1605 ~]# dd  if=/dev/zero  of=testfile  bs=20M  count=100 conv=fdatasync
記錄了100+0 的讀入
記錄了100+0 的寫出
2097152000字節(2.1 GB)已複製,19.7587 秒,106 MB/秒
注意:多次測試最後求平均值,最好每次測試前將系統緩存刪除一下
echo  3> /proc/sys/vm/drop_caches
示例二、
time dd if=/dev/zero of=test.dbf bs=8k count=300000   oflag=direct
記錄了300000+0 的讀入
記錄了300000+0 的寫出
2457600000字節(2.5 GB)已複製,20.0179 秒,123 MB/秒

real	0m20.022s
user	0m0.158s
sys	0m6.429s

2、磁盤測試命令hdparm

1、 -t參數可以測試硬盤讀寫速率
[root@centos7-1605 ~]# hdparm  -t   /dev/sda2 

/dev/sda2:
 Timing buffered disk reads: 318 MB in  3.01 seconds = 105.61 MB/sec
[root@centos7-1605 ~]# 

 2、-T 參數可以測試內存緩存的速率
[root@centos7-1605 ~]# hdparm  -T  /dev/sda2

/dev/sda2:
 Timing cached reads:   12322 MB in  2.00 seconds = 6167.64 MB/sec

 不僅要測試

dmesg |grep sata 可以查看看sata硬盤的運行級別

3、測試軟件bonnie++

 在默認的yum源中是沒有bonnie++軟件的,我們需要在額外添加一個叫RepoForge的yum源,其官網地址爲http://repoforge.org/,

image.png

安裝CentOS7 yum源:

rpm -ivh  http://repository.it4i.cz/mirrors/repoforge/redhat/el7/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
yum install  -y bonnie++ #安裝測試軟件
測試
bonnie++ -u  root  #制定一個用戶即可使用默認參數測試
 默認會生成8G大小的文件,會分成8份會通過寫操作 讀操作、隨機操作等操作測試
 [root@centos7-1605 ~]# bonnie++   -u  root
Using uid:0, gid:0.
Writing a byte at a time...done
Writing intelligently...done
Rewriting...done
Reading a byte at a time...done
Reading intelligently...done
start 'em...done...done...done...done...done...
Create files in sequential order...done.
Stat files in sequential order...done.
Delete files in sequential order...done.
Create files in random order...done.
Stat files in random order...done.
Delete files in random order...done.
Version  1.97       ------Sequential Output------ --Sequential Input- --Random-
Concurrency   1     -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
centos7-1605. 7576M   709  99 101811   8 59275   6  2671  99 118595   5  6809 155
Latency             17472us   46186us    2002ms   10232us    1038ms    7091us
Version  1.97       ------Sequential Create------ --------Random Create--------
centos7-1605.local  -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                 16 +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++
Latency              1187us     111us     755us    1436us      29us   52394us
1.97,1.97,centos7-1605.local,1,1527113410,7576M,,709,99,101811,8,59275,6,2671,99,118595,5,6809,155,16,,,,,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,17472us,46186us,2002ms,10232us,1038ms,7091us,1187us,111us,755us,1436us,29us,52394us
主要有Sequential Output(順序輸出 寫操作) Sequential Input(循序輸入 讀操作) Random Seeks(隨機尋道)Sequential Create(順序創建)
Random Create(隨機創建)等部分
Per Chr 字符形式
Block  塊形式
Rewrite  重寫
%CP CPU的使用率
++號可能是值太小被忽略

4、 iozone測試硬盤狀態

    可以通過 write, re-write, read, re-read, random read, random write, random mix, backwards read, record rewirte, strided read, fwrite, frewrite, fread, freread, mmap, async I/0 等不同的模式下的硬盤的性能。
測試的時候請注意,設置的測試文件的大小一定要大過你的內存(最佳爲內存的兩倍大小),不然linux會給你的讀寫的內容進行緩存,會使數值非常不準確。

yum install -y  iozone
測試實例
iozone  -l 1 -u 1  -r  16K  -s 128M  -F /tmp/tmpfile
-l 最小線程 
-r 最大線程
-r  讀寫的塊
-s 制定文件 
-F 臨時文件
[root@centos7-1605 var]# iozone  -l 1 -u 1  -r  16K  -s 128M  -F /tmp/tmpfile
        Iozone: Performance Test of File I/O
                Version $Revision: 3.424 $
                Compiled for 64 bit mode.
                Build: linux-AMD64 

        Contributors:William Norcott, Don Capps, Isom Crawford, Kirby Collins
                     Al Slater, Scott Rhine, Mike Wisner, Ken Goss
                     Steve Landherr, Brad Smith, Mark Kelly, Dr. Alain CYR,
                     Randy Dunlap, Mark Montague, Dan Million, Gavin Brebner,
                     Jean-Marc Zucconi, Jeff Blomberg, Benny Halevy, Dave Boone,
                     Erik Habbinga, Kris Strecker, Walter Wong, Joshua Root,
                     Fabrice Bacchella, Zhenghua Xue, Qin Li, Darren Sawyer,
                     Vangel Bojaxhi, Ben England, Vikentsi Lapa.

        Run began: Wed May 23 23:22:38 2018

        Record Size 16 kB
        File size set to 131072 kB
        Command line used: iozone -l 1 -u 1 -r 16K -s 128M -F /tmp/tmpfile
        Output is in kBytes/sec
        Time Resolution = 0.000001 seconds.
        Processor cache size set to 1024 kBytes.
        Processor cache line size set to 32 bytes.
        File stride size set to 17 * record size.
        Min process = 1 
        Max process = 1 
        Throughput test with 1 process
        Each process writes a 131072 kByte file in 16 kByte records

        Children see throughput for  1 initial writers  = 1301841.75 kB/sec
        Parent sees throughput for  1 initial writers   =  104271.16 kB/sec
        Min throughput per process                      = 1301841.75 kB/sec 
        Max throughput per process                      = 1301841.75 kB/sec
        Avg throughput per process                      = 1301841.75 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for  1 rewriters        = 3018765.25 kB/sec
        Parent sees throughput for  1 rewriters         =  105599.76 kB/sec
        Min throughput per process                      = 3018765.25 kB/sec 
        Max throughput per process                      = 3018765.25 kB/sec
        Avg throughput per process                      = 3018765.25 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for  1 readers          = 5413710.50 kB/sec
        Parent sees throughput for  1 readers           = 5205784.06 kB/sec
        Min throughput per process                      = 5413710.50 kB/sec 
        Max throughput per process                      = 5413710.50 kB/sec
        Avg throughput per process                      = 5413710.50 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for 1 re-readers        = 5649890.00 kB/sec
        Parent sees throughput for 1 re-readers         = 5533982.50 kB/sec
        Min throughput per process                      = 5649890.00 kB/sec 
        Max throughput per process                      = 5649890.00 kB/sec
        Avg throughput per process                      = 5649890.00 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for 1 reverse readers   = 5126607.00 kB/sec
        Parent sees throughput for 1 reverse readers    = 5018455.90 kB/sec
        Min throughput per process                      = 5126607.00 kB/sec 
        Max throughput per process                      = 5126607.00 kB/sec
        Avg throughput per process                      = 5126607.00 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for 1 stride readers    = 5201499.00 kB/sec
        Parent sees throughput for 1 stride readers     = 5104425.23 kB/sec
        Min throughput per process                      = 5201499.00 kB/sec 
        Max throughput per process                      = 5201499.00 kB/sec
        Avg throughput per process                      = 5201499.00 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for 1 random readers    = 5115397.00 kB/sec
        Parent sees throughput for 1 random readers     = 5009629.92 kB/sec
        Min throughput per process                      = 5115397.00 kB/sec 
        Max throughput per process                      = 5115397.00 kB/sec
        Avg throughput per process                      = 5115397.00 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for 1 mixed workload    = 5025566.50 kB/sec
        Parent sees throughput for 1 mixed workload     = 4931217.40 kB/sec
        Min throughput per process                      = 5025566.50 kB/sec 
        Max throughput per process                      = 5025566.50 kB/sec
        Avg throughput per process                      = 5025566.50 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for 1 random writers    = 3322413.50 kB/sec
        Parent sees throughput for 1 random writers     =  111279.78 kB/sec
        Min throughput per process                      = 3322413.50 kB/sec 
        Max throughput per process                      = 3322413.50 kB/sec
        Avg throughput per process                      = 3322413.50 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for 1 pwrite writers    = 1825668.12 kB/sec
        Parent sees throughput for 1 pwrite writers     =  102905.21 kB/sec
        Min throughput per process                      = 1825668.12 kB/sec 
        Max throughput per process                      = 1825668.12 kB/sec
        Avg throughput per process                      = 1825668.12 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for 1 pread readers     = 4462963.00 kB/sec
        Parent sees throughput for 1 pread readers      = 4265415.77 kB/sec
        Min throughput per process                      = 4462963.00 kB/sec 
        Max throughput per process                      = 4462963.00 kB/sec
        Avg throughput per process                      = 4462963.00 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for  1 fwriters         = 3229643.75 kB/sec
        Parent sees throughput for  1 fwriters          =  110374.10 kB/sec
        Min throughput per process                      = 3229643.75 kB/sec 
        Max throughput per process                      = 3229643.75 kB/sec
        Avg throughput per process                      = 3229643.75 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for  1 freaders         = 4342435.50 kB/sec
        Parent sees throughput for  1 freaders          = 4267932.42 kB/sec
        Min throughput per process                      = 4342435.50 kB/sec 
        Max throughput per process                      = 4342435.50 kB/sec
        Avg throughput per process                      = 4342435.50 kB/sec
        Min xfer                                        =  131072.00 kB



iozone test complete.

最簡單開始使用iozone方法是自動模式

1 #/opt/iozone/bin/iozone -a

iozone將在所有模式下進行測試,使用記錄塊從4k到16M,測試文件大小從64k到512M。

如果想以圖表形式顯示測試結果,可以使用,iozone將測試結果放在Excel中

1 #/opt/iozone/bin/iozone -Ra 或 #/opt/iozone/bin/iozone -Rab output.xls

如果內存大於512MB,則測試文件需要更大;最好測試文件是內存的兩倍。例如內存爲1G,將測試文件設置最大爲2G

#/opt/iozone/bin/iozone -Ra -g 2g

如果我們只關心文件磁盤的read/write性能,而不必花費時間在其他模式上測試,則我們需要指定測試模式。具體將在參數解釋中介紹

1 #/opt/iozone/bin/iozone -Ra -g 2g -i 0 -i 1

最後,如果我們測試的NFS,將使用-c,這通知iozone在測試過程中執行close()函數。使用close()將減少NFS客戶端緩存的影響。但是如果測試文件比內存大,就沒有必要使用參數-c

1 #/opt/iozone/bin/iozone -Rac

 

測試的定義
Write: 測試向一個新文件寫入的性能。當一個新文件被寫入時,不僅僅是那些文件中的數據需要被存儲,還包括那些用於定位數據存儲在存儲介質的具體位置的額外信息。這些額外信息被稱作“元數據”。它包括目錄信息,所分配的空間和一些與該文件有關但又並非該文件所含數據的其他數據。拜這些額外信息所賜,Write的性能通常會比Re-write的性能低。
Re-write: 測試向一個已存在的文件寫入的性能。當一個已存在的文件被寫入時,所需工作量較少,因爲此時元數據已經存在。Re-write的性能通常比Write的性能高。
Read: 測試讀一個已存在的文件的性能。
Re-Read: 測試讀一個最近讀過的文件的性能。Re-Read性能會高些,因爲操作系統通常會緩存最近讀過的文件數據。這個緩存可以被用於讀以提高性能。
Random Read: 測試讀一個文件中的隨機偏移量的性能。許多因素可能影響這種情況下的系統性能,例如:操作系統緩存的大小,磁盤數量,尋道延遲和其他。
Random Write: 測試寫一個文件中的隨機偏移量的性能。同樣,許多因素可能影響這種情況下的系統性能,例如:操作系統緩存的大小,磁盤數量,尋道延遲和其他。
Random Mix: 測試讀寫一個文件中的隨機偏移量的性能。同樣,許多因素可能影響這種情況下的系統性能,例如:操作系統緩存的大小,磁盤數量,尋道延遲和其他。這個測試只有在吞吐量測試模式下才能進行。每個線程/進程運行讀或寫測試。這種分佈式讀/寫測試是基於round robin 模式的。最好使用多於一個線程/進程執行此測試。
Backwards Read: 測試使用倒序讀一個文件的性能。這種讀文件方法可能看起來很可笑,事實上,有些應用確實這麼幹。MSC Nastran是一個使用倒序讀文件的應用程序的一個例子。它所讀的文件都十分大(大小從G級別到T級別)。儘管許多操作系統使用一些特殊實現來優化順序讀文件的速度,很少有操作系統注意到並增強倒序讀文件的性能。
Record Rewrite: 測試寫與覆蓋寫一個文件中的特定塊的性能。這個塊可能會發生一些很有趣的事。如果這個塊足夠小(比CPU數據緩存小),測出來的性能將會非常高。如果比CPU數據緩存大而比TLB小,測出來的是另一個階段的性能。如果比此二者都大,但比操作系統緩存小,得到的性能又是一個階段。若大到超過操作系統緩存,又是另一番結果。
Strided Read: 測試跳躍讀一個文件的性能。舉例如下:在0偏移量處讀4Kbytes,然後間隔200Kbytes,讀4Kbytes,再間隔200Kbytes,如此反覆。此時的模式是讀4Kbytes,間隔200Kbytes並重復這個模式。這又是一個典型的應用行爲,文件中使用了數據結構並且訪問這個數據結構的特定區域的應用程序常常這樣做。
  許多操作系統並沒注意到這種行爲或者針對這種類型的訪問做一些優化。同樣,這種訪問行爲也可能導致一些有趣的性能異常。一個例子是在一個數據片化的文件系統裏,應用程序的跳躍導致某一個特定的磁盤成爲性能瓶頸。
Fwrite: 測試調用庫函數fwrite()來寫文件的性能。這是一個執行緩存與阻塞寫操作的庫例程。緩存在用戶空間之內。如果一個應用程序想要寫很小的傳輸塊,fwrite()函數中的緩存與阻塞I/O功能能通過減少實際操作系統調用並在操作系統調用時增加傳輸塊的大小來增強應用程序的性能。
  這個測試是寫一個新文件,所以元數據的寫入也是要的。
Frewrite:測試調用庫函數fwrite()來寫文件的性能。這是一個執行緩存與阻塞寫操作的庫例程。緩存在用戶空間之內。如果一個應用程序想要寫很小的傳輸塊,fwrite()函數中的緩存與阻塞I/O功能能通過減少實際操作系統調用並在操作系統調用時增加傳輸塊的大小來增強應用程序的性能。
  這個測試是寫入一個已存在的文件,由於無元數據操作,測試的性能會高些。
Fread:測試調用庫函數fread()來讀文件的性能。這是一個執行緩存與阻塞讀操作的庫例程。緩存在用戶空間之內。如果一個應用程序想要讀很小的傳輸塊,fwrite()函數中的緩存與阻塞I/O功能能通過減少實際操作系統調用並在操作系統調用時增加傳輸塊的大小來增強應用程序的性能。
Freread: 這個測試與上面的fread 類似,除了在這個測試中被讀文件是最近纔剛被讀過。這將導致更高的性能,因爲操作系統緩存了文件數據。
  幾個特殊測試:
  Mmap:許多操作系統支持mmap()的使用來映射一個文件到用戶地址空間。映射之後,對內存的讀寫將同步到文件中去。這對一些希望將文件當作內存塊來使用的應用程序來說很方便。一個例子是內存中的一塊將同時作爲一個文件保存在於文件系統中。
  mmap 文件的語義和普通文件略有不同。如果發生了對內存的存儲,並不是立即發生相應的文件I/O操作。使用MS_SYNC 和MS_ASYNC標誌位的 msyc()函數調用將控制內存和文件的一致性。調用msync() 時將MS_SYNC置位將強制把內存裏的內容寫到文件中去並等待直到此操作完成才返回。而MS_ASYNC 置位則告訴操作系統使用異步機制將內存刷新到磁盤,這樣應用程序可以直接返回而不用等待此操作的完成。
  這個測試就是測量使用mmap()機制完成I/O的性能。
  Async I/O: 許多操作系統支持的另外一種I/O機制是POSIX 標準的異步I/O。本程序使用POSIX標準異步I/O接口來完成此測試功能。
  例如: aio_write(), aio_read(), aio_error()。這個測試測量POSIX異步I/O機制的性能。

 

參數介紹

iozone功能很強大,當然參數也很多,但是我們常用的就那幾個參數
Usage: iozone [-s filesize_Kb] [-r record_size_Kb ] [-f [path]filename]
  [-i test] [-E] [-p] [-a] [-A] [-z] [-Z] [-m] [-M] [-t children] [-h] [-o]
  [-l min_number_procs] [-u max_number_procs] [-v] [-R] [-x]
  [-d microseconds] [-F path1 path2...] [-V pattern] [-j stride]
  [-T] [-C] [-B] [-D] [-G] [-I] [-H depth] [-k depth] [-U mount_point]
  [-S cache_size] [-O] [-K] [-L line_size] [-g max_filesize_Kb]
  [-n min_filesize_Kb] [-N] [-Q] [-P start_cpu] [-c] [-e] [-b filename]
  [-J milliseconds] [-X filename] [-Y filename] [-w] [-W]
  [-y min_recordsize_Kb] [-q max_recordsize_Kb] [-+m filename]
  [-+u ] [ -+d ] [-+p percent_read] [-+r] [-+t ] [-+A #]


-a
全自動模式測試。測試記錄塊大小從4k到16M,測試文件從64k到512M

-A
使用自動模式雖然測試比較全面,但是比較花時間。-a選項將在文件大於32MB時停止使用低於64k一下記錄塊,來節省時間。-A通知iozone不要節省時間,進行所有測試。注:在3.61版本以後不建議使用,用-az代替-aA

-B
使用mmap()。這將使用mmap()接口來創建並訪問所有測試用的臨時文件。一些應用程序傾向於將文件當作內存的一塊來看待。這些應用程序對文件執行mmap()調用,然後就可以以讀寫內存的方式訪問那個塊來完成文件I/O。

-c
計算時間將close()包括進來

-C
顯示吞吐量測試中每個客戶端的字節數。

-D
對mmap文件使用MSYNC(MS_ASYNC)。告訴操作系統在mmap空間的所有數據需要被異步的寫到磁盤上。

-e
測試時間是包含flush(fsync, fflush)

-f filename
指定用來測試臨時文件,在測試完成後將被自動刪除

-F filename filename ...
指定測試中每個臨時文件名,文件名的數量應該和指定的進程或線程數相同

-g #
在自動模式下設置文件最大值,可以使用#k #m #g分別表示kb,mb,gb

-G
對mmap文件使用msync(MS_SYNC)。告訴操作系統在mmap空間的所有數據需要被同步的寫到磁盤上

-h
顯示幫助

-i #
指定運行於哪種模式測試。可以使用-i # -i # -i #進行多個測試
0=write/rewrite
1=read/re-read
2=random read/random write
3=backwards read
4=re-write-record
5=stride-read
6=fwirte/re-fwrite
7=fread/re-fread
8=random mix
9=pwrite/re-pwrite
10=pread/re-pread
11=pwritev/re-pwritev
12=preadv/re-preadv

-I
對所有文件操作使用DIRECT I/O。通知文件系統所有操作跳過緩存直接在磁盤上操作

-j #
設置訪問文件的跨度爲(# * 塊)。stride read測試將使用這個跨度來讀塊

-J #(毫秒)
在每個I/O操作之前產生指定毫秒的計算延遲。看-X和-Y獲取控制計算延遲的其他參數

-l #
設置程序最小進程數。在測試過程允許用戶設置的最小進程或線程數。需要配合-u選項使用。

-L #
設置處理器交換信息的單位量爲#(bytes)。可以加速測試。

-m
iozone將在內部使用多個緩存。一些程序反覆複寫一塊緩存,還有就是設置多個緩存塊。此參數將允許使用這兩種模式。iozone默認行爲是重複使用內部一個緩存。此選項將允許在內部使用多個緩存塊。

-M
調用uname(),將返回字符串放在輸出文件中

-n #
設置自動模式下測試文件的最小值

-N
報告結果以毫秒每操作的方式顯示

-o
寫方式是同步寫到磁盤上

-O
報告結果以操作每秒方式顯示

-q #
在自動模式下設置記錄塊的最大值,可以使用#k(kb),#m(mb),#g(gb)。使用-y可以設置最小值

-r #
設置記錄塊大小爲#

-R
使用Excel顯示結果

-s #
設置測試文件大小

-S #
設置處理器的緩存大小

-t #
設置測試程序的線程或進程數

-T 
使用POSIX的pthreads進行測試

-u #
設置最大進程或線程數,需要配合-l參數使用

-U mountpoint
在測試開始之前,iozone將unmount和remount掛載點。這將保證測試中緩存不包含任何文件

-w
在測試結束後不要刪除臨時文件。臨時文件將在測試過後保存下來

-W
在測試過程中,當讀或寫文件時鎖住文件

-y #
設置記錄塊最小值

-z
同-a一起使用,進行全部測試

-Z
允許mmap I/O和file I/O混合使用

 

下面做個在我機器上做的測試:只進行read/write測試,測試文件大小是4G,記錄塊從2k到8m,並將測試數據輸出到Excel文件中

複製代碼

#先在/tmp目錄下創建一個文件

[root@comput3 mnt]# cd /tmp/
[root@comput3 tmp]# touch testfile
[root@comput3 tmp]# ll
total 0
-rw-r--r-- 1 root root 0 Jun 22 13:22 testfile

#再執行測試命令(生成的文件大小,別給太大,會卡死。我們指定4G)

[root@comput3 mnt]# /opt/iozone/bin/iozone -a -s 4g -i 0 -i 1 -f /tmp/testfile -y 2k -q 8m -Rb output.xls
Iozone: Performance Test of File I/O
Version $Revision: 3.465 $
Compiled for 32 bit mode.
Build: linux

Contributors:William Norcott, Don Capps, Isom Crawford, Kirby Collins
Al Slater, Scott Rhine, Mike Wisner, Ken Goss
Steve Landherr, Brad Smith, Mark Kelly, Dr. Alain CYR,
Randy Dunlap, Mark Montague, Dan Million, Gavin Brebner,
Jean-Marc Zucconi, Jeff Blomberg, Benny Halevy, Dave Boone,
Erik Habbinga, Kris Strecker, Walter Wong, Joshua Root,
Fabrice Bacchella, Zhenghua Xue, Qin Li, Darren Sawyer,
Vangel Bojaxhi, Ben England, Vikentsi Lapa,
Alexey Skidanov.

Run began: Thu Jun 22 13:22:56 2017

Auto Mode
File size set to 4194304 kB
Using Minimum Record Size 2 kB
Using Maximum Record Size 8192 kB
Excel chart generation enabled
Command line used: /opt/iozone/bin/iozone -a -s 4g -i 0 -i 1 -f /tmp/testfile -y 2k -q 8m -Rb output.xls
Output is in kBytes/sec
Time Resolution = 0.000001 seconds.
Processor cache size set to 1024 kBytes.
Processor cache line size set to 32 bytes.
File stride size set to 17 * record size.
random random bkwd record stride 
kB reclen write rewrite read reread read write read rewrite read fwrite frewrite fread freread
4194304 2 1490669 2380831 3607767 3608702 
4194304 4 2055341 3253580 5060700 5085952 
4194304 8 2437956 3670713 5750648 5794959 
4194304 16 2529686 3698703 5750735 5778162 
4194304 32 2599803 3766791 5698635 5736475 
4194304 64 2660804 3828547 5624593 5665942 
4194304 128 2680742 3910113 5381341 5393153 
4194304 256 2515596 3830578 4935002 4965230 
4194304 512 2528649 3832630 4915910 4947781 
4194304 1024 2701632 3890505 4944666 4976889 
4194304 2048 2722534 3941544 4931400 4963038 
4194304 4096 2674452 3848342 4815188 4841886 
4194304 8192 2305839 3121477 3571541 3581370

iozone test complete.
Excel output is below:

"Writer report"
"2" "4" "8" "16" "32" "64" "128" "256" "512" "1024" "2048" "4096" "8192"
"4194304" 1490669 2055341 2437956 2529686 2599803 2660804 2680742 2515596 2528649 2701632 2722534 2674452 2305839

"Re-writer report"
"2" "4" "8" "16" "32" "64" "128" "256" "512" "1024" "2048" "4096" "8192"
"4194304" 2380831 3253580 3670713 3698703 3766791 3828547 3910113 3830578 3832630 3890505 3941544 3848342 3121477

"Reader report"
"2" "4" "8" "16" "32" "64" "128" "256" "512" "1024" "2048" "4096" "8192"
"4194304" 3607767 5060700 5750648 5750735 5698635 5624593 5381341 4935002 4915910 4944666 4931400 4815188 3571541

"Re-Reader report"
"2" "4" "8" "16" "32" "64" "128" "256" "512" "1024" "2048" "4096" "8192"
"4194304" 3608702 5085952 5794959 5778162 5736475 5665942 5393153 4965230 4947781 4976889 4963038 4841886 3581370

 

[root@comput3 mnt]# pwd
/mnt

[root@comput3 mnt]# ll
total 4
-rw-r--r-- 1 root root 3940 Jun 22 13:24 output.xls

複製代碼

最後數據就是測試結果,左邊第一列是測試文件大小,第二列是記錄塊大小(單位是kb),以後每列就是測試模式(單位是kb/s)


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章