BenchmarkSQL是一款经典的开源数据库测试工具,内嵌了TPCC测试脚本,可以对EnterpriseDB、PostgreSQL、MySQL、Oracle以及SQL Server等数据库直接进行测试。

二、测试前提
1. 安装JDK。因为BenchmarkSQL本身是使用Java语言编写的,所以如果在Linux系统下还没有安装JDK的话,我们首先需要对其进行安装;
2. 安装PostgreSQL数据库系统。俗话说巧妇难为无米之炊,测试之前肯定需要有测试对象,本文是测试PG系统,故需安装有PG;
3. 安装BenchmarkSQL
可到http://sourceforge.net中搜索BenchmarkSQL即可下到,windows,linux版均有。我下载的是linux版的软件包BenchmarkSQL-2.3.3.zip,unzip解压后可以在README文件中看到该软件的使用说明,下面用中文具体介绍一下它的使用方法。

三、测试步骤
1. 启动待测试的数据库系统,这里即指启动PostgreSQL

2. 在BenchmarkSQL-2.3.3/run目录下找到postgres.properties配置文件,修改该文件如下:
driver=org.postgresql.Driver
conn=jdbc:postgresql://localhost:5432/test        #链接数据库地址
user=postgres      #链接数据库用户名
password=password    #密码
如果想测试其他数据库系统,则修改其他相应的配置文件即可,如oracle.properties等等。

3. 创建TPC-C基础表(即上篇博文中介绍的TPC-C模拟场景中9张表)
命令: runSQL.sh postgres.properties sqlTableCreates

4. 向数据库中导入指定大小的数据(参考资料2中此步有个小问题,多写一个等号)
命令:loadData.sh postgres.properties numWarehouses 10
numWarehouse指的是仓库数(具体含义见上篇博文),默认为1,导入9张表的数据大小大概70多M,
当 numWarehouse为10时,数据大小可以近似当作1GB数据。

5. 为基础表创建必要的索引
命令: runSQL.sh postgres.properties sqlIndexCreates

6. 运行runBenchmark.sh借助GUI程序测试数据库
命令:runBenchmark.sh postgres.properties
注意:不要忘记设置图形界面的仓库数时要与第4步中设置的数量相符;此外,测试的结果报告除了显示在图形界面有显示以外,还在run/reports目录下有备份,随时可以查阅。

四、BenchmarkSQL界面说明
Control-Database:配置所要链接的数据库,默认会读取之前我们修改的配置文件,故此处不用动

Control-Terminals:配置终端数,仓库数,是否显示Debug信息,指定测试时间以及每终端事务等(每终端事务执行方式目前我也没理解,望交流)

Control-Weights:配置TPC-C测试中五中事务的比重(界面中只要配置4种),一般按默认比例测试即可

Control-Controls:控制器设置,点击Create Terminals创建一个终端;点击Start Transaction开始基准测试,点击Stop Transaction停止基准测试

Error:错误信息显示

Terminals:各个终端日志查看

注意:
1. 测试完后在界面下方会显示简要的测试结果,包括平均tpmC值(每分钟执行的事务数),当前tpmC值,内存使用情况等等;出结果以后尽量记录下来,以为之后如果乱点界面按钮的话,测试结果将会被重写(感觉是一个bug);

2.运行过程中如果想要修改终端数等参数,最好关闭GUI界面,重新运行runBenchmark.bat
首先,在Linux下安装JDK。因为BenchmarkSQL本身是使用Java语言编写的,所以如果在Linux系统下还没有安装JDK的话,我们首先需要对其进行安装。
1)下载Linux Platform JDK(如jdk-6u20-linux-i586.bin);
2)键入命令./jdk-6u20-linux-i586.bin运行安装程序,这时会有一段Sun的协议,敲几次Enter键,当询问是否同意的时候敲Yes就可以了,之后程序会自行安装JDK并创建一个文件夹jdk1.6.0-20;
3)将安装后的文件夹移动到一个指定的地方,如mv jdk1.6.0-20 /usr/local,当然这一步不是必须的;
4)设置环境变量。环境变量的设置方法有多种如用export直接在shell下设置、修改文件.bashrc设置以及修改/etc/profile设置,我们这里直接使用最后一种方法,虽然第二种方法比较受推崇。我们在profile文件末尾直接添加如下内容:
JAVA_HOME=/usr/local/jdk1.6.0-20
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
       然后,在Linux下安装Eclipse。因为BenchmarkSQL就是Java Project,在使用时直接加载到Eclipse中是最简单的运行的方式,所以我们需要安装Linux版本的Eclipse。
