tongsiying

阅读|运动|自律

0%

BlockStorage-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
一、安装
http://freshmeat.sourceforge.net/projects/fio上下载fio-2.1.10.tar.gz,版本包见附件
解压
tar  -xvf  fio-3.3.tar.gz
cd  fio-3.3

执行命令:
./configure
make
make install

安装libaio-devel
yum install libaio-devel

重新执行:
#./configure
#make
#make install

直接执行fio测试。
#fio -ioengine=libaio -filename=fiofile -bs=20k -direct=1 -iodepth=4 -thread -size=300g -rw=randwrite -name=20k_randwrite -numjobs=2 -group_reporting
如果有报错:是因为没装libaio-devel

检查libaio和rbd是否存在,存在表示已经安装了libaio和rdb,下面可以看到所有引擎
[root@ceph1 home]# fio --enghelp
Available IO engines:
cpuio
mmap
sync
psync
vsync
pvsync
null
net
netsplice
libaio
posixaio
falloc
e4defrag
splice
rbd
sg
binject

二、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
二、fio引擎介绍
参考网址:
http://blog.yufeng.info/archives/677
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 adjacents IOs into a single submission.
libaio
Linux native asynchronous I/O. This ioengine defines engine specific options.
posixaio
POSIX asynchronous I/O using aio_read(3) and aio_write(3).
solarisaio
Solaris native asynchronous I/O.
windowsaio
Windows native asynchronous I/O.
mmap
File is memory mapped with mmap(2) and data copied using memcpy(3).
splice
splice(2) is used to transfer the data and vmsplice(2) to transfer data from user-space to the kernel.
syslet-rw
Use the syslet system calls to make regular read/write asynchronous.
sg
SCSI generic sg v3 I/O. May be either synchronous using the SG_IO ioctl, or if the target is an sg character device, we use read(2) and write(2) for asynchronous I/O.
null
Doesn’t transfer any data, just pretends to. Mainly used to exercise fio itself and for debugging and testing purposes.
net
Transfer over the network. The protocol to be used can be defined with the protocol parameter. Depending on the protocol, filename, hostname, port, or listen must be specified. This ioengine defines engine specific options.
netsplice
Like net, but uses splice(2) and vmsplice(2) to map data and send/receive. This ioengine defines engine specific options.
cpuio
Doesn’t transfer any data, but burns CPU cycles according to cpuload and cpucycles parameters.
guasi
The GUASI I/O engine is the Generic Userspace Asynchronous Syscall Interface approach to asycnronous I/O.

个别中文解释:
默认值是sync同步阻塞I/O,
libaio是Linux的native异步I/O
io引擎使用pync方式
sync:采用read,write,使用fseek定位读写位置。
psync:采用pread、pwrite进行文件读写操作
vsync:采用readv(2) orwritev(2)进行文件读写操作

三、各引擎使用方法

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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
1、fio-vsync:
vsync:采用readv(2) orwritev(2)进行文件读写操作
fio -filename=/mnt/data/112.log -direct=1 -iodepth 1 -thread -rw=randread -ioengine=vsync -bs=4k -size=1G -numjobs=64 -runtime=10 -group_reporting -name=file

2、sync:采用read,write,使用fseek定位读写位置。同步阻塞I/O,
fio -filename=/mnt/data/111.log -ioengine=sync -direct=1 -rw=randwrite -bs=8k -size=1G -numjobs=8 -runtime=10-group_reporting -name=fio_test

3、psync对磁盘进行读写(lsblk),如下查出来就是/dev/vdb
[root@host111 data]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 75G 0 disk
├─vda1 252:1 0 200M 0 part /boot
└─vda2 252:2 0 74.8G 0 part
├─systemvg-swaplv (dm-0) 253:0 0 10G 0 lvm [SWAP]
├─systemvg-rootlv (dm-1) 253:1 0 8G 0 lvm /
├─systemvg-homelv (dm-2) 253:2 0 2G 0 lvm /home
├─systemvg-varlv (dm-3) 253:3 0 6G 0 lvm /var
├─systemvg-tmplv (dm-4) 253:4 0 2G 0 lvm /tmp
├─systemvg-optlv (dm-5) 253:5 0 30G 0 lvm /opt
└─systemvg-usrlv (dm-6) 253:6 0 10G 0 lvm /usr
vdb 252:16 0 100G 0 disk /mysql
vdc 252:32 0 500G 0 disk /mnt/data

