本文档的步骤均使用root用户操作。
1. 环境准备
1.1 操作系统及软件包
OS:kylin v10 sp3
软件包:R-4.6.1.tar.gz、benchmarksql-5.0-master.zip
1.2 安装依赖
yum安装如下依赖:
yum install -y python2
yum install -y java-1.8.0 java-devel
yum install -y ant
yum install -y xz-devel
yum install -y pcre2-devel pcre2-tools
yum install -y libcurl-devel
yum install -y readline-devel
yum install -y libX11-devel libXt-devel xorg-x11-server-devel
yum install -y libpng libpng-devel libtiff libtiff-devel libjpeg-turbo libjpeg-turbo-devel
yum install -y bzip2
编译安装R语言环境:
tar -xvf R-4.6.1.tar.gz
cd R-4.6.1
./configure --prefix=/home/kingbase/R
make && make install
安装后检查:
[root@ecs-kfxb41hgb3in6w R-4.6.1]# R
R version 4.6.1 (2026-06-24) -- "Happy Hop"
Copyright (C) 2026 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> capabilities()
jpeg png tiff tcltk X11 aqua
TRUE TRUE TRUE FALSE TRUE FALSE
http/ftp sockets libxml fifo cledit iconv
TRUE TRUE FALSE TRUE TRUE TRUE
NLS Rprof profmem cairo ICU long.double
TRUE TRUE FALSE TRUE TRUE TRUE
libcurl
TRUE
> png()
> q()
Save workspace image? [y/n/c]: n
其中X11应为true,否则后续html报告无法生成。
2. benchmarksql安装和配置
2.1 解压
unzip benchmarksql-5.0-master.zip
cd benchmarksql-5.0-master
2.2 适配金仓
修改源码使其适配金仓:
vi /home/kingbase/benchmarksql-5.0-master/src/client/jTPCC.java
检索oracle
可以看到:
if (iDB.equals("firebird"))
dbType = DB_FIREBIRD;
else if (iDB.equals("oracle"))
dbType = DB_ORACLE;
else if (iDB.equals("postgres"))
dbType = DB_POSTGRES;
在下方添加:
else if (iDB.equals("kingbase"))
dbType = DB_UNKNOWN;
最终效果:
if (iDB.equals("firebird"))
dbType = DB_FIREBIRD;
else if (iDB.equals("oracle"))
dbType = DB_ORACLE;
else if (iDB.equals("postgres"))
dbType = DB_POSTGRES;
else if (iDB.equals("kingbase"))
dbType = DB_UNKNOWN;
else
{
log.error("unknown database type '" + iDB + "'");
return;
}
2.3 添加驱动
增加kingbase的jdbc驱动,放到lib目录下。
注:驱动从官网下载,或从单机版软件中拷贝
[root@ecs-kfxb41hgb3in6w kingbase]# ll
total 6820
-rw-r--r-- 1 root root 1211760 Sep 15 18:06 kingbase8-8.6.0.jar
-rw-r--r-- 1 root root 1066868 Sep 15 18:06 kingbase8-8.6.0.jre6.jar
-rw-r--r-- 1 root root 1206857 Sep 15 18:06 kingbase8-8.6.0.jre7.jar
-rw-r--r-- 1 root root 1213216 Sep 15 18:06 postgresql-42.2.9.jar
-rw-r--r-- 1 root root 1068061 Sep 15 18:06 postgresql-42.2.9.jre6.jar
-rw-r--r-- 1 root root 1208316 Sep 15 18:06 postgresql-42.2.9.jre7.jar
[root@ecs-kfxb41hgb3in6w kingbase]# pwd
/home/kingbase/benchmarksql-5.0-master/lib/kingbase
修改脚本配置驱动路径:
vi /home/kingbase/benchmarksql-5.0-master/run/funcs.sh
检索getCP
可以看到
function setCP()
{
case "$(getProp db)" in
firebird)
cp="../lib/firebird/*:../lib/*"
;;
oracle)
cp="../lib/oracle/*"
if [ ! -z "${ORACLE_HOME}" -a -d ${ORACLE_HOME}/lib ] ; then
cp="${cp}:${ORACLE_HOME}/lib/*"
fi
cp="${cp}:../lib/*"
;;
postgres)
cp="../lib/postgres/*:../lib/*"
;;
esac
myCP=".:${cp}:../dist/*"
export myCP
}
添加如下内容:
kingbase)
cp="../lib/kingbase/*:../lib/*"
;;
最终效果:
# ----
# getCP()
#
# Determine the CLASSPATH based on the database system.
# ----
function setCP()
{
case "$(getProp db)" in
firebird)
cp="../lib/firebird/*:../lib/*"
;;
oracle)
cp="../lib/oracle/*"
if [ ! -z "${ORACLE_HOME}" -a -d ${ORACLE_HOME}/lib ] ; then
cp="${cp}:${ORACLE_HOME}/lib/*"
fi
cp="${cp}:../lib/*"
;;
postgres)
cp="../lib/postgres/*:../lib/*"
;;
kingbase)
cp="../lib/kingbase/*:../lib/*"
;;
esac
myCP=".:${cp}:../dist/*"
export myCP
}
2.4 编译打包
在有build.xml文件的根目录下输入 ant。
完成后/dist/下会生成一个jar包:/home/kingbase/benchmarksql-5.0-master/dist/BenchmarkSQL-5.0.jar
[root@ecs-kfxb41hgb3in6w benchmarksql-5.0-master]# ant
Buildfile: /home/kingbase/benchmarksql-5.0-master/build.xml
init:
compile:
[javac] Compiling 11 source files to /home/kingbase/benchmarksql-5.0-master/build
dist:
[jar] Building jar: /home/kingbase/benchmarksql-5.0-master/dist/BenchmarkSQL-5.0.jar
BUILD SUCCESSFUL
Total time: 2 seconds
3. TPC-C测试
3.1 配置基准测试控制文件
cp props.pg props.kingbase
vi props.kingbase
配置如下:
db=kingbase
driver=com.kingbase8.Driver
conn=jdbc:kingbase8://localhost:54321/test
user=system
password=123456
warehouses=10
loadWorkers=4
terminals=10
//To run specified transactions per terminal- runMins must equal zero
runTxnsPerTerminal=0
//To run for specified minutes- runTxnsPerTerminal must equal zero
runMins=3
//Number of total transactions per minute
limitTxnsPerMin=300
//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=1
//osCollectorSSHAddr=user@dbhost
osCollectorDevices=net_eth0 blk_vdb
本次测试仅开了10仓、10个并发,后续可逐步增加
本次磁盘是vdb
3.2 添加数据
添加数据命令:
[root@ecs-kfxb41hgb3in6w run]# ./runDatabaseBuild.sh props.kingbase
如果要清理刚创建的数据库则使用如下脚本
[root@ecs-kfxb41hgb3in6w run]# ./runDatabaseDestroy.sh props.kingbase
3.3 正式测试
开始测试:./runBenchmark.sh props.kingbase
[root@ecs-kfxb41hgb3in6w run]# ./runBenchmark.sh props.kingbase
18:29:48,379 [main] INFO jTPCC : Term-00,
18:29:48,383 [main] INFO jTPCC : Term-00, +-------------------------------------------------------------+
18:29:48,383 [main] INFO jTPCC : Term-00, BenchmarkSQL v5.0
18:29:48,383 [main] INFO jTPCC : Term-00, +-------------------------------------------------------------+
18:29:48,383 [main] INFO jTPCC : Term-00, (c) 2003, Raul Barbosa
18:29:48,383 [main] INFO jTPCC : Term-00, (c) 2004-2016, Denis Lussier
18:29:48,386 [main] INFO jTPCC : Term-00, (c) 2016, Jan Wieck
18:29:48,386 [main] INFO jTPCC : Term-00, +-------------------------------------------------------------+
18:29:48,386 [main] INFO jTPCC : Term-00,
18:29:48,386 [main] INFO jTPCC : Term-00, db=kingbase
18:29:48,386 [main] INFO jTPCC : Term-00, driver=com.kingbase8.Driver
18:29:48,386 [main] INFO jTPCC : Term-00, conn=jdbc:kingbase8://localhost:54321/test
18:29:48,387 [main] INFO jTPCC : Term-00, user=system
18:29:48,387 [main] INFO jTPCC : Term-00,
18:29:48,387 [main] INFO jTPCC : Term-00, warehouses=20
18:29:48,387 [main] INFO jTPCC : Term-00, terminals=10
18:29:48,389 [main] INFO jTPCC : Term-00, runMins=3
18:29:48,389 [main] INFO jTPCC : Term-00, limitTxnsPerMin=300
18:29:48,389 [main] INFO jTPCC : Term-00, terminalWarehouseFixed=true
18:29:48,389 [main] INFO jTPCC : Term-00,
18:29:48,389 [main] INFO jTPCC : Term-00, newOrderWeight=45
18:29:48,389 [main] INFO jTPCC : Term-00, paymentWeight=43
18:29:48,389 [main] INFO jTPCC : Term-00, orderStatusWeight=4
18:29:48,389 [main] INFO jTPCC : Term-00, deliveryWeight=4
18:29:48,390 [main] INFO jTPCC : Term-00, stockLevelWeight=4
18:29:48,390 [main] INFO jTPCC : Term-00,
18:29:48,390 [main] INFO jTPCC : Term-00, resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
18:29:48,390 [main] INFO jTPCC : Term-00, osCollectorScript=./misc/os_collector_linux.py
18:29:48,390 [main] INFO jTPCC : Term-00,
18:29:48,418 [main] INFO jTPCC : Term-00, copied props.kingbase to my_result_2026-09-15_182948/run.properties
18:29:48,418 [main] INFO jTPCC : Term-00, created my_result_2026-09-15_182948/data/runInfo.csv for runID 9
18:29:48,419 [main] INFO jTPCC : Term-00, writing per transaction results to my_result_2026-09-15_182948/data/result.csv
18:29:48,419 [main] INFO jTPCC : Term-00, osCollectorScript=./misc/os_collector_linux.py
18:29:48,420 [main] INFO jTPCC : Term-00, osCollectorInterval=1
18:29:48,420 [main] INFO jTPCC : Term-00, osCollectorSSHAddr=null
18:29:48,420 [main] INFO jTPCC : Term-00, osCollectorDevices=net_eth0 blk_sda
18:29:48,507 [main] INFO jTPCC : Term-00,
18:29:48,854 [main] INFO jTPCC : Term-00, C value for C_LAST during load: 138
18:29:48,854 [main] INFO jTPCC : Term-00, C value for C_LAST this run: 211
18:29:48,854 [main] INFO Term-00, Running Average tpmTOTAL: 300.56 Current tpmTOTAL: 5760 Memory Usage: 14MB / 120MB 18:32:52,032 [Thread-2] INFO jTPCC : Term-00,
18:32:52,032 [Thread-2] INFO jTPCC : Term-00,
18:32:52,032 [Thread-2] INFO jTPCC : Term-00, Measured tpmC (NewOrders) = 140.39
18:32:52,032 [Thread-2] INFO jTPCC : Term-00, Measured tpmTOTAL = 297.26
18:32:52,032 [Thread-2] INFO jTPCC : Term-00, Session Start = 2026-09-15 18:29:49
18:32:52,033 [Thread-2] INFO jTPCC : Term-00, Session End = 2026-09-15 18:32:52
18:32:52,033 [Thread-2] INFO jTPCC : Term-00, Transaction Count = 901
3.4 生成报告
会生成一个html报告,下载到本地后查看。其中报告的命名统一按照tpc-c测试结果编号命名。
[root@ecs-kfxb41hgb3in6w run]# ./generateReport.sh my_result_2026-09-15_183902
Generating my_result_2026-09-15_183902/tpm_nopm.png ... OK
Generating my_result_2026-09-15_183902/latency.png ... OK
Generating my_result_2026-09-15_183902/cpu_utilization.png ... OK
Generating my_result_2026-09-15_183902/dirty_buffers.png ... OK
Generating my_result_2026-09-15_183902/blk_vdb_iops.png ... OK
Generating my_result_2026-09-15_183902/blk_vdb_kbps.png ... OK
Generating my_result_2026-09-15_183902/net_eth0_iops.png ... OK
Generating my_result_2026-09-15_183902/net_eth0_kbps.png ... OK
Generating my_result_2026-09-15_183902/report.html ... OK
最后修改时间:2026-10-08 09:45:37
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




