当前位置: 首页 > news >正文

【案例分享】BenchmarkSQL 5.0 压测 openGauss 5.0.0

一、前言

本次BenchmarkSQL 压测openGauss仅作为学习使用压测工具测试tpcc为目的,并不代表数据库性能如本次压测所得数据。实际生产性能压测,还需结合服务器软硬件配置、数据库性能参数调优、BenchmarkSQL 配置文件参数相结合,是一个复杂的过程。

1.1 BenchmarkSQL 工具介绍

BenchmarkSQL 是一款经典的开源数据库测试工具,其内含了TPC-C测试脚本,可同时支持 Oracle、MySQL、PostGreSQL、SQL Server以及一些国产数据库的基准测试,应用其对数据库进行 TPC-C 标准测试,可模拟多种事务处理:如新订单、支付操作、订单状态查询、发货、库存状态查询等,从而获得TpmC 值。截止到2023年8月,最新的BenchmarkSQL 版本是5.0。

1.2 数据库信息介绍

本次压测所使用的openGauss数据库是一套两节点主备集群,数据库版本为5.0.0。在进行压测前假设已创建了测试数据库和用户,设置了用户权限,并为数据库配置了白名单,创建数据库、用户、设置权限及设置白名单基本操作如下。

-- 数据库服务器,omm用户操作
-- 连接数据库
[omm@opengauss-db2 ~]$ gsql -d gaussdb -p 26000

-- 创建数据库用户
gaussdb=# CREATE USER openuser WITH SYSADMIN password "Openuser@123";

-- 分配用户权限
gaussdb=# GRANT ALL PRIVILEGES TO openuser;

-- 设置白名单,运行程序从192.168.73.21 访问数据库
[omm@opengauss-db2 ~]$ gs_guc reload -N all -I all -h "host gaussdb openuser 192.168.73.21/32 sha256"

二、环境信息

2.1 服务器信息

主机名称 主机IP 配置描述 操作系统 用途描述 opengauss-db1 10.110.3.156 4C/8G CentOS Linux release 7.9.2009 (Core) DB服务器 opensource-db 192.168.73.21 2c/4G CentOS Linux release 7.9.2009 (Core) BenchmarkSQL服务器

2.2 软件信息

软件名称 版本信息 信息描述 openGauss 5.0.0 openGauss数据库版本 BenchmarkSQL 5.0 BenchmarkSQL软件版本 JDK OpenJDK 11 JDK版本,编译ant python 3.10.12 BenchmarkSQL压测收集OS信息脚本依赖python ant 1.9.4 编译构建BenchmarkSQL的Java源代码 R语言 3.6.3 用于生成BenchmarkSQL压测后的png图片等信息

三、环境准备

3.1 安装软件依赖包

部署BenchmarkSQL需要系统安装一些依赖包,如果服务器可联网,可通过yum直接安装,如果无法联网,可在服务器上配置本地YUM源,通过本地YUM安装软件依赖包。

-- BenchmarkSQL 服务器,root用户操作
-- yum 安装软件依赖包
[root@opensource-db ~]# yum install gcc glibc-headers gcc-c++ gcc-gfortran readline-devel libXt-devel pcre-devel libcurl libcurl-devel \
java-11-openjdk ant ncurses ncurses-devel autoconf automake zlib zlib-devel bzip2 bzip2-devel xz-devel -y

-- 检查是否已安装
rpm -qa --queryformat "%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n" | grep -E "gcc|glibc-headers|gcc-c++|gcc-gfortran|readline-devel|libXt-devel|pcre-devel|libcurl libcurl-devel|java-11-openjdk|ant|ncurses|ncurses-devel|autoconf|automake|zlib|zlib-devel|bzip2|bzip2-devel|xz-devel"

3.2 创建用户

BenchmarkSQL选择部署在非root用户omm用户下。

[root@opensource-db ~]# /usr/sbin/groupadd -g 1000 dbgrp
[root@opensource-db ~]# /usr/sbin/useradd -u 1000 -g dbgrp omm
[root@opensource-db ~]# echo "omm123" | passwd --stdin omm

3.3 安装部署BenchmarkSQL

3.3.1 下载BenchmarkSQL

登录https://sourceforge.net/projects/benchmarksql/files/网站下载最新版BenchmarkSQL 5.0,将下载的benchmarksql-5.0.zip上传至服务器omm用户/home/omm目录下并解压。

1424a7c08b2ddfac7cec5649ea58fac1.jpeg

3.3.2 解压BenchmarkSQL

-- BenchmarkSQL 服务器,omm用户操作
[root@opensource-db ~]# su - omm
[omm@opensource-db ~]$ unzip benchmarksql-5.0.zip
[omm@opensource-db ~]$ tree -f benchmarksql-5.0
benchmarksql-5.0
├── benchmarksql-5.0/build
│   ├── benchmarksql-5.0/build/ExecJDBC.class
│   ├── benchmarksql-5.0/build/jTPCC.class
│   ├── benchmarksql-5.0/build/jTPCCConfig.class
│   ├── benchmarksql-5.0/build/jTPCCConnection.class
│   ├── benchmarksql-5.0/build/jTPCCRandom.class
│   ├── benchmarksql-5.0/build/jTPCCTData$1.class
│   ├── benchmarksql-5.0/build/jTPCCTData.class
│   ├── benchmarksql-5.0/build/jTPCCTData$DeliveryBGData.class
│   ├── benchmarksql-5.0/build/jTPCCTData$DeliveryData.class
│   ├── benchmarksql-5.0/build/jTPCCTData$NewOrderData.class
│   ├── benchmarksql-5.0/build/jTPCCTData$OrderStatusData.class
│   ├── benchmarksql-5.0/build/jTPCCTData$PaymentData.class
│   ├── benchmarksql-5.0/build/jTPCCTData$StockLevelData.class
│   ├── benchmarksql-5.0/build/jTPCCTerminal.class
│   ├── benchmarksql-5.0/build/jTPCCUtil.class
│   ├── benchmarksql-5.0/build/LoadData.class
│   ├── benchmarksql-5.0/build/LoadDataWorker.class
│   ├── benchmarksql-5.0/build/OSCollector.class
│   └── benchmarksql-5.0/build/OSCollector$CollectData.class
├── benchmarksql-5.0/build.xml
├── benchmarksql-5.0/dist
│   └── benchmarksql-5.0/dist/BenchmarkSQL-5.0.jar
├── benchmarksql-5.0/doc
│   └── benchmarksql-5.0/doc/src
│   └── benchmarksql-5.0/doc/src/TimedDriver.odt
├── benchmarksql-5.0/HOW-TO-RUN.txt
├── benchmarksql-5.0/lib
│   ├── benchmarksql-5.0/lib/apache-log4j-extras-1.1.jar
│   ├── benchmarksql-5.0/lib/firebird
│   │   ├── benchmarksql-5.0/lib/firebird/connector-api-1.5.jar
│   │   └── benchmarksql-5.0/lib/firebird/jaybird-2.2.9.jar
│   ├── benchmarksql-5.0/lib/log4j-1.2.17.jar
│   ├── benchmarksql-5.0/lib/oracle
│   │   └── benchmarksql-5.0/lib/oracle/README.txt
│   └── benchmarksql-5.0/lib/postgres
│   └── benchmarksql-5.0/lib/postgres/postgresql-9.3-1102.jdbc41.jar
├── benchmarksql-5.0/README.md
├── benchmarksql-5.0/run
│   ├── benchmarksql-5.0/run/funcs.sh
│   ├── benchmarksql-5.0/run/generateGraphs.sh
│   ├── benchmarksql-5.0/run/generateReport.sh
│   ├── benchmarksql-5.0/run/log4j.properties
│   ├── benchmarksql-5.0/run/misc
│   │   ├── benchmarksql-5.0/run/misc/blk_device_iops.R
│   │   ├── benchmarksql-5.0/run/misc/blk_device_kbps.R
│   │   ├── benchmarksql-5.0/run/misc/cpu_utilization.R
│   │   ├── benchmarksql-5.0/run/misc/dirty_buffers.R
│   │   ├── benchmarksql-5.0/run/misc/latency.R
│   │   ├── benchmarksql-5.0/run/misc/net_device_iops.R
│   │   ├── benchmarksql-5.0/run/misc/net_device_kbps.R
│   │   ├── benchmarksql-5.0/run/misc/os_collector_linux.py
│   │   └── benchmarksql-5.0/run/misc/tpm_nopm.R
│   ├── benchmarksql-5.0/run/props.fb
│   ├── benchmarksql-5.0/run/props.ora
│   ├── benchmarksql-5.0/run/props.pg
│   ├── benchmarksql-5.0/run/runBenchmark.sh
│   ├── benchmarksql-5.0/run/runDatabaseBuild.sh
│   ├── benchmarksql-5.0/run/runDatabaseDestroy.sh
│   ├── benchmarksql-5.0/run/runLoader.sh
│   ├── benchmarksql-5.0/run/runSQL.sh
│   ├── benchmarksql-5.0/run/sql.common
│   │   ├── benchmarksql-5.0/run/sql.common/buildFinish.sql
│   │   ├── benchmarksql-5.0/run/sql.common/foreignKeys.sql
│   │   ├── benchmarksql-5.0/run/sql.common/indexCreates.sql
│   │   ├── benchmarksql-5.0/run/sql.common/indexDrops.sql
│   │   ├── benchmarksql-5.0/run/sql.common/tableCreates.sql
│   │   ├── benchmarksql-5.0/run/sql.common/tableDrops.sql
│   │   └── benchmarksql-5.0/run/sql.common/tableTruncates.sql
│   ├── benchmarksql-5.0/run/sql.firebird
│   │   └── benchmarksql-5.0/run/sql.firebird/extraHistID.sql
│   ├── benchmarksql-5.0/run/sql.oracle
│   │   └── benchmarksql-5.0/run/sql.oracle/extraHistID.sql
│   └── benchmarksql-5.0/run/sql.postgres
│   ├── benchmarksql-5.0/run/sql.postgres/buildFinish.sql
│   ├── benchmarksql-5.0/run/sql.postgres/extraHistID.sql
│   └── benchmarksql-5.0/run/sql.postgres/tableCopies.sql
└── benchmarksql-5.0/src
├── benchmarksql-5.0/src/client
│   ├── benchmarksql-5.0/src/client/jTPCCConfig.java
│   ├── benchmarksql-5.0/src/client/jTPCCConnection.java
│   ├── benchmarksql-5.0/src/client/jTPCC.java
│   ├── benchmarksql-5.0/src/client/jTPCCRandom.java
│   ├── benchmarksql-5.0/src/client/jTPCCTData.java
│   ├── benchmarksql-5.0/src/client/jTPCCTerminal.java
│   └── benchmarksql-5.0/src/client/jTPCCUtil.java
├── benchmarksql-5.0/src/jdbc
│   └── benchmarksql-5.0/src/jdbc/ExecJDBC.java
├── benchmarksql-5.0/src/LoadData
│   ├── benchmarksql-5.0/src/LoadData/LoadData.java
│   └── benchmarksql-5.0/src/LoadData/LoadDataWorker.java
└── benchmarksql-5.0/src/OSCollector
└── benchmarksql-5.0/src/OSCollector/OSCollector.java

