【案例分享】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了。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/160628.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

redis集群-主从复制

目录 一、主从复制概念二、单机安装Redis2.1、安装 Redis 需要的软件 gcc 和 tcl2.2、上传Redis压缩包2.3、编辑 redis.conf 文件2.4、执行安装 Redis 命令2.5、注意防火墙配置 三、主从复制 - 环境搭建3.1、配置一个 master 节点&#xff0c;两个 slave 节点3.2、配置 redis63…

数组的访问

注意&#xff1a;如果一个数组对象指向null&#xff0c;那么该数组对象中不存储任何地址。 这时使用System.out.println(a); System.out.println(a[0]);会出现空指针报错

SHELL中的循环语句

快捷查看指令 ctrlf 进行搜索会直接定位到需要的知识点和命令讲解&#xff08;如有不正确的地方欢迎各位小伙伴在评论区提意见&#xff0c;博主会及时修改&#xff09; 循环结构 连续出现的功能性代码 shell循环有四种: while 条件成立,循环就开始 直到循环条件不满足或者跳出…

Vatee万腾科技引领创新潮流:Vatee数字化探索的前沿之光

在Vatee万腾科技引领创新潮流的浪潮中&#xff0c;我们见证了一场数字化探索的前沿之光。Vatee万腾以其卓越的科技实力和创新精神&#xff0c;成为数字化时代的领军者&#xff0c;为创新潮流注入了强大动力。 Vatee万腾积极探索数字化的前沿&#xff0c;不断挑战科技的极限。他…

2023-11-18 Android Linux资源限制命令 ulimit,比如ulimit -d 是设置进程占用的最大数据段大小,默认是unlimited。

一、通过ulimit -a 命令可以查看当前的各种资源限制&#xff0c;比如ulimit -d 是 进程占用的最大数据段大小。 # ulimit -a -t: time(cpu-seconds) unlimited -f: file(blocks) unlimited -c: coredump(blocks) 0 -d: data(KiB) unlimited -s:…

VS2022 配置 OpenCV并开始第一个程序

VS2022安装 首先下载 VisualStudioSetup.exe 下载连接&#xff1a;Visual Studio 2022 IDE - 适用于软件开发人员的编程工具 点击上面的链接即可进入到下载页面。进入到下载页面&#xff0c;可看到有几个版本可选&#xff0c;如下&#xff1a; 我选择的是企业版&#xff1a;E…

Angular菜单项激活状态保持

菜单项激活状态保持 需求描述详细需求 解决方案 需求描述 如果有个需求&#xff0c;让你实现一个导航栏&#xff0c;点击不同菜单&#xff0c;图表会有不同变化&#xff0c;页面刷新后&#xff0c;该菜单状态仍旧保持&#xff0c;实现方法如下&#xff1a; 例图&#xff0c;有…

机器人走迷宫问题

题目 1.房间有XY的方格组成&#xff0c;例如下图为64的大小。每一个方格以坐标(x,y) 描述。 2.机器人固定从方格(0, 0)出发&#xff0c;只能向东或者向北前进&#xff0c;出口固定为房间的最东北角&#xff0c;如下图的 方格(5,3)。用例保证机器人可以从入口走到出口。 3.房间…

若依中脱敏

SpringBoot使用自定义注解实现返回数据脱敏操作 在实际项目中&#xff0c;对于敏感数据的保护十分重要&#xff0c;数据脱敏又称数据去隐私化或数据变形&#xff0c;是在给定的规则、策略下对敏感数据进行变换、修改的技术机制&#xff0c;能够在很大程度上解决敏感数据在非可…

【Linux】进程间是这样通信的--管道篇

TOC 目录 进程间通信的介绍 进程间通信的概念 进程间通信的目的 进程间通信的本质 进程间通信的分类 管道 什么是管道 匿名管道 pipe函数 匿名管道使用步骤 管道读写规则 管道的特点 1、管道内部自带同步与互斥机制 2、管道的生命周期随进程 3、管道提供的是流式…

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

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

