我们所处行业的核心应用业务,当前还是传统的OLTP业务,应用系统使用 java 开发,并且不建议使用存储过程,使用 benchmarksql 压测数据库最公平,既可以测试数据库性能,也可以测试JDBC驱动。

一、tpmC性能测试要点

1、流量指标(Throughput,简称tpmC)

按照TPC组织的定义,流量指标描述了系统在执行支付操作、订单状态查询、发货和库存状态查询这4种交易的同时,每分钟可以处理多少个新订单交易。所有交易的响应时间必须满足TPC-C测试规范的要求,且各种交易数量所占的比例也应该满足TPC-C测试规范的要求。在这种情况下,流量指标值越大说明系统的联机事务处理能力越高。

2、测试时长

benchmarksql跑的时间越长,数据库也会越大,一般来说当数据库大小超过数据库共享缓存的3倍后,性能就会开始明显的下降。

3、cpu负荷

可使用htop监控数据库服务端和tpcc客户端CPU利用情况,最佳性能测试情况下,各个业务CPU的占用率应尽可能高。如果有CPU占用率没有达标,可能是绑核方式不对或其他问题,可采用 cpu 绑定技术。

4、warehouses

指定仓库数,仓库数决定性能测试的成绩。如果期望有较高测试结果,仓库数就不能太低。生产环境机器测试,建议 5000 仓库起步(5000仓与我们的业务场景不太相符,建议100仓)。

5、terminals

指定性能压测时的并发数,建议并发数不要高于仓库数 * 10。否则,会有不必要的锁等待。在生产环境中,该并发数设置到 1000 就很高了。一般环境测试建议从 100 开始。

6、runMins

指定性能测试持续的时间,时间越久,越能考验数据库的性能和稳定性。建议不要少于 10 分钟,生产环境中机器建议不少于 1 小时。

二、测试步骤

1、benchmarksql 下载

wget https://gitee.com/MapLover/benchmarksql5.1/repository/archive/master.zip

2、Requirements

■ 配置 ant java

yum install -y ant java

如果无法安装 ant,安装java后下载ant

https://ant.apache.ac.cn/bindownload.cgi 确认 ant 的最新版本

https://mirrors.nju.edu.cn/apache/ant/binaries/apache-ant-1.10.14-bin.tar.gz

仅 bin 和 lib 目录是运行 Ant 所必需的,安装 Ant,请选择一个目录并将发行版文件复制到该目录,此目录将被称为 ANT_HOME

运行 Ant 之前,需进行一些额外的设置,除非安装的是 RPM 版本

1、将 bin 目录添加到路径中

2、将 ANT_HOME 环境变量设置为安装 Ant 的目录

3、可选地,设置 JAVA_HOME 环境变量

ln -s /u01/nfs/soft/apache-ant-1.10.14 /opt/ant

vim /etc/profile

export JAVA_HOME=/u01/app/oracle/product/19.3.0/db_1/jdk

export ANT_HOME=/opt/ant

export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH

■ 配置 python

采集cpu、disk、network等相关性能信息时需要调用python程序,支持的python版本是2,如果采用3版本会报错:

2024-07-31 15:15:52: osCollectorScript=./misc/os_collector_linux.py
2024-07-31 15:15:52: osCollectorInterval=1
2024-07-31 15:15:52: osCollectorSSHAddr=null
2024-07-31 15:15:52: osCollectorDevices=net_ens39 blk_sda
2024-07-31 15:15:52: Term-00,
File "<stdin>", line 63
print ",".join([str(x) for x in sysInfo])
^
SyntaxError: invalid syntax
2024-07-31 15:15:52: OSCollector, unexpected EOF while reading from external helper process

因为信息采集是在数据库端执行的,下载

https://mirrors.nju.edu.cn/python/2.7.18/Python-2.7.18.tgz

解压缩、配置:

./configure --enable-optimizations --prefix=/usr/local/python2.7/

修改配置文件:

vim Modules/Setup

_ssl _ssl.c

-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl

-L$(SSL)/lib -lssl -lcrypto

默认这块是注释的,放开注释即开。这块功能是开启SSL模块,不然会出现安装完毕后,提示找不到ssl模块的错误。

