1.工具下载
OS: CentOS Linux release 7.2.1511 (Core) X64
fio-2.1.10.tar.gz
http://freecode.com/projects/fio/
2.安装
系统包安装
yum install -y libaio-devel zlib-devel
# tar zxvf fio-2.1.10.tar.gz
# cd fio-2.1.10
# make
# make install
3.fio 参数
说明:
filename=/test_fname 测试文件名称,通常选择需要测试的盘的data目录,而不是某个具体盘符(如/dev/sdb1),否则会破坏磁盘分区,使之无法启动。
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 每个进程生成文件的数量。
4.磁盘布局
# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00032b5f
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2000895 999424 83 Linux
/dev/sda2 2000896 4098047 1048576 82 Linux swap / Solaris
/dev/sda3 4098048 41943039 18922496 83 Linux
[root@localhost fio-2.1.10]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 19G 1.4G 17G 8% /
devtmpfs 908M 0 908M 0% /dev
tmpfs 917M 16K 917M 1% /dev/shm
tmpfs 917M 8.6M 908M 1% /run
tmpfs 917M 0 917M 0% /sys/fs/cgroup
/dev/sda1 973M 125M 848M 13% /boot
tmpfs 184M 0 184M 0% /run/user/1000
tmpfs 184M 0 184M 0% /run/user/0
#
5.测试注意事项:
filename,测试文件生成一般选择需要测试磁盘分区或者RAID挂载的data目录。
如测试/dev/sda3分区,“/”目录,-filename=/test_disk_io_5g。
6.测试场景
随机混合读写,读占 70%,写占 30%。
测试结果:关注结果中红色字体部分
# fio -filename=/test_disk_io_5g -direct=1 -iodepth 1-thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=16k -size=5G -numjobs=30 -runtime=100 -group_reporting -name=mytest1
min value out of range: 0 (1 min)
mytest1: (g=0): rw=randrw, bs=16K-16K/16K-16K/16K-16K, ioengine=psync, iodepth=1
...
fio-2.1.10
Starting 30 processes
mytest1: Laying out IO file(s) (1 file(s) / 5120MB)
Jobs: 10 (f=10): [m_m__m__m__m__m___m___mm____m_] [4.8% done] [1004KB/622KB/0KB /s] [62/38/0 iops] [eta 33m:19s]
mytest1: (groupid=0, jobs=30): err= 0: pid=3553: Wed May 24 17:09:13 2017
read : io=106800KB, bw=1065.3KB/s, iops=66, runt=100261msec
clat (usec): min=85, max=989584, avg=327366.77, stdev=157655.01
lat (usec): min=85, max=989585, avg=327367.35, stdev=157655.03
clat percentiles (msec):
| 1.00th=[ 48], 5.00th=[ 100], 10.00th=[ 139], 20.00th=[ 192],
| 30.00th=[ 233], 40.00th=[ 273], 50.00th=[ 314], 60.00th=[ 351],
| 70.00th=[ 396], 80.00th=[ 449], 90.00th=[ 529], 95.00th=[ 619],
| 99.00th=[ 799], 99.50th=[ 840], 99.90th=[ 898], 99.95th=[ 938],
| 99.99th=[ 988]
bw (KB /s): min= 10, max= 95, per=3.63%, avg=38.68, stdev=16.16
write: io=42816KB, bw=437294B/s, iops=26, runt=100261msec
clat (msec): min=6, max=995, avg=306.19, stdev=154.79
lat (msec): min=6, max=995, avg=306.19, stdev=154.79
clat percentiles (msec):
| 1.00th=[ 37], 5.00th=[ 87], 10.00th=[ 124], 20.00th=[ 174],
| 30.00th=[ 217], 40.00th=[ 253], 50.00th=[ 293], 60.00th=[ 330],
| 70.00th=[ 367], 80.00th=[ 420], 90.00th=[ 498], 95.00th=[ 594],
| 99.00th=[ 783], 99.50th=[ 832], 99.90th=[ 979], 99.95th=[ 988],
| 99.99th=[ 996]
bw (KB /s): min= 11, max= 91, per=6.47%, avg=27.64, stdev=11.07
lat (usec) : 100=0.02%
lat (msec) : 10=0.04%, 20=0.12%, 50=1.19%, 100=4.04%, 250=30.30%
lat (msec) : 500=52.37%, 750=10.28%, 1000=1.65%
cpu : usr=0.00%, sys=0.06%, ctx=9379, majf=0, minf=975
IO depths : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.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.0%, 32=0.0%, 64=0.0%, >=64=0.0%
issued : total=r=6675/w=2676/d=0, short=r=0/w=0/d=0
latency : target=0, window=0, percentile=100.00%, depth=1
Run status group 0 (all jobs):
READ: io=106800KB, aggrb=1065KB/s, minb=1065KB/s, maxb=1065KB/s, mint=100261msec, maxt=100261msec
WRITE: io=42816KB, aggrb=427KB/s, minb=427KB/s, maxb=427KB/s, mint=100261msec, maxt=100261msec
Disk stats (read/write):
sda: ios=6680/2683, merge=0/3, ticks=2185394/820558, in_queue=3008831, util=100.00%
#