我们所处行业的核心应用业务,当前还是传统的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. Springboot 整合 xxl-job

    前言 很久很久以前写过好几篇关于定时任务的使用系列的文章: 这一篇是最简单的,就是单纯跑跑定时任务,那你看这篇就行,没必要用xxljob(因为xxljob要跑服务端,然后自己服务作为客户端接入): 文 ...

  2. Elasticsearch(4)--- 基本概念(Index、Type、Document、集群、节点、分片及副本、倒排索引)

    这篇博客讲到基本概念包括: Index.Type.Document.集群,节点,分片及副本,倒排索引. 一.Index.Type.Document 1.Index index:索引是文档(Docume ...

  3. 【原创】thinkbook16+2023锐龙7840h版本笔记本C口充电需要重新插拔才起作用的问题自己利用延时继电器解决,笔记本两次插拔才能充电

    这个笔记本左边有两个c口都可以充电有一个是usb4,pd100w. 现在出现一个问题需要插两次才能申请到pd协议.看了主板,也没有办法直接给他dc20v的电压输入.怀念以前的笔记本都是dc供电,简单耐 ...

  4. Spring,Spring Ioc,Bean详解

    Spring框架 Spring框架是Java应用最广的框架,其的成功来自于理念,并非是技术,其中几个理念非常重要,例如IoC(控制反转),AOP(面向切面编程) Spring的优势 低耦合/低侵入(解 ...

  5. PayDay Intermediate

    nmap + dirsearch 发现web站点 扫目录 ┌──(root㉿kali)-[/home/ftpuserr] └─# nmap -p- -A 192.168.167.39 Starting ...

  6. Android平台从上到下,无需ROOT/解锁/刷机,应用级拦截框架的最后一环,SVC系统调用拦截。

    Android平台从上到下,无需ROOT/解锁/刷机,应用级拦截框架的最后一环 -- SVC系统调用拦截. ☞ Github: https://www.github.com/iofomo/abyss ...

  7. Java01-基础入门(准备工作)

    从零开始开发Java的第一个程序: [ 任务列表 ] 最新的程序开发手段 Java是什么 Java开发工具 JDK的卸载,下载及安装 JDK配置环境变量 命令行运行第一个Java程序 Java开发工具 ...

  8. [记录点滴]Ionic编译过程的研究

    [记录点滴]Ionic编译过程的研究 0x00 摘要 之前研究Ionic编译过程的笔记,发出来做个记录.当时是因为有些图片没有拷贝到应用中,所以需要调试编译过程. 0x01 入口 编译的入口在plat ...

  9. [记录点滴] 一个Python中实现flatten的方法

    之前如果想使用flatten,一般借助于numpy.ndarray.flatten. 但是 flatten只能适用于numpy对象,即array或者mat,普通的list列表不适用. 最近找到一个轻便 ...

  10. CSP 初赛要点复习

    位运算 逻辑与.按位与之类的东西是不同的!"逻辑"的是判断两个数都不为 \(0\),"按位"的是判断两个数的每一个二进制位与的结果,是不同的.其他运算也类似. ...