编译、安装:

make -j8 && make install

建新软链:

mv /usr/bin/python /usr/bin/python.bak

ln -s /usr/local/python2.7/bin/python2.7 /usr/bin/python

python -V

Compile the BenchmarkSQL source code

总算可以编译 BenchmarkSQL 了:

[root@BC86 benchmarksql5.1-master]# ant
Buildfile: /u01/nfs/soft/benchmark/benchmarksql5.1-master/build.xml
init:
[mkdir] Created dir: /u01/nfs/soft/benchmark/benchmarksql5.1-master/build
compile:
[javac] Compiling 11 source files to /u01/nfs/soft/benchmark/benchmarksql5.1-master/build
dist:
[jar] Building jar: /u01/nfs/soft/benchmark/benchmarksql5.1-master/dist/BenchmarkSQL-5.1.jar
BUILD SUCCESSFUL

---如果遇见如下错误,需配置 JAVA_HOME:

BUILD FAILED
/u01/nfs/soft/benchmarksql5.1-master/build.xml:24: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-11.oe2203.aarch64/jre"

Create the benchmark configuration file

创建测试的配置文件:

cd run

cp props.pg my_postgres.properties

vim my_postgres.properties
---
db=postgres
driver=org.postgresql.Driver
conn=jdbc:postgresql://192.168.10.108:5432/postgres
user=postgres
password=passwdsefsdfsdf //每个W约100MB,则100个约10G
warehouses=5
loadWorkers=5 //终端数,即并发客户端数量,通常设置为CPU线程总数的2~6倍
terminals=5 //To run specified transactions per terminal- runMins must equal zero
//每个终端运行的固定事务数量,如该值为10, 则每个terminal运行10个事务,如果有32个终端,那整体运行320个事务后,测试结束。该参数配置为非0值时,下面的runMins参数必须设置为0。
runTxnsPerTerminal=0 //To run for specified minutes- runTxnsPerTerminal must equal zero
//runMins表示要压测的时间长度,单位为分钟。该值为非0值时,runTxnsPerTerminal参数必须设置为0。这两个参数不能同时设置为正整数,如果设置其中一个,另一个必须为0,主要区别是runMins定义时间长度来控制测试时间;runTxnsPerTerminal定义事务总数来控制时间。
runMins=5 //Number of total transactions per minute
limitTxnsPerMin=100000000 //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=pg_result_%tY-%tm-%td_%tH%tM%tS
osCollectorScript=./misc/os_collector_linux.py
osCollectorInterval=1
//osCollectorSSHAddr=root@192.168.81.23
osCollectorDevices=net_ens39 blk_sda

---如下官方文档供参考:

Note that the provided example configuration is meant to test the functionality of your setupr. That benchmarksql can connect to the database and execute transactions. [■■■That configuration is NOT a benchmark run.■■■] To make it into one you need to have a configuration that matches your database server size and workload. Leave the sizing for now and perform a first functional test.

The BenchmarkSQL database has an initial size of approximately 100-100MB per configured warehouse. A typical setup would be a database of 2-5 times the physical RAM of the server.

Likewise the number of concurrent database connections (config parameter terminals) should be something about 2-6 times the number of CPU threads.

Last but not least benchmark runs are normally done for hours, if not days. This is because on the database sizes above it will take that long to reach a steady state and make sure that all performance relevant functionality of the database, like checkpointing and vacuuming, is included in the measurement.

So you can see that with a modern server, that has 32-256 CPU threads and 64-512GBi, of RAM we are talking about thousands of warehouses and hundreds of concurrent database connections.

Build the schema and initial database load

创建模式和初始化数据库:

./runDatabaseBuild.sh my_postgres.properties > load_`date '+%Y-%m-%d-%H%M'`.log 2>&1 &
tail -100f load_*.log

如果 oracle 数据库,执行测试前可先生成一个awr快照

exec dbms_workload_repository.create_snapshot();

Run the configured benchmark

执行测试:

./runBenchmark.sh my_postgres.properties > run_`date '+%Y-%m-%d-%H%M'`.log 2>&1 &
tail -100f run_*.log

