二、测试
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;也可以只