间间隔报告测试信息,不用等到运行结束时再得到反馈
--report-checkpoints=[LIST,...]dump full statistics and reset all counters at specified points in time. The argument is a list of comma-separated values representing the amount of time in seconds elapsed from start of test when report checkpoint(s) must be performed. Report checkpoints are off by default. []
--test=STRING test to run
--debug=[on|off] print more debugging info [off]
--validate=[on|off] perform validation checks where possible [off]
--help=[on|off] print help and exit
--version=[on|off] print version and exit [off]
--rand-init=[on|off] initialize random number generator [off]#初始化时生成随机的数据,默认关闭
--rand-type=STRING random numbers distribution {uniform,gaussian,special,pareto} [special]
--rand-spec-iter=N number of iterations used for numbers generation [12]
--rand-spec-pct=N percentage of values to be treated as 'special' (for special distribution) [1]
--rand-spec-res=N percentage of 'special' values to use (for special distribution) [75]
--rand-seed=N seed for random number generator, ignored when 0 [0]
--rand-pareto-h=N parameter h for pareto distibution [0.2]
Log options:
--verbosity=N verbosity level {5 - debug, 0 - only critical messages} [3]
--percentile=N percentile rank of query response times to count [95]
Compiled-in tests:测试项目
fileio - File I/O test #磁盘IO测试
cpu - CPU performance test #CPU运算性能
memory - Memory functions speed test #内存分配及传输速度
threads - Threads subsystem performance test #POSIX线程性能
mutex - Mutex performance test #互斥性能测试
Commands: prepare run cleanup help version
See 'sysbench --test= help' for a list of options for each test.
二、测试
1.MySQL-OLTP测试
数据准备
[root@localhost sysbench_0.5]# sysbench --mysql-db=sbtest --num-threads=24 --mysql-engine-trx=yes --mysql-table-engine=innodb --rand-type=special --mysql-host=localhost --mysql-port=3307 --mysql-user=root --mysql-password= --mysql-socket=/data1/lib/mysql/mysql.sock --test=sysbench/tests/db/oltp.lua --oltp_tables_count=50 --oltp-table-size=10000000 --rand-init=on prepare
参数说明:
--mysql-db:指定在哪个数据库创建测试表,默认为sbtest库,需要提前创建好
--num-threads:使用多线程创建多表,节省准备时间
--mysql-engine-trx=yes 支持事务
--mysql-table-engine:指定存储引擎,如myisam,innodb,heap,ndbcluster,bdb,maria,falcon,pbxt 默认InnoDB
--test=tests/db/oltp.lua 表示调用 tests/db/oltp.lua 脚本进行 oltp 模式测试
--oltp_tables_count=10 表示会生成 10 个测试表
--oltp-table-size=1000000 表示每个测试表填充数据量为 1000000
--db-driver:指定驱动,默认为Mysql
--rand-init=on 表示每个测试表都是用随机数据来填充的
#使用1000个线程开始测试,读写模式。
模拟 对50个表并发OLTP测试,每个表1000万行记录,持续压测时间为 1小时
[root@localhost sysbench_0.5]# sysbench --mysql-engine-trx=yes --mysql-table-engine=innodb --mysql-host=localhost --mysql-port=3307 --mysql-user=root --mysql-password= --mysql-socket=/data1/lib/mysql/mysql.sock --test=sysbench/tests/db/oltp.lua --oltp_tables_count=50 --oltp-table-size=100000000 --num-threads=1000 --oltp-read-only=off --report-interval=10 --rand-type=uniform --max-time=3600 --max-requests=0 --percentile=95 run >>/data1/sysbench-rw.txt
参数说明
--oltp-read-only=off 表示不要进行只读测试,也就是会采用读写混合模式测试
--report-interval=10 表示每10秒输出一次测试进度报告
--rand-type=uniform:数据分布模式,special表示存在热点数据,uniform表示非热点数据模式: uniform(固定),gaussian(高斯),special(特定的),pareto(帕累托)
--max-time=3600 表示最大执行时长为 3600秒
--max-requests=0 表示总请求数为 0,因为上面已经定义了总执行时长,所以总请求数可以设定为 0;也可以只