使用benchmarksql工具对数据库进行稳定性测试过程中,生成测试报告需要依赖R语言,本文记录R安装部署与benchmarksql生成测试报告。
一、R语言安装
R语言安装选择的是R-3.6.3,之前安装R-4.2版本发现存在兼容性问题,导致benchmarksql中OS收集脚本os_collector_linux.py无法收集。
- R安装包下载
https://mirror.bjtu.edu.cn/cran/src/base/R-3/
- 上传至服务器,并解压
tar -xf R-3.6.3.tar.gz
- 编译安装
[root@localhost R]# cd R-3.6.3/
[root@localhost R-3.6.3]# ./configure && make && make install
- 验证
[root@localhost R-3.6.3]# R --version
R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
[root@localhost R-3.6.3]# R
> capabilities()
jpeg png tiff tcltk X11 aqua
TRUE TRUE TRUE FALSE TRUE FALSE
http/ftp sockets libxml fifo cledit iconv
TRUE TRUE TRUE TRUE TRUE TRUE
NLS profmem cairo ICU long.double libcurl
TRUE FALSE FALSE FALSE TRUE TRUE
二、异常处理
异常1:configure: error: No Fortran compiler found
解决措施:yum -y install gcc-gfortran
异常2:configure: error: C++ preprocessor "/lib/cpp" fails sanity check
解决措施:yum install gcc-c++
异常3: configure: error: --with-readline=yes (default) and headers/libs are not available
解决措施:yum -y install readline readline-devel readline-static
异常4: configure: error: --with-x=yes (default) and X11 headers/libs are not available
解决措施:yum -y install xorg-x11-server-devel libX11-devel libXt-devel
异常5: configure: error: zlib library and headers are required
解决措施:yum -y install bzip2-devel
异常6: configure:error: pcre >= 8.20 library and headers are required
解决措施:
yum install -y pcre pcre-devel
异常7: configure: error: libcurl >= 7.22.0 library and headers are required with support for https
解决措施:
下载:https://curl.haxx.se/download/curl-7.47.1.tar.gz
上传解压:tar -xf curl-7.47.1.tar.gz
编译安装:
cd curl*
./configure
make && make install
异常8: configure: WARNING: neither inconsolata.sty nor zi4.sty found: PDF vignettes and package manuals will not be rendered optimally
解决措施:
下载:http://mirrors.ctan.org/fonts/inconsolata.zip
上传解压:unzip inconsolata.zip
拷贝安装:
[root@localhost R]# cp -Rfp inconsolata/* /usr/share/texmf/
[root@localhost R]# mktexlsr
mktexlsr: Updating /usr/share/texlive/texmf/ls-R…
mktexlsr: Updating /usr/share/texlive/texmf-config/ls-R…
mktexlsr: Updating /usr/share/texlive/texmf-dist/ls-R…
mktexlsr: Updating /usr/share/texlive/texmf-local///ls-R…
mktexlsr: Updating /usr/share/texlive/texmf-var/ls-R…
mktexlsr: Done.
验证:
cd R*
./configure
异常8: capabilities() jpeg png tiff tcltk X11 aqua FALSE FALSE FALSE FALSE FALSE FALSE
解决措施:先解决终端x11为false,卸载R(which R -> rm -rf /usr/local/bin/R)重新编译安装。或者选择MobaXterm终端(setting->X11->X11 remote access->full),进行编译安装。
异常9: gcc -std=gnu99 -I"/home/test/R/R-3.6.3/include" -DNDEBUG -I/usr/local/include -fpic -g -O2 -c conftest.c -o conftest.o conftest.c:1:17: fatal error: jni.h: No such file or directory
解决措施:安装javac: yum -y install java-1.8.0-openjdk-devel.x86_64
三、使用R绘制benchmarksql结果
- benchmarksql配置文件
conn=jdbc:kingbase8://127.0.0.1:52222/test #数据库端口及database
user=system #测试用户
warehouses=5 #数据仓数
loadWorkers=5 #灌数加载并发数
terminals=5 #压测并发数
runMins=5 #压测时间
limitTxnsPerMin=0
terminalWarehouseFixed=true
newOrderWeight=45
paymentWeight=43
orderStatusWeight=4
deliveryWeight=4
stockLevelWeight=4
resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS #结果收集日志目录
osCollectorScript=./misc/os_collector_linux.py #结果收集脚本
osCollectorInterval=1 #数据采集间隔
osCollectorDevices=net_ens33 blk_sda #采集网口名(ip addr)和磁盘名(lsblk)
- 灌数
$benchmarksql/run/runDatabaseBuild.sh props.pg
- 压测
$benchmarksql/run/runBenchmark.sh props.kb
- 解析结果
chmod +x generateReport.sh
chmod +x generateGraphs.sh
./generateReport.sh my_result_2024-08-09_054647/
- 查看tpmc结果