sysbench对MySQL的压测,使用sysbench压测磁盘io

QPS - query per second
TPS - transaction per second 不是特别关注,每个业务场景中事务标准是不一样的

Ⅰ、sysbench测试框架

Ⅱ、常用测试脚本

[[email protected]_42_63_centos lua]# pwd
/usr/local/src/sysbench-master/src/lua
[[email protected]_42_63_centos lua]# ll *.lua
-rwxr-xr-x 1 root root  1446 Jun 27 02:35 bulk_insert.lua
-rw-r--r-- 1 root root  1307 Jun 27 02:35 empty-test.lua
-rw-r--r-- 1 root root 14468 Jun 27 02:35 oltp_common.lua
-rwxr-xr-x 1 root root  1290 Jun 27 02:35 oltp_delete.lua
-rwxr-xr-x 1 root root  2415 Jun 27 02:35 oltp_insert.lua
-rwxr-xr-x 1 root root  1265 Jun 27 02:35 oltp_point_select.lua
-rwxr-xr-x 1 root root  1649 Jun 27 02:35 oltp_read_only.lua
-rwxr-xr-x 1 root root  1824 Jun 27 02:35 oltp_read_write.lua
-rwxr-xr-x 1 root root  1118 Jun 27 02:35 oltp_update_index.lua
-rwxr-xr-x 1 root root  1127 Jun 27 02:35 oltp_update_non_index.lua
-rwxr-xr-x 1 root root  1440 Jun 27 02:35 oltp_write_only.lua
-rw-r--r-- 1 root root  1631 Jun 27 02:35 prime-test.lua
-rwxr-xr-x 1 root root  1933 Jun 27 02:35 select_random_points.lua
-rwxr-xr-x 1 root root  2132 Jun 27 02:35 select_random_ranges.lua

Ⅲ、开搞

这个老版本好像有参数设置热数据的量什么的,现在最新版本不知道咋搞,就先将就直接弄吧,不管了

准备数据
[[email protected]_42_63_centos lua]# sysbench --mysql-host=127.0.0.1 --mysql-port=3307 --mysql-db=sbtest --tables=10 --table-size=10000 --mysql-user=root --mysql-password=123 oltp_update_index.lua prepare
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

Creating table ‘sbtest1‘...
Inserting 10000 records into ‘sbtest1‘
Creating a secondary index on ‘sbtest1‘...
Creating table ‘sbtest2‘...
Inserting 10000 records into ‘sbtest2‘
Creating a secondary index on ‘sbtest2‘...
Creating table ‘sbtest3‘...
Inserting 10000 records into ‘sbtest3‘
Creating a secondary index on ‘sbtest3‘...
...

开始测试
[[email protected]_42_63_centos lua]# sysbench oltp_update_index.lua --mysql-host=127.0.0.1 --mysql-port=3307 --mysql-user=root --mysql-password=123 --threads=10 --time=120 --report-interval=10 run
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 10
Report intermediate results every 10 second(s)
Initializing random number generator from current time

Initializing worker threads...

Threads started!

[ 10s ] thds: 10 tps: 804.14 qps: 804.14 (r/w/o: 0.00/804.14/0.00) lat (ms,95%): 36.89 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: 10 tps: 647.70 qps: 647.70 (r/w/o: 0.00/647.70/0.00) lat (ms,95%): 35.59 err/s: 0.00 reconn/s: 0.00
[ 30s ] thds: 10 tps: 2220.50 qps: 2220.50 (r/w/o: 0.00/2220.50/0.00) lat (ms,95%): 18.28 err/s: 0.00 reconn/s: 0.00
[ 40s ] thds: 10 tps: 4566.59 qps: 4566.59 (r/w/o: 0.00/4566.59/0.00) lat (ms,95%): 2.71 err/s: 0.00 reconn/s: 0.00
[ 50s ] thds: 10 tps: 4194.30 qps: 4194.30 (r/w/o: 0.00/4194.30/0.00) lat (ms,95%): 7.30 err/s: 0.00 reconn/s: 0.00
[ 60s ] thds: 10 tps: 4717.91 qps: 4717.91 (r/w/o: 0.00/4717.91/0.00) lat (ms,95%): 2.76 err/s: 0.00 reconn/s: 0.00
...