19 directories, 74 files

3.3.3 编译BenchmarkSQL

-- BenchmarkSQL 服务器,omm用户操作
[omm@opensource-db benchmarksql-5.0]$ ant
Buildfile: /home/omm/benchmarksql-5.0/build.xml

init:

compile:
[javac] Compiling 11 source files to /home/omm/benchmarksql-5.0/build

dist:
[jar] Building jar: /home/omm/benchmarksql-5.0/dist/BenchmarkSQL-5.0.jar

BUILD SUCCESSFUL
Total time: 7 seconds

3.4 安装R语言

3.4.1 下载R语言软件包

登录https://mirror.bjtu.edu.cn/cran/src/base/R-3/ 网站下载最新版的R-3.6.3软件包,将下载的R语言软件包使用root用户上传至部署BenchmarkSQL服务器。

999b2be9dd6691654c368140a04b89fb.jpeg

3.4.2 解压编译R语言

-- 解压R语言软件包
[root@opensource-db fio]# tar -zxvf R-3.6.3.tar.gz
-- 编译R语言软件包
[root@opensource-db fio]# cd R-3.6.3
[root@opensource-db fio]# ./configure && make && make install
-- 默认R语言安装在/usr/local/bin/R目录下
[root@opensource-db fio]# which R
/usr/local/bin/R

3.5 更新JDBC驱动

3.5.1 下载openGauss JDBC驱动

登录openGauss官网https://opengauss.org/zh/download/,选择当前操作系统对应并和openGauss 5.0.0 数据库版对应的jdbc驱动包,如下所示。

911fe389bf41b4b6339ae40fe9f20ef9.jpeg
将下载的JDBC驱动包openGauss-5.0.0-JDBC.tar.gz使用ftp工具二进制上传至BenchmarkSQL服务器omm用户 /home/omm/benchmarksql-5.0/lib/postgres目录下。

3.5.2 替换postgresql驱动

解压openGauss-5.0.0-JDBC.tar.gz驱动包,并替换postgresql驱动,具体操作如下所示。

-- BenchmarkSQL 服务器,omm用户操作
[omm@opensource-db ~]$ cd /home/omm/benchmarksql-5.0/lib/postgres
[omm@opensource-db postgres]$ tar -zxvf openGauss-5.0.0-JDBC.tar.gz
[omm@opensource-db postgres]$ mkdir bak
[omm@opensource-db postgres]$ mv postgresql-9.3-1102.jdbc41.jar ./bak

3.6 配置props文件

使用BenchmarkSQL压测,需要配置压测所需的props文件,配置方法及文件内容如下

实际生产和性能压测,要根据服务器配置及对应业务调整各参数值。

-- BenchmarkSQL 服务器,omm用户操作
-- 编辑props.openGauss配置文件
[omm@opensource-db ~]$ cat > /home/omm/benchmarksql-5.0/run/props.openGauss<<EOF
db=postgres
driver=org.postgresql.Driver
conn=jdbc:postgresql://10.110.3.156:26000/tpcc?binaryTransfer=false&forcebinary=false
user=openuser
password=Openuser@123
warehouses=20
loadWorkers=6
terminals=50
runTxnsPerTerminal=0
runMins=5
limitTxnsPerMin=0
terminalWarehouseFixed=false
newOrderWeight=45
paymentWeight=43
orderStatusWeight=4
deliveryWeight=4
stockLevelWeight=4
resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
osCollectorScript=./misc/os_collector_linux.py
osCollectorInterval=1
osCollectorSSHAddr=omm@10.110.3.155
osCollectorDevices=net_ens33 blk_sda
EOF

--- props.openGauss 文件内容及其具体含义如下
db=postgres // 指定了用于压测的目标数据库管理系统为PostgreSQL
driver=org.postgresql.Driver //设置了用于PostgreSQL的Java数据库连接(JDBC)驱动程序类
conn = xxx // 定义了连接字符串,用于连接到运行PostgreSQL数据库的主机IP、数据库和端口号,binaryTransfer=false和forcebinary=false指示在压测期间客户端与服务器之间数据传输的方式
user=openuser // 指定了将用于认证连接到数据库的用户名
password=Openuser@123 // 设置了指定用户的密码
warehouses=20 // 设置了压测中将使用的仓库数量
loadWorkers=6 // 设置了用于初始数据加载阶段的工作线程数量
terminals=50 // 设置了在性能测试期间将使用的模拟终端(用户)数量
runTxnsPerTerminal=0 // 指定了每个终端在性能测试期间要执行的事务数量
runMins=5 // 设置了性能测试的持续时间,以分钟为单位
limitTxnsPerMin=0 // 设置了性能测试期间每分钟可以执行的事务数量上限
terminalWarehouseFixed=false // 指示是否将终端分配到固定的仓库。如设置为"true",每个终端将分配到特定的仓库。如果设置为"false",终端将随机分配到仓库
newOrderWeight=45 // 设置了在压测工作负载中NewOrder事务的权重
paymentWeight=43 // 设置了在压测工作负载中Payment事务的权重
orderStatusWeight=4 // 设置了在压测工作负载中OrderStatus事务的权重
deliveryWeight=4 // 设置了在压测工作负载中Delivery事务的权重
stockLevelWeight=4 //设置了在压测工作负载中StockLevel事务的权重
resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS // 定义了存储压测结果的目录
osCollectorScript=./misc/os_collector_linux.py // 指定了用于在压测期间收集系统性能指标(CPU\内存\磁盘\网络)的操作系统收集脚本的路径
osCollectorInterval=1 // 设置了操作系统收集脚本在压测期间收集系统性能指标的间隔(以秒为单位)
osCollectorSSHAddr=omm@10.110.3.155 // 指定了操作系统收集脚本用于连接到目标机器并收集性能指标的SSH地址
osCollectorDevices=net_ens33 blk_sda // 定义了操作系统收集脚本将监视性能指标的网络和块设备

-- 注意,osCollectorDevices 后 net_xxx 要使用数据库实际网卡名称

3.7 配置互信

使用BenchmarkSQL压测,要配置BenchmarkSQL服务器到openGauss数据库omm用户的互信,配置方法如下。

