使用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;";

相关推荐
JIngJaneIL12 小时前
助农惠农服务平台|助农服务系统|基于SprinBoot+vue的助农服务系统(源码+数据库+文档)
java·前端·数据库·vue.js·论文·毕设·助农惠农服务平台
云外天ノ☼12 小时前
待办事项全栈实现:Vue3 + Node.js (Koa) + MySQL深度整合,构建生产级任务管理系统的技术实践
前端·数据库·vue.js·mysql·vue3·koa·jwt认证
小光学长13 小时前
基于Vue的智慧楼宇报修平台设计与实现066z15wb(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
前端·数据库·vue.js
CodeBlossom13 小时前
Spring Cache快速入门
java·数据库·spring
tuokuac13 小时前
ps -ef | grep redis
数据库·redis·缓存
⑩-13 小时前
如何保证Redis和Mysql数据缓存一致性?
java·数据库·redis·mysql·spring·缓存·java-ee
征尘bjajmd14 小时前
Java使用okhttp发送get、post请求
java·服务器·数据库
清风66666614 小时前
基于单片机的智能高温消毒与烘干系统设计
数据库·单片机·嵌入式硬件·毕业设计·课程设计·期末大作业
Databend14 小时前
Databend 十月月报:存储过程正式可用,数据流程全面自动化
数据库
wangjialelele14 小时前
MySQL操作库
数据库·mysql·oracle