欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

达蒙 TPCC BENCHMARKSQL 性能测试

最编程 2024-06-11 14:21:25
...
测试模型
TPC-C测试用到的模型是一个大型的商品批发销售公司,它拥有若干个分布在不同区域的商品仓库。当业务扩展的时候,公司将添加新的仓库。每个仓库负责为10个销售点供货,其中每个销售点为3000个客户提供服务,每个客户提交的订单中,平均每个订单有10项产品,所有订单中约1%的产品在其直接所属的仓库中没有存货,必须由其他区域的仓库来供货。同时,每个仓库都要维护公司销售的100000种商品的库存记录。
测试指标
TPC-C测试的结果主要有两个指标,即流量指标(Throughput,简称tpmC)和性价比(Price/Performance,简称Price/tpmC)。
流量指标(Throughput,简称tpmC):按照TPC组织的定义,流量指标描述了系统在执行支付操作、订单状态查询、发货和库存状态查询这4种交易的同时,每分钟可以处理多少个新订单交易。所有交易的响应时间必须满足TPC-C测试规范的要求,且各种交易数量所占的比例也应该满足TPC-C测试规范的要求。在这种情况下,流量指标值越大说明系统的联机事务处理能力越高。
性价比(Price/Performance,简称Price/tpmc):即测试系统的整体价格与流量指标的比值,在获得相同的tpmC值的情况下,价格越低越好。
 
环境准备
详细信息
数据版本
dm8
jdk版本
jdk1.8.0_242
apache-ant版本
1.10.10
benchmarkSQL版本
benchmarksql-5.0
cpu
32核 x86
内存
64G
操作系统
centos7.8
实例挂载磁盘大小
500G
 
初始化数据库
./dminit path=/dmdata page_size=32
上传安装包到/tpcc下
1 安装jdk并配置环境变量
解压jdk
tar -zxvf jdk-8u271-linux-x64.tar.gz
编辑/etc/profile文件,在文件末尾添加一下内容
export JAVA_HOME=/tpcc/jdk1.8.0_271
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin
执行命令source /etc/profile 生效
执行命令java -version或jps环境变量是否生效
2 apache-ant 安装和配置环境变量
官网下载apache-ant    https://ant.apache.org/bindownload.cgi
解压apache-ant
unzip apache-ant-1.10.10-bin.zip
vim ~/.bash_profile
export APACH_HOME=/tpcc/apache-ant-1.10.10
export PATH=$PATH:$APACH_HOME/bin
执行命令source ~/.bash_profile生效
执行命令ant -version 查看是否生效
3 benchmarksql安装和配置
官网下载BenchmarkSQL   https://sourceforge.net/projects/benchmarksql/
解压安装包
unzip benchmarksql-5.0\(2\).zip
官方版本默认不支持达梦数据库,需要修改源码
vim /tpcc/benchmarksql-5.0/src/client/jTPCC.java 添加如下内容
vim /tpcc/benchmarksql-5.0/run/funcs.sh 修改如下
 
