BenchmarkSQL测试工具 对 DM 达梦单机数据库进行tpcc测试

1 下载BenchmarkSQL

自行去官网下载 ,此处不贴下载链接;

略 : 自行去官网下载 ,个人实验用的是5.0版本

上传到到DM服务器并解压缩

[dmdba@centos benchmarksql-5.0]$ pwd
/dm/benchmarksql-5.0
[dmdba@centos benchmarksql-5.0]$ ls
build.xml  doc  HOW-TO-RUN.txt  lib  README.md  run  src
[dmdba@centos benchmarksql-5.0]$

 

2 创建测试用户

SQL> create tablespace cndba datafile '/dm/dmdbms/data/dave/cndba01.dbf' size 200;
executed successfully
used time: 29.584(ms). Execute id is 2139.
SQL> create user cndba identified by cndba0551 default tablespace cndba;
executed successfully
used time: 7.071(ms). Execute id is 2140.
SQL> grant resource,dba to cndba;
executed successfully
used time: 3.974(ms). Execute id is 2141.
SQL>

3 复制对应版本的jdbc驱动到benchmarksql


#复制jdbc驱动:
[dmdba@centos jdbc]$ pwd
/dm/dmdbms/drivers/jdbc
[dmdba@centos jdbc]$ ls
dialect                        DmDictionary.jar    DmJdbcDriver17.jar  Hibernate Dialect&JDBC.txt
dm8-oracle-jdbc16-wrapper.jar  DmJdbcDriver16.jar  DmJdbcDriver18.jar  version.txt
[dmdba@centos jdbc]$ 

[dmdba@centos jdbc]$ cp DmJdbcDriver18.jar /dm/benchmarksql-5.0/lib/dameng/
[dmdba@centos jdbc]$ ll /dm/benchmarksql-5.0/lib/dameng/
total 600
-rwxr-xr-x. 1 dmdba dinstall 611987 Sep 26 08:39 DmJdbcDriver18.jar
[dmdba@centos jdbc]$

4 修改benchmarksql 参数

[root@dm8 run]# pwd
/dm/benchmarksql-5.0/run
[root@dm8 run]# ls
dmsql.buf1569457832999202.buf  log4j.properties  props.pg               runLoader.sh  sql.oracle
funcs.sh                       misc              runBenchmark.sh        runSQL.sh     sql.postgres
generateGraphs.sh              props.fb          runDatabaseBuild.sh    sql.common
generateReport.sh              props.ora         runDatabaseDestroy.sh  sql.firebird
[root@dm8 run]# 

修改的props.dm 脚本如下
[dmdba@centos run]$ cat props.dm 
db=dm
driver=dm.jdbc.driver.DmDriver
conn=jdbc:dm://192.xxxxxxxx:5236
user=dmdba
password=dmdba
warehouses=4
loadWorkers=4
terminals=32
//To run specified transactions per terminal- runMins must equal zero
runTxnsPerTerminal=0
//To run for specified minutes- runTxnsPerTerminal must equal zero
runMins=15
//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
//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_enp62s0f0 blk_sda
[dmdba@centos run]$

5 创建模式并初始化数据

[dmdba@centos run]$ ./runDatabaseBuild.sh props.dm
# ------------------------------------------------------------
# Loading SQL file ./sql.common/tableCreates.sql
# ------------------------------------------------------------
dm.jdbc.driver.DmDriver
create table bmsql_config (
cfg_name    varchar(30) primary key,
cfg_value   varchar(50)
);
create table bmsql_warehouse (
w_id        integer   not null,
w_ytd       decimal(12,2),
w_tax       decimal(4,4),
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)
);
create table bmsql_district (
d_w_id       integer       not null,
d_id         integer       not null,
d_ytd        decimal(12,2),
d_tax        decimal(4,4),
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)
);
create table bmsql_customer (
c_w_id         integer        not null,
c_d_id         integer        not null,
c_id           integer        not null,
c_discount     decimal(4,4),
c_credit       char(2),
c_last         varchar(16),
c_first        varchar(16),
c_credit_lim   decimal(12,2),
c_balance      decimal(12,2),
c_ytd_payment  decimal(12,2),
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)
);
create sequence bmsql_hist_id_seq;
create table 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 decimal(6,2),
h_data   varchar(24)
);
create table bmsql_new_order (
no_w_id  integer   not null,
no_d_id  integer   not null,
no_o_id  integer   not null
);
create table 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     integer,
o_all_local  integer,
o_entry_d    timestamp
);
create table 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       decimal(6,2),
ol_supply_w_id  integer,
ol_quantity     integer,
ol_dist_info    char(24)
);
create table bmsql_item (
i_id     integer      not null,
i_name   varchar(24),
i_price  decimal(5,2),
i_data   varchar(50),
i_im_id  integer
);
create table bmsql_stock (
s_w_id       integer       not null,
s_i_id       integer       not null,
s_quantity   integer,
s_ytd        integer,
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)
);
Starting BenchmarkSQL LoadData

