1.通過命令行連接Hammerdb工具
1)切換到數(shù)據(jù)庫用戶下
2)進(jìn)入Hammerdb安裝目錄執(zhí)行./hammerdbcli
[root@INFOGOV n]# su - oracle
[oracle@INFOGOV ~]$ cd /data/hammerdb/n/
[oracle@INFOGOV n]$ ./hammerdbcli
HammerDB CLI v3.1
Copyright (C) 2003-2018 Steve Shaw
Type "help" for a list of commands
The xml is well-formed, applying configuration
hammerdb>
2.查看所有命令
1)使用help可以查看所有可用命令
2)使用help [command] 可以查看具體命令的用途
hammerdb>help
HammerDB v3.1 CLI Help Index
Type "help command" for more details on specific commands below
buildschema
clearscript
customscript
datagenrun
dbset
dgset
diset
librarycheck
loadscript
print
vucomplete
vucreate
vudestroy
vurun
vuset
vustatus
hammerdb>help buildschema
buildschema - Usage: buildschema
Runs the schema build for the database and benchmark selected with dbset and variables selected with diset. Equivalent to the Build command in the graphical interface.
3.設(shè)置測試數(shù)據(jù)庫類型
使用命令 dbset db [dbtype],dbtype有以下幾種類型,命令中的dbtype只需輸入對應(yīng)的簡寫代號即可:
Oracle = ora、MSSQLServer = mssqls、Db2 = db2、MySQL = mysql、PostgreSQL = pg、Redis = redis
操作中如果dbtype輸入錯誤,返回錯誤信息中也會有相應(yīng)的簡寫提示
hammerdb>dbset db $dbtype
To change do: dbset db prefix, one of:
Oracle = ora MSSQLServer = mssqls Db2 = db2 MySQL = mysql PostgreSQL = pg Redis = redis
檢查設(shè)置結(jié)果
hammerdb>print db
Database Oracle set.
4.設(shè)置壓力測試標(biāo)準(zhǔn)程序
這里設(shè)置的是OLTP的基準(zhǔn)測試TPC-C類型
hammerdb>dbset bm TPC-C
Benchmark set to TPC-C for Oracle
設(shè)置后可以用以下命令檢查配置情況
hammerdb>print bm
Benchmark set to TPC-C
5.用print dict命令查看可用配置的數(shù)據(jù)庫變量
hammerdb>print dict
Dictionary Settings for Oracle
connection {
system_user = system
system_password = manager
instance = oracle
rac = 0
}
tpcc {
count_ware = 1
num_vu = 1
tpcc_user = tpcc
tpcc_pass = tpcc
tpcc_def_tab = tpcctab
tpcc_ol_tab = tpcctab
tpcc_def_temp = temp
partition = false
hash_clusters = false
tpcc_tt_compat = false
total_iterations = 1000000
raiseerror = false
keyandthink = false
checkpoint = false
ora_driver = test
rampup = 2
duration = 5
allwarehouse = false
timeprofile = false
}
6.數(shù)據(jù)庫配置參數(shù)說明以及修改方式
修改數(shù)據(jù)庫配置參數(shù)有兩種方式,一是使用hammerdb中的diset命令修改,而是修改參數(shù)文件。使用命令行修改參數(shù)只是基于當(dāng)前會話,在其他會話中修改的參數(shù)將不生效,如需將參數(shù)修改為默認(rèn)值,可以直接修改配置文件。
使用命令修改-connection參數(shù)說明與修改
- system_user參數(shù)用于指定數(shù)據(jù)庫連接用戶
hammerdb>diset connection system_user test
Changed connection:system_user from system to test for Oracle
- system_password參數(shù)用戶指定數(shù)據(jù)庫連接密碼
hammerdb>diset connection system_password test
Changed connection:system_password from manager to test for Oracle
使用命令修改-tpcc參數(shù)說明與修改
- count_ware 參數(shù)用于指定倉庫個數(shù),用于控制測試數(shù)據(jù)量,默認(rèn)為1,導(dǎo)入9張表的數(shù)據(jù)大小大概70多M,當(dāng)numWarehouse為10時,數(shù)據(jù)大小可以近似當(dāng)作1GB數(shù)據(jù)
hammerdb>diset tpcc count_ware 10
Changed tpcc:count_ware from 1 to 10 for Oracle
- num_vu 參數(shù)用于指定加載warehouse的用戶數(shù),這里越多越好,也要和CPU 數(shù)匹配,一般是CPU數(shù)量的1 -1.5倍
hammerdb>diset tpcc num_vu 4
Changed tpcc:num_vu from 1 to 4 for Oracle
- tpcc_user 參數(shù)用于指定tpcc測試數(shù)據(jù)加載schema
hammerdb>diset tpcc tpcc_user hammerdbtest
Changed tpcc:tpcc_user from test to hammerdbtest for Oracle
- tpcc_pass 參數(shù)用于指定TPC-C測試數(shù)據(jù)加載schema對應(yīng)密碼
hammerdb>diset tpcc tpcc_pass test
Changed tpcc:tpcc_pass from tpcc to test for Oracle
- tpcc_def_tab(TPC-C Default Tablespace)參數(shù)用于指定TPC-C基準(zhǔn)測試數(shù)據(jù)加載的默認(rèn)表空間
hammerdb>diset tpcc tpcc_def_tab TBS_BIGTABLE
Changed tpcc:tpcc_def_tab from tpcctab to TBS_BIGTABLE for Oracle
- tpcc_ol_tab(Order Line Tablespace)參數(shù)用于指定TPC-C基準(zhǔn)測試中訂單數(shù)據(jù)表的指定表空間
可以與其他數(shù)據(jù)表相同的數(shù)據(jù)空間,也可以額外劃分新表空間用于存儲訂單表的數(shù)據(jù)
hammerdb>diset tpcc tpcc_ol_tab TBS_BIGTABLE
Changed tpcc:tpcc_ol_tab from tpcctab to TBS_BIGTABLE for Oracle
- tpcc_def_temp(TPC-C Temporary Tablespace)參數(shù)用于指定TPC-C基準(zhǔn)測試所使用的臨時表空間
hammerdb>diset tpcc tpcc_def_temp TBS_BIGTABLE
Changed tpcc:tpcc_def_temp from temp to TBS_BIGTABLE for Oracle
修改配置文件
配置文件在安裝目錄下./config/oracle.xml
[root@INFOGOV config]# vi oracle.xml
<?xml version="1.0" encoding="utf-8"?>
<oracle>
<connection>
<system_user>system</system_user>
<system_password>root</system_password>
<instance>orcl</instance>
<rac>0</rac>
</connection>
<tpcc>
<schema>
<count_ware>1</count_ware>
<num_vu>16</num_vu>
<tpcc_user>hammertest</tpcc_user>
<tpcc_pass>test</tpcc_pass>
<tpcc_def_tab>TBS_BIGTABLE</tpcc_def_tab>
<tpcc_ol_tab>TBS_BIGTABLE</tpcc_ol_tab>
<tpcc_def_temp>USER</tpcc_def_temp>
<partition>false</partition>
<hash_clusters>false</hash_clusters>
<tpcc_tt_compat>false</tpcc_tt_compat>
</schema>
<driver>
<total_iterations>1000000</total_iterations>
<raiseerror>false</raiseerror>
<keyandthink>false</keyandthink>
<checkpoint>false</checkpoint>
<ora_driver>test</ora_driver>
<rampup>2</rampup>
<duration>5</duration>
<allwarehouse>false</allwarehouse>
<timeprofile>false</timeprofile>
</driver>
</tpcc>
<tpch>
<schema>
<scale_fact>1</scale_fact>
<tpch_user>tpch</tpch_user>
<tpch_pass>tpch</tpch_pass>
<tpch_def_tab>tpchtab</tpch_def_tab>
<tpch_def_temp>temp</tpch_def_temp>
<num_tpch_threads>1</num_tpch_threads>
<tpch_tt_compat>false</tpch_tt_compat>
</schema>
<driver>
<total_querysets>1</total_querysets>
<raise_query_error>false</raise_query_error>
<verbose>false</verbose>
<degree_of_parallel>2</degree_of_parallel>
<refresh_on>false</refresh_on>
<update_sets>1</update_sets>
<trickle_refresh>1000</trickle_refresh>
<refresh_verbose>false</refresh_verbose>
<cloud_query>false</cloud_query>
</driver>
</tpch>
</oracle>