案例说明:
通过jmeter压测,测试KingbaseES RAC集群负载均衡功能。
数据库版本:
test=# select version();
version
---------------------
KingbaseES V008R006
(1 row)
测试架构:
一、jmeter版本
1、系统jiava版本
[root@node203 ~]# java -version
openjdk version "1.8.0_412"
OpenJDK Runtime Environment (build 1.8.0_412-b08)
OpenJDK 64-Bit Server VM (build 25.412-b08, mixed mode)
2、jmeter java配置
[root@node203 ~]# cat /etc/profile
export JMETER_HOME=/soft/apache-jmeter-5.6.3
export PATH=$JMETER_HOME/bin:$PATH
export CLASSPATH=$JMETER_HOME/lib/ext/ApacheJMeter_core.jar:$JMETER_HOME/lib/jorphan.jar:$CLASSPATH
3、jmeter版本
[root@node203 bin]# ./jmeter -v
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
_ ____ _ ____ _ _ _____ _ __ __ _____ _____ _____ ____
/ \ | _ \ / \ / | | | | | | | / | | | | _
/ _ \ | |) / _ | | | || | | _ | | |/| | | | | | | | |) |
/ ___ | / ___ \ || _ | | | || | | | | | | | | || _ <
// __| // __|| ||___| _/|| ||_____| || |_____|_| _\ 5.6.3
Copyright (c) 1999-2024 The Apache Software Foundation
二、jmeter配置
1、配置jar驱动接口
如下所示,将数据库jdbc下的jar包拷贝到jmeter的lib目录下:
# 拷贝数据库jar包到jmeter
[root@node209 KingbaseHA]# cd /opt/Kingbase/ES/V8/Interface/jdbc/
[root@node209 jdbc]# ls -lh kingbase8-8.6.0.j*
-rw-rw-r-- 1 kingbase kingbase 1.2M Nov 12 11:09 kingbase8-8.6.0.jar
-rw-rw-r-- 1 kingbase kingbase 1.1M Nov 12 11:09 kingbase8-8.6.0.jre6.jar
-rw-rw-r-- 1 kingbase kingbase 1.2M Nov 12 11:09 kingbase8-8.6.0.jre7.jar
[root@node209 jdbc]# scp kingbase8-8.6.0.j* 192.168.1.203:/soft/apache-jmeter-5.2.1/lib/
root@192.168.1.203's password:
# 查看jmeter下的jar包
[root@node203 ~]# cd /soft/apache-jmeter-5.6.3/lib/
[root@node203 lib]# ls -lh kingbase8-8.*
-rw-r--r-- 1 root root 787K Jan 14 18:06 kingbase8-8.2.0.jar
-rw-r--r-- 1 root root 1.2M Jan 14 18:06 kingbase8-8.6.0.jar
-rw-r--r-- 1 root root 1.1M Jan 14 18:06 kingbase8-8.6.0.jre6.jar
-rw-r--r-- 1 root root 1.2M Jan 14 18:06 kingbase8-8.6.0.jre7.jar
2、启动jmeter
3、配置thread group
4、配置jdbc连接
如下所示,jdbc url连接串(其中:192.168.1.208,192.168.1.209为数据库节点物理ip,以下为负载均衡配置):
jdbc:kingbase8://192.168.1.208::54321,192.168.1.209::54321/prod?targetServerType=master&loadBalanceHosts=true&hostRecheckSeconds=240
5、配置jdbc request
6、配置view results tree(结果查询)
压测结果:
7、配置测试结果汇总
8、jmeter配置汇总
如下所示,jdbc url连接串中192.168.1.11,192.168.1.12分别为在集群两个节点上的vip(手工加载):
<JDBCDataSource guiclass="TestBeanGUI" testclass="JDBCDataSource" testname="kingbaseRAC">
<boolProp name="autocommit">true</boolProp>
<stringProp name="checkQuery"></stringProp>
<stringProp name="connectionAge">5000</stringProp>
<stringProp name="connectionProperties"></stringProp>
<stringProp name="dataSource">kingbaseRAC</stringProp>
<stringProp name="dbUrl">jdbc:kingbase8://192.168.1.11:54321,192.168.1.12:54321/prod?targetServerType=master&loadBalanceHosts=true&hostRecheckSeconds=240</stringProp>
<stringProp name="driver">com.kingbase8.Driver</stringProp>
<stringProp name="initQuery"></stringProp>
<boolProp name="keepAlive">true</boolProp>
<stringProp name="password">123456</stringProp>
<stringProp name="poolMax">0</stringProp>
<boolProp name="preinit">false</boolProp>
<stringProp name="timeout">10000</stringProp>
<stringProp name="transactionIsolation">DEFAULT</stringProp>
<stringProp name="trimInterval">60000</stringProp>
<stringProp name="username">system</stringProp>
</JDBCDataSource>
三、负载均衡测试结果
如下所示,在jmeter启动20个thread压测,其中集群两个节点负载分配如下,一个节点客户端的连接数为11,另外一个节点为9,基本实现了集群的负载均衡:
集群状态:
1、查看节点一客户端连接进程
2、统计客户端访问数据库进程
node208:
node209: