Benchmarksql基於PostgreSQL安裝與使用


1、下載並解壓benchmarksql

BenchMarkSQL下載鏈接:http://sourceforge.net/projects/benchmarksql/

下載后放置到安裝機器上直接upzip安裝包

2、安裝ant


[root@localhost data]# yum install ant [root@localhost data]# ant 

3、下載最新java版本對應的postgresql jdbc jar

把要測試的數據庫的JDBC DRIVER放到./ benchmarksql-5.0/lib目錄下

wget https://jdbc.postgresql.org/download/postgresql-9.4.1207.jre7.jar mv postgresql-9.4.1207.jre7.jar benchmarksql-5.0/lib/ 

4、下載安裝 JDK7

JDK下載鏈接:[https://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html]

rpm -ivh jdk-7u80-linux-x64.rpm

5、配置JAVA環境變量

export JAVA_HOME=/usr/java/jdk1.7.0_80  ##jdk安裝路徑

export PATH=$JAVA_HOME/bin:$PATH

6、配置benchmarksql,使用新的postgresql java驅動

在run/目錄下的 runBenchmark.sh 、 runLoader.sh 、 runSQL.sh三個文件中加入要測試的數據庫的JDBC DRIVER的位置;

$ vi runBenchmark.sh 

java -cp .:../lib/postgresql-9.4.1207.jre7.jar:../lib/log4j-1.2.17.jar:../lib/apache-log4j-extras-1.1.jar:../dist/BenchmarkSQL-4.1.jar -Dprop=$1 jTPCC 

$ vi runLoader.sh 

java -cp .:../lib/postgresql-9.4.1207.jre7.jar:../dist/BenchmarkSQL-5.0.jar -Dprop=$1 LoadData $2 $3 $4 $5 

$ vi runSQL.sh 

myCP="../lib/postgresql-9.4.1207.jre7.jar" 

myCP="$myCP:../dist/BenchmarkSQL-4.1.jar" 

myOPTS="-Dprop=$1" 

myOPTS="$myOPTS -DcommandFile=$2" 

java -cp .:$myCP $myOPTS ExecJDBC 

7、修改props.pg配置文件

props.pg配置文件在benchmarksql-5.0/run/下,改配置文件主要用於配置測試數據庫連接以及測試數據加載量,以及其他測試參數,詳情看以下備注

db=postgres driver=org.postgresql.Driver conn=jdbc:postgresql://192.168.1.3:5432/test user=test password=test warehouses=32 loadWorkers=8 terminals=1 //To run specified transactions per terminal- runMins must equal zero runTxnsPerTerminal=0 //To run for specified minutes- runTxnsPerTerminal must equal zero runMins=3 //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_eth0 blk_sda 

conn=jdbc:postgresql://localhost:5432/benchmarksql

conn參數用於指定連接串,可以修改ip,端口與dbname

loadworkers

該參數用於指定測試數據加載時的並行度

warehouses

warehouses 參數用於指定倉庫個數,用於控制測試數據量,默認為1,導入9張表的數據大小大概70多M,當numWarehouse為10時,數據大小可以近似當作1GB數據
每個倉庫負責十個區域的供貨,每個區域 3000 個客戶服務,每個倉庫維護 100000 種商品的庫存紀錄,每個倉庫至多有10個終端

terminals

terminals參數用於指定模擬終端數

runTxnsPerTerminal

runTxnsPerTerminal參數用於指定每個終端提交事務數,這個參數與runMins只能選擇設置其中一個,另一個必須設置為0
runTxnsPerTerminal=100
runMins=0

runMins

runMins參數用於指定運行時間,單位是分鍾,這個參數與runTxnsPerTerminal只能選擇設置其中一個,另一個必須設置為0
runTxnsPerTerminal=0
runMins=12

limitTxnsPerMin=100000

limitTxnsPerMin參數用於指定每分鍾提交事務數限制,設置太小,壓力會不夠,如果測試結果不能接近該值就代表壓力足夠

terminalWarehouseFixed=true

terminalWarehouseFixed參數用於指定終端和倉庫的綁定模式,設置為true時可以運行4.x兼容模式,意思為每個終端都有一個固定的倉庫。設置為false時可以均勻的使用數據庫整體配置。TPCC規定每個終端都必須有一個綁定的倉庫,所以一般使用默認值true

8、創建測試表,以及測試數據預加載

在benchmarksql-5.0/run/下執行腳本 ./runDatabaseBuild.sh props.pg

執行該腳本會創建TPC-C標准模型中的9張表並按照props.pg設置的倉庫數(warehouses)進行數據測試數據寫入、主外鍵以及索引創建。

9、執行測試

在benchmarksql-5.0/run/下執行腳本 ./runBenchmark.sh props.pg

10、測試結果

Running Average tpmTOTAL:每分鍾平均執行事務數(所有事務)
Memory Usage:客戶端內存使用情況
Measured tpmC (NewOrders) :每分鍾執行的事務數(只統計NewOrders事務)
Transaction Count:執行的交易總數量

Term-00, Running Average tpmTOTAL: 292.39 Current tpmTOTAL: 22860 Memory Usage: 19MB / 61MB 17:15:14,684 [Thread-2] INFO jTPCC : Term-00, 17:15:14,684 [Thread-2] INFO jTPCC : Term-00, 17:15:14,685 [Thread-2] INFO jTPCC : Term-00, Measured tpmC (NewOrders) = 133.7 17:15:14,685 [Thread-2] INFO jTPCC : Term-00, Measured tpmTOTAL = 292.31 17:15:14,685 [Thread-2] INFO jTPCC : Term-00, Session Start = 2018-10-24 17:03:14 17:15:14,685 [Thread-2] INFO jTPCC : Term-00, Session End = 2018-10-24 17:15:14 17:15:14,685 [Thread-2] INFO jTPCC : Term-00, Transaction Count = 3508 

11、測試后清除數據

在benchmarksql-5.0/run/下執行腳本./runDatabaseDestroy.sh props.pg
執行該腳本會將TPC-C測試相關表刪除,測試下一個場景可以從第8個步驟重新執行。



作者:clorislam_cmm
鏈接:https://www.jianshu.com/p/5a056102c8b8
來源:簡書
著作權歸作者所有。商業轉載請聯系作者獲得授權,非商業轉載請注明出處。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM