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

相关推荐
IT成长日记2 小时前
【MySQL基础】聚合函数从基础使用到高级分组过滤
数据库·mysql·聚合函数
Guarding and trust3 小时前
python系统之综合案例:用python打造智能诗词生成助手
服务器·数据库·python
夜间出没的AGUI3 小时前
SQLiteBrowser 的详细说明,内容结构清晰,涵盖核心功能、使用场景及实用技巧
数据库
不再幻想,脚踏实地4 小时前
MySQL(一)
java·数据库·mysql
Tyler先森5 小时前
Oracle数据库数据编程SQL<3.5 PL/SQL 存储过程(Procedure)>
数据库·sql·oracle
KevinRay_6 小时前
从零开始学习SQL
数据库·学习·mysql
Json_181790144807 小时前
python采集淘宝拍立淘按图搜索API接口,json数据示例参考
服务器·前端·数据库
Albert Tan7 小时前
Oracle 10G DG 修复从库-磁盘空间爆满导致从库无法工作
数据库·oracle
好记忆不如烂笔头abc7 小时前
oracle-blob导出,在ob导入失败
大数据·数据库·python