天天看點

磁盤 io 測試

[root@yunwei-system-89 data]# dd bs=16k count=138000 if=/dev/zero of=test oflag=dsync
138000+0 records in
138000+0 records out
2260992000 bytes (2.3 GB) copied, 126.701 s, 17.8 MB/s

[root@yunwei-system-89 data]# dd bs=16k count=138000 if=/dev/zero of=test conv=fsync 
138000+0 records in
138000+0 records out
2260992000 bytes (2.3 GB) copied, 9.03316 s, 250 MB/s

使用dsync,dd會從/dev/zero中,每次讀取16Kbytes資料,然後直接寫入到硬碟當中,重複此步驟,直到共讀取并且寫入了2.3GB的資料。
使用fdatasync,dd會從/dev/zero中一次性讀取2.3 G的資料,寫入到磁盤的緩存中,然後再從磁盤緩存中讀取,一次性寫入到硬碟當中。      
wget http://brick.kernel.dk/snaps/fio-2.0.7.tar.gz
yum install libaio-devel      
fio -direct=1-iodepth=64 -rw=【randread/randwrite/randrw】-ioengine=libaio -bs=【4/16/64】k -size=10G-numjobs=1 -runtime=1000 -group_reporting -name=/data/fiofile

說明: 
name=/data/fiofile 測試檔案名稱,通常選擇需要測試的盤的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引擎使用pync方式 
rwmixwrite=30 在混合讀寫的模式下,寫占30% 
group_reporting 關于顯示結果的,彙總每個程序的資訊。 
此外 
lockmem=1g 隻使用1g記憶體進行測試。 
zero_buffers 用0初始化系統buffer。 
nrfiles=8 每個程序生成檔案的數量。 
随機寫:
[root@yunwei-system-89 data]# fio -direct=1 -iodepth=64 -rw=randwrite -ioengine=libaio -bs=16k -size=10G -numjobs=1 -runtime=1000 -group_reporting -name=/data/fiofile
/data/fiofile: (g=0): rw=randwrite, bs=16K-16K/16K-16K, ioengine=libaio, iodepth=64
fio 2.0.7
Starting 1 process
Jobs: 1 (f=1): [w] [100.0% done] [0K/430.2M /s] [0 /26.3K iops] [eta 00m:00s]
/data/fiofile: (groupid=0, jobs=1): err= 0: pid=12943
  write: io=10240MB, bw=388621KB/s, iops=24288 , runt= 26982msec
    slat (usec): min=1 , max=3180 , avg= 9.56, stdev=12.77
    clat (usec): min=347 , max=210174 , avg=2621.27, stdev=3396.37
     lat (usec): min=353 , max=210186 , avg=2632.01, stdev=3396.32
    clat percentiles (usec):
     |  1.00th=[  804],  5.00th=[ 1096], 10.00th=[ 1320], 20.00th=[ 1640],
     | 30.00th=[ 1896], 40.00th=[ 2128], 50.00th=[ 2384], 60.00th=[ 2640],
     | 70.00th=[ 2928], 80.00th=[ 3312], 90.00th=[ 3952], 95.00th=[ 4576],
     | 99.00th=[ 6368], 99.50th=[ 7456], 99.90th=[13632], 99.95th=[18560],
     | 99.99th=[201728]
    bw (KB/s)  : min=237829, max=469984, per=99.76%, avg=387678.58, stdev=44951.13
    lat (usec) : 500=0.02%, 750=0.62%, 1000=2.57%
    lat (msec) : 2=30.81%, 4=56.42%, 10=9.38%, 20=0.13%, 50=0.01%
    lat (msec) : 100=0.01%, 250=0.03%
  cpu          : usr=18.25%, sys=32.51%, ctx=88980, majf=0, minf=26
  IO depths    : 1=0.1%, 2=0.1%, 4=0.1%, 8=0.1%, 16=0.1%, 32=0.1%, >=64=100.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.0%, 32=0.0%, 64=0.1%, >=64=0.0%
     issued    : total=r=0/w=655360/d=0, short=r=0/w=0/d=0

Run status group 0 (all jobs):
  WRITE: io=10240MB, aggrb=388620KB/s, minb=388620KB/s, maxb=388620KB/s, mint=26982msec, maxt=26982msec

Disk stats (read/write):
  sdb: ios=0/653272, merge=0/225, ticks=0/1676391, in_queue=1675890, util=99.72%