1)下载Eclipse for Linux(如eclipse-java-galileo-SR2-Linux-gtk.tar.gz);
2)解压得到eclipse目录。
3)为了让每一个账号都可以使用Eclipse,我们需要写一个脚本eclipse.sh,其内容如下:
Eclipse安装目录/eclipse -vm JDK安装目录/bin/java -data ~/workspace
这里-vm参数用于指定使用哪一个jvm来执行Eclipse,-data参数用于指定Eclipse要将项目存储在哪一个目录下,在此为用户根目录下的workspace目录。
4)将eclipse.sh加上权限755,以便可以执行。
chmod 755 eclipse.sh
5)启动Eclipse。
./eclipse.sh
       最后,我们使用BenchmarkSQL对PostgreSQL进行测试(这里默认PostgreSQL已经安装,安装方法可参考本人之见的博客)。
1)下载BenchmarkSQL-2.3.2;
2)在Eclipse中创建一个Java Project并选择从已有工程创建,如下图所示;

3)修改postgres.properties文件,即设置正确的数据库名和密码,如下图所示;

4)运行BenchmarkSQL进行测试。我们首先进入到BenchmarkSQL-2.3.2/run的目录下,然后运行如下命令:
./runSQL.sh postgres.properties sqlTableCreates
此命令用于创建我们进行TPCC测试所需的数据库表
./loadData.sh postgres.properties numWarehouses=10
此命令用于加载我们进行TPCC测试所需的数据
./runSQL.sh postgres.properties sqlIndexCreates
此命令用于创建我们进行TPCC测试所需的索引
./runBenchmark.sh postgres.properties
开始TPCC测试,这时会跳出一个对话框,用户可以根据自己的测试需要设定相关的warehouse数目和terminal数目,然后进行测试。


参考资料:
1.http://blog.sina.com.cn/s/blog_4485748101019wsh.html
2.http://blog.sina.com.cn/s/blog_48c95a190100j35g.html
3.http://www.docin.com/p-242425868.html