-- BenchmarkSQL 服务器,omm用户操作
[omm@opensource-db ~]$ ssh-keygen -t rsa // 按回车
Generating public/private rsa key pair.
Enter file in which to save the key (/home/omm/.ssh/id_rsa): // 按回车
Created directory '/home/omm/.ssh'.
Enter passphrase (empty for no passphrase): // 按回车
Enter same passphrase again: // 按回车
Your identification has been saved in /home/omm/.ssh/id_rsa.
Your public key has been saved in /home/omm/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:s9ncyhcmAjneSnYsNgNcxWKPHkoGQyP7AqBPMDxppkk omm@opensource-db
The key's randomart image is:
+---[RSA 2048]----+
|*.+ o. |
|oEo. + . |
|O.o+ o = |
|++ = * . |
|. oo = *S |
| . . X =*..o |
| + *o.oo.. |
| . . .. |
| o. |
+----[SHA256]-----+

[omm@opensource-db ~]$ ssh-copy-id omm@10.110.3.156
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/omm/.ssh/id_rsa.pub"
The authenticity of host '10.110.3.156 (10.110.3.156)' can't be established.
ECDSA key fingerprint is SHA256:EP/j7VG6/RAnl5lBNc2LLOKtyksDBUvXyvNc7hzPHx8.
ECDSA key fingerprint is MD5:f7:f7:93:08:85:63:37:65:18:92:e5:e7:36:f9:c7:6d.
Are you sure you want to continue connecting (yes/no)? yes
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
omm@10.110.3.156's password:

Number of key(s) added: 1

Now try logging into the machine, with: "ssh 'omm@10.110.3.156'"
and check to make sure that only the key(s) you wanted were added.

-- 测试免密登录,如果不输入密码可以远程登录,表明免密配置成功
[omm@opensource-db ~]$ ssh omm@10.110.3.156
Last login: Thu Aug 3 09:05:03 2023

四、BenchmarkSQL压测

4.1 导入测试数据

通过执行BenchmarkSQL工具中runDatabaseBuild.sh脚本,导入测试数据。

-- BenchmarkSQL 服务器,omm用户操作
[omm@opensource-db ~]$ cd /home/omm/benchmarksql-5.0/run
[omm@opensource-db run]$ ./runDatabaseBuild.sh props.openGauss
# ------------------------------------------------------------
# Loading SQL file ./sql.common/tableCreates.sql
# ------------------------------------------------------------
Aug 03, 2023 11:14:51 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [e1de774d-e8df-40f8-8436-b026b3cdcbe8] Try to connect. IP: 10.110.3.156:26000
Aug 03, 2023 11:14:52 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [192.168.73.21:53626/10.110.3.156:26000] Connection is established. ID: e1de774d-e8df-40f8-8436-b026b3cdcbe8
Aug 03, 2023 11:14:52 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: Connect complete. ID: e1de774d-e8df-40f8-8436-b026b3cdcbe8
create table bmsql_config (
cfg_name varchar(30) primary key,
cfg_value varchar(50)
);
create table bmsql_warehouse (
w_id integer not null,
w_ytd decimal(12,2),
w_tax decimal(4,4),
w_name varchar(10),
w_street_1 varchar(20),
w_street_2 varchar(20),
w_city varchar(20),
w_state char(2),
w_zip char(9)
);
create table bmsql_district (
d_w_id integer not null,
d_id integer not null,
d_ytd decimal(12,2),
d_tax decimal(4,4),
d_next_o_id integer,
d_name varchar(10),
d_street_1 varchar(20),
d_street_2 varchar(20),
d_city varchar(20),
d_state char(2),
d_zip char(9)
);
create table bmsql_customer (
c_w_id integer not null,
c_d_id integer not null,
c_id integer not null,
c_discount decimal(4,4),
c_credit char(2),
c_last varchar(16),
c_first varchar(16),
c_credit_lim decimal(12,2),
c_balance decimal(12,2),
c_ytd_payment decimal(12,2),
c_payment_cnt integer,
c_delivery_cnt integer,
c_street_1 varchar(20),
c_street_2 varchar(20),
c_city varchar(20),
c_state char(2),
c_zip char(9),
c_phone char(16),
c_since timestamp,
c_middle char(2),
c_data varchar(500)
);
create sequence bmsql_hist_id_seq;
create table bmsql_history (
hist_id integer,
h_c_id integer,
h_c_d_id integer,
h_c_w_id integer,
h_d_id integer,
h_w_id integer,
h_date timestamp,
h_amount decimal(6,2),
h_data varchar(24)
);
create table bmsql_new_order (
no_w_id integer not null,
no_d_id integer not null,
no_o_id integer not null
);
create table bmsql_oorder (
o_w_id integer not null,
o_d_id integer not null,
o_id integer not null,
o_c_id integer,
o_carrier_id integer,
o_ol_cnt integer,
o_all_local integer,
o_entry_d timestamp
);
create table bmsql_order_line (
ol_w_id integer not null,
ol_d_id integer not null,
ol_o_id integer not null,
ol_number integer not null,
ol_i_id integer not null,
ol_delivery_d timestamp,
ol_amount decimal(6,2),
ol_supply_w_id integer,
ol_quantity integer,
ol_dist_info char(24)
);
create table bmsql_item (
i_id integer not null,
i_name varchar(24),
i_price decimal(5,2),
i_data varchar(50),
i_im_id integer
);
create table bmsql_stock (
s_w_id integer not null,
s_i_id integer not null,
s_quantity integer,
s_ytd integer,
s_order_cnt integer,
s_remote_cnt integer,
s_data varchar(50),
s_dist_01 char(24),
s_dist_02 char(24),
s_dist_03 char(24),
s_dist_04 char(24),
s_dist_05 char(24),
s_dist_06 char(24),
s_dist_07 char(24),
s_dist_08 char(24),
s_dist_09 char(24),
s_dist_10 char(24)
);
Starting BenchmarkSQL LoadData

driver=org.postgresql.Driver
conn=jdbc:postgresql://10.110.3.156:26000/gaussdb?binaryTransfer=false&forcebinary=false
user=openuser
password=***********
warehouses=20
loadWorkers=6
fileLocation (not defined)
csvNullValue (not defined - using default 'NULL')

