硬盘简单测试--使用虚拟机

IO测试工具有fio、iometer。

使用dd测试一下SATA硬盘的MBPS(吞吐量)

[root@node3 ~]# dd if=/dev/zero of=/dev/sdb  bs=4k  count=1000000 oflag=direct 
1000000+0 records in
1000000+0 records out
4096000000 bytes (4.1 GB) copied, 30.3562 s, 135 MB/s #MBPS(吞吐量)= 135 MB/s
[root@node3 ~]# yum install sysstat -y  #iostat工具包 

[root@node3 ~]# iostat -x sdb 1 10 #在设备 sdb的1秒钟内显示10个扩展统计的报告。
Linux 3.10.0-327.el7.x86_64 (node3)     08/28/2018  _x86_64_    (8 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.11    0.00    0.65    0.05    0.00   99.18

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
sdb               0.00     0.00    1.33  897.65     9.99 25018.07    55.68     0.05    0.05    0.24    0.05   0.04   3.34
[root@node3 ~]# yum install fio 
[root@node3 ~]# fio -ioengine=libaio -bs=4k -direct=1 -thread -rw=randwrite -size=5G -filename=/dev/sdb \
> -name="EBS 4K randwrite test" -iodepth=64 -runtime=60
EBS 4K randwrite test: (g=0): rw=randwrite, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=64
fio-3.1
Starting 1 thread
Jobs: 1 (f=1): [w(1)][100.0%][r=0KiB/s,w=42.2MiB/s][r=0,w=10.8k IOPS][eta 00m:00s]
EBS 4K randwrite test: (groupid=0, jobs=1): err= 0: pid=5319: Tue Aug 28 02:57:49 2018
  write: IOPS=5828, BW=22.8MiB/s (23.9MB/s)(1366MiB/60004msec)
    slat (nsec): min=1166, max=20277k, avg=121766.21, stdev=166800.80
    clat (usec): min=1996, max=47059, avg=10850.52, stdev=5967.36
     lat (usec): min=2003, max=47066, avg=10973.42, stdev=6072.34
    clat percentiles (usec):
     |  1.00th=[ 3294],  5.00th=[ 4178], 10.00th=[ 4948], 20.00th=[ 6194],
     | 30.00th=[ 6849], 40.00th=[ 7504], 50.00th=[ 8848], 60.00th=[10552],
     | 70.00th=[12518], 80.00th=[15664], 90.00th=[20317], 95.00th=[23725],
     | 99.00th=[27132], 99.50th=[28967], 99.90th=[32900], 99.95th=[34866],
     | 99.99th=[41681]
   bw (  KiB/s): min= 8375, max=43952, per=99.95%, avg=23301.18, stdev=10817.01, samples=120
   iops        : min= 2093, max=10988, avg=5825.22, stdev=2704.24, samples=120
  lat (msec)   : 2=0.01%, 4=3.86%, 10=52.91%, 20=32.72%, 50=10.50%
  cpu          : usr=3.28%, sys=80.47%, ctx=135760, majf=0, minf=4
  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 rwt: total=0,349723,0, short=0,0,0, dropped=0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=64

Run status group 0 (all jobs):
  WRITE: bw=22.8MiB/s (23.9MB/s), 22.8MiB/s-22.8MiB/s (23.9MB/s-23.9MB/s), io=1366MiB (1432MB), run=60004-60004msec

Disk stats (read/write):
  sdb: ios=61/348462, merge=0/7, ticks=24/1130684, in_queue=1131044, util=99.56%

4K随机写测试
#4K随机写测试
#fio -ioengine=libaio -bs=4k -direct=1 -thread -rw=randwrite -size=5G -filename=/dev/sdb  -name="EBS 4KB randwrite test" -iodepth=32 -runtime=60

#4K随机读测试
#fio -ioengine=libaio -bs=4k -direct=1 -thread -rw=randread -size=100G -filename=/dev/sdb -name="EBS 4KB randread test" -iodepth=8 -runtime=60

#512KB顺序写测试
#fio -ioengine=libaio -bs=512k -direct=1 -thread -rw=write -size=100G -filename=/dev/sdb -name="EBS 512KB seqwrite test" -iodepth=64 -runtime=60
#介绍fio的参数
#ioengine: 负载引擎,我们一般使用libaio,发起异步IO请求。
#bs: IO大小
#direct: 直写,绕过操作系统Cache。因为我们测试的是硬盘,而不是操作系统的Cache,所以设置为1。
#rw: 读写模式,有顺序写write、顺序读read、随机写randwrite、随机读randread等。
#size: 寻址空间,IO会落在 [0, size)这个区间的硬盘空间上。这是一个可以影响IOPS的参数。一般设置为硬盘的大小。
#filename: 测试对象
#iodepth: 队列深度,只有使用libaio时才有意义。这是一个可以影响IOPS的参数。
#runtime: 测试时长

加大硬盘队列深度就是让硬盘不断工作,减少硬盘的空闲时间。
加大队列深度 -> 提高利用率 -> 获得IOPS和MBPS峰值 ->注意响应时间在可接受的范围内,
增加队列深度的办法有很多,使用异步IO,同时发起多个IO请求,相当于队列中有多个IO请求,多线程发起同步IO请求,相当于队列中有多个IO请求。
增大应用IO大小,到达底层之后,会变成多个IO请求,相当于队列中有多个IO请求 队列深度增加了。
队列深度增加了,IO在队列的等待时间也会增加,导致IO响应时间变大,这需要权衡。

#Linux系统查看默认队列深度:
[root@node3 ~]# lsscsi -l
[0:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda 
  state=running queue_depth=32 scsi_level=3 type=0 device_blocked=0 timeout=180
[0:0:1:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sdb 
  state=running queue_depth=32 scsi_level=3 type=0 device_blocked=0 timeout=180
[2:0:0:0]    cd/dvd  NECVMWar VMware IDE CDR10 1.00  /dev/sr0 
  state=running queue_depth=1 scsi_level=6 type=5 device_blocked=0 timeout=30
[root@node3 ~]# 

猜你喜欢

转载自blog.csdn.net/genglei1022/article/details/82148325
今日推荐