BenchmarkSQL v5.0測試達夢資料庫
1、安裝jdk7及以上版本
(本文使用版本:1.8.0_181)
2、官網下載apache-ant
https://ant.apache.org/bindownload.cgi下載zip包,解壓
(本文使用版本:apache-ant-1.9.15-bin.zip)
將bin目錄新增進環境變數PATH中:
vim ~/.bashrc
最後一行加入 export PATH=/xxx/apache-ant-1.9.15/bin:$PATH
儲存退出,重新載入環境變數 source~/.bashrc
3、官網下載BenchmarkSQL
https://sourceforge.net/projects/benchmarksql/
(本文使用版本:BenchmarkSQL v5.0)
4、修改原始碼,使其支援達夢資料庫
vim benchmarksql-5.0/src/client/jTPCC.java,新增下圖紅框內容: 5、使用ant編譯原始碼進入解壓後的benchmarksql-5.0 目錄,執行 ant 即可。
【報錯】 /root/sikl/benchmarksql-5.0/build.xml:24: Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK.cd benchmarksql-5.0/run cp props.ora props.dm //根據oracle檔案建立dm檔案
db=dameng driver=dm.jdbc.driver.DmDriver conn=jdbc:dm://localhost:5236 user=benchmarksql password=123456789 warehouses=100 //表示要裝載100個倉庫,1個倉庫約100M loadWorkers=4 //表示執行緒數 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 //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 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=dameng_result_%tY-%tm-%td_%tH%tM%tS osCollectorScript=./misc/os_collector_linux.py osCollectorInterval=1 //osCollectorSSHAddr=user@dbhost osCollectorDevices=net_enp5s0f1 blk_sda
7、修改funcs.sh檔案,新增dameng資料庫
按下圖兩處紅框處新增:
8、在lib庫中新增dameng目錄,放置driver包
9、修改benchmarksql-5.0/run/runDatabaseBuild.sh,去掉AFTER_LOAD中的extraHistID
10、初始化資料庫
./dminit path=/mnt/lun2/tpcc
11、啟動伺服器
./dmserver /mnt/lun2/tpcc/DAMENG/dm.ini
12、建使用者建表
#刪除benchmarksql使用者 drop user benchmarksql cascade; #建立benchmarksql使用者,密碼123456789 CREATE USER benchmarksql IDENTIFIED BY 123456789; #授權benchmarksql使用者DBA管理員許可權 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) );
13、裝載資料
cd benchmarksql-5.0/run
./runLoader.sh props.dm
可以看到MAIN.DBF檔案變大
14、建立索引和序列
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);
15、修改dm.ini引數
通過disql登入DM8伺服器並執行如下SQL命令:
SP_SET_PARA_VALUE (2,'MAX_OS_MEMORY',100); SP_SET_PARA_VALUE (2,'MEMORY_POOL',300); SP_SET_PARA_VALUE (2,'BUFFER',14000); SP_SET_PARA_VALUE (2,'BUFFER_POOLS',97); SP_SET_PARA_VALUE (2,'FAST_POOL_PAGES',10000); SP_SET_PARA_VALUE (2,'FAST_ROLL_PAGES',8000); SP_SET_PARA_VALUE (2,'RECYCLE',8); SP_SET_PARA_VALUE (2,'MULTI_PAGE_GET_NUM',1); SP_SET_PARA_VALUE (2,'MAX_BUFFER',14000); SP_SET_PARA_VALUE (2,'WORKER_THREADS',16); 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',16); 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);
16、退出伺服器
手動修改dm.ini引數,以下引數對效能提升有很大幫助
CKPT_FLUSH_PAGES = 0 ENABLE_MONITOR = 0 RS_PRE_FETCH=0 FAST_RW_LOCK=2 HASH_ACTIVE_TRX_VIEW=0 BDTA_SIZE=16 FIRST_ROWS=16 RLOG_RESERVE_SIZE=0
其他記憶體引數, worker_threads等可以看情況調節
17、重啟伺服器
./dmserver /mnt/lun2/tpcc/DAMENG/dm.ini
18、擴庫以及日誌檔案、優化表
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";
19、執行測試
./runBenchmark.sh props.dm
執行結果如下:
jTPCC : Term-00, C value for C_LTerm-00, Running Average tpmTOTAL: 66755.57
jTPCC : Term-00, Measured tpmC (NewOrders) = 30082.27
jTPCC : Term-00, Measured tpmTOTAL = 66751.79
jTPCC : Term-00, Session Start = 2020-08-20 15:44:30
jTPCC : Term-00, Session End = 2020-08-20 15:49:30
jTPCC : Term-00, Transaction Count = 333877
測試結果說明
Measured tpmC (NewOrders) = 30082.27,每分鐘新訂單數為30082.27
Measured tpmTOTAL = 66751.79,每分鐘處理的總數為66751.79
Transaction Count = 333877,5分鐘處理的總數為333877