携手创作,一起生长!这是我参加「日新方案 8 月更文挑战」的第13天,点击查看活动概况


哈喽!大家好,我是【IT邦德】,江湖人称jeames007,10年DBA工作经验
中国DBA联盟(ACDU)成员,目前从事DBA及程序编程
擅长Oracle、MySQL、PG 运维开发,备份康复,装置迁移,功能优化、故障应急处理。
❤️❤️❤️感谢各位大可爱小可爱!❤️❤️❤️

前言

HammerDB 是一个开源的数据库负载测验和基准测验东西,一起支撑 Windows 和 Linux 渠道。

⛳️ 1. HammerDB简介

HammerDB 是一个开源的数据库负载测验和基准测验东西,一起支撑 Windows 和 Linux 渠道,可以针对 Oracle 、SQL Server、DB2、TimesTen、 MySQL、MariaDB、
PostgreSQL、Postgres Plus Advanced Server、Greenplum、Redis、Amazon Aurora、Redshift 等进行压力测验。
它主要模拟两种不同的测验模型:TPC-C 测验模型和 TPC-H 测验模型。相比于规范的 TPC-C 和 TPC-H,HammerDB 运行成本低,操作简单, 是服务器数据库压力测验的很好选择。
• HammerDB 通过模拟 批发商的货物管理环境,完结了 TPC-C 测验模型,即在线业务处理(OLTP)的基准测验模型。测验成果由 TPC-C 吞吐率衡量,规范测验模型中
的单位是 tpmC(在 在 B HammerDB 是 中,测验成果的单位是 tpm,不是 tpmC。m tpm 表示每分钟的业务买卖数量,tpmC 是 TPC-C 的业务买卖单位)。
• HammerDB 通过模拟供应商和采购商之间的买卖行为,完结了 TPC-H 测验模型,即在线剖析处理(OLAP)的基准测验模型。测验成果由 TPCH Power 来衡量,该值
与数据量和买卖平均时刻有关,表示一小时内能够完结的杂乱买卖的数量。
关于 TPC-C 和 TPC-H 的详细介绍请参考 TPC 官方网站(www.tpc.org/)

MySQL压测神器HammerDB的布置及运用

⛳️ 2. 容器布置

✨ 2.1 镜像下载

docker pull techerwang/oracle:centos76

✨ 2.2 创建容器

docker rm -f jemhammerdb
docker run -d --name jemhammerdb -h jemhammerdb 
-p 34389:3389 -p 42222:22 
techerwang/oracle:centos76 init
docker exec -it jemhammerdb bash

✨ 2.3 Linux 下装置

wget https://github.com/TPC-Council/HammerDB/releases/download/v4.0/HammerDB-4.0-Linux.tar.gz
[root@jeames ~]# tar -zxvf HammerDB-4.0-Linux.tar.gz -C /usr/local/
[root@jeames ~]# cd /usr/local/HammerDB-4.0
[root@jeames HammerDB-4.0]# ./hammerdbcli
HammerDB CLI v4.0
Copyright (C) 2003-2020 Steve Shaw
Type "help" for a list of commands
The xml is well-formed, applying configuration
hammerdb>
hammerdb>help
HammerDB v4.0 CLI Help Index
Type "help command" for more details on specific commands below
        buildschema
        clearscript
        customscript
        datagenrun
        dbset
        dgset
        diset 
        distributescript
        librarycheck
        loadscript
        print 
        quit
        runtimer
        switchmode
        vucomplete
        vucreate
        vudestroy
        vurun
        vuset
        vustatus 
        waittocomplete

✨ 2.4 相关校验

hammerdb>librarycheck
Checking database library for Oracle
Error: failed to load Oratcl - can't read "env(ORACLE_HOME)": no such variable
Ensure that Oracle client libraries are installed and the location in the LD_LIBRARY_PATH environment variable
Checking database library for MSSQLServer
Error: failed to load tdbc::odbc - couldn't load file "libiodbc.so": libiodbc.so: cannot open shared object file: No such file or directory
Ensure that MSSQLServer client libraries are installed and the location in the LD_LIBRARY_PATH environment variable
Checking database library for Db2
Error: failed to load db2tcl - couldn't load file "/usr/local/HammerDB-4.0/lib/db2tcl2.0.0/libdb2tcl.so.0.0.1": libdb2.so.1: cannot open shared object file: No such file or directory
Ensure that Db2 client libraries are installed and the location in the LD_LIBRARY_PATH environment variable
Checking database library for MySQL
Success ... loaded library mysqltcl for MySQL
Checking database library for PostgreSQL
Error: failed to load Pgtcl - couldn't load file "/usr/local/HammerDB-4.0/lib/pgtcl2.1.1/libpgtcl2.1.1.so": libpq.so.5: cannot open shared object file: No such file or directory
Ensure that PostgreSQL client libraries are installed and the location in the LD_LIBRARY_PATH environment variable

⛳️3 . HammerDB压测MySQL

1.如果是Windows直接点击hammerdb.bat,如果是Linux需要调用图形化界面
2.windows渠道压测,非常耗CPU
## 调用图形化界面
export DISPLAY=192.168.1.1:0.0
echo $DISPLAY
[root@jeames ~]# cd /usr/local/HammerDB-4.0
[root@jemhammerdb HammerDB-4.0]# ./hammerdb

MySQL压测神器HammerDB的布置及运用
MySQL压测神器HammerDB的布置及运用
MySQL压测神器HammerDB的布置及运用
注:生产环境压测,建议库房数不少于100
MySQL压测神器HammerDB的布置及运用

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mes_db             |
| mysql              |
| performance_schema |
| sbtest             |
| sys                |
| tpcc               |
+--------------------+
7 rows in set (0.00 sec)
mysql> use tpcc
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+----------------+
| Tables_in_tpcc |
+----------------+
| customer       |
| district       |
| history        |
| item           |
| new_order      |
| order_line     |
| orders         |
| stock          |
| warehouse      |
+----------------+
9 rows in set (0.00 sec)

MySQL压测神器HammerDB的布置及运用

select a.SCHEMA_NAME, a.DEFAULT_CHARACTER_SET_NAME,a.DEFAULT_COLLATION_NAME,
sum(table_rows) as '记录数',
sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',
sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)',
sum(truncate((data_length+index_length)/1024/1024, 2)) as '总大小(MB)',
sum(truncate(max_data_length/1024/1024, 2)) as '最大值(MB)',
sum(truncate(data_free/1024/1024, 2)) as '闲暇空间(MB)'
from INFORMATION_SCHEMA.SCHEMATA a
left outer join information_schema.tables b
on a.SCHEMA_NAME=b.TABLE_SCHEMA
group by a.SCHEMA_NAME, a.DEFAULT_CHARACTER_SET_NAME,a.DEFAULT_COLLATION_NAME
order by sum(data_length) desc, sum(index_length) desc;

MySQL压测神器HammerDB的布置及运用
MySQL压测神器HammerDB的布置及运用
MySQL压测神器HammerDB的布置及运用
MySQL压测神器HammerDB的布置及运用
mysql> show processlist;
MySQL压测神器HammerDB的布置及运用
MySQL压测神器HammerDB的布置及运用