mysql sysbench_使用sysbench进行MySQL压力测试

1. 安装 sysbench

[root@benchserver ~]# yum install sysbench

[root@benchserver ~]# rpm -ql sysbench-1.0.17-2.el7.x86_64 | grep lua$

sysbench使用lua脚本编写,所以最终测试都需要调用lua脚本。

[root@benchserver ~]# sysbench --help

实际使用中参数不多,核心参数如下:

General options:

--config-file=FILENAME          File containing command line options

--threads=N                     number of threads to use [1]

--time=N                        limit for total execution time in seconds [10]

--report-interval=N             periodically report intermediate statistics with a specified interval in seconds.

--db-driver=STRING  specifies database driver to use [mysql]

Compiled-in database drivers:

mysql - MySQL driver

pgsql - PostgreSQL driver

mysql options:

--mysql-host=[LIST,...]          MySQL server host [localhost]

--mysql-port=[LIST,...]          MySQL server port [3306]

--mysql-user=STRING              MySQL user [sbtest]

--mysql-password=STRING          MySQL password []

--mysql-db=STRING                MySQL database name [sbtest]

2. MySQL数据库创建压力测试用账号

(root@localhost 18:38) [(none)]> create user 'admin'@'10.9.82.187' identified by 'oracle';

(root@localhost 18:39) [(none)]> flush privileges;

(root@localhost 18:39) [(none)]> create database sbtest;

(root@localhost 18:39) [(none)]> grant all on sbtest.* to 'admin'@'10.9.82.187';

3. 压力测试主机测试远程登录

[root@benchserver ~]# mysql -h 10.9.59.32 -u admin -poracle -D sbtest

4. 创建压力测试脚本

[root@benchserver ~]# mkdir sysbench

[root@benchserver ~]# cd sysbench/

[root@benchserver sysbench]# vi mysql_config

mysql-host=10.9.59.32

mysql-port=3306

mysql-user=admin

mysql-password=oracle

mysql-db=sbtest

time=6000

threads=8

report-interval=1

db-driver=mysql

5. 数据初始化

[root@benchserver sysbench]# sysbench --config-file=mysql_config oltp_point_select --tables=16 --table-size=100000 prepare

prepare 为初始化测试

6. 压力测试

[root@benchserver sysbench]# sysbench --config-file=mysql_config oltp_point_select --tables=16 --table-size=100000 run | tee oltp_point_select.rpt

run 为实际压力测试

Initializing worker threads...

Threads started!

[ 1s ] thds: 16 tps: 25021.07 qps: 25021.07 (r/w/o: 25021.07/0.00/0.00) lat (ms,95%): 0.90 err/s: 0.00 reconn/s: 0.00

[ 24s ] thds: 16 tps: 26823.29 qps: 26823.29 (r/w/o: 26823.29/0.00/0.00) lat (ms,95%): 0.84 err/s: 0.00 reconn/s: 0.00

标签:benchserver,0.00,MySQL,测试,mysql,root,sysbench

来源: https://blog.51cto.com/recyclebin/2428609

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值