driver=dm.jdbc.driver.DmDriver
conn=jdbc:dm://192.168.xxxxxxx:5236
user=cndba
password=***********
warehouses=4
loadWorkers=4
fileLocation (not defined)
csvNullValue (not defined - using default 'NULL')

Worker 000: Loading ITEM
Worker 001: Loading Warehouse      1
Worker 002: Loading Warehouse      2
Worker 003: Loading Warehouse      3
Worker 000: Loading ITEM done
Worker 000: Loading Warehouse      4
Worker 001: Loading Warehouse      1 done
Worker 002: Loading Warehouse      2 done
Worker 003: Loading Warehouse      3 done
Worker 000: Loading Warehouse      4 done
# ------------------------------------------------------------
# Loading SQL file ./sql.common/indexCreates.sql
# ------------------------------------------------------------
dm.jdbc.driver.DmDriver
alter table bmsql_warehouse add constraint bmsql_warehouse_pkey
primary key (w_id);
alter table bmsql_district add constraint bmsql_district_pkey
primary key (d_w_id, d_id);
alter table bmsql_customer add constraint bmsql_customer_pkey
primary key (c_w_id, c_d_id, c_id);
create index bmsql_customer_idx1
on  bmsql_customer (c_w_id, c_d_id, c_last, c_first);
alter table bmsql_oorder add constraint bmsql_oorder_pkey
primary key (o_w_id, o_d_id, o_id);
create unique index bmsql_oorder_idx1
on  bmsql_oorder (o_w_id, o_d_id, o_carrier_id, o_id);
alter table bmsql_new_order add constraint bmsql_new_order_pkey
primary key (no_w_id, no_d_id, no_o_id);
alter table bmsql_order_line add constraint bmsql_order_line_pkey
primary key (ol_w_id, ol_d_id, ol_o_id, ol_number);
alter table bmsql_stock add constraint bmsql_stock_pkey
primary key (s_w_id, s_i_id);
alter table bmsql_item add constraint bmsql_item_pkey
primary key (i_id);
# ------------------------------------------------------------
# Loading SQL file ./sql.common/foreignKeys.sql
# ------------------------------------------------------------
dm.jdbc.driver.DmDriver
alter table bmsql_district add constraint d_warehouse_fkey
foreign key (d_w_id)
references bmsql_warehouse (w_id);
alter table bmsql_customer add constraint c_district_fkey
foreign key (c_w_id, c_d_id)
references bmsql_district (d_w_id, d_id);
alter table bmsql_history add constraint h_customer_fkey
foreign key (h_c_w_id, h_c_d_id, h_c_id)
references bmsql_customer (c_w_id, c_d_id, c_id);
alter table bmsql_history add constraint h_district_fkey
foreign key (h_w_id, h_d_id)
references bmsql_district (d_w_id, d_id);
alter table bmsql_new_order add constraint no_order_fkey
foreign key (no_w_id, no_d_id, no_o_id)
references bmsql_oorder (o_w_id, o_d_id, o_id);
alter table bmsql_oorder add constraint o_customer_fkey
foreign key (o_w_id, o_d_id, o_c_id)
references bmsql_customer (c_w_id, c_d_id, c_id);
alter table bmsql_order_line add constraint ol_order_fkey
foreign key (ol_w_id, ol_d_id, ol_o_id)
references bmsql_oorder (o_w_id, o_d_id, o_id);
alter table bmsql_order_line add constraint ol_stock_fkey
foreign key (ol_supply_w_id, ol_i_id)
references bmsql_stock (s_w_id, s_i_id);
alter table bmsql_stock add constraint s_warehouse_fkey
foreign key (s_w_id)
references bmsql_warehouse (w_id);
alter table bmsql_stock add constraint s_item_fkey
foreign key (s_i_id)
references bmsql_item (i_id);
# ------------------------------------------------------------
# Loading SQL file ./sql.common/buildFinish.sql
# ------------------------------------------------------------
dm.jdbc.driver.DmDriver
-- ----
-- Extra commands to run after the tables are created, loaded,
-- indexes built and extra's created.
-- ----
[dmdba@centos run]$