在benchmarksql的lib库中添加dameng目录,放置driver包
cp /dm8/drivers/jdbc/DmJdbcDriver18.jar /tpcc/benchmarksql-5.0/lib/dameng
在benchmarksql-5.0 目录使用ant命令编译源码
在benchmarksql的run目录编辑props.dm
db=dameng
driver=dm.jdbc.driver.DmDriver
conn=jdbc:dm://192.168.10.74:5236
user=BENCHMARKSQL
password=123456789
warehouses=100
terminals=144
//To run specified transactions per terminal- runMins must equal zero
runTxnsPerTerminal=0
//To run for specified minutes- runTxnsPerTerminal must equal zero
runMins=5
//Number of total transactions per minute
limitTxnsPerMin=0
//The following five values must add up to 100
newOrderWeight=45
paymentWeight=43
orderStatusWeight=4
deliveryWeight=4
stockLevelWeight=4
创建测试用户及授权
CREATE TABLESPACE BENCHMARKSQL1 DATAFILE 'BENCHMARKSQL1.dbf' SIZE 10000;
CREATE USER "BENCHMARKSQL" IDENTIFIED BY "123456789" DEFAULT TABLESPACE "BENCHMARKSQL1";
GRANT DBA TO BENCHMARKSQL;
创建表
create table benchmarksql.bmsql_config (
  cfg_name    varchar(30) cluster primary key,
  cfg_value   varchar(50)
);
create table benchmarksql.bmsql_warehouse (
  w_id        integer   not null,
  w_ytd       float,
  w_tax       float,
  w_name      varchar(10),
  w_street_1  varchar(20),
  w_street_2  varchar(20),
  w_city      varchar(20),
  w_state     char(2),
  w_zip       char(9),
  cluster primary key(w_id)
)STORAGE(FILLFACTOR 1);
create table benchmarksql.bmsql_district (
  d_w_id       integer       not null,
  d_id         integer       not null,
  d_ytd        float,
  d_tax        float,
  d_next_o_id  integer,
  d_name       varchar(10),
  d_street_1   varchar(20),
  d_street_2   varchar(20),
  d_city       varchar(20),
  d_state      char(2),
  d_zip        char(9),
cluster primary key(d_w_id, d_id)
)STORAGE(FILLFACTOR 1);
create table benchmarksql.bmsql_customer (
  c_w_id         integer        not null,
  c_d_id         integer        not null,
  c_id           integer        not null,
  c_discount     float,
  c_credit       char(2),
  c_last         varchar(16),
  c_first        varchar(16),
  c_credit_lim   float,
  c_balance      float,
  c_ytd_payment  float,
  c_payment_cnt  integer,
  c_delivery_cnt integer,
  c_street_1     varchar(20),
  c_street_2     varchar(20),
  c_city         varchar(20),
  c_state        char(2),
  c_zip          char(9),
  c_phone        char(16),
  c_since        timestamp,
  c_middle       char(2),
  c_data         varchar(500),
  cluster primary key(c_w_id, c_d_id, c_id)
);
create table benchmarksql.bmsql_history (
  hist_id  integer,
  h_c_id   integer,
  h_c_d_id integer,
  h_c_w_id integer,
  h_d_id   integer,
  h_w_id   integer,
  h_date   timestamp,
  h_amount float,
  h_data   varchar(24)
)storage(branch(32,32),without counter);
create table benchmarksql.bmsql_oorder (
  o_w_id       integer      not null,
  o_d_id       integer      not null,
  o_id         integer      not null,
  o_c_id       integer,
  o_carrier_id integer,
  o_ol_cnt     float,
  o_all_local  float,
  o_entry_d    timestamp,
  cluster primary key(o_w_id, o_d_id, o_id)
)storage(without counter);
create table benchmarksql.bmsql_new_order (
  no_w_id  integer   not null,
  no_d_id  integer   not null,
  no_o_id  integer   not null,
  cluster primary key(no_w_id, no_d_id, no_o_id)
)storage(without counter);
create table benchmarksql.bmsql_order_line (
  ol_w_id         integer   not null,
  ol_d_id         integer   not null,
  ol_o_id         integer   not null,
  ol_number       integer   not null,
  ol_i_id         integer   not null,
  ol_delivery_d   timestamp,
  ol_amount       float,
  ol_supply_w_id  integer,
  ol_quantity     float,
  ol_dist_info    char(24),
  cluster primary key(ol_w_id, ol_d_id, ol_o_id, ol_number)
)storage(without counter);
create table benchmarksql.bmsql_stock (
  s_w_id       integer       not null,
  s_i_id       integer       not null,
  s_quantity   float,
  s_ytd        float,
  s_order_cnt  integer,
  s_remote_cnt integer,
  s_data       varchar(50),
  s_dist_01    char(24),
  s_dist_02    char(24),
  s_dist_03    char(24),
  s_dist_04    char(24),
  s_dist_05    char(24),
  s_dist_06    char(24),
  s_dist_07    char(24),
  s_dist_08    char(24),
  s_dist_09    char(24),
  s_dist_10    char(24),
cluster primary key(s_w_id, s_i_id)
);
create table benchmarksql.bmsql_item (
  i_id     integer      not null,
  i_name   varchar(24),
  i_price  float,
  i_data   varchar(50),
  i_im_id  integer,
  cluster primary key(i_id)
);
装载数据
运行以下命令装载 100 个仓库数据
./runLoader.sh props.dm numWarehouses 100
 
创建索引和序列
create index ndx_customer_name on benchmarksql.bmsql_customer (c_w_id, c_d_id, c_last, c_first);
create or replace procedure benchmarksql.createsequence
as
n int;
stmt1 varchar(200);
begin
   select count(*)+1 into n from benchmarksql.bmsql_history;
   if(n != 1) then
      select max(hist_id) + 1 into n from benchmarksql.bmsql_history;
   end if;
   PRINT n;
   stmt1:='create sequence benchmarksql.bmsql_hist_id_seq start with '||n||' MAXVALUE 9223372036854775807 CACHE 50000;';
   EXECUTE IMMEDIATE stmt1;
end;
/
call benchmarksql.createsequence;
alter table benchmarksql.bmsql_history modify hist_id integer default (benchmarksql.bmsql_hist_id_seq.nextval);
 
修改dm.ini动态参数(sql脚本)
修改静态参数
CKPT_FLUSH_PAGES = 0
FAST_RW_LOCK=2
ENABLE_MONITOR = 0
FIRST_ROWS=16
重启数据库服务
systemctl restart DmServiceDM.service
数据预加载
扩库以及日志文件、优化表
alter tablespace "ROLL" resize datafile 'ROLL.DBF' to 10000;
alter database resize logfile 'DAMENG01.log' to 50000;
alter database resize logfile 'DAMENG02.log' to 50000;
--测试前执行如下SQL:
--item表,8K的页,需要占用1300页
SP_SET_TAB_FAST_POOL_FLAG('BENCHMARKSQL', 'BMSQL_ITEM', 1);
SP_SET_TAB_FAST_POOL_FLAG('BENCHMARKSQL', 'BMSQL_WAREHOUSE', 1);
SP_SET_TAB_FAST_POOL_FLAG('BENCHMARKSQL', 'BMSQL_DISTRICT', 1);
如果是压力测试(数据都可以在内存放下),可以执行下面的语句,把数据预加载到内存:
select count(*) from "BENCHMARKSQL"."BMSQL_CUSTOMER" union all
select count(*) from "BENCHMARKSQL"."BMSQL_DISTRICT" union all
select count(*) from "BENCHMARKSQL"."BMSQL_ITEM" union all
select count(*) from "BENCHMARKSQL"."BMSQL_NEW_ORDER" union all
select count(*) from "BENCHMARKSQL"."BMSQL_OORDER" union all
select count(*) from "BENCHMARKSQL"."BMSQL_ORDER_LINE" union all
select count(*) from "BENCHMARKSQL"."BMSQL_STOCK" union all
select count(*) from "BENCHMARKSQL"."BMSQL_WAREHOUSE" union all
select count(*) from "BENCHMARKSQL"."BMSQL_HISTORY"  union all
select count("C_PAYMENT_CNT") from "BENCHMARKSQL"."BMSQL_CUSTOMER";
执行测试
./runBenchmark.sh props.dm

测试后清除数据

./runDatabaseDestroy.sh props.dm