使用GBASE南大通用负载均衡连接池

若要使用负载均衡连接池功能,需要在连接串中配置相关的关键字。有关更详细的关键字信息在 GBASE南大通用 连接参数表‛中介绍。假设存在如下场景:

 现有集群中存在 4 个节点:

192.168.9.173, 192.168.9.174, 192.168.9.175, 192.168.9.176

 客户端开启负载均衡连接池,设置连接串参数如下:

server=192.168.9.173;user id=gbase;password=gbase20110531;

database=test;pooling=true;min idle size=20;max idle size=40;

gclusterid=g1;failover=true; initial pool size=20;

iplist=192.168.9.174,192.168.9.175,192.168.9.176;

test on borrow=true;test on return=true;test while idle=true;

load balance strategy=polling;max inuse lifetime=0;

 客户端使用 GBaseConnection 通过上述连接串进行初始化,并打开连接后。GBASE南大通用驱动会在集群的每个节点上创建 5 个连接,并缓存起来,并以polling(轮询)的方式先从 173 节点获取缓存连接。

注:当某个连接请求访问 173 节点时,接口在 173 节点上获取缓存连接后,若发现 173 节点故障,会尝试获取 174 节点的缓存连接,若发现 174 节点故障,会尝试获取 175 节点缓存连接,直到获取到 176 节点的缓存连接。如果所有节点都不可用,则会在默认超时时间后抛出异常。

C# 示例:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Diagnostics;

using System.Data;

using GBase.Data.GBaseClient;

namespace UsingAdoNet

{

class Program

{

public int _finish = 0;

public int _thread = 20;

public int _runTime = 500;

static void Main(string[] args)

{

string enableNewPoolStr =

"server=192.168.9.173;user id=gbase;password=gbase20110531;"+

"pooling=true;Connection lifetime=0;min idle size=20;max idle

size=40;"+

"gclusterid=g1;failover=true;iplist=192.168.9.174,192.168.9.175,

192.168.9.176;"+

"checkout timeout=0;initial pool size=24;max active size=2000;"+

"max idle lifetime=2880000;"+

"test on borrow=true;test on return=true;test while idle=true;"+

"invalid idle test period=30;supply idle period=20;load balance

strategy=polling;max inuse lifetime=0;";

相关推荐
杨云龙UP20 分钟前
ODA服务器RAC节点2/u01分区在线扩容操作记录及后续处理流程(Linux LVM + ext4 文件系统在线扩容操作手册)_20260307
linux·运维·服务器·数据库·ubuntu·centos
parafeeee7 小时前
程序人生-Hello’s P2P
数据库·后端·asp.net
欲买桂花同载酒5827 小时前
程序人生-Hello’s P2P
运维·服务器·数据库
iPadiPhone7 小时前
流量洪峰下的数据守护者:InnoDB MVCC 全实现深度解析
java·数据库·mysql·面试
NineData7 小时前
AI时代的数据对比:DBA还需要盯着屏幕看差异吗?
运维·数据库
Javatutouhouduan8 小时前
SpringBoot整合reids:JSON序列化文件夹操作实录
java·数据库·redis·html·springboot·java编程·java程序员
QWQ___qwq8 小时前
Spring Security + MyBatis-Plus 实现自定义数据库用户认证
数据库·spring·mybatis
Filotimo_9 小时前
Java后端开发标准流程:从数据库到接口的完整实现
数据库·oracle
泯仲9 小时前
从零起步学习MySQL 第一章:初识MySQL及深入理解内部数据类型
数据库·mysql
有想法的py工程师9 小时前
PostgreSQL 触发器性能评估实战(pg_stat_user_functions)
数据库·postgresql