6 执行benchmark 压测

[dmdba@centos run]$ ./runBenchmark.sh props.dm
13:36:09,861 [main] INFO   jTPCC : Term-00, 
13:36:09,867 [main] INFO   jTPCC : Term-00, +-------------------------------------------------------------+
13:36:09,867 [main] INFO   jTPCC : Term-00,      BenchmarkSQL v5.0
13:36:09,867 [main] INFO   jTPCC : Term-00, +-------------------------------------------------------------+
13:36:09,868 [main] INFO   jTPCC : Term-00,  (c) 2003, Raul Barbosa
13:36:09,868 [main] INFO   jTPCC : Term-00,  (c) 2004-2016, Denis Lussier
13:36:09,872 [main] INFO   jTPCC : Term-00,  (c) 2016, Jan Wieck
13:36:09,873 [main] INFO   jTPCC : Term-00, +-------------------------------------------------------------+
13:36:09,873 [main] INFO   jTPCC : Term-00, 
13:36:09,873 [main] INFO   jTPCC : Term-00, db=dm
13:36:09,873 [main] INFO   jTPCC : Term-00, driver=dm.jdbc.driver.DmDriver
13:36:09,874 [main] INFO   jTPCC : Term-00, conn=jdbc:dm://192.xxxxxxx:5236
13:36:09,874 [main] INFO   jTPCC : Term-00, user=cndba
13:36:09,874 [main] INFO   jTPCC : Term-00, 
13:36:09,874 [main] INFO   jTPCC : Term-00, warehouses=4
13:36:09,874 [main] INFO   jTPCC : Term-00, terminals=32
13:36:09,878 [main] INFO   jTPCC : Term-00, runMins=15
13:36:09,878 [main] INFO   jTPCC : Term-00, limitTxnsPerMin=0
13:36:09,878 [main] INFO   jTPCC : Term-00, terminalWarehouseFixed=true
13:36:09,879 [main] INFO   jTPCC : Term-00, 
13:36:09,879 [main] INFO   jTPCC : Term-00, newOrderWeight=45
13:36:09,879 [main] INFO   jTPCC : Term-00, paymentWeight=43
13:36:09,879 [main] INFO   jTPCC : Term-00, orderStatusWeight=4
13:36:09,879 [main] INFO   jTPCC : Term-00, deliveryWeight=4
13:36:09,880 [main] INFO   jTPCC : Term-00, stockLevelWeight=4
13:36:09,880 [main] INFO   jTPCC : Term-00, 
13:36:09,880 [main] INFO   jTPCC : Term-00, resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
13:36:09,880 [main] INFO   jTPCC : Term-00, osCollectorScript=./misc/os_collector_linux.py
13:36:09,880 [main] INFO   jTPCC : Term-00, 
13:36:09,913 [main] INFO   jTPCC : Term-00, copied props.dm to my_result_2021-03-26_133609/run.properties
13:36:09,914 [main] INFO   jTPCC : Term-00, created my_result_2019-09-26_133609/data/runInfo.csv for runID 12
13:36:09,914 [main] INFO   jTPCC : Term-00, writing per transaction results to my_result_2019-09-26_133609/data/result.csv
13:36:09,917 [main] INFO   jTPCC : Term-00, osCollectorScript=./misc/os_collector_linux.py
13:36:09,917 [main] INFO   jTPCC : Term-00, osCollectorInterval=1
13:36:09,917 [main] INFO   jTPCC : Term-00, osCollectorSSHAddr=null
13:36:09,917 [main] INFO   jTPCC : Term-00, osCollectorDevices=net_enp62s0f0 blk_sda
13:36:10,062 [main] INFO   jTPCC : Term-00,
Traceback (most recent call last):
  File "", line 299, in 
  File "", line 90, in main
  File "", line 269, in initNetDevice
