sysbench mysql 数据库oltp 测试

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/saga_gallon/article/details/82810868

oltp是针对数据库的基准测试,例如每次对数据库进行优化后执行基准测试来测试不同的配置的tps。

sysbench 0.5之后通过一系列LUA脚本来替换之前的oltp,来模拟更接近真实的基准测试环境。这些测试

脚本包含:insert.lua、oltp.lua、parallel_prepare.lua、select_random_points.lua、

update_index.lua、delete.lua oltp_simple.lua、select.lua、select_random_ranges.lua、

update_non_index.lua
预置条件:

1,创建一个数据库
2,一个mysql用户

OLTP测试:
准备阶段:
sysbench --test= /usr/local/share/sysbench/tests/include/oltp_legacy/oltp.lua --oltp-

table-size=10000 --mysql-table-engine=innodb --oltp-tables-count=10 --mysql-user=testDB --

mysql-password=testDB --mysql-port=3306 --mysql-host=127.0.0.1 --max-requests=0 --time=10

--report-interval=1 --threads=10 --oltp-point-selects=1 --oltp-simple-ranges=0 --

oltp_sum_ranges=0 --oltp_order_ranges=0 --oltp_distinct_ranges=0 --oltp-read-only=on

prepare
测试阶段:
命令如下:
sysbench --test= /usr/local/share/sysbench/tests/include/oltp_legacy/oltp.lua --oltp-

table-size=10000 --mysql-table-engine=innodb --oltp-tables-count=10 --mysql-user=testDB --

mysql-password=testDB --mysql-port=3306 --mysql-host=127.0.0.1 --max-requests=0 --time=10

--report-interval=1 --threads=10 --oltp-point-selects=1 --oltp-simple-ranges=0 --

oltp_sum_ranges=0 --oltp_order_ranges=0 --oltp_distinct_ranges=0 --oltp-read-only=on run
清理阶段:
sysbench --test= /usr/local/share/sysbench/tests/include/oltp_legacy/oltp.lua --oltp-

table-size=10000 --mysql-table-engine=innodb --oltp-tables-count=10 --mysql-user=testDB --

mysql-password=testDB --mysql-port=3306 --mysql-host=127.0.0.1 --max-requests=0 --time=10

--report-interval=1 --threads=10 --oltp-point-selects=1 --oltp-simple-ranges=0 --

oltp_sum_ranges=0 --oltp_order_ranges=0 --oltp_distinct_ranges=0 --oltp-read-only=on

cleanup
最后删除数据库
SQL>drop database testDB;

参数解释

通过命令sysbench –help可以了解各参数的具体解释
--test=tests/db/oltp.lua 表示调用 tests/db/oltp.lua 脚本进行 oltp 模式测试
--oltp_tables_count=10 表示会生成 10 个测试表
--oltp-table-size=100000 表示每个测试表填充数据量为 100000
--mysql-engine-trx=STRING指定不同的存储引擎测试。
--oltp-test-mode=STRING测试类型:simple(简单select测试),complex(事务测试),nontrx(非事务测试),sp(存储过程) ;默认complex
--oltp-sp-name=STRING指定存储过程进行语句测试
--oltp-table-size=N指定表的记录大小,默认[10000]
--oltp-num-tables=N指定测试表的数量,默认1
--rand-init=on 表示每个测试表都是用随机数据来填充的
--file-num=N创建测试文件的数量,默认128个
--file-block-size=N block size大小,默认16K
--file-total-size=SIZE所有文件的总大小,默认2G
--file-test-mode=STRING测试类型 {seqwr(顺序写), seqrewr(顺序读写), seqrd(顺序读), rndrd(随机读), rndwr(随机写), rndrw(随机读写)} --file-io-mode=STRING I/O模式,需要系统支持默认sync[sync(同步IO),async(异步IO),mmap()]
--file-async-backlog=N每个线程的异步操作队列数,默认128个,需要--file-io-mode=async;
--file-extra-flags=STRING additional flags to use on opening files {sync,dsync,direct} []
--file-fsync-freq=N当请求数达到多少时执行fsync()刷新,默认100,0代表过程中不执行fsync()
--file-fsync-all=[on|off] 执行每一个写操作后执行fsync()刷新操作,默认关闭off --file-fsync-end=[on|off] 测试结束执行fsync()操作,默认开启on --file-fsync-mode=STRING 同步刷新方法,默认fsync {fsync, fdatasync} --file-merged-requests=N合并指定数量的IO请求,0代表不合并,默认0 --file-rw-ratio=N 读写比例,默认1.5/1

猜你喜欢

转载自blog.csdn.net/saga_gallon/article/details/82810868