分布式服务与分布式框架

分布式副武其实就是根据某个粒度&#xff0c;将服务拆分&#xff0c;而分布式框架就是将这些服务协调&#xff0c;管理起来。分布式框架&#xff0c;我认为服务调用是他的基础能力&#xff0c;该能力是所有分布式框架的基础能力&#xff0c;其次是服务注册与发现。 在这个维度…

springboot项目yml文件中使用${}配置

1、传统写法 &#xff08;1&#xff09;配置服务启动端口 # 服务端口 server:port: 9898 &#xff08;2&#xff09;使用idea启动 &#xff08;3&#xff09;使用jar包启动 2、使用${}写法 格式&#xff1a;${自定义参数名:默认值} 作用&#xff1a; 项目启动时动态配置变量…

【计算机基础】优雅的PPT就应该这样设计

&#x1f4e2;&#xff1a;如果你也对机器人、人工智能感兴趣&#xff0c;看来我们志同道合✨ &#x1f4e2;&#xff1a;不妨浏览一下我的博客主页【https://blog.csdn.net/weixin_51244852】 &#x1f4e2;&#xff1a;文章若有幸对你有帮助&#xff0c;可点赞 &#x1f44d;…

DevSeo Studio设置中文界面

安装好DevSeo Studio后默认打开是欢迎页。 左下角Configure点击展开&#xff0c;选择plugins 弹出页面选择“installed”,然后输入chinese,默认是关闭的&#xff0c;点击enable将它启用&#xff0c;然后点击OK。 弹出页面点击“restart”重启即可。

2023年优化算法之之霸王龙优化算法(TROA),原理公式详解,附matlab代码

霸王龙优化算法&#xff08;Tyrannosaurus optimization&#xff0c;TROA&#xff09;是一种新的仿生优化算法&#xff0c;该算法模拟霸王龙的狩猎行为&#xff0c;具有搜索速度快等优势。该成果于2023年发表在知名SCI期刊e-Prime-Advances in Electrical Engineering, Electro…

基于ssm的房屋租售网站(有报告)。Javaee项目,ssm项目。

演示视频&#xff1a; 基于ssm的房屋租售网站(有报告)。Javaee项目&#xff0c;ssm项目。 前些天发现了一个巨牛的人工智能学习网站&#xff0c;通俗易懂&#xff0c;风趣幽默&#xff0c;忍不住分享一下给大家。点击跳转到网站。 项目介绍&#xff1a; 采用M&#xff08;mode…

JUC并发工具-CAS机制

面试的时候经常被问到锁、JUC工具包等相关内容&#xff0c;其中CAS机制是必问题目&#xff0c;以下简单总结CAS的机制、CAS产生的ABA现象、CAS产生的ABA现象解决思路 1.什么是CAS&#xff1f; CAS&#xff08;Compare and Swap&#xff09;是一种多线程同步的原子操作&#xf…

融合语言模型中的拓扑上下文和逻辑规则实现知识图谱补全11.18

融合语言模型中的拓扑上下文和逻辑规则实现知识图谱补全 摘要1 引言2 相关工作2.1 事实嵌入法2.2 拓扑嵌入方法2.3 规则融合方法2.4 基于LM的方法 3 准备3.1 知识图谱和拓扑上下文3.2 KG中的逻辑规则4.3 三元组嵌入 5 实验和结果5.1 数据集和评价指标 摘要 知识图补全&#xf…

社区无人零售:投资新热点,创业新机遇

社区无人零售是一个备受关注的创业项目&#xff0c;被视为投资的“爆点”。与其他国家相比&#xff0c;无人零售在国内市场远未达到饱和&#xff0c;因此成为了当下的新风口。今天&#xff0c;我将详细分析这个创业项目&#xff0c;以帮助感兴趣的朋友们了解更多。 首先&#x…