Aug 03, 2023 11:14:52 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [f92333a4-8b64-4d98-be59-e76d89125f8e] Try to connect. IP: 10.110.3.156:26000
Aug 03, 2023 11:14:52 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [192.168.73.21:53628/10.110.3.156:26000] Connection is established. ID: f92333a4-8b64-4d98-be59-e76d89125f8e
Aug 03, 2023 11:14:52 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: Connect complete. ID: f92333a4-8b64-4d98-be59-e76d89125f8e
Worker 000: Loading ITEM
Aug 03, 2023 11:14:52 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [4f6b3c8b-f753-485d-a671-9505c00b1755] Try to connect. IP: 10.110.3.156:26000
Aug 03, 2023 11:14:53 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [192.168.73.21:53630/10.110.3.156:26000] Connection is established. ID: 4f6b3c8b-f753-485d-a671-9505c00b1755
Aug 03, 2023 11:14:53 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: Connect complete. ID: 4f6b3c8b-f753-485d-a671-9505c00b1755
Worker 001: Loading Warehouse 1
Aug 03, 2023 11:14:53 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [c95ec3f6-c980-48d2-bf90-292028550537] Try to connect. IP: 10.110.3.156:26000
Aug 03, 2023 11:14:53 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [192.168.73.21:53632/10.110.3.156:26000] Connection is established. ID: c95ec3f6-c980-48d2-bf90-292028550537
Aug 03, 2023 11:14:53 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: Connect complete. ID: c95ec3f6-c980-48d2-bf90-292028550537
Worker 002: Loading Warehouse 2
Aug 03, 2023 11:14:53 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [35bc44aa-0f4f-456b-a369-355104489259] Try to connect. IP: 10.110.3.156:26000
Aug 03, 2023 11:14:53 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [192.168.73.21:53634/10.110.3.156:26000] Connection is established. ID: 35bc44aa-0f4f-456b-a369-355104489259
Aug 03, 2023 11:14:53 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: Connect complete. ID: 35bc44aa-0f4f-456b-a369-355104489259
Worker 003: Loading Warehouse 3
Aug 03, 2023 11:14:53 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [650475e1-42f5-464b-9fbf-644ab231af5c] Try to connect. IP: 10.110.3.156:26000
Aug 03, 2023 11:14:53 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [192.168.73.21:53636/10.110.3.156:26000] Connection is established. ID: 650475e1-42f5-464b-9fbf-644ab231af5c
Aug 03, 2023 11:14:53 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: Connect complete. ID: 650475e1-42f5-464b-9fbf-644ab231af5c
Worker 004: Loading Warehouse 4
Aug 03, 2023 11:14:53 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [0d7dd192-c56d-4dcc-adf7-a3cf8f493546] Try to connect. IP: 10.110.3.156:26000
Aug 03, 2023 11:14:53 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [192.168.73.21:53638/10.110.3.156:26000] Connection is established. ID: 0d7dd192-c56d-4dcc-adf7-a3cf8f493546
Aug 03, 2023 11:14:53 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: Connect complete. ID: 0d7dd192-c56d-4dcc-adf7-a3cf8f493546
Worker 005: Loading Warehouse 5
Worker 000: Loading ITEM done
Worker 000: Loading Warehouse 6
Worker 001: Loading Warehouse 1 done
Worker 001: Loading Warehouse 7
Worker 003: Loading Warehouse 3 done
Worker 003: Loading Warehouse 8
Worker 005: Loading Warehouse 5 done
Worker 005: Loading Warehouse 9
Worker 004: Loading Warehouse 4 done
Worker 004: Loading Warehouse 10
Worker 002: Loading Warehouse 2 done
Worker 002: Loading Warehouse 11
Worker 000: Loading Warehouse 6 done
Worker 000: Loading Warehouse 12
Worker 001: Loading Warehouse 7 done
Worker 001: Loading Warehouse 13
Worker 005: Loading Warehouse 9 done
Worker 005: Loading Warehouse 14
Worker 003: Loading Warehouse 8 done
Worker 003: Loading Warehouse 15
Worker 004: Loading Warehouse 10 done
Worker 004: Loading Warehouse 16
Worker 002: Loading Warehouse 11 done
Worker 002: Loading Warehouse 17
Worker 000: Loading Warehouse 12 done
Worker 000: Loading Warehouse 18
Worker 001: Loading Warehouse 13 done
Worker 001: Loading Warehouse 19
Worker 004: Loading Warehouse 16 done
Worker 004: Loading Warehouse 20
Worker 003: Loading Warehouse 15 done
Worker 005: Loading Warehouse 14 done
Worker 000: Loading Warehouse 18 done
Worker 002: Loading Warehouse 17 done
Worker 001: Loading Warehouse 19 done
Worker 004: Loading Warehouse 20 done
# ------------------------------------------------------------
# Loading SQL file ./sql.common/indexCreates.sql
# ------------------------------------------------------------
Aug 03, 2023 11:17:06 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [ee5aaeba-26ed-4df8-8532-169b37f1edb5] Try to connect. IP: 10.110.3.156:26000
Aug 03, 2023 11:17:06 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [192.168.73.21:53644/10.110.3.156:26000] Connection is established. ID: ee5aaeba-26ed-4df8-8532-169b37f1edb5
Aug 03, 2023 11:17:06 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: Connect complete. ID: ee5aaeba-26ed-4df8-8532-169b37f1edb5
alter table bmsql_warehouse add constraint bmsql_warehouse_pkey
primary key (w_id);
alter table bmsql_district add constraint bmsql_district_pkey
primary key (d_w_id, d_id);
alter table bmsql_customer add constraint bmsql_customer_pkey
primary key (c_w_id, c_d_id, c_id);
create index bmsql_customer_idx1
on bmsql_customer (c_w_id, c_d_id, c_last, c_first);
alter table bmsql_oorder add constraint bmsql_oorder_pkey
primary key (o_w_id, o_d_id, o_id);
create unique index bmsql_oorder_idx1
on bmsql_oorder (o_w_id, o_d_id, o_carrier_id, o_id);
alter table bmsql_new_order add constraint bmsql_new_order_pkey
primary key (no_w_id, no_d_id, no_o_id);
alter table bmsql_order_line add constraint bmsql_order_line_pkey
primary key (ol_w_id, ol_d_id, ol_o_id, ol_number);
alter table bmsql_stock add constraint bmsql_stock_pkey
primary key (s_w_id, s_i_id);
alter table bmsql_item add constraint bmsql_item_pkey
primary key (i_id);
# ------------------------------------------------------------
# Loading SQL file ./sql.common/foreignKeys.sql
# ------------------------------------------------------------
Aug 03, 2023 11:17:52 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [4636695b-a98d-496a-8893-234a849d39e3] Try to connect. IP: 10.110.3.156:26000
Aug 03, 2023 11:17:52 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [192.168.73.21:53648/10.110.3.156:26000] Connection is established. ID: 4636695b-a98d-496a-8893-234a849d39e3
Aug 03, 2023 11:17:52 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: Connect complete. ID: 4636695b-a98d-496a-8893-234a849d39e3
# ------------------------------------------------------------
# Loading SQL file ./sql.postgres/extraHistID.sql
# ------------------------------------------------------------
Aug 03, 2023 11:17:53 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [af9bb608-c0ec-49a3-8670-a4d41aa47974] Try to connect. IP: 10.110.3.156:26000
Aug 03, 2023 11:17:53 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [192.168.73.21:53650/10.110.3.156:26000] Connection is established. ID: af9bb608-c0ec-49a3-8670-a4d41aa47974
Aug 03, 2023 11:17:53 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: Connect complete. ID: af9bb608-c0ec-49a3-8670-a4d41aa47974
-- ----
-- Extra Schema objects/definitions for history.hist_id in PostgreSQL
-- ----
-- ----
-- This is an extra column not present in the TPC-C
-- specs. It is useful for replication systems like
-- Bucardo and Slony-I, which like to have a primary
-- key on a table. It is an auto-increment or serial
-- column type. The definition below is compatible
-- with Oracle 11g, using a sequence and a trigger.
-- ----
-- Adjust the sequence above the current max(hist_id)
select setval('bmsql_hist_id_seq', (select max(hist_id) from bmsql_history));
-- Make nextval(seq) the default value of the hist_id column.
alter table bmsql_history
alter column hist_id set default nextval('bmsql_hist_id_seq');
-- Add a primary key history(hist_id)
alter table bmsql_history add primary key (hist_id);
# ------------------------------------------------------------
# Loading SQL file ./sql.postgres/buildFinish.sql
# ------------------------------------------------------------
Aug 03, 2023 11:17:56 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [8aa56b0b-1332-4a11-a8da-cdc17bae1072] Try to connect. IP: 10.110.3.156:26000
Aug 03, 2023 11:17:56 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [192.168.73.21:53652/10.110.3.156:26000] Connection is established. ID: 8aa56b0b-1332-4a11-a8da-cdc17bae1072
Aug 03, 2023 11:17:56 AM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: Connect complete. ID: 8aa56b0b-1332-4a11-a8da-cdc17bae1072
-- ----
-- Extra commands to run after the tables are created, loaded,
-- indexes built and extra's created.
-- PostgreSQL version.
-- ----
vacuum analyze;

4.2 执行TPCC压测

通过执行BenchmarkSQL工具中runBenchmark.sh脚本,用来压测数据。

-- BenchmarkSQL 服务器,omm用户操作
[omm@opensource-db ~]$ cd /home/omm/benchmarksql-5.0/run
[antdb@opensource-db run]$ ./runBenchmark.sh props.openGauss
13:15:32,094 [main] INFO jTPCC : Term-00,
13:15:32,099 [main] INFO jTPCC : Term-00, +-------------------------------------------------------------+
13:15:32,099 [main] INFO jTPCC : Term-00, BenchmarkSQL v5.0
13:15:32,099 [main] INFO jTPCC : Term-00, +-------------------------------------------------------------+
13:15:32,099 [main] INFO jTPCC : Term-00, (c) 2003, Raul Barbosa
13:15:32,099 [main] INFO jTPCC : Term-00, (c) 2004-2016, Denis Lussier
13:15:32,102 [main] INFO jTPCC : Term-00, (c) 2016, Jan Wieck
13:15:32,102 [main] INFO jTPCC : Term-00, +-------------------------------------------------------------+
13:15:32,102 [main] INFO jTPCC : Term-00,
13:15:32,118 [main] INFO jTPCC : Term-00, db=postgres
13:15:32,118 [main] INFO jTPCC : Term-00, driver=org.postgresql.Driver
13:15:32,119 [main] INFO jTPCC : Term-00, conn=jdbc:postgresql://10.110.3.156:26000/gaussdb?binaryTransfer=false&forcebinary=false
13:15:32,119 [main] INFO jTPCC : Term-00, user=openuser
13:15:32,119 [main] INFO jTPCC : Term-00,
13:15:32,119 [main] INFO jTPCC : Term-00, warehouses=20
13:15:32,119 [main] INFO jTPCC : Term-00, terminals=50
13:15:32,125 [main] INFO jTPCC : Term-00, runMins=5
13:15:32,126 [main] INFO jTPCC : Term-00, limitTxnsPerMin=0
13:15:32,126 [main] INFO jTPCC : Term-00, terminalWarehouseFixed=false
13:15:32,126 [main] INFO jTPCC : Term-00,
13:15:32,126 [main] INFO jTPCC : Term-00, newOrderWeight=45
13:15:32,127 [main] INFO jTPCC : Term-00, paymentWeight=43
13:15:32,127 [main] INFO jTPCC : Term-00, orderStatusWeight=4
13:15:32,127 [main] INFO jTPCC : Term-00, deliveryWeight=4
13:15:32,127 [main] INFO jTPCC : Term-00, stockLevelWeight=4
13:15:32,127 [main] INFO jTPCC : Term-00,
13:15:32,127 [main] INFO jTPCC : Term-00, resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
13:15:32,128 [main] INFO jTPCC : Term-00, osCollectorScript=./misc/os_collector_linux.py
13:15:32,128 [main] INFO jTPCC : Term-00,
13:15:32,176 [main] INFO jTPCC : Term-00, copied props.openGauss to my_result_2023-08-03_131532/run.properties
13:15:32,186 [main] INFO jTPCC : Term-00, created my_result_2023-08-03_131532/data/runInfo.csv for runID 20
13:15:32,186 [main] INFO jTPCC : Term-00, writing per transaction results to my_result_2023-08-03_131532/data/result.csv
13:15:32,188 [main] INFO jTPCC : Term-00, osCollectorScript=./misc/os_collector_linux.py
13:15:32,188 [main] INFO jTPCC : Term-00, osCollectorInterval=1
13:15:32,188 [main] INFO jTPCC : Term-00, osCollectorSSHAddr=omm@10.110.3.156
13:15:32,188 [main] INFO jTPCC : Term-00, osCollectorDevices=net_ens33 blk_sda
13:15:32,209 [main] INFO jTPCC : Term-00,
Aug 03, 2023 1:15:32 PM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [442d140d-5e56-4497-9dac-9154696c60ca] Try to connect. IP: 10.110.3.156:26000
Aug 03, 2023 1:15:32 PM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [192.168.73.21:53906/10.110.3.156:26000] Connection is established. ID: 442d140d-5e56-4497-9dac-9154696c60ca
......省略部分内容
Aug 03, 2023 1:15:36 PM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: Connect complete. ID: a8718921-1f95-424d-8079-b5ae01ff1f44
Aug 03, 2023 1:15:36 PM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [b11af915-865f-45d7-90bc-b8d9d1cd3ddc] Try to connect. IP: 10.110.3.156:26000
Aug 03, 2023 1:15:36 PM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: [192.168.73.21:54008/10.110.3.156:26000] Connection is established. ID: b11af915-865f-45d7-90bc-b8d9d1cd3ddc
Aug 03, 2023 1:15:36 PM org.postgresql.core.v3.ConnectionFactoryImpl openConnectionImpl
INFO: Connect complete. ID: b11af915-865f-45d7-90bc-b8d9d1cd3ddc
Term-00, Running Average tpmTOTAL: 45291.44 Current tpmTOTAL: 1497552 Memory Usage: 246MB / 1004MB
13:20:36,822 [Thread-27] INFO jTPCC : Term-00,
13:20:36,824 [Thread-27] INFO jTPCC : Term-00,
13:20:36,826 [Thread-27] INFO jTPCC : Term-00, Measured tpmC (NewOrders) = 20372.52
13:20:36,827 [Thread-27] INFO jTPCC : Term-00, Measured tpmTOTAL = 45251.92
13:20:36,827 [Thread-27] INFO jTPCC : Term-00, Session Start = 2023-08-03 13:15:36
13:20:36,827 [Thread-27] INFO jTPCC : Term-00, Session End = 2023-08-03 13:20:36
13:20:36,828 [Thread-27] INFO jTPCC : Term-00, Transaction Count = 226506

五、生成测试报告

5.1 生成测试报告

通过执行BenchmarkSQL工具中generateReport.sh脚本,用来生成测试报告。

-- BenchmarkSQL 服务器,omm用户操作
[omm@opensource-db ~]$ cd /home/omm/benchmarksql-5.0/run
[antdb@opensource-db run]$ ./generateReport.sh my_result_2023-08-03_131532
Generating my_result_2023-08-03_131532/tpm_nopm.png ... OK
Generating my_result_2023-08-03_131532/latency.png ... OK
Generating my_result_2023-08-03_131532/cpu_utilization.png ... OK
Generating my_result_2023-08-03_131532/dirty_buffers.png ... OK
Generating my_result_2023-08-03_131532/blk_sda_iops.png ... OK
Generating my_result_2023-08-03_131532/blk_sda_kbps.png ... OK
Generating my_result_2023-08-03_131532/net_ens33_iops.png ... OK
Generating my_result_2023-08-03_131532/net_ens33_kbps.png ... OK
Generating my_result_2023-08-03_131532/report.html ... OK

5.2 查看测试报告

打包并下载my_result_2023-08-03_131532目录文件,里面包含了生成的测试报告,其中report.html文件已html格式生成测试报告。

报告里包含了数据库、磁盘、网卡压测等信息。

f9ceeda3f49acd44009c5ca95bc1e282.jpeg

a4e7a948e3895e9bac67c45a54dd7459.jpeg

81f40a791c4b94c890dff813db063b1d.jpeg

9715b914fc440775812872dffc3fbeb0.jpeg

cc6dd5a618358cd68a2a28f39cd6b8ba.jpeg

a558f0ad99e91b806324a80a3045347e.jpeg

六、附录

6.1 IOError: [Errno 2] No such file or directory

如果props配置文件数据库网卡名称错误,在执行压测时会报如下错误:

Traceback (most recent call last):
File "<stdin>", line 211, in <module>
File "<stdin>", line 39, in main
File "<stdin>", line 186, in initNetDevice
IOError: [Errno 2] No such file or directory: '/sys/class/net/eth0/statistics/rx_packets'
13:41:25,933 [Thread-0] ERROR OSCollector$CollectData : OSCollector, unexpected EOF while reading from external helper process

745f33305448ba92c856b96ca2d2bc77.jpeg

6.2 ValueError: can’t have unbufferd text I/O

如果部署BenchmarkSQL的服务器没有部署python2,而部署了python3,会导致os_collector_linux.py采集报错,无法采集到数据库操作系统信息,因为os_collector_linux.py脚本部分内容不兼容python3,会报如下错误:

Traceback (most recent call last):
File "<stdin>", line 302, in <module>
File "<stdin>", line 65, in main
File "<stdin>", line 162, in initNetDevice
ValueError: can’t have unbufferd text I/O
17:36:26,676 [Thread-0] ERROR OSCollector$CollectData : OSCollector, unexpected EOF while reading from external helper process

0f95a0d59d7239cbee55cf1ca354fb84.jpeg

以下提供了一份改写的兼容python3的os_collector_linux.py脚本

import errno
import math
import os
import sys
import time

def main(argv):
global deviceFDs
global lastDeviceData

runID = int(argv[ 0])
interval = float(argv[ 1])
startTime = time.time()
nextDue = startTime + interval

sysInfo = [ 'run', 'elapsed', ]
sysInfo += initSystemUsage()
print( ",".join([ str(x) for x in sysInfo]))

devices = []
deviceFDs = {}
lastDeviceData = {}

for dev in argv[ 2:]:
if dev.startswith( 'blk_'):
devices.append(dev)
elif dev.startswith( 'net_'):
devices.append(dev)
else:
raise Exception( "unknown device type '" + dev + "'")

for dev in devices:
if dev.startswith( 'blk_'):
devInfo = [ 'run', 'elapsed', 'device', ]
devInfo += initBlockDevice(dev)
print( ",".join([ str(x) for x in devInfo]))
elif dev.startswith( 'net_'):
devInfo = [ 'run', 'elapsed', 'device', ]
devInfo += initNetDevice(dev)
print( ",".join([ str(x) for x in devInfo]))

sys.stdout.flush()

try:
while True:
now = time.time()
if nextDue > now:
time.sleep(nextDue - now)

elapsed = int((nextDue - startTime) * 1000.0)
sysInfo = [runID, elapsed, ]
sysInfo += getSystemUsage()
print( ",".join([ str(x) for x in sysInfo]))

for dev in devices:
if dev.startswith( 'blk_'):
devInfo = [runID, elapsed, dev, ]
devInfo += getBlockUsage(dev, interval)
print( ",".join([ str(x) for x in devInfo]))
elif dev.startswith( 'net_'):
devInfo = [runID, elapsed, dev, ]
devInfo += getNetUsage(dev, interval)
print( ",".join([ str(x) for x in devInfo]))

nextDue += interval
sys.stdout.flush()
except KeyboardInterrupt:
print( "")
return 0
except IOError as e:
if e.errno == errno.EPIPE:
return 0
else:
raise e

def initSystemUsage():
global procStatFD
global procVMStatFD
global lastStatData
global lastVMStatData

procStatFD = open( "/proc/stat", "rb")
for line in procStatFD:
line = line.decode().split()
if line[ 0] == "cpu":
lastStatData = [ int(x) for x in line[ 1:]]
break
if len(lastStatData) != 10:
raise Exception( "cpu line in /proc/stat too short")

procVMStatFD = open( "/proc/vmstat", "rb")
lastVMStatData = {}
for line in procVMStatFD:
line = line.decode().split()
if line[ 0] in [ 'nr_dirty', ]:
lastVMStatData[ 'vm_' + line[ 0]] = int(line[ 1])
if len(lastVMStatData.keys()) != 1:
raise Exception( "not all elements found in /proc/vmstat")

return [
'cpu_user', 'cpu_nice', 'cpu_system',
'cpu_idle', 'cpu_iowait', 'cpu_irq',
'cpu_softirq', 'cpu_steal',
'cpu_guest', 'cpu_guest_nice',
'vm_nr_dirty',
]

def getSystemUsage():
global procStatFD
global procVMStatFD
global lastStatData
global lastVMStatData

procStatFD.seek( 0, 0)
for line in procStatFD:
line = line.decode().split()
if line[ 0] != "cpu":
continue
statData = [ int(x) for x in line[ 1:]]
deltaTotal = float( sum(statData) - sum(lastStatData))
if deltaTotal == 0:
result = [ 0.0 for x in statData]
else:
result = []
for old, new in zip(lastStatData, statData):
result.append( float(new - old) / deltaTotal)
lastStatData = statData
break

procVMStatFD.seek( 0, 0)
newVMStatData = {}
for line in procVMStatFD:
line = line.decode().split()
if line[ 0] in [ 'nr_dirty', ]:
newVMStatData[ 'vm_' + line[ 0]] = int(line[ 1])

for key in [ 'vm_nr_dirty', ]:
result.append(newVMStatData[key])

return result

def initBlockDevice(dev):
global deviceFDs
global lastDeviceData

devPath = os.path.join( "/sys/block", dev[ 4:], "stat")
deviceFDs[dev] = open(devPath, "rb")
line = deviceFDs[dev].readline().decode().split()
newData = []
for idx, mult in [
( 0, 1.0), ( 1, 1.0), ( 2, 0.5),
( 4, 1.0), ( 5, 1.0), ( 6, 0.5),
]:
newData.append( int(line[idx]))
lastDeviceData[dev] = newData
return [ 'rdiops', 'rdmerges', 'rdkbps', 'wriops', 'wrmerges', 'wrkbps', ]

def getBlockUsage(dev, interval):
global deviceFDs
global lastDeviceData

deviceFDs[dev].seek( 0, 0)
line = deviceFDs[dev].readline().decode().split()
oldData = lastDeviceData[dev]
newData = []
result = []
ridx = 0
for idx, mult in [
( 0, 1.0), ( 1, 1.0), ( 2, 0.5),
( 4, 1.0), ( 5, 1.0), ( 6, 0.5),
]:
newData.append( int(line[idx]))
result.append( float(newData[ridx] - oldData[ridx]) * mult / interval)
ridx += 1
lastDeviceData[dev] = newData
return result

def initNetDevice(dev):
global deviceFDs
global lastDeviceData

devPath = os.path.join( "/sys/class/net", dev[ 4:], "statistics")
deviceData = []
for fname in [ 'rx_packets', 'rx_bytes', 'tx_packets', 'tx_bytes', ]:
key = dev + "." + fname
deviceFDs[key] = open(os.path.join(devPath, fname), "rb")
deviceData.append( int(deviceFDs[key].read()))
lastDeviceData[dev] = deviceData
return [ 'rxpktsps', 'rxkbps', 'txpktsps', 'txkbps', ]

def getNetUsage(dev, interval):
global deviceFDs
global lastDeviceData

oldData = lastDeviceData[dev]
newData = []
for fname in [ 'rx_packets', 'rx_bytes', 'tx_packets', 'tx_bytes', ]:
key = dev + "." + fname
deviceFDs[key].seek( 0, 0)
newData.append( int(deviceFDs[key].read()))
result = [
float(newData[ 0] - oldData[ 0]) / interval,
float(newData[ 1] - oldData[ 1]) / interval / 1024.0,
float(newData[ 2] - oldData[ 2]) / interval,
float(newData[ 3] - oldData[ 3]) / interval / 1024.0,
]
lastDeviceData[dev] = newData
return result

if __name__ == '__main__':
sys.exit(main(sys.argv[ 1:]))

6.3 ant无法编译BenchmarkSQL

有时会遇到ant无法编译BenchmarkSQL的问题,遇到如下报错:

Error: Could not find or load main class org.apache.tools.ant.launch.Launcher
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.launch.Launcher

解决办法是,要配置环境JAVA_HOME和CLASSPATH环境变量,如下所示:

-- BenchmarkSQL服务器,omm用户操作
-- 编辑 .bash_profile文件,添加如下内容
export JAVA_HOME=/usr/java/jdk-11
export CLASSPATH=.:${JAVA_HOME}/lib:/usr/share/ant/lib/ant-launcher.jar
-- 生效 .bash_profile文件

此时就可以使用ant正常编译BenchmarkSQL了。

相关文章:

【案例分享】BenchmarkSQL 5.0 压测 openGauss 5.0.0

一、前言 本次BenchmarkSQL 压测openGauss仅作为学习使用压测工具测试tpcc为目的&#xff0c;并不代表数据库性能如本次压测所得数据。实际生产性能压测&#xff0c;还需结合服务器软硬件配置、数据库性能参数调优、BenchmarkSQL 配置文件参数相结合&#xff0c;是一个复杂的过…...

Linux之 4 种休眠模式

目录 1. Linux之 4 种休眠模式 1. Linux之 4 种休眠模式 # echo standby >/sys/power/state //CPU和RAM在运行 # echo mem > /sys/power/state //挂起到内存(待机),关闭硬 盘、外设等设备 # echo disk > /sys/power/state //挂起到硬盘(休眠),关闭硬盘、外设等设备&…...

homeassiant主题

下载主题 https://github.com/maartenpaauw/home-assistant-community-themes.git 使用file editor到homeassiant路径下&#xff0c;新建文件夹themes文件夹&#xff0c;用terminal新建也可以。 使用file editor上传文件 使用Terminal解压 mkdir themes unzip home-assistan…...

《2020年最新面经》—字节跳动Java社招面试题

文章目录 前言&#xff1a;一面&#xff1a;01、Java基础知识答疑&#xff0c;简单概述一下&#xff1f;02、倒排索引了解吗&#xff1f;使用Java语言怎么实现倒排&#xff1f;03、详细讲解一下redis里面的哈希表&#xff0c;常用的Redis哈希表命名有哪些&#xff0c;举例说明其…...

2.3IP详解及配置

2.3IP详解及配置 一、ip地址组成 IP地址由4部分数字组成&#xff0c;每部分数字对应于8位二进制数字&#xff0c;各部分之间用小数点分开 这是点分 2进制 如果换算为10进制我们称为点分10进制. 每个ip地址由两部分组成网络地址(NetID)和主z机地址(HostID).网络地址表示其属于…...

Python程序打包指南:手把手教你一步步完成

最近感兴趣想将开发的项目转成Package&#xff0c;研究了一下相关文章&#xff0c;并且自己跑通了&#xff0c;走了一下弯路&#xff0c;这里记录一下如何打包一个简单的Python项目&#xff0c;展示如何添加必要的文件和结构来创建包&#xff0c;如何构建包&#xff0c;以及如何…...

Linux yum 使用时提示 获取 GPG 密钥失败Couldn‘t open file RPM-GPG-KEY-EPEL-7

资料 错误提示&#xff1a; no crontab for root - using an empty one 888 原因剖析&#xff1a; 第一次使用crontab -e 命令时会让我们选择编辑器&#xff0c;很多人会不小心选择默认的nano&#xff08;不好用&#xff09;&#xff0c;或则提示no crontab for root - usin…...

OpenGL_Learn13(材质)

1. 材质 cube.vs #version 330 core layout (location 0) in vec3 aPos; layout (location 0 ) in vec3 aNormal;out vec3 FragPos; out vec3 Normal;uniform mat4 model; uniform mat4 view; uniform mat4 projection;void main() {FragPosvec3(model*vec4(aPos,1.0));Norma…...

buildadmin+tp8表格操作(1)----表头上方添加按钮和自定义按钮

