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

相关推荐
恣艺10 小时前
Redis是什么?一篇讲透它的定位、特点与应用场景
数据库·redis·缓存
天天爱吃肉821810 小时前
【比亚迪璇玑架构深度解析:重新定义智能电动汽车的“整车智能”】
数据库·人工智能·嵌入式硬件·架构·汽车
一成码农10 小时前
MySQL问题8
数据库·mysql
axban10 小时前
QT M/V架构开发实战:M/V架构的初步认识
开发语言·数据库·qt
Dontla10 小时前
Docker Compose healthcheck介绍(监控容器中服务的实际健康状态)数据库健康检查pg_isready
数据库·docker·容器
semantist@语校10 小时前
第十九篇|东京世界日本语学校的结构数据建模:制度函数、能力矩阵与升学图谱
数据库·人工智能·线性代数·矩阵·prompt·github·数据集
数巨小码人10 小时前
Oracle SQL调优技巧实战指南
数据库·sql·oracle
noravinsc10 小时前
在银河麒麟v10上安装达梦8数据库
服务器·数据库·oracle
没有bug.的程序员11 小时前
Redis 内存优化与压缩:从原理到实战的完整指南
java·数据库·redis·内存优化·压缩内存
肃清111 小时前
《Redis核心机制解析》
数据库·redis·缓存