温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

安装sysbench并进行MySQL压力测试讲义

发布时间:2020-04-23 14:33:55 来源:亿速云 阅读:356 作者:三月 栏目:MySQL数据库

本文主要给大家介绍安装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

  安装sysbench并进行MySQL压力测试讲义

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

看了以上安装sysbench并进行MySQL压力测试讲义介绍,希望能给大家在实际运用中带来一定的帮助。本文由于篇幅有限,难免会有不足和需要补充的地方,大家可以继续关注亿速云行业资讯板块,会定期给大家更新行业新闻和知识,如有需要更加专业的解答,可在官网联系我们的24小时售前售后,随时帮您解答问题的。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI