BenchmarkSQL 之二 basic pressure test

版权声明:本文为博主原创文章,转载请标明出处。 https://blog.csdn.net/ctypyb2002/article/details/84852641

os: centos 7.4
db: postgresql 9.6

上一篇 blog 介绍了安装好了 BenchmarkSQL,现在开始压测配置。

仔细阅读下 benchmarksql-5.0.zip 解压后 HOW-TO-RUN.txt 、 README.md 这两个文件,里面有详细的步骤。

创建数据库

$ psql
psql (9.6.11)
Type "help" for help.

postgres=# 
postgres=# create user benchmarksql superuser password 'benchmarksql';  
  
postgres=# create database benchmarksql owner benchmarksql;  
  
postgres=# \q

$ psql -h 127.0.0.1 -U benchmarksql benchmarksql  
psql (9.6.11)
Type "help" for help.

benchmarksql=# 
benchmarksql=# create schema benchmarksql;  

benchmarksql=# \dn+
                                   List of schemas
     Name     |    Owner     |      Access privileges       |      Description       
--------------+--------------+------------------------------+------------------------
 benchmarksql | benchmarksql |                              | 
 public       | postgres     | postgres=UC/postgres        +| standard public schema
              |              | =UC/postgres                 | 
(2 rows) 

编辑 benchmarksql 连接配置和压测配置

初始化10个仓库,测试时长3分钟,不限事务数,本地虚拟机,性能不够。

参数很好理解,看看就明白

$ cd ~/benchmarksql-5.0/run/  
$ cp props.pg props.pg.bak  
$ vi props.pg  

db=postgres
db=postgres
driver=org.postgresql.Driver
conn=jdbc:postgresql://127.0.0.1:5432/benchmarksql
user=benchmarksql
password=benchmarksql

warehouses=10
loadWorkers=2

terminals=2
//To run specified transactions per terminal- runMins must equal zero
runTxnsPerTerminal=0
//To run for specified minutes- runTxnsPerTerminal must equal zero
runMins=3
//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=false

//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

// 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=user@dbhost
osCollectorDevices=net_eth0 blk_sda 

创建表结构

$ cd ~/benchmarksql-5.0/run   
$ ./runSQL.sh ./props.pg ./sql.common/tableCreates.sql   

生成测试数据

$ mkdir ~/benchmarksql-csv    
$ cd ~/benchmarksql-5.0/run
$ ./runLoader.sh ./props.pg fileLocation ~/benchmarksql-csv/ 
$ ls -l ~/benchmarksql-csv
total 714740
-rw-r--r-- 1 postgres postgres        62 Dec  6 12:03 config.csv
-rw-r--r-- 1 postgres postgres  20563737 Dec  6 12:03 cust-hist.csv
-rw-r--r-- 1 postgres postgres 173002967 Dec  6 12:03 customer.csv
-rw-r--r-- 1 postgres postgres      9496 Dec  6 12:03 district.csv
-rw-r--r-- 1 postgres postgres   7568445 Dec  6 12:03 item.csv
-rw-r--r-- 1 postgres postgres    828000 Dec  6 12:03 new-order.csv
-rw-r--r-- 1 postgres postgres  13461204 Dec  6 12:03 order.csv
-rw-r--r-- 1 postgres postgres 210432944 Dec  6 12:03 order-line.csv
-rw-r--r-- 1 postgres postgres 305998994 Dec  6 12:03 stock.csv
-rw-r--r-- 1 postgres postgres       889 Dec  6 12:03 warehouse.csv 

导入数据

$ cd ~/benchmarksql-5.0/run
$ ln -s ~/benchmarksql-csv /tmp/csv 
$ ./runSQL.sh ./props.pg ./sql.postgres/tableCopies.sql  
$ ./runSQL.sh ./props.pg ./sql.common/indexCreates.sql  
$ ./runSQL.sh ./props.pg ./sql.common/foreignKeys.sql  

tableCopies.sql 是从/tmp/csv 导入数据的,所以要 ln -s

提示:可以运行 ./runDatabaseBuild.sh ./props.pg 一步完成 创建表、生成测试数据、导入数据。

tpc-c 压测以及性能指标

$ cd ~/benchmarksql-5.0/run
$ ./runBenchmark.sh ./props.pg

tpc-c 结果绘图

查看压测数据

$ cd ~/benchmarksql-5.0/run

$ tree ./my_result_2018-12-06_121705/
./my_result_2018-12-06_121705/
├── data
│   ├── blk_sda.csv
│   ├── result.csv
│   ├── runInfo.csv
│   └── sys_info.csv
└── run.properties

1 directory, 5 files

生成报告

$ cd ~/benchmarksql-5.0/run
$ ./generateGraphs.sh ./my_result_2018-12-06_121705/
$ ./generateReport.sh ./my_result_2018-12-06_121705/

重新压测

对发现的问题优化后,可以重新再压测。

$ cd ~/benchmarksql-5.0/run
$ ./runDatabaseDestroy.sh ./props.pg
$ ./runDatabaseBuild.sh ./props.pg
$ ./runBenchmark.sh ./props.pg

猜你喜欢

转载自blog.csdn.net/ctypyb2002/article/details/84852641