mysql压力测试---sysbench

一、sysbench简介

sysbench是一款开源的多线程性能测试工具,可以执行CPU/内存/线程/IO/数据库等方面的性能测试。数据库目前支持MySQL/Oracle/PostgreSQL。

二、sysbench安装

下载sysbench-0.4.12.tar.gz

tar -xvf sysbench-0.4.12.tar.gz

如果 MySQL 并不是安装在标准目录下的话,那么就需要自己指定 MySQL 的路径了。

编译安装:

./configure --with-mysql-includes=/usr/local/mysqlndb/include --with-mysql-libs=/usr/local/mysql/lib
make
make install

三、测试

测试分为prepare、run.

ndbcluster测试prepare  

sysbench --test=oltp --mysql-table-engine=ndbcluster --mysql-db=ndb --oltp-table-size=100 --mysql-user=root --mysql-password="" --mysql-socket=/usr/local/mysql/tmp/mysql.sock --db-driver=mysql --num-threads=16 prepare

手动自己写一个存储过程录入数据:

DELIMITER $$
DROP PROCEDURE test.wuxin_erp_insert $$
CREATE PROCEDURE test.wuxin_erp_insert()
BEGIN
DECLARE i INT;
SET i=0;
WHILE i< 100000 DO
REPLACE INTO ndb.sbtest SELECT i,0,‘‘,‘qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt‘;
END WHILE;
COMMIT;
END$$
DELIMITER ;

录入数据:

call test.wuxin_erp_insert ();

分别测试线程说为8,16,32

下面以线程数量为8进行测试

并发线程数量:8

sysbench --test=oltp --mysql-table-engine=ndbcluster --mysql-db=ndb --oltp-table-size=100000 --mysql-user=root --mysql-password="" --mysql-socket=/usr/local/mysql/tmp/mysql.sock --db-driver=mysql --num-threads=8 run

测试结果:
WARNING: Preparing of "BEGIN" is unsupported, using emulation
(last message repeated 7 times)
Running the test with following options:
Number of threads: 8

Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases)
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Maximum number of requests for OLTP test is limited to 10000
Threads started!
Done.

OLTP test statistics:
    queries performed:
        read:                            140000
        write:                           50000
        other:                           20000
        total:                           210000
    transactions:                        10000  (143.72 per sec.)
    deadlocks:                           0      (0.00 per sec.)
    read/write requests:                 190000 (2730.70 per sec.)
    other operations:                    20000  (287.44 per sec.)

Test execution summary:
    total time:                          69.5791s
    total number of events:              10000
    total time taken by event execution: 556.3746
    per-request statistics:
         min:                            0.0201s
         avg:                            0.0556s
         max:                            0.3690s
         approx.  95 percentile:         0.0766s

Threads fairness:
    events (avg/stddev):           1250.0000/8.28
    execution time (avg/stddev):   69.5468/0.01

Innodb测试prepare 

sysbench --test=oltp --mysql-table-engine=innodb --mysql-db=test --oltp-table-size=100000 --mysql-user=root --mysql-password="" --mysql-socket=/usr/local/mysql/tmp/mysql.sock --db-driver=mysql --num-threads=8 prepare

分别测试线程说为8,16,32

下面以线程数量为8进行测试:

开始测试 8线程

sysbench --test=oltp --mysql-table-engine=innodb --mysql-db=test --oltp-table-size=100000 --mysql-user=root --mysql-password="" --mysql-socket=/usr/local/mysql/tmp/mysql.sock --db-driver=mysql --num-threads=8 run

测试结果:
WARNING: Preparing of "BEGIN" is unsupported, using emulation
(last message repeated 7 times)
Running the test with following options:
Number of threads: 8

Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases)
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Maximum number of requests for OLTP test is limited to 10000
Threads started!
Done.

OLTP test statistics:
    queries performed:
        read:                            140000
        write:                           50000
        other:                           20000
        total:                           210000
    transactions:                        10000  (771.84 per sec.)
    deadlocks:                           0      (0.00 per sec.)
    read/write requests:                 190000 (14664.87 per sec.)
    other operations:                    20000  (1543.67 per sec.)

Test execution summary:
    total time:                          12.9561s
    total number of events:              10000
    total time taken by event execution: 103.5427
    per-request statistics:
         min:                            0.0023s
         avg:                            0.0104s
         max:                            0.3084s
         approx.  95 percentile:         0.0185s

