1,615 瀏覽數

Fio – 硬碟的壓力測試

要把 Fio 當作硬碟的壓力測試工具,有兩個參數可以使用,關於 FIO 的基礎使用與設定請參考 http://benjr.tw/34632

測試環境為 Ubuntu 16.04 64bit

  • verify=str
    Method of verifying file contents after each iteration of the job. 支援這幾種驗證方式 md5 crc16 crc32 crc32c crc32c-intel crc64 crc7 sha256 sha512 sha1

    上面這幾種都是 One Way Hashes ,他主要會讀取資料並產生一組固定長度字串 (fingerprint ),用這組字串用來比對原資料是否遭到修改,既然無法回推成原資料,那怎知資料是否正確, One Way hash 會再將資料再做一次 One Way hash 然後直接比對 fingerprint 是否一樣.

  • do_verify=bool
    預設值是 true.會在執行 write 之後做資料的驗證(讀取時不需要).

除了這兩個參數外還需要下面的參數

  • –rw=str
    可以設定的參數說明如下.

    • read : Sequential reads. (循序讀)
    • write : Sequential writes. (循序寫)
    • randread : Random reads. (隨機讀)
    • randwrite : Random writes. (隨機寫)
    • rw : Mixed sequential reads and writes. (循序讀寫)
    • randrw : Mixed random reads and writes. (隨機讀寫)
  • –rwmixread=int
    當設定為 Mixed ,同一時間 read 的比例為多少,預設為 50% (50% read + 50% write),也可以用 rwmixwrite=int 來設定,不建議同時使用.
  • –bs=int[,int]
    bs 或是 blocksize ,也就是檔案寫入大小,預設值為 4K,如何設定這個值,因為不同性質的儲存裝置需要不同的值.看你是 File Server,Web server , Database … 設定都會不一樣.可以用逗號 分開設定 read,write

    既然是做壓力測試 block 的設定需要多一點彈性,可以使用下面兩種方式來設定 block size.

  • blocksize_range=irange[,irange], bsrange=irange[,irange]
    我們可以設定一個區間 如 bsrange=1k-4k,2k-8k. 一樣可以用逗號 分開設定 read,write

  • bssplit=str
    也可以用比例的方式來設定 bssplit=blocksize/percentage.

    如 bssplit=4k/10:64k/50:32k/40 將使用 50% 64k blocks, 10% 4k blocks 以及 40% 32k blocks.可以用逗號分開設定 read,write

範例:

root@ubuntu:~# fio --filename=/dev/sdb --direct=1 --rw=randrw --ioengine=libaio --bssplit=4k/10:8K/40:16K/50 --rwmixread=80 --iodepth=16 --numjobs=1 --runtime=60 --group_reporting --name=stresstest --verify=md5 
stresstest: (g=0): rw=randrw, bs=4K-16K/4K-16K/4K-16K, ioengine=libaio, iodepth=16
fio-2.2.10
Starting 1 process
Jobs: 1 (f=1): [m(1)] [100.0% done] [52839KB/13858KB/0KB /s] [6680/1714/0 iops] [eta 00m:00s]
stresstest: (groupid=0, jobs=1): err= 0: pid=5900: Wed Mar  1 23:28:56 2017
  read : io=3939.1MB, bw=67237KB/s, iops=7040, runt= 60003msec
    slat (usec): min=33, max=18948, avg=85.82, stdev=79.60
    clat (usec): min=1, max=195804, avg=1803.90, stdev=1960.51
     lat (usec): min=46, max=195902, avg=1891.06, stdev=1962.46
    clat percentiles (usec):
     |  1.00th=[  290],  5.00th=[  740], 10.00th=[  932], 20.00th=[ 1144],
     | 30.00th=[ 1272], 40.00th=[ 1400], 50.00th=[ 1512], 60.00th=[ 1656],
     | 70.00th=[ 1880], 80.00th=[ 2288], 90.00th=[ 3024], 95.00th=[ 3632],
     | 99.00th=[ 5600], 99.50th=[ 6944], 99.90th=[11584], 99.95th=[14272],
     | 99.99th=[75264]
    bw (KB  /s): min=34488, max=92088, per=100.00%, avg=67376.38, stdev=11607.87
  write: io=989.68MB, bw=16879KB/s, iops=1765, runt= 60003msec
    slat (usec): min=36, max=7549, avg=90.69, stdev=81.23
    clat (usec): min=2, max=191116, avg=1354.20, stdev=1904.96
     lat (usec): min=70, max=191309, avg=1446.37, stdev=1911.79
    clat percentiles (usec):
     |  1.00th=[  253],  5.00th=[  628], 10.00th=[  788], 20.00th=[  940],
     | 30.00th=[ 1048], 40.00th=[ 1128], 50.00th=[ 1208], 60.00th=[ 1288],
     | 70.00th=[ 1400], 80.00th=[ 1576], 90.00th=[ 1976], 95.00th=[ 2416],
     | 99.00th=[ 3920], 99.50th=[ 4896], 99.90th=[10176], 99.95th=[13632],
     | 99.99th=[121344]
    bw (KB  /s): min= 7736, max=23416, per=100.00%, avg=16919.19, stdev=2974.88
    lat (usec) : 2=0.09%, 4=0.09%, 10=0.01%, 20=0.01%, 50=0.06%
    lat (usec) : 100=0.14%, 250=0.50%, 500=1.49%, 750=3.46%, 1000=9.43%
    lat (msec) : 2=61.62%, 4=20.40%, 10=2.56%, 20=0.12%, 50=0.01%
    lat (msec) : 100=0.01%, 250=0.01%
  cpu          : usr=14.47%, sys=77.68%, ctx=15732, majf=0, minf=2476
  IO depths    : 1=0.1%, 2=0.1%, 4=0.1%, 8=0.1%, 16=100.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.1%, 32=0.0%, 64=0.0%, >=64=0.0%
     issued    : total=r=422434/w=105908/d=0, short=r=0/w=0/d=0, drop=r=0/w=0/d=0
     latency   : target=0, window=0, percentile=100.00%, depth=16

Run status group 0 (all jobs):
   READ: io=3939.1MB, aggrb=67237KB/s, minb=67237KB/s, maxb=67237KB/s, mint=60003msec, maxt=60003msec
  WRITE: io=989.68MB, aggrb=16879KB/s, minb=16879KB/s, maxb=16879KB/s, mint=60003msec, maxt=60003msec

Disk stats (read/write):
  sdb: ios=422345/105880, merge=0/0, ticks=375476/45876, in_queue=421220, util=99.65%

當發現錯誤時可以透過 指令 #smartctl 檢測該顆硬碟的錯誤狀態為何.

smartctl 是透過硬碟本身所提供的 S.M.A.R.T. (Self-Monitoring Analysis and Reporting Technology )技術 ,就可以檢測該顆硬碟的 Error count (Errors Corrected by ECC fast | delayed , Errors Corrected by rereads / rewrites , Total errors corrected , Correction algorithm invocations , Total uncorrected errors) 如下所示:

root@ubuntu:~# smartctl -l error /dev/sdb
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-24-generic] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
 
=== START OF READ SMART DATA SECTION ===
Error counter log:
           Errors Corrected by           Total   Correction     Gigabytes    Total
               ECC          rereads/    errors   algorithm      processed    uncorrected
           fast | delayed   rewrites  corrected  invocations   [10^9 bytes]  errors
read:          0        0         0         0          0     123263.011           0
write:         0        0         0         0          0       5218.671           0
verify:        0        0         0         0          0         24.721           0
 
Non-medium error count:      148

更多關於 smartctl 的使用請參考 http://benjr.tw/95984

發表迴響