暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

PostgreSQL数据库TPCC测试-Banchmarksql 5.0部署详解

转载自公众号DB印象

前言


TPCC模拟大型商品服务公司的OLTP系统,测试模型包括新建订单、付款、发货、订单查询、库存查询5种事务操作。执行TPCC测试程序,我们可以得到被测系统的吞吐量、时延、事务完成数等信息。

更多介绍可参考TPC官方网站:http://www.tpc.org/tpcc/

BenchmarkSQL是开源数据库测试工具,内嵌了TPCC测试脚本,可以对Oracle、PostgreSQL、SQL Server直接进行测试,在BenchmarkSQL 5.0版本,也可以改写相关脚本使其适用MYSQL环境。


文章目录

一、测试环境介绍

二、BenchmarkSQL-5.0安装部署

三、测试数据的准备及执行

四、部署相关报错处理


一、测试部署环境介绍

本次部署BenchmarkSQL 5.0使用的是CentOS 7.2,另外需要依赖java环境,我这里使用的是jdk-1.8.0。具体如下:


1.操作系统版本

    [root@Aken-DB ~]# cat etc/redhat-release 
    CentOS Linux release 7.2 (Final)

    2.PostgreSQL和BenchmarSQL版本

      benchmarksql 5.0
      PostgreSQL 11.5
      3.本次使用的jdk版本
        [tbase@Aken-DB ~]$ java -version
        java version "1.8.0_241"
        Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
        Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)e


        二、BenchmarkSQL安装部署

        1.部署Java环境

        1)jdk下载地址:

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

          2)上传jdk到服务器并解压:

            mkdir -p usr/java
            tar -zxvf jdk-8u241-linux-x64.tar.gz -C /data/aken


            2.安装ant工具。

              yum -y install ant  
              没有yum源的话也可到https://ant.apache.org/bindownload.cgi自行下载apache-ant-1.9.14-bin.zip


              3. 编辑jdk和ant环境变量,vi .bash_profile编辑内容如下:

                export PATH=$PATH:$HOME/.ft
                export JAVA_HOME=/data/aken/jdk1.8.0_241
                export ANT_HOME=/data/aken/tpcc/apache-ant-1.9.14
                export JDK_PATH=${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin
                export JDK_CLASSPATH=${JAVA_HOME}/lib:${JAVA_HOME}/jre/lib
                export PATH=${JDK_PATH}:${ANT_HOME}/bin:${PATH}


                4. 下载benchmarksql 5.0 源码包,解压编译。

                1)下载地址

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

                  2)上传解压

                    su - tbase   --我这里使用的是tbase用户,切换到对应的测试用户即可
                    cd /data/aken/tpcc
                    tar -zxvf benchmarksql-5.0.tar
                    cd benchmarksql-5.0

                    3) 编译

                      source ~/.bash_profile
                      ant

                      此时编译后的benchmarkSQL默认支持PostgresqlSQL:

                        [tbase@Aken-DB ~/tpcc]$ cat benchmarksql-5.0/src/client/jTPCC.java | grep postgres
                        else if (iDB.equals("postgres"))
                        [tbase@Aken-DB ~/tpcc]$

                        三、测试数据准备及执行

                        1.编辑props_file文件

                        vi data/aken/tpcc/benchmarksql-5.0/run/props.pg_cn01内容如下:

                          [tbase@Aken-DB ~/tpcc/benchmarksql-5.0/run]$ cat props.pg_cn01
                          db=postgres
                          driver=org.postgresql.Driver
                          conn=jdbc:postgresql://192.168.10.16:3452/benchmarksql  <<<填写需要测试的目标环境 ip、port和database name
                          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
                          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
                          [tbaest@Aken-DB data/aken/tpcc/benchmarksql-5.0/run]#


                          2.修改表结构和索引

                          如果是分布式系统,则需要考虑分布式环境下是否需要显式主键、分布键、外键、sequence等,可根据具体的SQL兼容性问题修改具体的DDL语句:
                            [tbase@Aken-DB /data/aken/tpcc/benchmarksql-5.0/run/sql.common]ls -rlt
                            -rw-r--r-- 1 tbase tbase 282 May 26 2016 tableTruncates.sql
                            -rw-r--r-- 1 tbase tbase 306 May 26 2016 tableDrops.sql
                            -rw-r--r-- 1 tbase tbase 620 May 26 2016 indexDrops.sql
                            -rw-r--r-- 1 tbase tbase 1392 May 26 2016 foreignKeys.sql 《《《 如果测试分布式环境不支持外键,将该文件清空
                            -rw-r--r-- 1 tbase tbase 117 May 26 2016 buildFinish.sql
                            -rw-r--r-- 1 tbase tbase 3068 Mar 19 10:21 tableCreates.sql.bak 《《《修改表结构、字段、添加主键、分布键等
                            -rw-r--r-- 1 tbase tbase 960 Mar 19 11:44 indexCreates.sql.bak 《《《如有需要修改的索引,也需要调整
                            -rw-r--r-- 1 tbase tbase 191 Mar 19 11:45 indexCreates.sql
                            -rw-r--r-- 1 tbase tbase 3495 Mar 19 19:46 tableCreates.sql
                            [tbase@Aken-DB data/aken/tpcc/benchmarksql-5.0/run/sql.common]#


                            3.初始化测试数据:

                            1) 创建测试库

                              postgres=# 
                              postgres=# create database benchmarksql;
                              CREATE DATABASE
                              postgres=#


                              2) 根据上述props.pg_cn01的配置,2000个仓库的数据量约为100G:

                                cd /data/aken/tpcc/benchmarksql-5.0/run
                                ./runDatabaseBuild.sh props.pg_cn01


                                  benchmarksql=# \l+
                                  List of databases
                                  Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | Tablespace | Description
                                  --------------+-------+----------+------------+------------+-------------------+-------+------------+--------------------------------------------
                                  benchmarksql | tbase | UTF8 | zh_CN.utf8 | zh_CN.utf8 | | 22 GB | pg_default |
                                  postgres | tbase | UTF8 | zh_CN.utf8 | zh_CN.utf8 | | 21 MB | pg_default | default administrative connection database
                                  template0 | tbase | UTF8 | zh_CN.utf8 | zh_CN.utf8 | =c/tbase +| 18 MB | pg_default | unmodifiable empty database
                                  | | | | | tbase=CTc/tbase | | |
                                  template1 | tbase | UTF8 | zh_CN.utf8 | zh_CN.utf8 | =c/tbase +| 20 MB | pg_default | default template for new databases
                                  | | | | | tbase=CTc/tbase | | |
                                  (4 rows)
                                  postgres=# \c benchmarksql
                                  psql (11.5)
                                  Type "help" for help.
                                  benchmarksql=# \dt
                                  List of relations
                                  Schema | Name | Type | Owner
                                  --------+-----------------------------+-------+-------
                                  public | bmsql_config | table | tbase
                                  public | bmsql_customer | table | tbase
                                  public | bmsql_district | table | tbase
                                  public | bmsql_history | table | tbase
                                  public | bmsql_item | table | tbase
                                  public | bmsql_new_order | table | tbase
                                  public | bmsql_oorder | table | tbase
                                  public | bmsql_order_line | table | tbase
                                   public | bmsql_stock                 | table | tbase
                                  public | bmsql_warehouse | table | tbase
                                  public | tbase_subscription | table | tbase
                                  public | tbase_subscription_parallel | table | tbase
                                  (12 rows)


                                  4.执行benchmar测试
                                    cd /data/aken/tpcc/benchmarksql-5.0/run
                                    ./runBenchmark.sh props.pg_cn01

                                    四、部署相关报错处理

                                    1.jdk版本冲突问题

                                      [tbase@Aken-DB /data/aken/tpcc/benchmarksql-5.0/run]# ./runDatabaseBuild.sh props.mysql 
                                      # ------------------------------------------------------------
                                      # Loading SQL file ./sql.common/tableCreates.sql
                                      # ------------------------------------------------------------
                                      Exception in thread "main" java.lang.UnsupportedClassVersionError: ExecJDBC : Unsupported major.minor version 52.0
                                      at java.lang.ClassLoader.defineClass1(Native Method)
                                      at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
                                      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
                                      at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
                                      at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
                                      at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
                                      at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
                                      at java.security.AccessController.doPrivileged(Native Method)
                                      at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
                                      at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
                                      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
                                      at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
                                      at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

                                      解决方法:
                                      原因是benchmarksql使用比本地jdk版本高的jdk编译,将本地jdk更新到更新版本即可。



                                      I Love PG

                                      关于我们

                                      中国开源软件推进联盟PostgreSQL分会(简称:PG分会)于2017年成立,由国内多家PG生态企业所共同发起,业务上接受工信部产业发展研究院指导。PG分会致力于构建PG产业生态,推动PG产学研用发展,是国内一家PG行业协会组织。



                                      欢迎投稿

                                      做你的舞台,show出自己的才华 。

                                      投稿邮箱:partner@postgresqlchina.com

                                                                     

                                                                       ——愿能安放你不羁的灵魂


                                      技术文章精彩回顾




                                      PostgreSQL学习的九层宝塔
                                      PostgreSQL职业发展与学习攻略
                                      搞懂PostgreSQL数据库透明数据加密之加密算法介绍
                                      一文读懂PostgreSQL-12分区表
                                      PostgreSQL源码学习之:RegularLock
                                      Postgresql源码学习之词法和语法分析
                                      PostgreSQL buffer管理
                                      最佳实践—PG数据库系统表空间重建
                                      PostgreSQL V12中的流复制配置
                                      2019,年度数据库舍 PostgreSQL 其谁?
                                      PostgreSQL使用分片(sharding)实现水平可扩展性
                                      一文搞懂PostgreSQL物化视图
                                      PostgreSQL原理解析之:PostgreSQL备机是否做checkpoint
                                      PostgreSQL复制技术概述

                                      PG活动精彩回顾




                                      见证精彩|PostgresConf.CN2019大会盛大开幕
                                      PostgresConf.CN2019大会DAY2|三大分论坛,精彩不断
                                      PostgresConf.CN2019培训日|爆满!Training Day现场速递!
                                      「PCC-Training Day」培训日Day2圆满结束,PCC2019完美收官
                                      创建PG全球生态!PostgresConf.CN2019大会盛大召开
                                      首站起航!2019“让PG‘象’前行”上海站成功举行
                                      走进蓉城丨2019“让PG‘象’前行”成都站成功举行
                                      中国PG象牙塔计划发布,首批合作高校授牌仪式在天津举行
                                      PostgreSQL实训基地落户沈阳航空航天大学和渤海大学,高校数据库课改正当时
                                      群英论道聚北京,共话PostgreSQL
                                      相聚巴厘岛| PG Conf.Asia 2019  DAY0、DAY1简报
                                      相知巴厘岛| PG Conf.Asia 2019 DAY2简报
                                      相惜巴厘岛| PG Conf.Asia 2019 DAY3简报
                                      独家|硅谷Postgres大会简报
                                      全球规模最大的PostgreSQL会议等你来!

                                      PG培训认证精彩回顾




                                      关于中国PostgreSQL培训认证,你想知道的都在这里!
                                      首批中国PGCA培训圆满结束,首批认证考试将于10月18日和20日举行!
                                      中国首批PGCA认证考试圆满结束,203位考生成功获得认证!
                                      中国第二批PGCA认证考试圆满结束,115位考生喜获认证!
                                      请查收:中国首批PGCA证书!
                                      重要通知:三方共建,中国PostgreSQL认证权威升级!
                                      一场考试迎新年 | 12月28日,首次PGCE中级认证考试开考!
                                      近500人参与!首次PGCE中级、第三批次PGCA初级认证考试落幕!

                                      文章转载自开源软件联盟PostgreSQL分会,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

                                      评论