The benchmark should run for the number of configured concurrent connections (terminals) and the duration or number of transactions.

如果 oracle 执行测试后,再生成一个awr快照,然后获取测试期间的 awr 报告

exec dbms_workload_repository.create_snapshot();

Scale the benchmark configuration.

Change the my_postgres.properties file to the correct scaling (number of warehouses and concurrent connections/terminals). Switch from using a transaction count to time based:

runTxnsPerTerminal=0

runMins=5

Rebuild the database

重新创建测试库:

./runDatabaseDestroy.sh my_postgres.properties

./runDatabaseBuild.sh my_postgres.properties

为了方便多次测试,减少导入数据的时间,可以通过停止数据库,将整个数据目录执行一次拷贝对数据库进行备份。

Result report

生成数据库测试报告:

./generateReport.sh pg_result_2024-07-31_195621

生成报告时,如果提示"无法打开链结到X11显示",则需开启 vncserver 服务

配置 R

wget https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/base/R-4/R-4.4.1.tar.gz
./configure
make -j18
make install

---configure 如果错误较多,缺啥装啥:

yum install -y gcc gcc-c++ gcc-gfortran readline-devel

yum install -y gcc-gfortran

如报错:configure: error: --with-x=yes (default) and X11 headers/libs are not available

yum install -y libX11-devel libXt-devel

yum install -y zlib-devel bzip2-devel

如报错:liblzma library and headers are required

yum install -y xz-devel

yum install -y pcre2-devel

如报错:configure: error: libcurl >= 7.28.0 library and headers are required with support for https

yum install -y libcurl-devel

■ 不支持 png 的解决办法

yum install -y libpng-devel libtiff-devel libjpeg-turbo-devel pango-devel

再次 configure 即可!

正确结果应该是 png TRUE, bitmapType 是 cairo,如下:

R
capabilities()
> capabilities()
jpeg png tiff tcltk X11 aqua
TRUE TRUE TRUE FALSE TRUE FALSE
http/ftp sockets libxml fifo cledit iconv
TRUE TRUE FALSE TRUE TRUE TRUE
NLS Rprof profmem cairo ICU long.double
TRUE TRUE FALSE FALSE FALSE TRUE
libcurl
TRUE
getOption("bitmapType")
[1] "cairo"

■ 以下是使用 Cairo 配置支持 png【可选】

wget https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/contrib/png_0.1-8.tar.gz

wget https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/contrib/Cairo_1.6-2.tar.gz

install.packages("Cairo_1.6-2.tar.gz",repos=NULL)

报错:configure: error: Cannot find cairo.h!

yum install -y cairo* libxt*

install.packages("png_0.1-8.tar.gz",repos=NULL)
library(Cairo)
library(png)
Cairo.capabilities()
---
png jpeg tiff pdf svg ps x11 win
TRUE TRUE TRUE TRUE TRUE TRUE TRUE FALSE
raster freetype harfbuzz
TRUE TRUE FALSE

