原 数据库命令行压测工具介绍--Hammerdb、swingbench
Tags: 原创工具介绍压测数据库压测HammerDBswingbench命令行压测工具
通过命令行连接Hammerdb工具
1.通过命令行连接Hammerdb工具
1)切换到数据库用户下
2)进入Hammerdb安装目录执行./hammerdbcli
1 2 3 4 5 6 7 8 | [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] 可以查看具体命令的用途
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 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 |
1 2 3 | 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.设置测试数据库类型
使用命令 dbset db [dbtype],dbtype有以下几种类型,命令中的dbtype只需输入对应的简写代号即可:
Oracle = ora、MSSQLServer = mssqls、Db2 = db2、MySQL = mysql、PostgreSQL = pg、Redis = redis
操作中如果dbtype输入错误,返回错误信息中也会有相应的简写提示
1 2 3 | hammerdb>dbset db $dbtype To change do: dbset db prefix, one of: Oracle = ora MSSQLServer = mssqls Db2 = db2 MySQL = mysql PostgreSQL = pg Redis = redis |
检查设置结果
1 2 | hammerdb>print db Database Oracle set. |
4.设置压力测试标准程序
这里设置的是OLTP的基准测试TPC-C类型
1 2 | hammerdb>dbset bm TPC-C Benchmark set to TPC-C for Oracle |
设置后可以用以下命令检查配置情况
1 2 | hammerdb>print bm Benchmark set to TPC-C |
5.用print dict命令查看可用配置的数据库变量
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 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.数据库配置参数说明以及修改方式
修改数据库配置参数有两种方式,一是使用hammerdb中的diset命令修改,而是修改参数文件。使用命令行修改参数只是基于当前会话,在其他会话中修改的参数将不生效,如需将参数修改为默认值,可以直接修改配置文件。
使用命令修改-connection参数说明与修改
- system_user参数用于指定数据库连接用户
1 2 | hammerdb>diset connection system_user test Changed connection:system_user from system to test for Oracle |
- system_password参数用户指定数据库连接密码
1 2 | hammerdb>diset connection system_password test Changed connection:system_password from manager to test for Oracle |
使用命令修改-tpcc参数说明与修改
- count_ware 参数用于指定仓库个数,用于控制测试数据量,默认为1,导入9张表的数据大小大概70多M,当numWarehouse为10时,数据大小可以近似当作1GB数据
1 2 | hammerdb>diset tpcc count_ware 10 Changed tpcc:count_ware from 1 to 10 for Oracle |
- num_vu 参数用于指定加载warehouse的用户数,这里越多越好,也要和CPU 数匹配,一般是CPU数量的1 -1.5倍
1 2 | hammerdb>diset tpcc num_vu 4 Changed tpcc:num_vu from 1 to 4 for Oracle |
- tpcc_user 参数用于指定tpcc测试数据加载schema
1 2 | hammerdb>diset tpcc tpcc_user hammerdbtest Changed tpcc:tpcc_user from test to hammerdbtest for Oracle |
- tpcc_pass 参数用于指定TPC-C测试数据加载schema对应密码
1 2 | hammerdb>diset tpcc tpcc_pass test Changed tpcc:tpcc_pass from tpcc to test for Oracle |
- tpcc_def_tab(TPC-C Default Tablespace)参数用于指定TPC-C基准测试数据加载的默认表空间
1 2 | 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)参数用于指定TPC-C基准测试中订单数据表的指定表空间
可以与其他数据表相同的数据空间,也可以额外划分新表空间用于存储订单表的数据
1 2 | 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)参数用于指定TPC-C基准测试所使用的临时表空间
1 2 | hammerdb>diset tpcc tpcc_def_temp TBS_BIGTABLE Changed tpcc:tpcc_def_temp from temp to TBS_BIGTABLE for Oracle |
修改配置文件
配置文件在安装目录下./config/oracle.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | [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> |
SQL Server
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | cd /usr/local/HammerDB-4.0/ ./hammerdbcli librarycheck dbset db mssqls dbset bm tpc-c diset connection mssqls_server 172.72.9.200 diset connection mssqls_linux_server 172.72.9.200 diset connection mssqls_tcp true diset connection mssqls_pass lhr diset tpcc mssqls_dbase lhrdb print dict |
swingbench命令行
安装
下载地址:
http://www.dominicgiles.com/downloads.html