Threads fairness:
    events (avg/stddev):           1250.0000/9.50
    execution time (avg/stddev):   12.9428/0.01
时间: 2024-08-26 08:33:31

mysql压力测试---sysbench的相关文章

使用sysbench对mysql压力测试

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

MySQL压力测试工具

工具名称:mysqlha_sysbench.sh 工具用途:用于MySQL压力测试  (2种功能:填充数据&&测试数据) 工具参数: options: -P 需要测试的端口-D 需要测试的db名字-H 需要测试的host-S 填充&&测试 表的数据量,default 100w-C 填充&&测试 表的数量, default 1-T prepare and run ,prepare is 制造数据 run is 开始测试 ,default run-O on an

mysql压力测试

1,使用 mysqlslap  进行压力测试 mysqlslap  --defaults-file=/etc/my.cnf --concurrency=200 --iterations=1 --number-int-cols=1 --auto-generate-sql --auto-generate-sql-load-type=write --engine=myisam,innodb --number-of-queries=200 -S/home/mysql/mysql.sock  --debu

MySQL Study之--MySQL压力测试工具mysqlslap

MySQL Study之--MySQL压力测试工具mysqlslap 一.Mysqlslap介绍 mysqlslap是MySQL5.1之后自带的benchmark基准测试工具,类似Apache Bench负载产生工具,生成schema,装载数据,执行benckmark和查询数据,语法简单,灵活,容易使用.该工具可以模拟多个客户端同时并发的向服务器发出查询更新,给出了性能测试数据而且提供了多种引擎的性能比较.mysqlslap为mysql性能优化前后提供了直观的验证依据,笔者建议系统运维人员应该掌

mysql 压力测试工具

mysql  压力测试工具 自从mysql5.1 之后就自带有一个压力测试的工具 mysqlslap mysqlslap可以自动生成测试脚本 ,也可以使用第三方提供的测试脚本. mysqlslap可以测试的指标 (1).系统的最大并发度 (2).不同存储引擎之间的性能比较 (3).系统同一变量设置为不同值时的性能比较 (4).不同版本之间的性能比较 mysqlslap 的具体使用方法可以直接查看帮助   mysqlslap --help 常用的参数有: --concurrency代表并发数量,多

使用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

tcpcopy,模拟在线MySQL压力测试的好帮手

主要信息来自:http://code.google.com/p/tcpcopy/ tcpcopy是一个基于底层的应用请求复制(所有基于tcp的packets)开源项目,可用于替代ab做在线模拟压力测试,可转发各种在线请求到测试服务器上,进行较为详尽的近乎实际的测试,从而避免了新业务.系统上线带来的潜在问题. tcpcopy的四大功能: 1)分布式压力测试,将多个前段请求集中到某个后端进行压力测试2)上线前测试,检验新系统可靠性,提前发现潜在问题3)对比测试,同样请求,针对不同或不同版本程序,可以

mysql5.6压力测试 sysbench工具

面对高并发大流量服务器,根据业务需要往往需要对数据库,操作系统I/O,带宽等等做压力测试.从而来判断什么时候要做负载均衡,增加服务器等来为业务支撑做准备.linux系统可以通过iotop,dstat,top等分析系统的压力.对mysql压测有很多优秀的工具sysbench,tpcc等都是很不错的工具. 今天就用sysbench压测一下mysql5.6.23社区版本,服务器比较渣,4核cpu,16G,磁盘转速9600 但压测结果还是比较满意的. 通过压力测试,能够对服务器的处理能力有个基本的认识.

MySQL压力测试工具使用

一.MySQL自带的压力测试工具--Mysqlslap mysqlslap是mysql自带的基准测试工具,该工具查询数据,语法简单,灵活容易使用.该工具可以模拟多个客户端同时并发的向服务器发出查询更新,给出了性能测试数据而且提供了多种引擎的性能比较.mysqlslap为mysql性能优化前后提供了直观的验证依据,系统运维和DBA人员应该掌握一些常见的压力测试工具,才能准确的掌握线上数据库支撑的用户流量上限及其抗压性等问题. 1.更改其默认的最大连接数 在对MySQL进行压力测试之前,需要更改其默