IOError: [Errno 2] No such file or directory: '/sys/class/net/enp62s0f0/statistics/rx_packets'
13:36:10,201 [Thread-0] ERROR  OSCollector$CollectData : OSCollector, unexpected EOF while reading from external helper process
13:36:10,544 [main] INFO   jTPCC : Term-00, C value for C_LAST during load: 155
13:36:10,545 [main] INFO   jTPCC : Term-00, C value for C_LAST this run:    230
13:36:10,545 [main] INFO   jTPCC : Term-00,                                      13:36:35,478 [Thread-16] ERROR  jTPCCTData : Unexpected SQLException in NEW_ORDER Usage: 176MB / 287MB                              
13:36:35,480 [Thread-16] ERROR  jTPCCTData : Deadlock
dm.jdbc.driver.DMException: Deadlock
    at dm.jdbc.driver.DBError.throwException(Unknown Source)
    at dm.jdbc.c.b.n.Q(Unknown Source)
    at dm.jdbc.c.b.n.N(Unknown Source)
    at dm.jdbc.c.b.n.M(Unknown Source)
    at dm.jdbc.c.a.a(Unknown Source)
    at dm.jdbc.c.a.a(Unknown Source)
    at dm.jdbc.driver.DmdbPreparedStatement.executeInner(Unknown Source)
    at dm.jdbc.driver.DmdbPreparedStatement.do_executeQuery(Unknown Source)
    at dm.jdbc.driver.DmdbPreparedStatement.executeQuery(Unknown Source)
    at jTPCCTData.executeNewOrder(jTPCCTData.java:474)
    at jTPCCTData.execute(jTPCCTData.java:89)
    at jTPCCTerminal.executeTransactions(jTPCCTerminal.java:262)
    at jTPCCTerminal.run(jTPCCTerminal.java:89)
    at java.lang.Thread.run(Thread.java:748)            
……
Term-00, Runnin13:51:11,538 [Thread-3] INFO   jTPCC : Term-00, : 2540328    Memory Usage: 31MB / 47MB                     13:51:11,538 [Thread-3] INFO   jTPCC : Term-00, 
13:51:11,538 [Thread-3] INFO   jTPCC : Term-00, Measured tpmC (NewOrders) = 11490.51
13:51:11,539 [Thread-3] INFO   jTPCC : Term-00, Measured tpmTOTAL = 25588.58
13:51:11,539 [Thread-3] INFO   jTPCC : Term-00, Session Start     = 2021-03-26 13:36:11
13:51:11,539 [Thread-3] INFO   jTPCC : Term-00, Session End       = 2021-03-26 13:51:11
13:51:11,540 [Thread-3] INFO   jTPCC : Term-00, Transaction Count = 383882
[dmdba@centos run]$

7 修改benchmark 参数

在测试过程中,如果对性能不满意,可以对props.dm 中的配置参数进行修改。

修改完成之后需要重新reduild benchmark 然后再进行测试。

[dmdba@centos run]$ ./runDatabaseDestroy.sh props.dm
[dmdba@centos run]$ ./runDatabaseBuild.sh props.dm

8 查看测试报告

默认生成的数据在run 目录下,以日期命名:

[dmdba@centos run]$ pwd
/dm/benchmarksql-5.0/run
[dmdba@centos run]$ ll my_result_2021-02-26_xxxxx/
total 4
drwxr-xr-x. 2 dmdba dinstall 107 Sep 26 13:36 data
-rwxr-xr-x. 1 dmdba dinstall 999 Sep 26 13:36 run.properties
[dmdba@centos run]$

你可能感兴趣的:(数据库)