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

相关推荐
2601_966377136 分钟前
运营商密评密改落地实践:透明加密解决密码应用合规与安全痛点
数据库·安全·oracle
伯恩bourne11 分钟前
Qdrant 快速入门 :数据模型介绍
服务器·数据库·人工智能
AgentMaster26 分钟前
元数据、血缘、质量、安全四大模块能力拆解,数据治理方案对比:4 种技术路线深度评测
大数据·数据库·数据仓库·人工智能·原型模式
tryxr31 分钟前
Redis 的背景知识
数据库·redis·缓存
IvorySQL1 小时前
PostgreSQL 日报 |SUM-AVG 溢出检测不足(9 月 5 日)
数据库·postgresql·区块链
2601_962099081 小时前
python flask sqlalchemy连接数据库流程介绍
数据库·python·flask·教程·sqlalchemy
TDengine (老段)1 小时前
TDgpt 概览 — AI 增强的时序数据库
大数据·数据库·人工智能·物联网·时序数据库·iot·tdengine
2501_933670791 小时前
采购运营校招Excel能力清单:函数、透视表、ERP数据与SQL入门
数据库·sql·excel
YOLO数据集集合1 小时前
红外热成像人员检测数据集 |红外检测 白热模式 人员检测 夜间监控 目标检测 YOLO格式 深度学习数据集 计算机视觉9067期
数据库·深度学习·yolo·目标检测·计算机视觉·红外人员·红外数据
BUG指挥官1 小时前
Redis已接入AI
数据库·人工智能·spring boot·redis·spring cloud