FIO之一: 硬盘性能测试工具FIO初步使用

FIO(flexible I/O tester)是一个测试硬盘性能非常好的工具,这里测试下。

安装 FIO

下载
http://freecode.com/projects/fio

安装相关包

1
yum install libaio libaio-devel

解压安装

1
2
3
4
[root@csv-tfcs01 fio-2.1.10]# cd /opt/soft_bak/fio-2.1.10
[root@csv-tfcs01 fio-2.1.10]# ./configure
[root@csv-tfcs01 fio-2.1.10]# make
[root@csv-tfcs01 fio-2.1.10]# make install

备注:FIO 的安装非常简单,接下对计划在物理机上做个 FIO 测试,物理机上用了两块900G SAS 盘做了系统盘,SSD 盘做了数据盘,计划对系统盘和数据盘做性能测试, 主要测试指标:测试8K随机写、8K随机读、8K混合读写、1MB顺序写、1MB顺序读、1MB顺序读写;测试命令模板如下

FIO 测试命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
--8k  随机写
fio -name=8krandw -runtime=120 -filename=/data/rand.txt -ioengine=libaio -direct=1 -bs=8K -size=10g -iodepth=128 -numjobs=1 -rw=randwrite -group_reporting -time_based

--8K 随机读
fio -name=8krandr -runtime=120 -filename=/data/rand.txt -ioengine=libaio -direct=1 -bs=8K -size=10g -iodepth=128 -numjobs=1 -rw=randread -group_reporting -time_based

--8k 混合读写
fio -name=8krandrw -runtime=120 -filename=/data/rand.txt -ioengine=libaio -direct=1 -bs=8k -size=10g -iodepth=128 -numjobs=1 -rw=randrw -rwmixwrite=30 -group_reporting -time_based

--1Mb 顺序写
fio -name=1mseqw -runtime=120 -filename=/data/seq.txt -ioengine=libaio -direct=1 -bs=1024k -size=20g -iodepth=128 -numjobs=1 -rw=write -group_reporting -time_based

--1Mb 顺序读
fio -name=1mseqr -runtime=120 -filename=/data/seq.txt -ioengine=libaio -direct=1 -bs=1024k -size=20g -iodepth=128 -numjobs=1 -rw=read -group_reporting -time_based

--1Mb 顺序读写
fio -name=1mseqrw -runtime=120 -filename=/data/seq.txt -ioengine=libaio -direct=1 -bs=1024k -size=20g -iodepth=128 -numjobs=1 -rw=rw -rwmixwrite=30 -group_reporting -time_based

8K随机写命令输出

测试结果

设备型号:RH5885 V3; 硬盘:900G/SAS 10K/2.5寸硬盘/RAID1

1
2
3
4
5
6
8k 随机写:iops=798
8k 随机读:iops=11190
8k 混合读写(读写7:3):读iops=1114 写iops=479
1m 顺序写:iops=170
1m 顺序读:iops=246
1m 顺序读写(读写7:3):读iops=134 写iops=56

型号:RH5885 V3; 硬盘:480G/Intel SATA接口SSD/2.5寸硬盘/RAID5

1
2
3
4
5
6
8k 随机写:iops=12873
8k 随机读:iops=68636
8k 混合读写(读写7:3):读iops=24846 写iops=10643
1m 顺序写:iops=1687
1m 顺序读:iops=2347
1m 顺序读写(读写7:3):读iops=1019 写iops=431

虚拟机 4c/8G 接软件定义存储

1
2
3
4
5
6
8k  随机写:iops=20234  
8k 随机读:iops=20192
8k 混合读写:读iops=14510 写iops=6215
1m 顺序写:iops=923
1m 顺序读:iops=699
1m 顺序读写:读iops=571 写iops=241

备注:从测试结果来看, SATA 接口的 SSD 盘 8K随机读写、1M顺序读写能力远远超过 SAS 盘

附:FIO 相关参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
readwrite=str, rw=str
Type of I/O pattern. Accepted values are:

read Sequential reads.

write Sequential writes.

trim Sequential trim (Linux block devices only).

randread
Random reads.
randwrite
Random writes.
randtrim
Random trim (Linux block devices only).
rw, readwrite
Mixed sequential reads and writes.

randrw Mixed random reads and writes.

direct=bool
If true, use non-buffered I/O (usually O_DIRECT). Default: false.
iodepth=int
Number of I/O units to keep in flight against the file. Note that increasing iodepth beyond 1 willnot
affect synchronous ioengines (except for small degress when verify_async is in use). Even async engines
may impose OS restrictions causing the desired depth not to be achieved. This may happen on Linux when
using libaio and not setting direct=1, since buffered IO is not async on that OS. Keep an eye on the IO
depth distribution in the fio output to verify that the achieved depth is as expected. Default: 1.
ioengine=str
Defines how the job issues I/O. The following types are defined:
sync Basic read(2) or write(2) I/O. fseek(2) is used to position the I/O location.
psync Basic pread(2) or pwrite(2) I/O.
vsync Basic readv(2) or writev(2) I/O. Will emulate queuing by coalescing adjacent IOs into a
single submission.
pvsync Basic preadv(2) or pwritev(2) I/O.
libaio Linux native asynchronous I/O. This ioengine defines engine specific options.
blocksize=int[,int], bs=int[,int]
Block size for I/O units. Default: 4k. Values for reads, writes, and trims can be specified separately
in the format read,write,trim either of which may be empty to leave that value at its default. If a
trailing comma isn’t given, the remainder will inherit the last value set.
size=int
Total size of I/O for this job. fio will run until this many bytes have been transferred, unless lim-
ited by other options(runtime, for instance). Unless nrfiles and filesize options are given, this
amount will be divided between the available files for the job. If not set, fio will use the full size
of the given files or devices. If the files do not exist, size must be given. It is also possible to
give size as a percentage between 1 and 100. If size=20% is given, fio will use 20% of the full size of
the given files or devices.
numjobs=int
Number of clones (processes/threads performing the same workload) of this job. Default: 1.

参考

最后推荐和张文升共同编写的《PostgreSQL实战》,本书基于PostgreSQL 10 编写,共18章,重点介绍SQL高级特性、并行查询、分区表、物理复制、逻辑复制、备份恢复、高可用、性能优化、PostGIS等,涵盖大量实战用例!

购买链接:https://item.jd.com/12405774.html

PostgreSQL实战
感谢支持!
0%