或者对一个文件进行写:
fio -filename=/mnt/data/112.log -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=4k -size=1G -numjobs=64 -runtime=10 -group_reporting -name=file

4、posixaio:glibc POSIX asynchronous I/O using aio_read(3) and aio_write(3).
fio -name=/mnt/data/11.log -direct=0 -iodepth=96 -rw=randread -ioengine=posixaio -bs=4k -size=1G -numjobs=64 -runtime=10 -group_reporting

5、libaio:Linux native asynchronous I/O.Linux的native异步I/O
fio -filename=/mnt/data/112.log -direct=1 -iodepth 1 -thread -rw=randread -ioengine=libaio -bs=4k -size=1G -numjobs=64 -runtime=10 -group_reporting -name=file

6、mmap:File is memory mapped with mmap(2) and data copied using memcpy(3).
fio -filename=/mnt/data/112.log -direct=1 -iodepth 1 -thread -rw=randread -ioengine=mmap -bs=4k -size=1G -numjobs=64 -runtime=10 -group_reporting -name=file

7、splice: splice(2) is used to transfer the data and vmsplice(2) to transfer data from user-space to the kernel.
fio -filename=/mnt/data/112.log -direct=1 -iodepth 1 -thread -rw=randread -ioengine=splice -bs=4k -size=1G -numjobs=64 -runtime=10 -group_reporting -name=file

8、falloc
fio -filename=/mnt/data/112.log -direct=1 -iodepth 1 -thread -rw=randread -ioengine=falloc -bs=4k -size=1G -numjobs=64 -runtime=10 -group_reporting -name=file

9、pvsync:
fio -filename=/mnt/data/112.log -direct=1 -iodepth 1 -thread -rw=randread -ioengine=pvsync -bs=4k -size=1G -numjobs=64 -runtime=10 -group_reporting -name=file

引擎参照:没有举例的可能执行有问题,或者是针对块存储的
binject:只针对block devices
sg:针对块
splice
e4defrag:Option inplace: missing long option name
falloc
posixaio
libaio
net:fio: network IO can't be random
netsplice
null
sync
psync
vsync
pvsync
mmap
cpuio
syslet-rw

使用配置文件执行:
参考:https://segmentfault.com/a/1190000003880571
如下为rdb测试的配置文件:执行:fio 256k-randread.fio
[root@host111 fio_cfg]# vi 256k-randread.fio
[randread-256k]
description="randread test with block size of 256k-test-poolimages1"
ioengine=rbd
clientname=admin
pool=test-pool
rbdname=test-poolimages1
iodepth=8
runtime=300
rw=randread
bs=256k
numjobs=1
size=5g
#write_iops_log=write_iops
#log_avg_msec=1000
#filename=/data/osd.0/1.txt
write_bw_log=rw
write_lat_log=rw
write_iops_log=rw

[randread-256k]
description="randread test with block size of 256k-test-poolimages2"
ioengine=rbd
clientname=admin
pool=test-pool
rbdname=test-poolimages2
iodepth=8
runtime=300
rw=randread
bs=256k
numjobs=1
size=5g
#write_iops_log=write_iops
#log_avg_msec=1000
#filename=/data/osd.0/1.txt
write_bw_log=rw
write_lat_log=rw
write_iops_log=rw

四、补充

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
50
51
52
53
54
55
56
57
58
1、安装插件:
yum install gnuplot

2.输出bw,lat和iops数据并画图
fio安装完后自带有一个高级脚本fio_generate_plots能够根据fio输出的数据进行画图。操作流程如下:
fio的输出日志主要包含三种:bw,lat和iops,设置这三种的参数如下:
write_bw_log=rw
w
write_lat_log=rw
w
write_iops_log=rw


