达梦数据库TPCC测试

随着达梦数据库越来越流行,数据库性能测试成为日常DBA或运维人员必备技能知识,常见的性能测试工具有jemeter、loadrunner、tpcc、tpc-h等软件。常见的测试软件中tpcc工具相对大众化,适合用户快速正确确定数据库性能好坏的一个工具。

TPC-C是专门针对联机交易处理系统(OLTP系统)的规范。TPC-C测试的结果主要有两个指标,即流量指标(Throughput,简称tpmC)和性价比(Price/Performance,简称Price/tpmC)。

流量指标(Throughput,简称tpmC):按照TPC组织的定义,流量指标描述了系统在执行支付操作、订单状态查询、发货和库存状态查询这4种交易的同时,每分钟可以处理多少个新订单交易。所有交易的响应时间必须满足TPC-C测试规范的要求,且各种交易数量所占的比例也应该满足TPC-C测试规范的要求。在这种情况下,流量指标值越大说明系统的联机事务处理能力越高。

性价比(Price/Performance,简称Price/tpmc):即测试系统的整体价格与流量指标的比值,在获得相同的tpmC值的情况下,价格越低越好。

本文通过实际用例介绍达梦数据的tpcc测试,旨在介绍达梦数据tpcc测试的方法和注意事项。

测试工具;bms5

达梦数据库版本:dm8

测试操作系统:centos7.4

数据服务器内存;4g

Cpu: 4核

 

 

 

1初始化实例

1)准备初始化数据库实例,最好选取SSD作为实例路径,本例虚拟机所有磁盘都是SSD

./dminit path=/opt/ssd

 

 

 2)启动数据库实例;

./dmserver /opt/ssd/DAMENG/dm.ini

 

 

 

2创建tpcc测试需要的数据库对象

1)  创建表空间和用户,注意由于此处虚拟机配置较低所以表空间大小此处设置的相对较小,需要根据实际环境进行相应的增加表空间大小和数据文件,因为数据库表空间自动扩展的时候会消耗资源,需要提前分配好空间,避免自动扩展时候影响性能。

CREATE TABLESPACE BENCHMARKSQL_DATA DATAFILE 'BENCHMARKSQL_DATA01.dbf' SIZE 1024;

ALTER TABLESPACE BENCHMARKSQL_DATA ADD DATAFILE 'BENCHMARKSQL_DATA02.dbf' SIZE 1024;

ALTER TABLESPACE BENCHMARKSQL_DATA ADD DATAFILE 'BENCHMARKSQL_DATA03.dbf' SIZE 1024;

CREATE TABLESPACE BENCHMARKSQL_IDX DATAFILE 'BENCHMARKSQL_IDX01.dbf' SIZE 1024;

ALTER TABLESPACE BENCHMARKSQL_IDX ADD DATAFILE 'BENCHMARKSQL_IDX02.dbf' SIZE 1024;

ALTER TABLESPACE BENCHMARKSQL_IDX ADD DATAFILE 'BENCHMARKSQL_IDX03.dbf' SIZE 1024;

CREATE USER "BENCHMARKSQL" IDENTIFIED BY "123456789" DEFAULT TABLESPACE "BENCHMARKSQL_DATA" default index tablespace "BENCHMARKSQL_IDX";

GRANT DBA TO BENCHMARKSQL;

1)  创建表,对于达梦数据库来说分区分区表需要根据达梦数据库自生来进行修改,可以用普通表,也可以用分区表。

 

 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)

);

commit;

 

 

 

3装载测试数据

一般标准的tpcc测试要求基准数据是100仓,但是由于我虚拟机配置相对底,所以以10仓的数据来模拟,实际情况读者可以根据用户要求进行基准数据装载。

1)上传bms5测试工具并完成解压

2) 修改bms5配置连接数据库,此处需要修改数据库连接地址,用户,装载基准数据仓数,加载线程数,运行窗口数等。

 

 

 3)拷贝数据库驱动到bms5工具的lib下,驱动选择一般是根据jdk环境进行选择,如虚拟机jdk环境是1.8就需要拷贝达梦数据库1.8的JDK驱动。

 

 

 4)加载基准数据,装载10个仓数据

cd /root/bms5/run/

./runLoader.sh props.dm numWarehouses 10

 

 

 

4优化数据库

1)  创建序列和索引(此处用的达梦管理用具执行方便观察结果)

 

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);

 

 

 

2)  优化数据库参数

注意此处参是按照本虚拟机配置进行配置的,实际在服务器资源比较充足的情况下应该调大部分参数。

 SP_SET_PARA_VALUE (2,'MAX_OS_MEMORY',10);

