![9fad18fb1d6cda4124d46d4249fd09e6.png](https://i-blog.csdnimg.cn/blog_migrate/d9871f6da10778cd22f4e4bdf48d6ec4.jpeg)
安装sysbench
| sudo bash
sudo yum -y install sysbench
sysbench --version
默认安装目录:/usr/share/sysbench
Mysql测试
- 注意根据机器设置,不要贪多设置成很大,比如磁盘不大,表与记录条数都设置很大,CPU一般线程设置成很多等等...
首先需要创建一个测试库
使用已有库也可以
mysql
准备数据
[root@tx19 ~
- --mysql-db 测试数据库,需要已被创建
- --table_size 生成表的数据行数
- --tables 生成多少张测试表,实际测试多设置些,例如250张表
- --events 请求数限制,默认 0
- --time 压测运行时间设置,默认 10s
- oltp_read_write 测试类型,这个是 oltp业务的读写,lua 在 /usr/share/sysbench/
执行
[root@tx19 ~
- threads : 定义多少个连接
- time : 运行的时间
- warmup-time : 预热多少时间
- report-interva :间隔多久生一次报表
- rand-type : 字符串随机分布类型
- percentile : 95%百分位数意味着我们应该丢弃最长请求的5%,并从其余请求中选择最大值
报告解读
[root@tx19 ~
清除
=mysql --mysql-host
磁盘测试
准备数据
=
执行
=
- --file-num 文件数,默认128,iops会随着文件数增大而减小
- --file-extra-flags 打开文件方式
- --file-fsync-freq 完成多少次写入磁盘,默认 100
- --file-test-mode 写入方式{seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}
- --file-block-size 用于所有IO操作的块大小,默认 16k
- --file-io-mode 同步方式,同步或异步等
清除环境
=
测试结果
[root@tx19 ~
IOPS 计算
IOPS = (22.76 + 15.18) * 1024 / 16 = 2428.16 # IOPS = (读+写) * 1024 / 16kb