目录

性能测试benchmarksql工具724稳定性测试

【性能测试】benchmarksql工具7*24稳定性测试

文章目录


前言

本文主要介绍使用benchmark工具对数据库进行7*24小时稳定性测试。


一、执行前准备

通常指执行稳定性测试之前需要关注以下几点:

1、根据实际测试环境设计业务模型。

2、检查操作系统core日志记录相关参数是否开启。

二、使用步骤

1.tpcc业务模型

使用benchmark工具,进行稳定测试主要考虑以下几个因素:

1、数据量与并发数

warehouse(数据仓数)和terminals(并发数)配比,可以对每分钟事务数进行限制从而减少数据量的产生。

2、测试环境存储空间

若磁盘空间不够很容易在未达到指定时间,因磁盘写满而退出。

1.1 limitTxnsPerMin

使用benchmarksql工具跑稳定性时,需要限制limitTxnsPerMin(每分钟事务总数限制),防止处理事务太多将磁盘写满。

  • 测试吞吐量时,需要将此值设置极大(0),保证不会出现某个终端sleep现象。

  • 若terminals数量大于limitTxnsPerMin值,该参数会失效。

    假如limitTxnsPerMin参数使用默认300,terminals终端数量设置为150并发:

    A=limitTxnsPerMin/terminals=2

    “A为int类型,若terminals值大于limitTxnsPerMin,A值必然为0”

    benchmarksql工具会记录一个事务的开始时间和结束时间:

    假设B=2000毫秒,C=60000(1分钟)/2=30000

    若事务运行时间:B<C,则该事务执行完后,sleep C-B秒后再执行下一个事务;若B>C,则说明事务超过了预期时间,那么马上进行下一个事务;

2 props.pg典型配置

db=postgres
driver=org.postgresql.Driver
conn=jdbc:postgresql://127.0.0.1:54321/benchmarksql#?defaultRowFetchSize=5
user=benchmarksql
password=123456
warehouses=50
loadWorkers=50
terminals=50    //并发数不能过大,否则容易将磁盘写满
//To run specified transactions per terminal- runMins must equal zero
runTxnsPerTerminal=3000  //限制每分钟事务数,存储空间较小需要进行限制
//To run for specified minutes- runTxnsPerTerminal must equal zero
runMins=10080  //执行时间7*24小时
//Number of total transactions per minute
limitTxnsPerMin=0

//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=my*result*%tY-%tm-%td_%tH%tM%tS
osCollectorScript=./misc/os_collector_linux.py
osCollectorInterval=10 //执行时间越长调整间隔,单位秒。否则生成的日志较大可能导致报告解析失败
//osCollectorSSHAddr=user@dbhost
osCollectorDevices=net_eth0 blk_sda blk_nvme1n1 //根据实际修改监控的网口、硬盘

3 后台执行 benchmarksql

nohup bash runBenchmark.sh props.pg &

三、结果检查

1.数据库状态检查

数据库安装路径为:
/home/test/KES_install
  • 数据库启动时间
[test@localhost KES_install]$ ./Server/bin/ksql -U system -p 54321 -d test
ksql (V8.0)
Type "help" for help.

test=# select sys_postmaster_start_time;
sys_postmaster_start_time
-------------------------------
2023-01-29 00:34:32.041332-08
(1 row)

test=# select sysdate()-sys_postmaster_start_time() as uptime;
uptime
-------------------------------
+000000000 00:01:15.958668000
(1 row)
  • 数据库日志检查
egrep 'error|failed|错误' $data/sys_log/_.log
  • core 日志检查
ll ../data/core_

2.空间检查

  • 数据库数据文件检查

    主要检查 data 目录下的数据文件和 wal 日志文件

du -sh data/*

归档日志定时清除

grep '^archive_command' data/pg.conf

#!/bin/bash
archive_dir='/data/test/archive_dir'
while true;
do
rm -rf ${archive_dir}/_
sleep 300
done

3.数据一致性检查

检查 benchmarksql 执行完成后数据是否出现错乱

Select w_id, w_ytd from warehouse except(select d_w_id, sum(d_ytd) from district group by d_w_id);
Select d_w_id, d_id, D_NEXT_O_ID - 1 from district except (select o_w_id, o_d_id, max(o_id) from oorder group by o_w_id, o_d_id);
Select d_w_id, d_id, D_NEXT_O_ID - 1 from district except (select no_w_id, no_d_id, max(no_o_id) from new_order group by no_w_id, no_d_id);
select _ from (select (count(no_o_id)-(max(no_o_id)-min(no_o_id)+1)) as diff from new_order group by no_w_id, no_d_id) where diff != 0;
select o_w_id, o_d_id, sum(o_ol_cnt) from oorder group by o_w_id, o_d_id except (select ol_w_id, ol_d_id, count(ol_o_id) from order_line group by ol_w_id, ol_d_id);
select d_w_id, sum(d_ytd) from district group by d_w_id except(Select w_id, w_ytd from warehouse);

如果结果全为 0 行,则说明 tpcc 库是一致的,否则说明此库在运行过程中数据出现混乱。

4.benchmarksql 运行报告

生成 benchmarksql 报告需要提前安装 R,主要观察运行期间 tpmc 是否平稳。

cd benchmarksql-5.0/run
./generateReport.sh my_result_2023_01_29_150035/

https://i-blog.csdnimg.cn/blog_migrate/0118e0057f0b39e9f76ccc4fe465bcf3.png#pic_center