使用benchmarksql测试数据库处理能力的更多相关文章

  1. 使用benchmarkSQL测试数据库的TPCC

    压力测试是指在MySQL上线前,需要进行大量的压力测试,从而达到交付的标准.压力测试不仅可以测试MySQL服务的稳定性,还可以测试出MySQL和系统的瓶颈. TPCC测试:Transaction Pr ...

  2. 使用BenchmarkSQL测试PostgreSQL

    BenchmarkSQL是一款经典的开源数据库测试工具,内嵌了TPCC测试脚本,可以对EnterpriseDB.PostgreSQL.MySQL.Oracle以及SQL Server等数据库直接进行测 ...

  3. windows 测试数据库的连接状况-udl方法

    udl是windows系统上,用于测试数据库的连接状态的测试软件. 使用方法: 1.建立一个空白文本 2.将文件的后缀名更改为*.udl 即可     文件内容一定为空 3.选择windows的“提供 ...

  4. 共享参数ContentProvider 类与数据库绑定,如何通过共享参数测试类,测试数据库的增删改查功能

    Intent可以传一个对象 当两个界面之间跳转时,需要传递一个对象过去,是通过使用Bundle类,并且实体类需要serializable实现序列化,传递方法如下: 定义一个静态常量作为key值 pub ...

  5. 第三篇--Jmeter测试数据库Mysql

    Jmeter模拟100用户访问Mysql数据库 1.将Mysql数据库的驱动[mysql-connector-java-5.1.15-bin.jar]放到jmeter的lib目录下,新建线程组100[ ...

  6. Windows MySQL测试数据库employees的导入

    一: 首先下载employees测试数据库 https://launchpad.net/test-db/ 二:用文本编辑器打开其中的employees.sql文件,将第38行的set storage_ ...

  7. python+Django+test 测试数据库生成报错

    前提: 使用Django自带的test进行单元测试. 问题描述: 运行:python manage.py test,报错,出现数据库乱码的现象,报错如下: Creating test database ...

  8. 装服务器,测试数据库,简单的maven命令

    [说明]今天总体回顾一下:大概是早上装服务器,下午测试数据库,晚上了解简单的maven命令 一:今日完成 1)在远程服务器的tomcat 设置好管理员的登录账号 2)登录tomcat 的项目管理 查看 ...

  9. 导入MySQL测试数据库employee报错

    导入MySQL测试数据库employee 报错 下载地址:https://launchpad.net/test-db/ 上传解压: [root@001 ~]# tar xf employees_db- ...

  10. 快速生成500W测试数据库

    快速生成500W测试数据库: 创建测试表: DROP TABLE IF EXISTS `user`; CREATE TABLE `user` ( `id` int(10) NOT NULL AUTO_ ...

随机推荐

  1. Spring-RetryTemplate-RestTemplate的使用

    ------------------------------------------------------------------------------------ 1.基本概念 1.1应用场景 ...

  2. 如何快速的开发一个完整的iOS直播app(礼物篇)

    搭建礼物列表 使用modal,设置modal样式为custom,就能做到从小往上显示礼物列表,并且能看见前面的直播界面 礼物模型设计 一开始创建3个礼物模型,保存到数组,传入给礼物View展示,本来礼 ...

  3. Golang-接口7

    http://c.biancheng.net/golang/interface/ Go语言接口声明(定义) Go语言不是一种 "传统" 的面向对象编程语言:它里面没有类和继承的概念 ...

  4. 项目PMP之十一项目风险管理

    项目PMP之十一--项目风险管理   一.定义:削弱负面风险,增强正面风险,将风险敞口保持在可接受的范围,扩大项目实现的概率 非事件类风险:变异性风险,已规划的不确定性(通过蒙特卡洛分析,缩小结果区间 ...

  5. fopen在VS中不安全的问题

    问题 fopen函数哎VS中使用,报错: error C4996: 'fopen': This function or variable may be unsafe. Consider using f ...

  6. uni-app之页面跳转(点击按钮进行页面跳转)

    001==>点击按钮进行页面跳转 <view class="" @tap="gotoLunBo"> 去轮播页 </view> // ...

  7. CompletableFuture 超时功能有大坑!使用不当直接生产事故!

    CompletableFuture 超时功能有大坑!使用不当直接生产事故! 本文未经允许禁止转载! 上一篇文章<如何实现超时功能(以CompletableFuture为例)>中我们讨论了 ...

  8. mac支持rar解压缩

    一.下载 下载macOS版本:RAR 5.71 for macOS (64 bit) 二.安装 1.双击解压刚才下载的rarosx-5.7.1.tar,使用终端进入刚才解压的文件夹目录下cd /Use ...

  9. HT-014 Div3 扫雷 题解 [ 绿 ] [ 二维差分 ]

    分析 观察到是曼哈顿距离 \(\le r\) 的范围可以扫到,联想到如下图形: 左边是 \(r=1\) 可以扫到的范围,右边是 \(r=2\) 可以扫到的范围. 于是,我们只要对这样的图形在 \(10 ...

  10. K230学习记录

    K230学习记录 参考自: # 立创·庐山派-K230-CanMV开发板资料与相关扩展板软硬件资料官网全部开源 # 开发板官网:www.lckfb.com # 技术支持常驻论坛,任何技术问题欢迎随时交 ...