最新消息:

Fio模拟Mysql服务器IO压力脚本

未分类 admin 3457浏览 0评论

fio是个非常好用的io压力模拟工具,功能非常齐全, 有兴趣的同学参看 这里
这里我用fio模拟我们线上mysql服务器的压力来为厂家送来的pci-ssd卡做压力测试,底下是脚本(已经测试正确),也许有的同学有用。

cat mysql-test
# QPS: 40000(10 cores)
# Dataset: 200G
# R/W: 8/2
# ThreadPool Num: 64
#  IO ThreadNum: 32
[global]
runtime=86400
time_based
group_reporting
directory=/your_dir
ioscheduler=deadline
refill_buffers
[mysql-binlog]
filename=test-mysql-bin.log
bsrange=512-1024
ioengine=sync
rw=write
size=24G
sync=1
rw=write
overwrite=1
fsync=100
rate_iops=64
invalidate=1
numjobs=64
[innodb-data]
filename=test-innodb.dat
bs=16K
ioengine=psync
rw=randrw
size=200G
direct=1
rwmixread=80
numjobs=32
thinktime=600
thinktime_spin=200
thinktime_blocks=2
[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
sudo fio mysql-test
mysql-binlog: (g=0): rw=write, bs=512-1K/512-1K, ioengine=sync, iodepth=1
...
mysql-binlog: (g=0): rw=write, bs=512-1K/512-1K, ioengine=sync, iodepth=1
innodb-data: (g=0): rw=randrw, bs=16K-16K/16K-16K, ioengine=psync, iodepth=1
...
innodb-data: (g=0): rw=randrw, bs=16K-16K/16K-16K, ioengine=psync, iodepth=1
innodb-trxlog: (g=0): rw=write, bs=512-2K/512-2K, ioengine=sync, iodepth=1
...
innodb-trxlog: (g=0): rw=write, bs=512-2K/512-2K, ioengine=sync, iodepth=1
fio 1.50.2
Starting 160 threads
...

要注意的事项是:
1. 对iops的限制是针对每个线程的,总的限制是 限制*线程数
2. 在thinktime_blocks个io开始前先等待thinktime(其中thinktime_spin用于消耗cpu, 剩余时间用于sleep)
3. 每个io需要花费时间。这个时间随着设备的不同差别很大,最好的方法是测试。用一个线程测试,然后用strace查看。

上面的数字要根据具体的设备和mysql场景去调整。

转载请注明:爱开源 » Fio模拟Mysql服务器IO压力脚本

您必须 登录 才能发表评论!