benchmark在postgresql上的安装及使用
二、测试前提
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);
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语言。
benchmark在postgresql上的安装及使用的更多相关文章
- PostgreSQL系列一:PostgreSQL简介与安装
一.PostgreSQL简介 1.1 PostgreSQL概述 PostgreSQL数据库是目前功能最强大的开源数据库,支持丰富的数据类型(如JSON和JSONB类型. ...
- postgresql pgagent 的安装及使用
pgagent 作为postgresql的一个任务调度代理,在postgresql 9.0 以前 是附带在pgadmin 包下面的,只是默认不安装,9.0之后作为了一个单独是的安装包.所以要使用pga ...
- jemalloc在linux上从安装到使用
jemalloc在linux上从安装到使用 上次在引导大家安装Redis时提到可能会报错: 发现了redis有用到jemalloc. 首先,jemalloc是干什么的? 我们看看作者自己的介绍: j ...
- 与你相遇好幸运,Postgresql和postgis安装
笔者开发环境: windows 7 x86_64 一开始安装的是官网最新版 PostgreSQL 9.6 ,安装成功 之后安装PostGIS Bundle 2.2 for PostgreSQL x64 ...
- 分布式缓存技术redis学习系列(一)——redis简介以及linux上的安装
redis简介 redis是NoSQL(No Only SQL,非关系型数据库)的一种,NoSQL是以Key-Value的形式存储数据.当前主流的分布式缓存技术有redis,memcached,ssd ...
- Oracle 支持在具有 DHCP 分配的 IP 地址的系统上进行安装
今天在安装Oracle 10g的时候,遇到了“ Oracle 支持在具有 DHCP 分配的 IP 地址的系统上进行安装” 这个问题,经过搜索,找到了解决方案,具体如下: win7下右键单机" ...
- 在64位系统上不能安装Matlab notebook的解决方案
在64位系统上不能安装Matlab notebook的解决方案 过程分解 第一步:安装好matlab(附:Matalab R2015a界面) 第二步:在matlab中执行命令 >>note ...
- jinkins在windows上的安装 配置C#编译
首先jinkins在windows上的安装就不说,安装只需要下载相应安装包就可以了,后有些时候经常需要修改端口号.修改如下: 然后重启jenkins服务 首次运行界面 个人建议插件按需安装. 建立一个 ...
- Win7上Git安装及配置过程
Win7上Git安装及配置过程 文档名称 Win7上Git安装及配置过程 创建时间 2012/8/20 修改时间 2012/8/20 创建人 Baifx 简介(收获) 1.在win7上安装msysgi ...
随机推荐
- ulimit用法
ulimit -a:显示当前所有的资源限制 -c:core文件大小 -f:设置创建文件的最大值 -n:设置内核可以同时打开的文件描述符的最大值 -p:设置管道缓冲区的最大值 -s:设置堆栈的最大值 - ...
- 【Distributed】分布式配置中心
一.概述 1.1 什么是分布式配置中心 常用分布式配置中心框架 二.Apollo阿波罗 2.1 Apollo特点 2.2 Apollo整体架构原理 2.3 Apollo Portol 环境搭建 Lin ...
- 纪念一下,时隔多年,继delphi上成功运行sql之后
纪念一下,时隔多年,继delphi上成功运行sql之后,在linux上用eclipse成功运行Wordcount程序,不容易呀,折腾了十几天 但我知道,这仅仅是我学习大数据的一个开始,仅此纪念一下,不 ...
- zookeeper:3
zoo.cfg配置文件 tickTime=2000 :zookeeper中最小的时间单位长度 (ms). initLimit=10 :follower节点启动后与leader节点完成数据同步的时间 ...
- Linux命令——mkdir、rmdir
mkdir -p:递归创建目录 -v:每次创建新目录都显示信息 -m:直接指定权限(不使用默认umask演算的那个) [root@51cto /]# mkdir /a/b/c -pv mkdir: c ...
- 转: Javascript收藏
搜集的一些javascript小技巧! 事件源对象 event.srcElement.tagName event.srcElement.type 捕获释放 event.srcElement.set ...
- java学习笔记16-抽象类
抽象类: 定义了一系列的属性和方法的类.抽象方法是不能直接实现功能.需要通过继承去实现具体方法.为了将静态的业务流程跟动态的实现分开. 工厂生产产品时,都需要准备材料,执行组装,产品销售等流程.但是对 ...
- 更改jupyter notebook的单元格宽度和主题颜色(theme)
一.单元格宽度 这个命令: jt -t gruvboxl -f roboto -fs 12 -cellw 100% -T -N 它将宽度设置为100% 二.主题颜色 在用jupyter noteboo ...
- linux下禁止root远程登录
一.添加和root权限一样的用户 1. adduser admin passwd admin (修改密码) 2.修改 /etc/sudoers 文件,找到下面一行,在root下面添加一行,如下所示 ...
- iView的tree组件实现单选功能
iView中的树组件有复选框可以多选,但是目前还没有提供单选框的模式,不显示复选框可以提供高亮单选的模式,但是再次点击就被取消了,没有实现真正的单选: tree 的属性配置中 multiple 是否支 ...