看结果,这里就不解释了,比较简单,随便看看就好
SQL statistics:
    queries performed:
        read:                            0
        write:                           665574
        other:                           0
        total:                           665574
    transactions:                        665574 (5546.21 per sec.)
    queries:                             665574 (5546.21 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

Throughput:
    events/s (eps):                      5546.2076
    time elapsed:                        120.0052s
    total number of events:              665574

Latency (ms):
         min:                                    0.27
         avg:                                    1.80
         max:                                  123.45
         95th percentile:                        2.43
         sum:                              1199263.13

Threads fairness:
    events (avg/stddev):           66557.4000/209.28
    execution time (avg/stddev):   119.9263/0.00

Ⅰ、sysbench安装

cd /usr/local/src
yum -y install make automake libtool pkgconfig libaio-devel
git clone https://github.com/akopytov/sysbench.git
cd sysbench
./autogen.sh
./configure
make -j 4
make install
ldconfig /usr/local/mysql/lib

[[email protected]_42_63_centos sysbench]# sysbench --version;
sysbench 1.1.0-50966c8

Ⅱ、file io测试

2,1 生成测试文件

sysbench fileio --file-num=4 --file-block-size=16384 --file-total-size=110G prepare

2.2 看下参数

[[email protected]_42_63_centos data]# sysbench fileio help
sysbench 1.1.0-50966c8 (using bundled LuaJIT 2.1.0-beta3)

fileio options:
  --file-num=N                  number of files to create [128]
  --file-block-size=N           block size to use in all IO operations [16384]
  --file-total-size=SIZE        total size of files to create [2G]
  --file-test-mode=STRING       test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}
  --file-io-mode=STRING         file operations mode {sync,async,mmap} [sync]
  --file-extra-flags=[LIST,...] list of additional flags to use to open files {sync,dsync,direct} []
  --file-fsync-freq=N           do fsync() after this number of requests (0 - don‘t use fsync()) [100]
  --file-fsync-all[=on|off]     do fsync() after each write operation [off]
  --file-fsync-end[=on|off]     do fsync() at the end of test [on]
  --file-fsync-mode=STRING      which method to use for synchronization {fsync, fdatasync} [fsync]
  --file-merged-requests=N      merge at most this number of IO requests if possible (0 - don‘t merge) [0]
  --file-rw-ratio=N             reads/writes ratio for combined test [1.5]

2.3 测两把看看

  • 先看随机读
[[email protected]_42_63_centos sysdata]# sysbench fileio > --time=180 > --threads=24 > --file-total-size=110G > --file-test-mode=rndrd > --file-num=4 > --file-extra-flags=direct > --file-fsync-freq=0 > --file-block-size=16384 > run
sysbench 1.1.0-50966c8 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 24
Initializing random number generator from current time

Extra file open flags: directio
4 files, 2.5GiB each
10GiB total file size
Block size 16KiB
Number of IO requests: 0
Read/Write ratio for combined random IO test: 1.50
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random read test
Initializing worker threads...

Threads started!

Throughput:
         read:  IOPS=1752.15 27.38 MiB/s (28.71 MB/s)
         write: IOPS=0.00 0.00 MiB/s (0.00 MB/s)
         fsync: IOPS=0.00

Latency (ms):
         min:                                  0.07
         avg:                                 13.70
         max:                                687.59
         95th percentile:                     36.89
         sum:                            4319633.88
  • 再看随机写
[[email protected]_42_63_centos sysdata]# sysbench fileio > --time=180 > --threads=24 > --file-total-size=110G > --file-test-mode=rndwr > --file-num=4 > --file-extra-flags=direct > --file-fsync-freq=0 > --file-block-size=16384 > run
sysbench 1.1.0-50966c8 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 24
Initializing random number generator from current time

Extra file open flags: directio
4 files, 2.5GiB each
10GiB total file size
Block size 16KiB
Number of IO requests: 0
Read/Write ratio for combined random IO test: 1.50
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random write test
Initializing worker threads...

Threads started!

Throughput:
         read:  IOPS=0.00 0.00 MiB/s (0.00 MB/s)
         write: IOPS=1094.75 17.11 MiB/s (17.94 MB/s)
         fsync: IOPS=0.53

Latency (ms):
         min:                                  0.09
         avg:                                 21.92
         max:                               3376.77
         95th percentile:                     94.10
         sum:                            4319984.68

随机读的iops为1752,随机写的iops为1094,读写非对称

清理测试文件用cleanup选项即可

我们主要看随机写的性能哦

原文地址:https://www.cnblogs.com/DataArt/p/10236657.html

时间: 2024-10-12 19:57:51

sysbench对MySQL的压测,使用sysbench压测磁盘io的相关文章