如:fio -filename=/mnt/data/112.log -direct=1 -iodepth 1 -thread -rw=randread -ioengine=libaio -bs=4k -size=1G -numjobs=1 -runtime=10 -group_reporting -name=file -write_bw_log=rww -write_lat_log=rww -write_iops_log=rw
最后生成:
[root@host111 fio_cfg]# ls
psync randrw.fio read.fio rw_iops.1.log rww_clat.1.log rww_slat.1.log
randread.fio randwrite.fio rw.fio rww_bw.1.log rww_lat.1.log write.fio
需要将$1.log改为*.log
[root@host111 fio_cfg]# mv rw_iops.1.log rw_iops.log
[root@host111 fio_cfg]# mv rww_bw.1.log rww_bw.log
[root@host111 fio_cfg]# mv rww_clat.1.log rww_clat.log
[root@host111 fio_cfg]# mv rww_lat.1.log rww_lat.log
[root@host111 fio_cfg]# mv rww_slat.1.log rww_slat.log
[root@host111 fio_cfg]# ls
psync randrw.fio read.fio rw_iops.log rww_clat.log rww_slat.log
randread.fio randwrite.fio rw.fio rww_bw.log rww_lat.log write.fio

或者使用下面脚本进行修改:
这里需要强调的一点是,后面接的参数rw,是输出日志文件名的prefix,如最终会生成的日志文件如下:
rw_iops.log

rw_clat.log

rw_slat.log

rw_lat.log

rw_bw.log


这个参数在后面画图的时候也要用到。
for i in clat lat slat bw iops;do mv rbd_$i.1.log rbd_$i.log;done

3、画图
前提是还需要安装好gnuplot,然后使用下面的命令即可自动画图:
root@ubuntu:/tmp> fio_generate_plots bw


发现没有,fio_generate_plots接受的唯一参数就是这个日志文件名的prefix。
本例中生成的图片文件有:
bw-bw.svg 
bw-clat.svg 
bw-iops.svg 
bw-lat.svg 
bw-slat.svg

下载到本地,需要用谷歌浏览器才能打开,图片软件打不开

001-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
50
51
52
53
54
55

http://freshmeat.sourceforge.net/projects/fio上下载fio-2.1.10.tar.gz
解压。
#tar  -xvf  fio-3.3.tar.gz
#cd  fio-3.3

执行命令:
#./configure
#make
#make install

安装libaio-devel
yum install libaio-devel
或者rpm -ivh *rpm --force

重新执行:
#./configure
#make
#make install

直接执行fio测试。
#fio -ioengine=libaio -filename=fiofile -bs=20k -direct=1 -iodepth=4 -thread -size=300g -rw=randwrite -name=20k_randwrite -numjobs=2 -group_reporting
如果有报错:是因为没装libaio-devel

检查libaio和rbd是否存在,存在表示已经安装了libaio和rdb
[root@ceph1 home]# fio --enghelp
Available IO engines:
cpuio
mmap
sync
psync
vsync
pvsync
null
net
netsplice
libaio
posixaio
falloc
e4defrag
splice
rbd
sg
binject

创建一个rbd image
rbd -p rbd create --size 20480 fio_test_image

查看pool
ceph osd lspools
[root@ceph3 osd.19]# ceph osd lspools
0 rbd,1 docker-pool,

在pool中新建一个镜像:
rbd create docker-pool/docker-poolimages --size 102400

002-fio配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
胡正川给:
fio -filename=/data/osd.19/tstfile -size=10G -direct=1 -ioengine=libaio -thread -bs=4k -rw=randwrite -iodepth=64 -runtime=300 -iodepth_batch=1 -iodepth_batch_complete=1 -name=randwrite-iops-tst

fio -ioengine=libaio -bs=4k -direct=1 -thread -rw=randwrite -size=2G -directory=/usr/share/nginx/html/ -name="4KB randwrite test" -iodepth=32 -runtime=60
1)IO类型
向文件发起的IO类型。
<1>readwrite=str,rw=str
read 顺序读
write 顺序写
randwrite 随机写
randread 随机读
rw,readwrite 顺序混合读写
randrw 随机混合读写
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
fio模拟iometer
配置文件方式:
#cat iometer-file-access-server
[global]

bssplit=512/20:1k/20:2k/10:4k/40:8k/10
 
#2成512B,1KB,1成2KB,4成4KB,1成8KB的小文件进行测试
rw=randrw
rwmixread=80 #8成读,2成写
direct=1 #不使用io设备buffer
size=4g
numjobs=16 #产生16个进程
nrfiles=8 #每1个进程生成文件数量
ioengine=libaio
 
#IO engine,种类丰富,测试nfs,cpu,nic使用不同的引擎。
directory=/mnt
# IOMeter defines the server loads as the following:
# iodepth=1 Linear
# iodepth=4 Very Light
# iodepth=8 Light
# iodepth=64 Moderate
# iodepth=256 Heavy

iodepth=64 #每个文件io队列长度
lockmem=1g #fio只使用1g内存进行测试
zero_buffers 用0初始化系统buffer

一般fio配置文件和参数都是支持k/m/g的标识

顺序测试
命令行方式
fio –name=iometer --rw=randrw --size=4096m --bssplit=32K/20:64k/40:256k/20:512k/20 --direct=1 --ioengine=libaio --iodepth=32 -directory=/mnt --numjobs=8 --nrfiles=8 --rwmixread=60 --zero_buffers


模拟tiobench

# cat tiobench-example



[global]
direct=1
ioengine=libaio
size=512m
bsrange=4k-64k
timeout=60
numjobs=4

[f1]
rw=write
ioengine=sync
bsrange=4k-4k
timeout=120
numjobs=8

[f2]
stonewall
#等待上一个任务完成再开始
rw=randwrite

[f3]
stonewall
ioengine=posixaio
rw=read

[f4]
stonewall
rw=randread

其他参数详见help或者man page。
每一个子选项可以根据自己的需要再次配置,这个可以使用fio来模拟多种混合io。

测试CPU IO
# cat fiocpu.cfg
[global]
readwrite=randrw
name=stresser
directory=/tmp
size=8G
bssplit=32K/20:64k/40:256k/20:512k/20
nrfiles=16
fsync_on_close=1
thread

[cpu0]
ioengine=cpuio
cpuload=100
runtime=300
[cpu1]
ioengine=cpuio
cpuload=100
runtime=300

测试nic IO
测试网络
# cat fionet
[global]
ioengine=net
#the below defaults to a tcp connection, add /udp at the end for udp
filename=localhost/8888
bs=4k
size=10g
iodepth=128
#verify=sha512
#支持md5 crc16 crc32 crc64 crc7 sha256 sha512

[receiver]
rw=read

[sender]
rw=write


[receiver]

rw=read



[sender]

rw=write






example output:
$ fio --name=global --rw=randrw --size=128m --name=job1 --name=job2
job1: (g=0): rw=randrw, bs=4K-4K/4K-4K, ioengine=sync, iodepth=1
job2: (g=0): rw=randrw, bs=4K-4K/4K-4K, ioengine=sync, iodepth=1
Starting 2 processes
Jobs: 1 (f=1): [_m] [99.6% done] [516K/565K /s] [126/138 iops] [eta 00m:01s]
job1: (groupid=0, jobs=1): err= 0: pid=5117
read : io=65880KB, bw=298486B/s, iops=72, runt=226011msec
clat (usec): min=119, max=977960, avg=13487.89, stdev=37647.61
bw (KB/s) : min= 4, max= 603, per=51.98%, avg=300.42, stdev=113.69
write: io=65192KB, bw=295368B/s, iops=72, runt=226011msec
clat (usec): min=10, max=196312, avg=219.16, stdev=4909.93
bw (KB/s) : min= 4, max= 736, per=51.64%, avg=295.87, stdev=132.08
cpu : usr=0.05%, sys=0.57%, ctx=16529, majf=0, minf=555
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 r/w: total=16470/16298, short=0/0
lat (usec): 20=44.48%, 50=4.92%, 100=0.21%, 250=0.79%, 500=0.07%
lat (usec): 750=0.01%
lat (msec): 2=0.58%, 4=10.53%, 10=33.08%, 20=2.33%, 50=0.56%
lat (msec): 100=0.29%, 250=1.96%, 500=0.18%, 750=0.01%, 1000=0.01%
job2: (groupid=0, jobs=1): err= 0: pid=5118
read : io=65716KB, bw=295669B/s, iops=72, runt=227596msec
clat (usec): min=118, max=974169, avg=13608.29, stdev=38346.81
bw (KB/s) : min= 19, max= 766, per=51.65%, avg=298.54, stdev=122.36
write: io=65356KB, bw=294049B/s, iops=71, runt=227596msec
clat (usec): min=9, max=171343, avg=229.40, stdev=5166.00
bw (KB/s) : min= 5, max= 763, per=51.24%, avg=293.60, stdev=138.74
cpu : usr=0.07%, sys=0.54%, ctx=16489, majf=0, minf=1324
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 r/w: total=16429/16339, short=0/0
lat (usec): 10=0.01%, 20=44.36%, 50=5.16%, 100=0.19%, 250=0.91%
lat (usec): 500=0.05%, 750=0.02%, 1000=0.01%
lat (msec): 2=0.64%, 4=10.23%, 10=33.26%, 20=2.38%, 50=0.41%
lat (msec): 100=0.17%, 250=2.01%, 500=0.20%, 750=0.01%, 1000=0.02%

