https://github.com/nuodb/sysbench
wget https://github.com/nuodb/sysbench/archive/master.zip
cd sysbench-master
./autogen.sh 
./configure --with-mysql-includes=/data/mysql/include/  --with-mysql-libs=/data/mysql/lib/ 
make

export LD_LIBRARY_PATH=/data/mysql/lib/
./sysbench/sysbench --help

常用命令参数:

/usr/local/sysbench-0.5/bin/sysbench
     --mysql-host=test.mysql.rds.aliyuncs.com           #数据库host
     --mysql-port=3306                                              #数据库端口
     --mysql-user=your_username                             #数据库用户名
     --mysql-password=your_password                      #数据库密码
     --mysql-socket=
     --mysql-db=your_db_for_test                              #数据库名
     --mysql-table-engine=innodb
     --oltp-tables-count=10                        #模拟的表的个数,规格越高该值越大
     --oltp-table-size=6000000                  #模拟的每张表的行数,规格越高该值越大
     --num-threads=50                              #模拟的并发数量,规格越高该值越大
     --max-requests=100000000               #最大请求次数
     --max-time=20                           #最大测试时间(与--max-requests只要有一个超过,则退出)
     --report-interval=1                     #每1秒打印一次当前的QPS等值
     --test=/tmp/sysbench-0.5/sysbench/tests/db/oltp.lua    #选用的测试脚本(lua),此脚本可以从sysbench-0.5源代码文件目录下找

     [prepare | run | cleanup]           #prepare准备数据,run执行测试,cleanup清理数据

测试结果解读如下:
sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 8
Report intermediate results every 10 second(s)
Random number generator seed is 0 and will be ignored


Threads started!
-- 每10秒钟报告一次测试结果,tps、每秒读、每秒写、99%以上的响应时长统计
[  10s] threads: 8, tps: 1111.51, reads/s: 15568.42, writes/s: 4446.13, response time: 9.95ms (99%)
[  20s] threads: 8, tps: 1121.90, reads/s: 15709.62, writes/s: 4487.80, response time: 9.78ms (99%)
[  30s] threads: 8, tps: 1120.00, reads/s: 15679.10, writes/s: 4480.20, response time: 9.84ms (99%)
[  40s] threads: 8, tps: 1114.20, reads/s: 15599.39, writes/s: 4456.30, response time: 9.90ms (99%)
[  50s] threads: 8, tps: 1114.00, reads/s: 15593.60, writes/s: 4456.70, response time: 9.84ms (99%)
[  60s] threads: 8, tps: 1119.30, reads/s: 15671.60, writes/s: 4476.50, response time: 9.99ms (99%)
OLTP test statistics:
    queries performed:
        read:                            938224    -- 读总数
        write:                           268064    -- 写总数
        other:                           134032    -- 其他操作总数(SELECT、INSERT、UPDATE、DELETE之外的操作,例如COMMIT等)
        total:                           1340320    -- 全部总数
    transactions:                        67016  (1116.83 per sec.)    -- 总事务数(每秒事务数)
    deadlocks:                           0      (0.00 per sec.)    -- 发生死锁总数
    read/write requests:                 1206288 (20103.01 per sec.)    -- 读写总数(每秒读写次数)
    other operations:                    134032 (2233.67 per sec.)    -- 其他操作总数(每秒其他操作次数)

General statistics:    -- 一些统计结果
    total time:                          60.0053s    -- 总耗时
    total number of events:              67016    -- 共发生多少事务数
    total time taken by event execution: 479.8171s    -- 所有事务耗时相加(不考虑并行因素)
    response time:    -- 响应时长统计
         min:                                  4.27ms    -- 最小耗时
         avg:                                  7.16ms    -- 平均耗时
         max:                                 13.80ms    -- 最长耗时
         approx.  99 percentile:               9.88ms    -- 超过99%平均耗时

Threads fairness:
    events (avg/stddev):           8377.0000/44.33
    execution time (avg/stddev):   59.9771/0.00


sysbench创建表的语句是:

CREATE TABLE sbtest (
  id int(10) unsigned NOT NULL AUTO_INCREMENT,
  k int(10) unsigned NOT NULL DEFAULT '0',
  c char(120) NOT NULL DEFAULT '',
  pad char(60) NOT NULL DEFAULT '',
  PRIMARY KEY (id),
  KEY k (k)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1

results matching ""

    No results matching ""