SP_SET_PARA_VALUE (2,'MEMORY_POOL',30);

SP_SET_PARA_VALUE (2,'BUFFER',2500);

SP_SET_PARA_VALUE (2,'BUFFER_POOLS',97);

SP_SET_PARA_VALUE (2,'FAST_POOL_PAGES',100);

SP_SET_PARA_VALUE (2,'FAST_ROLL_PAGES',800);

SP_SET_PARA_VALUE (2,'RECYCLE',2);

SP_SET_PARA_VALUE (2,'MULTI_PAGE_GET_NUM',1);

SP_SET_PARA_VALUE (2,'WORKER_THREADS',4);

SP_SET_PARA_VALUE (2,'CKPT_RLOG_SIZE',0);

SP_SET_PARA_VALUE (2,'CKPT_DIRTY_PAGES',0);

SP_SET_PARA_VALUE (2,'FORCE_FLUSH_PAGES',0);

SP_SET_PARA_VALUE (2,'DIRECT_IO',0);

SP_SET_PARA_VALUE (2,'IO_THR_GROUPS',4);

SP_SET_PARA_VALUE (2,'BDTA_SIZE',16);

SP_SET_PARA_VALUE (2,'FAST_COMMIT',99);

SP_SET_PARA_VALUE (2,'ENABLE_IN_VALUE_LIST_OPT',1);

SP_SET_PARA_VALUE (2,'ENABLE_SPACELIMIT_CHECK',0);

SP_SET_PARA_VALUE (2,'RLOG_PARALLEL_ENABLE',1);

SP_SET_PARA_VALUE (2,'SESS_CHECK_INTERVAL',30);

SP_SET_PARA_VALUE (2,'FAST_RELEASE_SLOCK',0);

SP_SET_PARA_VALUE (2,'NOWAIT_WHEN_UNIQUE_CONFLICT',1);

SP_SET_PARA_VALUE (2,'UNDO_EXTENT_NUM',32);

SP_SET_PARA_DOUBLE_VALUE (2,'UNDO_RETENTION',0.08);

SP_SET_PARA_VALUE (2,'MAX_SESSIONS',1000);

SP_SET_PARA_VALUE (2,'MAX_CONCURRENT_TRX',0);

SP_SET_PARA_VALUE (2,'MAX_SESSION_STATEMENT',20000);

SF_SET_SYSTEM_PARA_VALUE('SUBQ_EXP_CVT_FLAG', 0, 0, 1);

SF_SET_SYSTEM_PARA_VALUE('PURGE_DEL_OPT', 1, 0, 1);

SP_SET_PARA_VALUE (2,'ENABLE_FREQROOTS',0);

SP_SET_PARA_VALUE (2,'CACHE_POOL_SIZE',200);

SP_SET_PARA_VALUE (2,'DICT_BUF_SIZE',100);

SP_SET_PARA_VALUE (2,'RLOG_CHECK_SPACE',0);

SP_SET_PARA_VALUE (2,'CKPT_INTERVAL',3600);

SP_SET_PARA_VALUE (2,'BATCH_PARAM_OPT',0);

SP_SET_PARA_VALUE (2,'VM_MEM_HEAP',1);

SP_SET_PARA_VALUE (2,'COMM_VALIDATE',0);

SP_SET_PARA_VALUE (2,'DECIMAL_FIX_STORAGE',1);

SP_SET_PARA_VALUE(2, 'PARALLEL_PURGE_FLAG', 1);

SP_SET_PARA_VALUE(2, 'ENABLE_HASH_JOIN', 0);

 

 

 

修改数据库静态参数,并重启数据库服务。这几次组参数对测试结果也有影响

CKPT_FLUSH_PAGES = 0

ENABLE_MONITOR  = 0

RS_PRE_FETCH=0

FAST_RW_LOCK=2

3)  优化数据库日志文件

alter tablespace "ROLL" resize datafile 'ROLL.DBF' to 1000;

alter database resize logfile 'DAMENG01.log' to 2000;

alter database resize logfile 'DAMENG02.log' to 2000;

 

 

 

5开始测试

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";

 

 

1)  运行测试,此处测试时间是5分钟

./runBenchmark.sh props.dm

 

 

3)记录测试结果

查看日志记录结果

 

 

6总结

Tpcc测试时一个dba基本的技能知识,希望对您有所帮助。另外如果您想了解更多的达梦数据库知识

推荐使用达梦的云适配中心网站了解更多使用内容:http://eco.dameng.com

 

posted on 2021-05-28 11:14  bigli  阅读(1556)  评论(0编辑  收藏  举报