Run status group 0 (all jobs):
READ: io=131596KB, aggrb=578KB/s, minb=295KB/s, maxb=298KB/s, mint=226011msec, maxt=227596msec
WRITE: io=130548KB, aggrb=573KB/s, minb=294KB/s, maxb=295KB/s, mint=226011msec, maxt=227596msec

Disk stats (read/write):
sdb: ios=32878/8303, merge=0/1095, ticks=445868/20400284, in_queue=20964472, util=99.98%

003-安装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
fio
安装fio
apt-get install fio
 
可以把fio的输出数据自动画图的插件gnuplot
apt-get install gnuplot

1.输出bw,lat和iops数据并画图
fio安装完后自带有一个高级脚本fio_generate_plots能够根据fio输出的数据进行画图。操作流程如下:
1.1设置fio输出详细日志
fio的输出日志主要包含三种:bw,lat和iops,设置这三种的参数如下:
write_bw_log=rw
w
write_lat_log=rw
w
write_iops_log=rw


这里需要强调的一点是,后面接的参数rw,是输出日志文件名的prefix,如最终会生成的日志文件如下:
rw_iops.log
r
rw_clat.log
r
rw_slat.log
r
rw_lat.log
r
rw_bw.log


这个参数在后面画图的时候也要用到。
for i in clat lat slat bw iops;do mv rbd_$i.1.log rbd_$i.log;done
1.2 画图
前提是还需要安装好gnuplot,然后使用下面的命令即可自动画图:
root@ubuntu:/tmp> fio_generate_plots bw


发现没有,fio_generate_plots接受的唯一参数就是这个日志文件名的prefix。
本例中生成的图片文件有:

bw-bw.svg 
bw-clat.svg 
bw-iops.svg 
bw-lat.svg 
bw-slat.svg