buildAdmin 的表头上添加一些按钮&#xff0c;并实现功能 添加按钮 <template><!-- buttons 属性定义了 TableHeader 本身支持的顶部按钮&#xff0c;仅需传递按钮名即可 --><!-- 这里的框架自带的 顶部按钮 分别有 刷新 &#xff0c; 添加&#xff0c; 编辑&…...

MySQL 定时计划任务 事件的使用

目录 查看事件是否开启 开启事件 1&#xff09;通过设置全局参数修改 2&#xff09;更改配置文件 MySQL如何创建并执行事件&#xff1f; 例 1 MySQL查看事件状态信息 MySQL修改和删除事件 例 1 例 2 删除事件 例 3 在数据库管理中&#xff0c;经常要周期性的执行某…...

C++构造函数 拷贝构造函数 括号法显示法隐式转换法实现类

一.无参构造 & 有参构造 & 拷贝构造函数 拷贝的是自己所属的类&#xff0c;也就是克隆自己。 所以传参要穿自己的类名。 克隆归克隆&#xff0c;但是不能把本身给改了&#xff0c;所以参数前要加const。class Person { public:int age;public:Person(){cout<<&q…...

FreeRTOS中的内存分配策略

FreeRTOS为内存管理提供了几种不同的策略&#xff0c;分别由heap_1.c至heap_5.c实现。以下是每种策略&#xff1a; heap_1.c: 最简单的策略。只允许一次性的内存分配。不允许内存释放。对于只分配内存但不释放的系统特别有用&#xff0c;如仅在启动时分配任务和队列的系统。内存…...

HP惠普光影精灵7笔记本Victus by HP 16.1英寸游戏本16-d0000原装出厂Windows11.21H2预装OEM系统

下载链接&#xff1a;https://pan.baidu.com/s/1LGNeQR1AF1XBJb5kfZca5w?pwdhwk6 提取码&#xff1a;hwk6 可适用的型号&#xff1a; 16-d0111tx&#xff0c;16-d0112tx&#xff0c;16-d0125tx&#xff0c;16-d0127tx&#xff0c;16-d0128tx&#xff0c;16-d0129tx&#…...

组合模式 rust和java的实现

文章目录 组合模式介绍实现javarsut 组合模式 组合模式&#xff08;Composite Pattern&#xff09;&#xff0c;又叫部分整体模式&#xff0c;是用于把一组相似的对象当作一个单一的对象。组合模式依据树形结构来组合对象&#xff0c;用来表示部分以及整体层次。这种类型的设计…...

大数据基础设施搭建 - MySQL

文章目录 一、检查是否安装过MySQL二、上传安装包三、安装MySQL3.1 安装mysql依赖3.2 安装mysql-client3.3 安装mysql-server 四、启动MySQL五、配置MySQL5.1 修改密码&#xff08;1&#xff09;查看密码&#xff08;2&#xff09;登陆&#xff08;3&#xff09;设置复杂密码&a…...

二叉树递归遍历

能帮到你的话&#xff0c;就给个赞吧 &#x1f618; 二叉树遍历算法 指遍历一遍二叉树就能得到答案 什么是二叉树遍历 二叉树遍历 前中后序遍历 递归遍历 3种时间节点 递归遍历会依次遍历到每个节点。 而前中后序则是在递归遍历的基础上选择操作发生的时间。 递归遍历 …...

【ArcGIS Pro二次开发】:CC工具箱1.1.1更新_免费_安装即可用

CC工具箱1.1.1更新【2023.11.15】 使用环境要求&#xff1a;ArcGIS Pro 3.0 一、下载链接 工具安装文件及使用文档&#xff1a; https://pan.baidu.com/s/1OJmO6IPtMfX_vob3bMtvEg?pwduh5rhttps://pan.baidu.com/s/1OJmO6IPtMfX_vob3bMtvEg?pwduh5r 二、使用方法 1、在下…...

Dubbo的优雅下线原理分析

文/朱季谦 Dubbo如何实现优雅下线&#xff1f; 这个问题困扰了我一阵&#xff0c;既然有优雅下线这种说法&#xff0c;那么&#xff0c;是否有非优雅下线的说法呢&#xff1f; 这&#xff0c;还真有。 可以从linux进程关闭说起&#xff0c;其实&#xff0c;我们经常使用到杀…...

leetcode做题笔记2342. 数位和相等数对的最大和

给你一个下标从 0 开始的数组 nums &#xff0c;数组中的元素都是 正 整数。请你选出两个下标 i 和 j&#xff08;i ! j&#xff09;&#xff0c;且 nums[i] 的数位和 与 nums[j] 的数位和相等。 请你找出所有满足条件的下标 i 和 j &#xff0c;找出并返回 nums[i] nums[j]…...

c# YOLOV5目标检测部署

using Emgu.CV; using Emgu.CV.CvEnum; using Emgu.CV.Dnn; using Emgu.CV.Structure; using Emgu.CV.Util...

学习笔记6——垃圾回收

学习笔记系列开头惯例发布一些寻亲消息 链接&#xff1a;https://baobeihuijia.com/bbhj/contents/3/190801.html java垃圾回收&#xff08;stop the world&#xff09; 专注于堆和方法区的垃圾回收&#xff0c;年轻代&#xff0c;老年代&#xff0c;永久代判断对象是否还存…...

3.1 Windows驱动开发:内核远程堆分配与销毁

在开始学习内核内存读写篇之前&#xff0c;我们先来实现一个简单的内存分配销毁堆的功能&#xff0c;在内核空间内用户依然可以动态的申请与销毁一段可控的堆空间&#xff0c;一般而言内核中提供了ZwAllocateVirtualMemory这个函数用于专门分配虚拟空间&#xff0c;而与之相对应…...

C++: 模板初阶

文章目录 一. 泛型编程二. 函数模板函数模板的原理函数模板的实例化隐式实例化: 让编译器根据实参推演模板参数的实际类型显示实例化: 在函数名后的<>中制定模板参数的世纪类型 模板参数的匹配原则 三. 类模板类模板的定义格式类模板的实例化 一. 泛型编程 如何实现一个…...

人工智能基础_机器学习036_多项式回归升维实战3_使用线性回归模型_对天猫双十一销量数据进行预测_拟合---人工智能工作笔记0076

首先我们拿到双十一从2009年到2018年的数据 可以看到上面是代码,我们自己去写一下 首先导包,和准备数据 from sklearn.linear_model import SGDRegressor import numpy as np import matplotlib.pyplot as plt X=np.arange(2009.2020)#左闭右开,2009到2019 获取从2009到202…...

【算法挨揍日记】day29——139. 单词拆分、467. 环绕字符串中唯一的子字符串

139. 单词拆分 139. 单词拆分 题目描述&#xff1a; 给你一个字符串 s 和一个字符串列表 wordDict 作为字典。请你判断是否可以利用字典中出现的单词拼接出 s 。 注意&#xff1a;不要求字典中出现的单词全部都使用&#xff0c;并且字典中的单词可以重复使用。 解题思路&am…...

YOLOv8-Seg改进:轻量级Backbone改进 | VanillaNet极简神经网络模型 | 华为诺亚2023

🚀🚀🚀本文改进:一种极简的神经网络模型 VanillaNet,支持vanillanet_5, vanillanet_6, vanillanet_7, vanillanet_8, vanillanet_9, vanillanet_10, vanillanet_11等版本,相比较yolov8-seg各个版本如下: layersparametersgradientsGFLOPsvanillanet_521230017523...

解决Requests中使用httpbin服务器问题:自定义URL的实现与验证

问题背景 在使用Python的Requests模块进行单元测试时&#xff0c;可能会遇到无法使用本地运行的httpbin服务器进行测试的问题。这是因为测试脚本允许通过环境变量HTTPBIN_URL指定用于测试的本地httpbin实例&#xff0c;但在某些测试用例中&#xff0c;URL是硬编码为httpbin.or…...

​软考-高级-系统架构设计师教程(清华第2版)【第17章 通信系统架构设计理论与实践(P614~646)-思维导图】​

软考-高级-系统架构设计师教程&#xff08;清华第2版&#xff09;【第17章 通信系统架构设计理论与实践&#xff08;P614~646&#xff09;-思维导图】 课本里章节里所有蓝色字体的思维导图...

【MATLAB源码-第82期】基于matlab的OFDM系统载波频移偏差(CFO)估计,对比三种不同的方法。

操作环境&#xff1a; MATLAB 2013b 1、算法描述 正交频分复用&#xff08;OFDM&#xff09;系统中的载波频率偏移&#xff08;CFO&#xff09;估计是一项关键技术&#xff0c;用于确保数据传输的准确性和效率。CFO通常由于振荡器频率不匹配和多普勒频移引起。不同的CFO估计…...

Docker Swarm: 容器编排的力量和优势深度解析

文章目录 Docker Swarm的核心概念1. 节点&#xff08;Node&#xff09;2. 服务&#xff08;Service&#xff09;3. 栈&#xff08;Stack&#xff09; 使用Docker Swarm1. 初始化Swarm2. 加入节点3. 创建服务4. 扩展和缩减服务5. 管理栈6. 管理服务更新 Docker Swarm的优势深度解…...

调整Windows键盘上只能看到拼音而无法看到实际的文本以及关闭输入法悬浮窗方法

一、输入法设置 如果您在键盘上只能看到拼音而无法看到实际的文本&#xff0c;这可能是因为您的输入法设置为中文拼音输入法或其他仅显示拼音的输入法。 要解决这个问题&#xff0c;您可以尝试以下方法&#xff1a; 1. 切换输入法&#xff1a;按下 Shift Alt 组合键或 Wind…...

【微软技术栈】C#.NET 中的管道操作

C#.NET 管道为进程间通信提供了平台。 管道分为两种类型&#xff1a; 匿名管道。 匿名管道在本地计算机上提供进程间通信。 与命名管道相比&#xff0c;虽然匿名管道需要的开销更少&#xff0c;但提供的服务有限。 匿名管道是单向的&#xff0c;不能通过网络使用。 仅支持一个服…...

Python学习笔记--进程

进程 Python 中的多线程其实并不是真正的多线程,如果想要充分地使用多核 CPU 的资源,在 Python 中大部分情况需要使用多进程。 Python 提供了非常好用的多进程包 multiprocessing,只需要定义一个函数,Python 会完成其他所有事情。 借助这个包,可以轻松完成从单进程到并…...

比亚迪刀片电池与特斯拉4680电池比较

1 电池材料 比亚迪刀片电池采用的磷酸铁锂LFP&#xff08;LiFePO4&#xff09;&#xff0c;特斯拉的4680电池采用的三元锂。 磷酸铁锂&#xff1a;循环寿命长&#xff0c;安全性能好&#xff0c;价格低廉&#xff0c;但是能量密度低&#xff0c;导电性能差&#xff0c;低温表现…...

在写windows C++代码的时候,从代码安全角度考虑,我们应该注意什么?

在写windows C代码的时候&#xff0c;从代码安全角度考虑&#xff0c;我们应该注意什么&#xff1f;分别是&#xff1a;输入验证、内存管理、错误处理、并发和线程安全、使用安全的API、避免使用不安全的函数、最小权限原则。 一、输入验证 1. 用户输入验证 #include <io…...

【草料】uni-app ts vue 小程序 如何如何通过草料生成对应的模块化二维码

一、查看uni-app项目 1、找到路径 可以看到项目从 src-race-pages-group 这个使我们目标的查询页面 下面我们将这个路径copy到草料内 2、找到进入页面入参 一般我们都会选择 onload() 函数下的入参 这里我们参数的是 id 二、草料 建议看完这里的教程文档 十分清晰&#xff01…...

CMS与FullGC

JVM中的CMS&#xff08;Concurrent Mark Sweep&#xff09;GC和Full GC&#xff08;Full Garbage Collection&#xff09;是两种不同的垃圾回收算法。 CMS GC&#xff1a;CMS GC是一种并发的垃圾回收算法&#xff0c;它在运行期间与应用程序线程并发工作&#xff0c;尽可能减少…...

一款.NET开源的小巧、智能、免费的Windows内存清理工具 - WinMemoryCleaner

前言 我们在使用Windows系统的时候经常会遇到一些程序不会释放已分配的内存&#xff0c;从而导致电脑变得缓慢。今天给大家推荐一款.NET开源的小巧、智能、免费的Windows内存清理工具&#xff1a;WinMemoryCleaner。 使用Windows内存清理工具来优化内存&#xff0c;这样不必浪…...

iptables详解:链、表、表链关系、规则的基本使用

目录 防火墙基本概念 什么是防火墙&#xff1f; Netfilter与iptables的关系 链的概念 表的概念 表链关系 规则的概念 查询规则 添加规则 删除iptables中的记录 修改规则 更详细的命令&#xff08;5链4表&#xff09; 防火墙基本概念 什么是防火墙&#xff1f; 在…...

安全管理中心(设备和技术注解)

网络安全等级保护相关标准参考《GB/T 22239-2019 网络安全等级保护基本要求》和《GB/T 28448-2019 网络安全等级保护测评要求》 密码应用安全性相关标准参考《GB/T 39786-2021 信息系统密码应用基本要求》和《GM/T 0115-2021 信息系统密码应用测评要求》 1系统管理 1.1对系统管…...

Failed to execute org.scala-tools:maven-scala-plugin:2.15.2解决

原因也不是很清楚&#xff0c;查看一个博主文章(net.alchim31.maven:scala-maven-plugin&#xff1a;maven依赖无法下载或无法编译)得到的解决方案&#xff1a; 在idea的terminal执行以下语句即可实现maven对scala代码的编译&#xff1a; mvn clean scala:compile compile pac…...

C#中委托和事件的使用总结

委托&#xff08;delegate&#xff09;特别用于实现事件和回调方法。所有的委托&#xff08;Delegate&#xff09;都派生自 System.Delegate 类。事件是一种特殊的多播委托&#xff0c;仅可以从声明事件的类或结构中对其进行调用。类或对象可以通过事件向其他类或对象通知发生的…...

基于STM32的外部中断(EXTI)在嵌入式系统中的应用

外部中断&#xff08;External Interrupt&#xff0c;EXTI&#xff09;是STM32嵌入式系统中常见且重要的功能之一。它允许外部事件&#xff08;例如按键按下、传感器触发等&#xff09;通过适当的引脚触发中断&#xff0c;从而应用于各种嵌入式系统中。在STM32微控制器中&#…...

【心得】PHP的文件上传个人笔记

目录 1 php的文件上传绕过 黑名单绕过 2 php文件上传的00截断 3 iconv字符转换异常后造成了字符截断 4 文件后缀是白名单的时候的绕过 web服务器的解析漏洞绕过 5.高级文件上传绕过 1 .htaccess nginx.htaccess 2 服务端内容检测 3 配合伪协议来绕过 4.配合日志包含绕…...

深度学习之基于Pytorch和OCR的识别文本检测系统

欢迎大家点赞、收藏、关注、评论啦 &#xff0c;由于篇幅有限&#xff0c;只展示了部分核心代码。 文章目录 一项目简介深度学习与OCRPyTorch在OCR中的应用文本检测系统的关键组成部分1. 图像预处理2. 深度学习模型3. 文本检测算法4. 后处理 二、功能三、系统四. 总结 一项目简…...

三十一、W5100S/W5500+RP2040树莓派Pico<TCP_Server多路socket>

文章目录 1 前言2 简介2. 1 使用多路socket的优点2.2 多路socket数据交互原理2.3 多路socket应用场景 3 WIZnet以太网芯片4 多路socket设置示例概述以及使用4.1 流程图4.2 准备工作核心4.3 连接方式4.4 主要代码概述4.5 结果演示 5 注意事项6 相关链接 1 前言 W5100S/W5500是一…...

带你精通chrony服务器

华子目录 为什么会出现Chrony&#xff1f;Linux的两个时钟NTP介绍Chrony介绍安装与配置安装Chrony配置文件分析实验1实验2chronyc命令查看时间服务器chronyc sources输出分析其他命令 常见时区 为什么会出现Chrony&#xff1f; 由于IT系统中&#xff0c;准确的计时非常重要&am…...

vs2017 编译Qt 5.11.2 源码

SDK 10.0.22000.194 有 2种编译方式 &#xff0c;第二种 看下面 方式一: 1、问题描述&#xff1a; 使用VS编译程序时&#xff0c;运行库选择多线程&#xff08;/MT&#xff09;&#xff0c;表示采用多线程静态release的方式进行编译。 但是&#xff0c;发现编译是不能通过的…...

【SpringBoot3+Vue3】四【实战篇】-前端(vue基础)

目录 一、项目前置知识 二、使用vscode创建 三、vue介绍 四、局部使用vue 1、快速入门 1.1 需求 1.2 准备工作 1.3 操作 1.3.1 创建html 1.3.2 创建初始html代码 1.3.3 参照官网import vue 1.3.4 创建vue应用实例 1.3.5 准备div 1.3.6 准备用户数据 1.3.7 通过…...

element ui修改select选择框背景色和边框色

一、修改选择框的背景色和边框色 style部分 .custom-select /deep/ .el-input__inner {color: #fff!important;border: 1px solid #326AFF;background: #04308D !important; } html部分 <el-select class"custom-select" v-model"dhvalue" placeholde…...