1.创建用户和数据库
[postgres#localhost ~] $ psql postgres
psql (9.5.2)
Type "help" for help.

postgres=# CREATE USER benchmarksql WITH ENCRYPTED PASSWORD 'changeme';
postgres=# CREATE DATABASE benchmarksql OWNER benchmarksql;
postgres=# \q
2.解压
[postgres@localhost run]$unzip benchmarksql-5.0.zip
[postgres@localhost ~] $ cd benchmarksql-5.0
[postgres@localhost benchmarksql-5.0]$ ant
bash: ant: command not found...
解决方法:
安装ant
[root@localhost etc]# yum install ant
[postgres@localhost benchmarksql-5.0]$ ant
Buildfile: /tmp/benchmarksql-5.0/build.xml

init:
[mkdir] Created dir: /tmp/benchmarksql-5.0/build

compile:
[javac] Compiling 11 source files to /tmp/benchmarksql-5.0/build

dist:
[mkdir] Created dir: /tmp/benchmarksql-5.0/dist
[jar] Building jar: /tmp/benchmarksql-5.0/dist/BenchmarkSQL-5.0.jar

BUILD SUCCESSFUL
Total time: 2 seconds
3.修改文件
[postgres@localhost benchmarksql] $ cd run
[postgres@localhost run] $ cp props.pg my_postgres.properties
[postgres@localhost run] $ vi my_postgres.properties
[postgres@localhost run] $
4.构建模式和初始数据库加载
[postgres@localhost run]$ ./runDatabaseBuild.sh my_postgres.properties
# ------------------------------------------------------------
# Loading SQL file ./sql.common/tableCreates.sql
# ------------------------------------------------------------
create table bmsql_config (
cfg_name varchar(30) primary key,
cfg_value varchar(50)
);

Starting BenchmarkSQL LoadData

driver=org.postgresql.jdbc.Driver
conn=jdbc:postgresql://localhost:5866/benchmarksql
user=benchmarksql
password=***********
warehouses=1
loadWorkers=4
fileLocation (not defined)
csvNullValue (not defined - using default 'NULL')

Worker 000: Loading ITEM
Worker 001: Loading Warehouse 1
Worker 000: Loading ITEM done
Worker 001: Loading Warehouse 1 done
# ------------------------------------------------------------
# Loading SQL file ./sql.common/indexCreates.sql
# ------------------------------------------------------------

# ------------------------------------------------------------
# Loading SQL file ./sql.postgres/extraHistID.sql
# ------------------------------------------------------------
-- ----

# ------------------------------------------------------------
# Loading SQL file ./sql.postgres/buildFinish.sql
# ------------------------------------------------------------
-- ----
-- Extra commands to run after the tables are created, loaded,
-- indexes built and extra's created.
-- PostgreSQL version.
-- ----
vacuum analyze;
如果这一步出现这样的错误说明你没有安装ant,先安装ant
[postgres@localhost run]$ ./runDatabaseBuild.sh my_postgres.properties
# ------------------------------------------------------------
# Loading SQL file ./sql.common/tableCreates.sql
# ------------------------------------------------------------
Error: Could not find or load main class ExecJDBC
Error: Could not find or load main class LoadData
# ------------------------------------------------------------
# Loading SQL file ./sql.common/indexCreates.sql
# ------------------------------------------------------------
Error: Could not find or load main class ExecJDBC
# ------------------------------------------------------------
# Loading SQL file ./sql.common/foreignKeys.sql
# ------------------------------------------------------------
Error: Could not find or load main class ExecJDBC
# ------------------------------------------------------------
# Loading SQL file ./sql.postgres/extraHistID.sql
# ------------------------------------------------------------
Error: Could not find or load main class ExecJDBC
# ------------------------------------------------------------
# Loading SQL file ./sql.postgres/buildFinish.sql
# ------------------------------------------------------------
Error: Could not find or load main class ExecJDBC
[postgres@localhost run]$ ./runDatabaseBuild.sh my_postgres.properties
# ------------------------------------------------------------
# Loading SQL file ./sql.common/tableCreates.sql
# ------------------------------------------------------------
Error: Could not find or load main class ExecJDBC
Error: Could not find or load main class LoadData
# ------------------------------------------------------------
# Loading SQL file ./sql.common/indexCreates.sql
# ------------------------------------------------------------
Error: Could not find or load main class ExecJDBC
# ------------------------------------------------------------
# Loading SQL file ./sql.common/foreignKeys.sql
# ------------------------------------------------------------
Error: Could not find or load main class ExecJDBC
# ------------------------------------------------------------
# Loading SQL file ./sql.postgres/extraHistID.sql
# ------------------------------------------------------------
Error: Could not find or load main class ExecJDBC
# ------------------------------------------------------------
# Loading SQL file ./sql.postgres/buildFinish.sql
# ------------------------------------------------------------
Error: Could not find or load main class ExecJDBC
[postgres@localhost run]$ ant
Buildfile: build.xml does not exist!
Build failed
4.运行配置
[postgres@localhost run]$ ./runBenchmark.sh my_postgres.properties
The benchmark should run for the number of configured concurrent
connections (terminals) and the duration or number of transactions.

The end result of the benchmark will be reported like this:

01:58:09,081 [Thread-1] INFO jTPCC : Term-00,
01:58:09,082 [Thread-1] INFO jTPCC : Term-00, Measured tpmC (NewOrders) = 179.55
01:58:09,082 [Thread-1] INFO jTPCC : Term-00, Measured tpmTOTAL = 329.17
01:58:09,082 [Thread-1] INFO jTPCC : Term-00, Session Start = 2016-05-25 01:58:07
01:58:09,082 [Thread-1] INFO jTPCC : Term-00, Session End = 2016-05-25 01:58:09
01:58:09,082 [Thread-1] INFO jTPCC : Term-00, Transaction Count = 10
到这一步已经安装完成了,只要修改my_postgres.properties的参数就可以进行压力测试了
5.重建运行数据库的方法(如果你修改了配置文件中的warehouse或者load的值都需要重建数据库)
[postgres@localhost run]$ ./runDatabaseDestroy.sh my_postgres.properties
[postgres@localhost run]$ ./runDatabaseBuild.sh my_postgres.properties
6.生成图表
用run目录下的generateReport.sh脚本去执行压力测试得到的结果目录 my_result_xxx
如:[postgres@localhost run]$ ./generateReport.sh my_result_2017-04-18_111400/
执行的时候是需要提前安装R语言环境的。
7.R语言环境的安装
解压
./configure
make
make过程中可能出现报错,几乎就是缺少对应的安装程序,用yum安装就好 。如X11 则要安装yum install yum install libX*
总之,缺什么就安装什么就好
make install
安装完成后
进入R环境
[postgres@localhost run]$ R

R version 3.0.0 (2013-04-03) -- "Masked Marvel"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> capabilities()
jpeg png tiff tcltk X11 aqua http/ftp sockets
TRUE TRUE TRUE FALSE FALSE FALSE TRUE TRUE
libxml fifo cledit iconv NLS profmem cairo
TRUE TRUE TRUE TRUE TRUE FALSE TRUE
>
如果像上述显示的结果 png 为true x11位true就可以了
执行文件生成图表数据
[postgres@localhost run]$ ./generateReport.sh my_result_2017-04-18_132736/
Generating my_result_2017-04-18_132736//tpm_nopm.png ... OK
Generating my_result_2017-04-18_132736//latency.png ... OK
Generating my_result_2017-04-18_132736//cpu_utilization.png ... OK
Generating my_result_2017-04-18_132736//dirty_buffers.png ... OK
Generating my_result_2017-04-18_132736//blk_sda_iops.png ... OK
Generating my_result_2017-04-18_132736//blk_sda_kbps.png ... OK
Generating my_result_2017-04-18_132736//net_enp3s0f0_iops.png ... OK
Generating my_result_2017-04-18_132736//net_enp3s0f0_kbps.png ... OK
Generating my_result_2017-04-18_132736//report.html ... OK
就可以看到目录下生成的图片和网页了,根据里面的内容来分析数据。
[postgres@localhost my_result_2017-04-18_132736]$ ls
blk_sda_iops.png blk_sda_kbps.png cpu_utilization.png data dirty_buffers.png latency.png net_enp3s0f0_iops.png net_enp3s0f0_kbps.png report.html run.properties tpm_nopm.png
执行生成文件出现以下错误
[postgres@localhost run]$ ./generateReport.sh my_result_2017-04-18_111724
Generating my_result_2017-04-18_111724/tpm_nopm.png ... Error in .External2(C_X11, paste("png::", filename, sep = ""), g$width, :
unable to start device PNG
Calls: png
In addition: Warning message:
In png("tpm_nopm.png", width = 1200, height = 400) :
unable to open connection to X11 display ''
Execution halted
ERROR

R version 3.0.0 (2013-04-03) -- "Masked Marvel"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> # ----
> # R graph to show tpmC and tpmTOTAL.
> # ----
>
> # ----
> # Read the runInfo.csv file.
> # ----
> runInfo <- read.csv("data/runInfo.csv", head=TRUE)
>
> # ----
> # Determine the grouping interval in seconds based on the
> # run duration.
> # ----
> xmax <- runInfo$runMins
> for (interval in c(1, 2, 5, 10, 20, 60, 120, 300, 600)) {
+ if ((xmax * 60) / interval <= 1000) {
+ break
+ }
+ }
> idiv <- interval * 1000.0
>
> # ----
> # Read the result.csv and then filter the raw data
> # for != DELIVERY_BG and == NEW_ORDER transactions.
> # ----
> data1 <- read.csv("data/result.csv", head=TRUE)
> total1 <- data1[data1$ttype != 'DELIVERY_BG', ]
> neworder1 <- data1[data1$ttype == 'NEW_ORDER', ]
>
> # ----
> # Aggregate the counts of both data sets grouped by second.
> # ----
> countTotal <- setNames(aggregate(total1$latency, list(elapsed=trunc(total1$elapsed / idiv) * idiv), NROW),
+ c('elapsed', 'count'));
> countNewOrder <- setNames(aggregate(neworder1$latency, list(elapsed=trunc(neworder1$elapsed / idiv) * idiv), NROW),
+ c('elapsed', 'count'));
>
> # ----
> # Determine the ymax by increasing in sqrt(2) steps until the
> # maximum of tpmTOTAL fits, then make sure that we have at least
> # 1.2 times that to give a little head room for the legend.
> # ----
> ymax_count <- max(countTotal$count) * 60.0 / interval
> ymax <- 1
> sqrt2 <- sqrt(2.0)
> while (ymax < ymax_count) {
+ ymax <- ymax * sqrt2
+ }
> if (ymax < (ymax_count * 1.2)) {
+ ymax <- ymax * 1.2
-
> # Start the output image.
> # ----
> png("tpm_nopm.png", width=1200, height=400)
Generating my_result_2017-04-18_111724/report.html ... ./generateReport.sh: line 161: data/tx_summary.csv: No such file or directory
grep: data/tx_summary.csv: No such file or directory
grep: data/tx_summary.csv: No such file or directory
grep: data/tx_summary.csv: No such file or directory
OK
因为你的R语言环境没有按照好,导致出现这中问题,建议安装好对应的包后,重新编译安装R语言。

转载于:https://www.cnblogs.com/klb561/p/10850743.html

benchmark在postgresql上的安装及使用相关推荐

  1. Postgresql在CentOS上的安装(脚本在线安装)

    场景 PostGresSQL简介与Windows上的安装教程: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/113981563 ...

  2. centos 7上ambari安装试用

    2019独角兽企业重金招聘Python工程师标准>>> 1.有三台centos7,名字分别是ws11.localdomain, ws12.localdomain, ws13.loca ...

  3. teamcity mysql 配置_CentOS 7 上 TeamCity 安装

    CentOS 7 上 TeamCity 安装 非入门教程, 初次接触centos/docker的朋友需要谨慎 一. 安装 MySQL 为了后续的需要, 这里安装了 Docker, 当然如果你已经有了 ...

  4. 时序数据库-Timescale 在Windows上的安装

    它是一个PostgreSQL数据库的扩展(exstension),一种开源的时序(time-series)数据库,在快速数据摄入和复杂查询的性能上做了优化. 一.本人的安装条件 1.jdk 2.系统 ...

  5. postgreSQL与postGIS安装过程中遇到的坑及解决

    记录一下postgreSQL与postGIS安装过程中遇到的坑及解决 写到前面 postgreSQL安装 postgreSQL安装包下载 postgreSQL安装 postGIS的安装 postGIS ...

  6. 【postgresql】centos7安装postgresql-devel步骤

    最近需要用到postgresql-devel,于是想在centos上手动安装一下,结果遇到了一大堆问题,查找了很多资料,于是记录下正确的安装过程. 首先在安装过程中遇到最大的问题是几个依赖包,分别是 ...

  7. 【OGG】经典架构在postgresql-14上的安装部署-1

    环境 操作系统: ORACLE Linux7.9-64bit 数据库版本: Postgresql-14.2-64bit OGG版本:OGG21.3-64bit 2台测试服务器:(源)192.168.5 ...

  8. PostgreSQL 介绍与安装 —— 千月的零基础学习PostgreSQL(1)

    PostgreSQL 介绍与安装 1.PostgreSQL 介绍(官方) PostgreSQL是一个强大的开源对象关系数据库系统,它使用和扩展了SQL语言,结合了许多存储和处理最复杂的数据工作的特性. ...

  9. Postgresql学习04-pg_hint_plan安装及使用、Sql优化小知识

    一.环境 名称 版本 操作系统 Centos7.9 Postgresql 14.4 pg_hint_plan 1.4 二.下载链接 pg_hint_plan下载地址 三.pg_hint_plan用途 ...

最新文章

  1. 实战课【1】jQuery实现表单校验及布局
  2. [转载] 故宫第三集 礼仪天下(下)
  3. Heinz College of Information Systems and Public Policy Carnegie Mellon University
  4. uniapp点击图片放大_想要放大镜将图片放大的效果?你只需这么做即可!
  5. 4.19计算机网络笔记
  6. multisim中轻触开关在哪_关于轻触开关的原理、区别、寿命以及接线方式的介绍...
  7. 项目实体类报错_分享elasticserch在质检算法项目中的应用
  8. Python3爬虫系列:理论+实验+爬取妹子图实战
  9. 广外男生病毒代码剖析
  10. 项目管理体验营day3:项目管理之沟通技巧
  11. matlab 双均线,[转载]百年一人的双均线系统及双均线系统公式
  12. 在zbox安装ubuntu18
  13. PS制作简单可爱马赛克像素画效果
  14. 云服务器与物理服务器有什么区别?
  15. 新手如何做自媒体赚钱?天天看头条却不赚钱,这份资料对你有启发
  16. java.lang.ClassNotFoundException: Cannot find class:
  17. Clojure Web开发–最新技术–第2部分
  18. 鼠标宏编写脚本代码教程_PHP登录脚本代码和教程
  19. window系统未能启动服务器,Windows系统下Apache服务器无法启动的问题解决
  20. 大数据2 Hadoop

热门文章

  1. 基于SpringBoot的健身房管理系统
  2. 百度BD09加密经纬度转国测局GCJ02经纬度
  3. Python实现旋转按钮控制小风扇
  4. 升级鸿蒙系统最新计划,华为鸿蒙系统更新升级方法分享
  5. 微信小程序解密用户信息--java解密
  6. 群体Polymorphism information content(PIC)、 Nei diversity index (Nei s) 和 Shannon index (I)计算方法
  7. Excel 怎么让行或列倒转过来?
  8. 【AWS云从业者基础知识笔记】——模块4:网络
  9. 《斯坦福高效睡眠法》读书笔记思维导图版,成年人的睡眠解决法
  10. jks文件转换keystore