Skip to content

第42章 FIO存储性能压测

xiaoboluo768 edited this page Jun 18, 2020 · 3 revisions

42.1 安装FIO

  • 1.yum安装
[root@localhost~]# yum install fio.x86_64
  • 2.源码安装
[root@localhost~]# wget https://github.com/axboe/fio/archive/fio-3.3.tar.gz

[root@localhost~]# yum install libaio-devel

[root@localhost~]# tar zxf fio-3.3.tar.gz

[root@localhost~]# cd fio-fio-3.3
[root@localhost~]# ./configure
[root@localhost~]# make
[root@localhost~]# make install

42.2.1 随机写

[root@localhost~]# fio -rw=randwrite -bs=4k -runtime=60 -iodepth 1 -numjobs=4 -size=10G\ -filename /data2/test1 -ioengine libaio -direct=1 -group_reporting -name iops_randwrite 

42.2.2 顺序写

[root@localhost~]# fio -rw=write -bs=1m -runtime=60 -iodepth 1 -numjobs=4 -size=10G\ -filename /data2/test1 -ioengine libaio -direct=1 -group_reporting -name bw_write

42.2.3 随机读

[root@localhost~]# fio -readonly -rw=randread -bs=4k -runtime=60 -iodepth 1 -numjobs=8\ -size=10G -filename /data2/test1 -ioengine libaio -direct=1 -group_reporting –name\ iops_randread

42.2.4 顺序读

[root@localhost~]# fio -readonly -rw=read -bs=1m -runtime=60 -iodepth 1 -numjobs=8\ -size=10G -filename /data2/test1 -ioengine libaio -direct=1 -group_reporting -name bw_read

42.2.5 混合随机读写

[root@localhost~]# fio -rw=randrw -rwmixread=70 -bs=16k -runtime=60 -iodepth 1\ -numjobs=8 -size=10G -filename /data2/test1 -ioengine libaio -direct=1 -group_reporting\ -name iops_randrw

42.2.6 FIO配置文件测试

[root@localhost~]# fio /usr/share/doc/fio-2.2.8/examples/ssd-test.fio

42.3.2 配置文件

  • 1.SSD性能测试配置文件
[root@localhost~]# cat examples/ssd-test.fio
......

[global]
bs=4k
ioengine=libaio
iodepth=4
size=10g
direct=1
runtime=60
directory=/mount-point-of-ssd
filename=ssd.test.file

[seq-read]
rw=read
stonewall

[rand-read]
rw=randread
stonewall

[seq-write]
rw=write
stonewall

[rand-write]
rw=randwrite
stonewall
  • 2.MySQL数据库FIO测试
[global]
runtime=86400
time_based
group_reporting
directory=/your_dir
ioscheduler=deadline
refill_buffers   	# 保证每次生成的测试文件内容有充分的随机性

[mysql-binlog]
filename=test-mysql-bin.log
bsrange=512-1024 	# I/O请求的块大小为512字节的整数倍,最大为1024字节
ioengine=sync
rw=write
size=24G
sync=1
rw=write
overwrite=1
fsync=100
rate_iops=64  		# 定义IOPS的最大值为64。由于bsrange为512~1024字节,对应的IOPS最大值为64个512字节的 I/O(或者32个1024字节的 I/O)
invalidate=1  		# 使buffer-cache(缓冲区)在开始I/O之前就失效
numjobs=64

[innodb-data]
filename=test-innodb.dat
bs=16K
ioengine=psync
rw=randrw
size=200G
direct=1
rwmixread=80 		# 读写比例设置为8∶2
numjobs=32

thinktime=600         # 从完成一个I/O到下一个I/O间隔600ms
# 在全速I/O压力下可以设置该参数为0
thinktime_spin=200  	# 在thinktime中200ms在消耗 CPU,剩下的400ms在睡眠
thinktime_blocks=2 	# 允许一次I/O最多有两个块等待一次thinktime

[innodb-trxlog]
filename=test-innodb.log
bsrange=512-2048 
ioengine=sync
rw=write
size=2G
fsync=1
overwrite=1
rate_iops=64 
invalidate=1
numjobs=64

42.3.3 结果解析

[root@localhost~]# fio -readonly -rw=randread -bs=4k -runtime=60 -iodepth 1 –filename\ /data/voting.7g -ioengine libaio -direct=1 -name iops_randread
......

上一篇:第41章 系统负载常用查看命令详解 | 下一篇:第43章 HammerDB在线事务处理测试

Clone this wiki locally