003-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
fio 验证数据一致性
原创flyandwalker2016-09-19 11:26:46评论(0)1241人阅读
Go to start of metadata
fio可以用md5, crc16,crr32等方式进行数据一致性的验证,基本的验证都是要进行的数据写完然后在进行,这个yuan yang之前已经进行了相关验证,且可行
这次我重点验证了当机器正在进行fio时突然关机或者重启的数据一致性:
一、这种验证方式称之为带trigger的verification–fio将当前的写状态保存到本地,随后的读可以找到相应的文件并可以确切的知道上一次写是停止到了哪里,这个验证方式有两个重要过程组成
1.保存每个job的写状态
2.执行trigger命令
二、执行过程:
1.在被测机器上创建trigger文件 ----touch /tmp/trigger-file
2.进行fio
可以按照以下四种方式进行:
(1)reboot--fio --name=test --filename=/dev/nvme0n1 --rw=write --trigger=reboot --trigger-timeout=60 --verify=md5(如果用CRC方式进行校验需要的时间比较长)
(2)shutdown-----fio --name=test --filename=/dev/nvme0n1 --rw=write --trigger="echo 0 > /sys/class/rtc/rtc0/wakealarm;echo `date '+%s' -d '+ 2 minutes'` > /sys/class/rtc/rtc0/wakealarm;poweroff" --trigger-timeout=30 --verify=md5
(3)reboot--fio --name=test --filename=/dev/nvme0n1 --rw=write --trigger=reboot --trigger-file=/tmp/trigger-file --verify=md5
(4)shutdown-----fio --name=test --filename=/dev/nvme0n1 --rw=write --trigger="echo 0 > /sys/class/rtc/rtc0/wakealarm;echo `date '+%s' -d '+ 2 minutes'` > /sys/class/rtc/rtc0/wakealarm;poweroff"  --trigger-file=/tmp/trigger-file --verify=md5
3.开机后进行验证
fio --name=test --filename=/dev/nvme0n1 --verify_state_load=1 --rw=read --verify=md5
三、重要参数
1.--trigger-file= 创建的trigger文件路径
 2.--trigger-timeout=t 执行fio多久后执行trigger cmd,单位是S
3.--trigger=cmd 命令可以是shut down, reboot
4.–verify_state_load 当需要用trigger方式进行验证时,该变量设置为1,如果不设置该变量,则进行常规的fio读
四、trigger 激活的两种方式
1.trigger-file=/tmp/trigger-file的方式,在被测机上创建一个特定的文件,如果这个文件存在,就会触发主机的reboot ,shutdown等,并且后续可以进行相应的读验证
2.trigger-timeout=t 执行fio多久后执行trigger cmd,单位是S, t秒后触发主机的reboot ,shutdown等,并且后续可以进行相应的读验证

004-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
fio测试脚本
    通过fio主要进行顺序读、顺序写、随机读、随机写的性能测试
#!/bin/bash
function tgt_r {
fio -filename=/rbddir1/1.txt -direct=1 -iodepth 1 -thread -rw=read -ioengine=libaio -bs=$1 -size=10G -numjobs=30 -runtime=300 -group_reporting -name=mytest &>> s_r_test
}

function tgt_w {
fio -filename=/dev/vdb -direct=1 -iodepth 1 -thread -rw=write -ioengine=libaio -bs=$1 -size=10G -numjobs=30 -runtime=300 -group_reporting -name=mytest &>> s_w_test
}

function tgt_rr {
fio -directory=/dev/vdb -direct=1 -iodepth 1 -thread -rw=randread -ioengine=libaio -bs=$1 -size=10G -numjobs=30 -runtime=300 -group_reporting -name=mytest &>> r_r_test
}

function tgt_rw {
fio -filename=/dev/vdb -directory=/dev/vdb -direct=1 -iodepth 1 -thread -rw=randwrite -ioengine=libaio -bs=$1 -size=10G -numjobs=30 -runtime=300 -group_reporting -name=mytest &>> r_w_test
}

for i in 4k 64k 1m
do
tgt_r $i
tgt_w $i
tgt_rr $i
tgt_rw $i
done

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
1)IO类型
向文件发起的IO类型。
<1>readwrite=str,rw=str
read 顺序读
write 顺序写
randwrite 随机写
randread 随机读
rw,readwrite 顺序混合读写
randrw 随机混合读写


fio中的I/O延迟包括三种:slat,clat,lat
关系是 lat = slat + clat。
slat 表示fio submit某个I/O的延迟。
clat 表示fio complete某个I/O的延迟。
lat 表示从fio将请求提交给内核,再到内核完成这个I/O为止所需要的时间


fio同时跑多个裸卷或者文件(注释numjobs为总的)
fio --bs=4K --iodepth=32 --rw=randrw  --rwmixread=80 --time_based --runtime=600 --direct=1 --name=test --filename=/dev/sds:/dev/sdt:/dev/sdu:/dev/sdv:/dev/sdw:/dev/sdx:/dev/sdz --numjobs=120
赞赏一下吧~