压测工具
上传压测工具包后,解压使用
unzip benchmarksql-5.0.zip
根据cpu架构选择合适的版本

benchmarksql工具脚本文件

创建压测用户及压测库
gsql -r
create user pwdb_exporter password 'xxx';
alter user pwdb_exporter;
修改配置文件props.pg
db=postgres
driver=org.postgresql.Driver
conn=jdbc:postgresql://x.x.x.x:17700/benchmarksql #压测仓库名
user=pwdb_exporter
password=xxx
warehouses=500 #仓库数量
loadWorkers=100 # 数据库初始化数据时候的进程数
terminals=500 #终端数量(并发数)
//To run specified transactions per terminal- runMins must equal zero
runTxnsPerTerminal=0
//To run for specified minutes- runTxnsPerTerminal must equal zero
runMins=10 # 测试时间
………
//The following five values must add up to 100
//The default percentages of 45, 43, 4, 4 & 4 match the TPC-C spec
newOrderWeight=45
paymentWeight=43
orderStatusWeight=4
deliveryWeight=4
stockLevelWeight=4
…………
下面五个值的总和必须等于100,默认值为:45, 43, 4, 4,4 ,与TPC-C测试定义的比例一致,实际操作过程中,可以调整比重来适应各种场景。
newOrderWeight=45 新订单事务占总事务的45%
paymentWeight=43 支付订单事务占总事务的43%
orderStatusWeight=4 订单状态事务占总事务的4%
deliveryWeight=4 到货日期事务占总事务的4%
stockLevelWeight=4 查看现存货品的事务占总事务的4%
创建压测环境
通过压测工具脚本创建表、索引等,创建压测环境
cd /home/omm/benchmarksql/benchmarksql-5.0-x86/run/
nohup sh runDatabaseBuild.sh props.pg > build.log &
# nohup后台运行,避免连接断开导致脚本运行失败
压测
cd /home/omm/benchmarksql/benchmarksql-5.0-x86/run/
nohup sh runBenchmark.sh props.pg > bench.log &
vim runBenchmark.sh
#!/usr/bin/env bash
……………
#source /root/tidb/benchmarksql-5.0-mysql-support-opt-2.1/run/funcs.sh $1
source /home/omm/benchmarksql/benchmarksql-5.0-x86/run/funcs.sh $1
# 这里修改为自己的路径
…………………
查看 bench.log文件来查看压测报告,并查看tpmC指标
在BenchmarkSQL的压测结果中,tpmC是一个关键的性能指标,它代表了系统的流量指标(Throughput),具体定义为每分钟系统可以处理的新订单交易数量。这一指标是评估OLTP(在线事务处理)数据库系统性能的重要标准之一。
cat bench.log

清除压测数据
gsql -r
drop database benchmarksql;
# 推荐使用工具自带脚本
sh runDatabaseDestroy.sh props.pg
问题报错
未创建benchmarksql数据库直接跑runDatabaseBuild.sh脚本
如果默认让rundatabaseBuild.sh脚本表创建在public下,pwdb_exporter 需要给sysadmin权限,否则建表语句会权限不足导致执行失败。
一般由自己创建benchmarksql数据库,并指定用户为pwdb_exporter
create database benchmarksql owner pwdb_exporter;
并发数大于仓数的10倍报错

props.pg文件里设置的需要满足:
0<numTerminals<=10*numWarehouses
即,并发数不大于仓数的10倍





