我们所处行业的核心应用业务,当前还是传统的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. ReactNative开发总结

    https://www.jianshu.com/u/b09c3959ab3b ReactNative之项目结构介绍 一.初始化ReactNative工程 自动创建iOS和安卓工程,和对应的JS文件,i ...

  2. Linux常见问题合集

    Linux基本指令 连接SSH ssh uesrname@ip 例如:ssh root@192.168.43.217 Linux 创建多级目录命令: mkdir -p 示例:mkdir -p proj ...

  3. w3cschool-Go 教程

    https://www.w3cschool.cn/go/ Go 是一个开源的编程语言,它能让构造简单.可靠且高效的软件变得容易. Go是从2007年末由Robert Griesemer, Rob Pi ...

  4. 未能加载文件或程序集"Symtem.Data.SQLite.dll"或它的某一个依赖项

    我在window service 2016 等更高版本的服务器上遇见过,普通window系统未预见.可尝试安装 VC ++ 2010 我下载安装  之后就好了.

  5. Python语法使用

    由于之前学习过js,代码基本上是相同的,先看看和js有那些区别 项目 python javascript 适用版本 python3 es6,即ECMAScript 2015 运行环境 #!/usr/b ...

  6. 同态加密技术及其在FL/MPC中的应用-洪澄

    转载:链接 Pailler是具有一次乘法同态的. Pailler 我好像一直叫的都是 "拍利尔" . 关于定理的证明,参考:Pailler 同态性 安全性 语义安全 DCR问题 简 ...

  7. WordPress产品导入后内容出现乱码,以及附属一些别的功能

    效果图如下 该插件附带了一个可以把产品描述里面的超链接给去掉,以及有的产品图片点击会在地址栏上面显示图片的路径,在该插件可以进行关闭,并且替换成一个模态窗,还有对产品邮费展示进行了处理,到金额到达包邮 ...

  8. Python · Jax | 在 python 3.8 上安装 jax,运行 offline RL 的 IQL

    致谢师兄的 jax 环境,完全按照师兄的 conda_env.yml 配置的 (如何导出其他环境的 conda_env.yml:Conda | 如何(在新服务器上)复制一份旧服务器的 conda 环境 ...

  9. mysql事务中使用临时表

    最近在使用存储过程完成晚上数据的定时汇总功能,其中需要在存储过程中启用事务,但是发现使用了create table语句后事务会自动提交这个语句前的语句,即便是这个语句后发生了错误进行了回滚. 测试语句 ...

  10. uniapp实现头部、底部固定,中间滚动的布局

    参考地址:https://blog.csdn.net/lll_liuhui/article/details/87923041 <template> <view class=" ...