记一次性能测试:mysql占用磁盘IO过高 的解决过程

在一次性能测试时,发现mysql的cpu使用率不高,但是磁盘io很高, 一开始考虑是mysql的慢日志比较多,但是查看后发现慢日志并不多,而且只有一台mysql. 进入实例,查看sync_binlog变量 mysql> show variables like '%sync_binlog%' -> ; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | sync_binlog | 1 |

使用sysbench对mysql压力测试

使用sysbench对mysql压力测试 sysbench是一个模块化的.跨平台.多线程基准测试工具,主要用于评估测试各种不同系统参数下的数据库负载情况.关于这个项目的详细介绍请看:https://github.com/akopytov/sysbench .它主要包括以下几种方式的测试: cpu性能 磁盘io性能 调度程序性能 内存分配及传输速度 POSIX线程性能 数据库性能(OLTP基准测试) sysbench的数据库OLTP测试支持MySQL.PostgreSQL.Oracle,目前主要用

使用Sysbench 进行Mysql 压力测试

安装压力测试工具:sysbench 1> 安装依赖环境包:yum install -y bzryum install -y libtool下载主程序包:bzr branch lp:sysbench   //下载到当前目录,文件名为: sysbench开始安装:cd sysbench./autogen.sh./configure --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib

MySQL 5.6 VS 5.7压测报告

  MySQL 5.6 VS 5.7压测报告   版本 姓名 时间 V1.0 刘占彬 2016.3.2   测试条件 1.        软件 OS:  CentOS release 6.7 (Final) 文件格式:xfs MySQL:percona5.6.24  VS  5.7.10 关键参数配置(yum install后初始化默认,未做修改): bufferpool大小16G sync_binlog=0 innodb_flush_log_at_trx_commit= 2 压测工具:sysb

sysbench测试mysql性能

sysbench测试mysql性能: 安装 sysbench 0.5: apt-get install bzr automake libtool libmysqlclient-dev ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20.3.14 /usr/lib/libmysqlclient_r.so bzr branch lp:sysbench cd sysbench/ ./autogen.sh ./configure make &&

sysbench利用fabric磁盘IO测试

利用sysbench测试磁盘IO: 10台机器并发测试,一台fabric控制server,控制端需要安装fabric,测试server安装sysbench,测试时生成15G的测试文件:测试案例如下: fabric的远程管理,可以看一下上篇博文: http://xujunxian.blog.51cto.com/8614409/1730780 测试执行: 1.创建11台ubuntu台虚拟机,1台安装fabric,10台安装sysbench,并配置好IP地址,fabric需要直接访问安装sysbenc

mysql 5.7 64位 解压版安装

64位操作系统最好安装64位的mysql数据库,充分利用内存的寻址能力,对于windows而言,mysql官网只提供了32位的MSI安装程序,因为在windows下安装64位的mysql,选择解压版安装. 1.官网下载mysql 5.7 64位 解压到D:\mysql-5.7.12-winx64\mysql-5.7.12-winx64 2.拷贝my-default.ini,重命名为my.ini my.ini中填写如下内容: [mysqld] basedir=D:\mysql-5.7.12-win

如何开展全链路压测&全链路压测核心要素

之前对全链路压测概念比较懵,现在简单梳理下,后续有学习到的干货再持续补充:可参考:阿里全链路压测京东全链路压测 1.什么是全链路压测 基于实际的生产业务场景.系统环境,模拟海量的用户请求和数据对整个业务链进行压力测试,并持续调优的过程. 2.全链路压测解决什么问题 针对业务场景越发复杂化.海量数据冲击下整个业务系统链的可用性.服务能力的瓶颈,让技术更好的服务业务,创造更多的价值. 3.如何开展全链路压测?分析压测业务场景涉及系统服务:协调各个压测系统资源:压测环境(需要将请求和访问.业务数据处理

磁盘IO高和线程切换过高性能压测案例分析

案例现象: 压力测试的时候,发现A请求压力80tps后,cpu占用就非常高了(24核的机器,每个cpu占用率全面飙到80%以上),且设置的检查点没有任何报错. 1.top命令如下: 2. 了解了一下后台实现逻辑:大体是这样的:服务器接到请求后,会再到另一台kv服务器请求数据,拿回来数据后,根据用户的机器码做个性化运算,最后将结果返回给客户端,期间会输出一些调试log. 查了下,kv服务器正常,说明是本机服务服务器的问题.具体用vmstat命令看一下异常的地方. 3. 从图中可以直观的看出,bi.