介紹
BenchmarkSQL5是一款經典的開源資料庫測試工具,内嵌了TPCC測試腳本,可以對PostgreSQL、Firebird以及Oracle等資料庫直接進行測試。由于其未對其它資料庫(如GBase 8s)進行支援,需要對源碼進行少量的修改,以增加對其它資料庫的支援。它通過JDBC測試OLTP(聯機事務處理, Online Transaction Processing)的TPC-C。
配置
1,擷取安裝包。
下載下傳benchmarksql-5.0.tgz安裝包(經修改,增加了對GBase 8s的支援)。
BenchmarkSQL需要ant編譯環境,通過yum安裝,将自動安裝ant及其依賴包
[[email protected] ~]# yum -y install ant
2,将benchmarksql-5.0.tgz壓縮包上傳至用戶端伺服器使用者HOME目錄下。
3,進入上傳的目錄并執行解壓指令。
[[email protected] ~]# tar -zxvf benchmarksql-5.0.tgz
将生成benchmarksql-5.0目錄
4,編譯BenchMarkSQL 5.0
進行benchmarksql-5.0目錄,執行ant進行編譯
[[email protected] ~]# cd benchmarksql-5.0
[[email protected] benchmarksql-5.0]# ant
Buildfile: /root/benchmarksql-5.0/build.xml
init:
[mkdir] Created dir: /root/benchmarksql-5.0/build
compile:
[javac] Compiling 11 source files to /root/benchmarksql-5.0/build
dist:
[jar] Building jar: /root/benchmarksql-5.0/dist/BenchmarkSQL-5.0.jar
BUILD SUCCESSFUL
Total time: 2 seconds
生成BenchmarkSQL-5.0.jar
測試GBase 8s
1,使用gbasedbt在已部署好的GBase 8s資料庫建立資料庫(bm5)。
####2,修改配置檔案。
根據實際情況修改配置檔案進入Benchmarksql的run目錄,按實際情況修改配置檔案。
[[email protected] benchmarksql-5.0]# cd run/
[[email protected] run]# cp props.gbase props.3.0.0_1
[[email protected] run]# vi props.3.0.0_1
修改下面部分,其餘部分可使用預設值,通常不用修改。
參數 | 值 | 說明 |
---|---|---|
db | gbase | 指定資料庫類型(修改後增加的資料庫類型) |
driver | com.gbasedbt.jdbc.Driver | 資料庫的驅動類名稱 |
conn | jdbc:gbasedbt-sqli://127.0.0.1:9088/bm5:GBASEDBTSERVER=gbase01; IFX_LOCK_MODE_WAIT=60; IFX_ISOLATION_LEVEL=1U; OPTOFC=1; | 連接配接字元串 特别注意: IFX_ISOLATION_LEVEL後需要U |
user | gbasedbt | 使用者名 |
password | GBase123 | 使用者密碼 |
warehouses | 10 | 初始化加載資料時,需要建立多少倉庫的資料。每倉庫約80MB資料 |
loadWorkers | 4 | 表示加載資料時,開啟加載資料的程序數。對于GBase 8s需要謹慎設定該參數,與邏輯日志量相關 |
terminals | 20 | 終端數量,指同時有多少終端并發執行,表示并發程度。 |
runTxnsPerTerminal | 每分鐘每個終端執行的事務數。 | |
runMins | 1 | 執行多少分鐘。 |
limitTnxsPermin | 限制每分鐘執行的事務總數。0表示不限制 | |
terminalWarehouseFixed | true | 用于指定終端和倉庫的綁定模式,設定為true時可以運作4.x相容模式,意思為每個終端都有一個固定的倉庫。設定為false時可以均勻的使用資料庫整體配置。 |
特别注意:
runMins和runTxnsPerTerminal這兩個參數指定了兩種運作方式,前者是按照指定運作時間執行,以時間為标準;後者以指定每個終端的事務數為标準執行。兩者不能同時生效,必須有一個設定為0。
3,初始化資料。
在run目錄下執行指令給檔案賦予可執行權限。
[[email protected] run]# chmod +x *.sh
注意:
如果已經賦予相關權限,不用重複操作。
4,加載資料。
[[email protected] run]# ./runDatabaseBuild.sh props.3.0.0_1
建立并初始化表—共9張表(warehouse, Stock, Item, Order-Line, New-Order, History, District, Customer,Order),外加一個配置表。
同時會建立相應的索引、主外鍵參考。
5,運作benchmarksql程式。
[[email protected] run]# ./runBenchmark.sh props.3.0.0_1
10:43:15,284 [main] INFO jTPCC : Term-00,
10:43:15,291 [main] INFO jTPCC : Term-00, +-------------------------------------------------------------+
10:43:15,291 [main] INFO jTPCC : Term-00, BenchmarkSQL v5.0
10:43:15,291 [main] INFO jTPCC : Term-00, +-------------------------------------------------------------+
10:43:15,291 [main] INFO jTPCC : Term-00, (c) 2003, Raul Barbosa
10:43:15,291 [main] INFO jTPCC : Term-00, (c) 2004-2016, Denis Lussier
10:43:15,293 [main] INFO jTPCC : Term-00, (c) 2016, Jan Wieck
10:43:15,293 [main] INFO jTPCC : Term-00, +-------------------------------------------------------------+
10:43:15,293 [main] INFO jTPCC : Term-00,
10:43:15,293 [main] INFO jTPCC : Term-00, db=gbase
10:43:15,293 [main] INFO jTPCC : Term-00, driver=com.gbasedbt.jdbc.Driver
10:43:15,293 [main] INFO jTPCC : Term-00, conn=jdbc:gbasedbt-sqli://127.0.0.1:9088/bm5:GBASEDBTSERVER=gbase01;IFX_LOCK_MODE_WAIT=60;IFX_ISOLATION_LEVEL=1U;OPTOFC=1;DB_LOCALE=en_US.819;CLIENT_LOCALE=en_US.819
10:43:15,293 [main] INFO jTPCC : Term-00, user=gbasedbt
10:43:15,294 [main] INFO jTPCC : Term-00,
10:43:15,294 [main] INFO jTPCC : Term-00, warehouses=4
10:43:15,294 [main] INFO jTPCC : Term-00, terminals=8
10:43:15,296 [main] INFO jTPCC : Term-00, runMins=1
10:43:15,296 [main] INFO jTPCC : Term-00, limitTxnsPerMin=0
10:43:15,296 [main] INFO jTPCC : Term-00, terminalWarehouseFixed=true
10:43:15,296 [main] INFO jTPCC : Term-00,
10:43:15,296 [main] INFO jTPCC : Term-00, newOrderWeight=45
10:43:15,296 [main] INFO jTPCC : Term-00, paymentWeight=43
10:43:15,296 [main] INFO jTPCC : Term-00, orderStatusWeight=4
10:43:15,297 [main] INFO jTPCC : Term-00, deliveryWeight=4
10:43:15,297 [main] INFO jTPCC : Term-00, stockLevelWeight=4
10:43:15,297 [main] INFO jTPCC : Term-00,
10:43:15,297 [main] INFO jTPCC : Term-00, resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
10:43:15,297 [main] INFO jTPCC : Term-00, osCollectorScript=./misc/os_collector_linux.py
10:43:15,297 [main] INFO jTPCC : Term-00,
10:43:15,318 [main] INFO jTPCC : Term-00, copied props.3.0.0_1 to my_result_2020-09-28_104315/run.properties
10:43:15,318 [main] INFO jTPCC : Term-00, created my_result_2020-09-28_104315/data/runInfo.csv for runID 1
10:43:15,318 [main] INFO jTPCC : Term-00, writing per transaction results to my_result_2020-09-28_104315/data/result.csv
10:43:15,319 [main] INFO jTPCC : Term-00, osCollectorScript=./misc/os_collector_linux.py
10:43:15,319 [main] INFO jTPCC : Term-00, osCollectorInterval=1
10:43:15,320 [main] INFO jTPCC : Term-00, osCollectorSSHAddr=null
10:43:15,320 [main] INFO jTPCC : Term-00, osCollectorDevices=net_eth0 blk_sda
10:43:15,467 [main] INFO jTPCC : Term-00,
10:43:15,699 [main] INFO jTPCC : Term-00, C value for C_LAST during load: 83
10:43:15,699 [main] INFO jTPCC : Term-00, C value for C_LAST this run: 11
10:43:15,699 [main] INFO jTPCC : Term-00, Traceback (most recent call last):: 0.00 Current tpmTOTAL: 0 Memory Usage: 5MB / 29MB
File "<stdin>", line 299, in <module>
File "<stdin>", line 86, in main
File "<stdin>", line 226, in initBlockDevice
IOError: [Errno 2] No such file or directory: '/sys/block/sda/stat'
10:43:16,009 [Thread-0] ERROR OSCollector$CollectData : OSCollector, unexpected EOF while reading from external helper process Term-00, Running Average tpmTOTAL: 17619.83 Current tpmTO10:44:15,988 [Thread-7] INFO jTPCC : Term-00,
10:44:15,988 [Thread-7] INFO jTPCC : Term-00,
10:44:15,988 [Thread-7] INFO jTPCC : Term-00, Measured tpmC (NewOrders) = 7952.5
10:44:15,988 [Thread-7] INFO jTPCC : Term-00, Measured tpmTOTAL = 17618.61
10:44:15,988 [Thread-7] INFO jTPCC : Term-00, Session Start = 2020-09-28 10:43:15
10:44:15,988 [Thread-7] INFO jTPCC : Term-00, Session End = 2020-09-28 10:44:15
10:44:15,988 [Thread-7] INFO jTPCC : Term-00, Transaction Count = 17632
執行結束後,取tpmC和tpmTOTAL作為測試名額。
6,删除資料庫和資料。
[[email protected] run]# ./runDatabaseDestroy.sh props.3.0.0_1
# ------------------------------------------------------------
# Loading SQL file ./sql.common/tableDrops.sql
# ------------------------------------------------------------
drop table bmsql_config;
drop table bmsql_new_order;
drop table bmsql_order_line;
drop table bmsql_oorder;
drop table bmsql_history;
drop table bmsql_customer;
drop table bmsql_stock;
drop table bmsql_item;
drop table bmsql_district;
drop table bmsql_warehouse;
drop sequence bmsql_hist_id_seq;