Benchmarksql压测数据库


title: Benchmarksql压测数据库
date: 2022-05-10
tags:

  • Benchmarksql

1 工具介绍

BenchmarkSQL是开源数据库测试工具,内嵌了TPCC测试脚本,可以对Oracle、PostgreSQL、SQL Server直接进行测试,在BenchmarkSQL 5.0版本。

2 环境介绍

操作系统:CentOS Linux release 7.6.1810 (Core)

Postgresql:11.5

安装R语言环境

Python环境使用Linux自带的Python2.7即可,版本过高可能会出问题。

JDK1.8

[root@192-118-0-195 ~]# java -version
openjdk version "1.8.0_322"
OpenJDK Runtime Environment (build 1.8.0_322-b06)
OpenJDK 64-Bit Server VM (build 25.322-b06, mixed mode)

3 部署环境

3.1 部署jdk
3.1.1 下载jdk压缩包

直接从Oracle官网下载jdk

https://www.oracle.com/java/technologies/javase-jdk8-downloads.html

3.1.2 jdk上传到服务器并解压

CentOS安装jdk

3.1.3 在.bash_profile文件中配置jdk环境变量

环境变量的配置根据具体的安装目录按照教程

3.2 安装ant编译工具

这里使用CentOS自带的yum工具安装,如果你的yum工具没有配置国内源请看这篇文章

yum install ant
3.3 安装R语言环境

安装R语言环境

3.4 下载并编译Benchmarksql5.0
3.4.1 下载B enchmarksql5.0压缩包

https://sourceforge.net/projects/benchmarksql/

3.4.2 上传压缩包并解压

我这里测试的是postgresql所以我先把用户切换成postgres用户

# 切换成postgres用户
su postgres

# 解压benchmarksql-5.0.tar
tar -zxvf benchmarksql-5.0.tar

4 配置benchmarksql

4.1 修改配置文件

配置文件位于

.../benchmarksql/run/props.pg

编辑配置文件

vim .../benchmarksql/run/props.pg

以下为配置文件内容

除了中文注释的内容必须修改,其余内容根据当时的要求自行设定

# 数据库名称
db=postgres
# 数据库驱动
driver=org.postgresql.Driver
# 修改成相应的数据库
conn=jdbc:postgresql://192.168.10.16:3452/benchmarksql 

# 数据库用户名
user=tbase  <<< DB用户名

# 数据库密码
password=****  <<< DB用户密码



warehouses=200

#warehouses=1000

loadWorkers=60



terminals=50

//To run specified transactions per terminal- runMins must equal zero

runTxnsPerTerminal=0

# 测试时间,单位为分钟。注意:该值设置之后,runTxnsPerTerminal参数必须为0.这两个参数同时只能一个生效
runMins=30



//Number of total transactions per minute

limitTxnsPerMin=0



//Set to true to run in 4.x compatible mode. Set to false to use the

//entire configured database evenly.

terminalWarehouseFixed=true



//To run for specified mitbaseult percentages of 45, 43, 4, 4 & 4 match the TPC-C spec

newOrderWeight=45

paymentWeight=43

orderStatusWeight=4

deliveryWeight=4

stockLevelWeight=4



// Directory name to create for collecting detailed result data.

// Comment this out to suppress.

//resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS

//osCollectorScript=./misc/os_collector_linux.py 

//osCollectorInterval=1

//osCollectorSSHAddr=ssh_user@target_dbhost

//osCollectorDevices=net_eth0 blk_sda

5 导入数据并测试

5.1 创建测试数据库
# 命令行进入postgres数据库
psql -U postgres

# 在postgres交互式命令行中创建benchmarksql数据库
create database benchmarksql;
5.2 执行建表脚本
# 进入脚本执行目录:/benchmarksql/run
cd .../benchmarksql/run

# 执行建表脚本(脚本的执行时间与仓库数量有关)
./runDatabaseBuild.sh props.pg
5.3 执行benchmarksql测试脚本
# 脚本成功执行完成会在benchmarksql/run/下生成的“my_result”开头的文件夹
./runBenchmark.sh props.pg
5.4 执行删除数据库测试数据脚本
./runDatabaseDestroy.sh props.pg
5.5 执行结果可视化生成脚本生成html文档

注意脚本后的参数是你的benchmarksql/run/下生成的my_result开头的文件夹,请换成你对应的文件夹名称,否则会报错

执行该脚本需要R语言环境支持。

./generateReport.sh my_result_**********
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值