欢迎光临
我们一直在努力

Oracle数据库负载均衡:流量指挥官的调度艺术

Oracle数据库负载均衡:流量指挥官的调度艺术

前言

在前几篇文章中,我们构建了一个强大的Oracle RAC集群,并为其配置了ASM存储。然而,仅仅搭建好集群还不够。如果所有用户请求都涌向某一个节点,而其他节点闲置,那么我们花大价钱搭建的集群就失去了意义。

这时,负载均衡(Load Balancing)就成为发挥RAC集群价值的核心技术。它像一个智能的流量指挥官,将数以万计的数据库连接请求,科学、合理地分发到集群的各个节点上,确保所有资源被充分利用,系统整体吞吐量达到最优。本文将全面解析Oracle数据库在多层面实现负载均衡的策略与配置。

1. 负载均衡的实现层次

在Oracle生态中,负载均衡不是一个单一的技术,而是贯穿在客户端连接、网络服务、集群服务和应用程序连接池等多个层面的立体化解决方案。

#publish-mermaid-1784268287118-0{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-1784268287118-0 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-1784268287118-0 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-1784268287118-0 .error-icon{fill:#552222;}#publish-mermaid-1784268287118-0 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-1784268287118-0 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-1784268287118-0 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-1784268287118-0 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-1784268287118-0 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-1784268287118-0 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-1784268287118-0 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-1784268287118-0 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-1784268287118-0 .marker.cross{stroke:#333333;}#publish-mermaid-1784268287118-0 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-1784268287118-0 p{margin:0;}#publish-mermaid-1784268287118-0 .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#publish-mermaid-1784268287118-0 .cluster-label text{fill:#333;}#publish-mermaid-1784268287118-0 .cluster-label span{color:#333;}#publish-mermaid-1784268287118-0 .cluster-label span p{background-color:transparent;}#publish-mermaid-1784268287118-0 .label text,#publish-mermaid-1784268287118-0 span{fill:#333;color:#333;}#publish-mermaid-1784268287118-0 .node rect,#publish-mermaid-1784268287118-0 .node circle,#publish-mermaid-1784268287118-0 .node ellipse,#publish-mermaid-1784268287118-0 .node polygon,#publish-mermaid-1784268287118-0 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#publish-mermaid-1784268287118-0 .rough-node .label text,#publish-mermaid-1784268287118-0 .node .label text,#publish-mermaid-1784268287118-0 .image-shape .label,#publish-mermaid-1784268287118-0 .icon-shape .label{text-anchor:middle;}#publish-mermaid-1784268287118-0 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#publish-mermaid-1784268287118-0 .rough-node .label,#publish-mermaid-1784268287118-0 .node .label,#publish-mermaid-1784268287118-0 .image-shape .label,#publish-mermaid-1784268287118-0 .icon-shape .label{text-align:center;}#publish-mermaid-1784268287118-0 .node.clickable{cursor:pointer;}#publish-mermaid-1784268287118-0 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#publish-mermaid-1784268287118-0 .arrowheadPath{fill:#333333;}#publish-mermaid-1784268287118-0 .edgePath .path{stroke:#333333;stroke-width:1px;}#publish-mermaid-1784268287118-0 .flowchart-link{stroke:#333333;fill:none;}#publish-mermaid-1784268287118-0 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-1784268287118-0 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#publish-mermaid-1784268287118-0 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-1784268287118-0 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#publish-mermaid-1784268287118-0 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#publish-mermaid-1784268287118-0 .cluster text{fill:#333;}#publish-mermaid-1784268287118-0 .cluster span{color:#333;}#publish-mermaid-1784268287118-0 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#publish-mermaid-1784268287118-0 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#publish-mermaid-1784268287118-0 rect.text{fill:none;stroke-width:0;}#publish-mermaid-1784268287118-0 .icon-shape,#publish-mermaid-1784268287118-0 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-1784268287118-0 .icon-shape p,#publish-mermaid-1784268287118-0 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#publish-mermaid-1784268287118-0 .icon-shape .label rect,#publish-mermaid-1784268287118-0 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-1784268287118-0 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#publish-mermaid-1784268287118-0 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#publish-mermaid-1784268287118-0 .node .neo-node{stroke:#9370DB;}#publish-mermaid-1784268287118-0 [data-look=\”neo\”].node rect,#publish-mermaid-1784268287118-0 [data-look=\”neo\”].cluster rect,#publish-mermaid-1784268287118-0 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1784268287118-0 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-1784268287118-0 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-1784268287118-0 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1784268287118-0 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-1784268287118-0 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1784268287118-0 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-1784268287118-0 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1784268287118-0 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1784268287118-0 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}负载均衡实现层次

4. 应用连接池层WebLogic/Tomcat Pool

3. RAC服务层Server-Side Load Balancing

2. Oracle Net层Client-Side Load Balancing

1. 网络/硬件层F5/LVS

2. 第一层:客户端负载均衡(Client-Side LB)

2.1 原理

这是最基础、最早出现的负载均衡方式。它通过在客户端(或应用服务器)的tnsnames.ora文件中配置多个监听器地址来实现。客户端在发起连接时,会随机或按顺序选择一个地址进行尝试。

2.2 配置示例

# $ORACLE_HOME/network/admin/tnsnames.ora
ORCL_RAC =
(DESCRIPTION =
(LOAD_BALANCE = ON) — 开启客户端负载均衡
(FAILOVER = ON) — 开启故障转移
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = node1-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = node3-vip)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl_service)
)
)

当LOAD_BALANCE=ON时,客户端会随机选择一个ADDRESS进行连接。如果连接失败,FAILOVER=ON会驱动客户端尝试列表中的下一个地址。

2.3 局限性

客户端负载均衡是“随机的”,而非“智能的”。它完全不考虑集群中各个节点的真实负载。可能节点1已经不堪重负,但客户端仍然随机选择它,而节点3非常空闲却无人问津。

3. 第二层:服务端负载均衡(Server-Side LB via SCAN)

3.1 原理

这是Oracle RAC 11g R2引入的革命性特性,通过SCAN(Single Client Access Name,单一客户端访问名称)实现。

SCAN是集群的一个统一访问入口域名,一般配置为3个IP地址(由GNS或DNS解析)。客户端只需连接SCAN域名,SCAN Listener会感知集群中所有节点的实时负载情况(由PMON进程定期报告),然后智能地将新连接请求路由到当前负载最低的节点。

PMON进程节点监听器 (低负载节点)SCAN Listener 2SCAN Listener 1DNS/GNS客户端PMON进程节点监听器 (低负载节点)SCAN Listener 2SCAN Listener 1DNS/GNS客户端#publish-mermaid-1784268287169-1{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-1784268287169-1 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-1784268287169-1 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-1784268287169-1 .error-icon{fill:#552222;}#publish-mermaid-1784268287169-1 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-1784268287169-1 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-1784268287169-1 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-1784268287169-1 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-1784268287169-1 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-1784268287169-1 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-1784268287169-1 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-1784268287169-1 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-1784268287169-1 .marker.cross{stroke:#333333;}#publish-mermaid-1784268287169-1 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-1784268287169-1 p{margin:0;}#publish-mermaid-1784268287169-1 .actor{stroke:#9370DB;fill:#ECECFF;stroke-width:1;}#publish-mermaid-1784268287169-1 rect.actor.outer-path[data-look=\”neo\”]{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1784268287169-1 rect.note[data-look=\”neo\”]{stroke:#aaaa33;fill:#fff5ad;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1784268287169-1 text.actor>tspan{fill:black;stroke:none;}#publish-mermaid-1784268287169-1 .actor-line{stroke:#9370DB;}#publish-mermaid-1784268287169-1 .innerArc{stroke-width:1.5;stroke-dasharray:none;}#publish-mermaid-1784268287169-1 .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333;}#publish-mermaid-1784268287169-1 .messageLine1{stroke-width:1.5;stroke-dasharray:2,2;stroke:#333;}#publish-mermaid-1784268287169-1 [id$=\”-arrowhead\”] path{fill:#333;stroke:#333;}#publish-mermaid-1784268287169-1 .sequenceNumber{fill:white;}#publish-mermaid-1784268287169-1 [id$=\”-sequencenumber\”]{fill:#333;}#publish-mermaid-1784268287169-1 [id$=\”-crosshead\”] path{fill:#333;stroke:#333;}#publish-mermaid-1784268287169-1 .messageText{fill:#333;stroke:none;}#publish-mermaid-1784268287169-1 .labelBox{stroke:#9370DB;fill:#ECECFF;filter:none;}#publish-mermaid-1784268287169-1 .labelText,#publish-mermaid-1784268287169-1 .labelText>tspan{fill:black;stroke:none;}#publish-mermaid-1784268287169-1 .loopText,#publish-mermaid-1784268287169-1 .loopText>tspan{fill:black;stroke:none;}#publish-mermaid-1784268287169-1 .sectionTitle,#publish-mermaid-1784268287169-1 .sectionTitle>tspan{fill:black;stroke:none;}#publish-mermaid-1784268287169-1 .loopLine{stroke-width:2px;stroke-dasharray:2,2;stroke:#9370DB;fill:#9370DB;}#publish-mermaid-1784268287169-1 .note{stroke:#aaaa33;fill:#fff5ad;}#publish-mermaid-1784268287169-1 .noteText,#publish-mermaid-1784268287169-1 .noteText>tspan{fill:black;stroke:none;font-weight:normal;}#publish-mermaid-1784268287169-1 .activation0{fill:#f4f4f4;stroke:#666;}#publish-mermaid-1784268287169-1 .activation1{fill:#f4f4f4;stroke:#666;}#publish-mermaid-1784268287169-1 .activation2{fill:#f4f4f4;stroke:#666;}#publish-mermaid-1784268287169-1 .actorPopupMenu{position:absolute;}#publish-mermaid-1784268287169-1 .actorPopupMenuPanel{position:absolute;fill:#ECECFF;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);filter:drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));}#publish-mermaid-1784268287169-1 .actor-man circle,#publish-mermaid-1784268287169-1 line{fill:#ECECFF;stroke-width:2px;}#publish-mermaid-1784268287169-1 g rect.rect{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));stroke:#9370DB;}#publish-mermaid-1784268287169-1 .node .neo-node{stroke:#9370DB;}#publish-mermaid-1784268287169-1 [data-look=\”neo\”].node rect,#publish-mermaid-1784268287169-1 [data-look=\”neo\”].cluster rect,#publish-mermaid-1784268287169-1 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1784268287169-1 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-1784268287169-1 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-1784268287169-1 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1784268287169-1 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-1784268287169-1 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1784268287169-1 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-1784268287169-1 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1784268287169-1 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1784268287169-1 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}loop[每10秒]解析 orcl-scan.com返回3个SCAN IP (轮询)连接请求 (从3个IP中随机选)查阅本地负载信息表发现节点3负载最低重定向:请连接 node3-vip:1521直接向节点3-VIP发起连接连接建立成功更新各节点的负载和会话统计更新各节点的负载和会话统计

流程详解:

  • 客户端通过DNS解析SCAN域名,获得三个SCAN IP地址。
  • 客户端随机选择一个SCAN IP并连接。
  • SCAN Listener根据其维护的集群节点负载信息,选择当前最优的节点。
  • SCAN Listener将该节点的VIP地址返回给客户端。
  • 客户端收到重定向信息后,断开与SCAN的短暂连接,重新直接连接到目标节点的本地监听器上。
  • 这种机制完美解决了客户端负载均衡“盲目随机”的缺陷,实现了基于真实负载的智能路由。

    3.2 客户端配置

    使用SCAN后,客户端的配置变得极为简单:

    ORCL_RAC_SCAN =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = prod-scan.com)(PORT = 1521))
    (CONNECT_DATA =
    (SERVICE_NAME = orcl_service)
    )
    )

    4. 第三层:服务层面的负载均衡

    4.1 原理

    Oracle RAC允许DBA创建数据库服务(Service),将业务模块化,并为每个服务指定其运行的节点池和负载均衡目标。这是一种更细粒度的负载管理方式。

    4.2 创建服务并配置负载均衡

    # 使用srvctl创建服务
    srvctl add service -d orcl -s sales_service \\
    -r orcl1,orcl2 \\ # 首选实例
    -a orcl3 \\ # 备用实例
    -B SERVICE_TIME \\ # 基于响应时间的负载均衡
    -j SHORT # 基于会话数的负载均衡

    关键参数说明:

    • -r:Preferred instances(首选实例),服务正常时运行的实例。
    • -a:Available instances(备用实例),首选实例全部故障时才启用的实例。
    • -B:Connection Load Balancing Goal(连接负载均衡目标)
    • SERVICE_TIME:基于服务的响应时间,将新连接导向响应最快的实例。
    • THROUGHPUT:基于吞吐量,将新连接导向处理作业速率最高的实例。
    • -j:Runtime Connection Load Balancing(运行时连接负载均衡)
    • SHORT:仅对短连接进行负载均衡。
    • LONG:对长连接也考虑负载均衡。

    — 启动服务
    EXEC DBMS_SERVICE.START_SERVICE('sales_service');

    5. 第四层:连接池负载均衡与透明故障转移

    5.1 原理

    在现代的三层或多层架构中,应用服务器(如WebLogic、Tomcat)会维护一个数据库连接池。连接池本身也具备强大的负载均衡和故障转移能力。

    5.2 连接池的典型配置(WebLogic示例)

    在WebLogic的数据源配置中,可以这样设置:

    • 多数据源(Multi Data Source):配置一个逻辑数据源,其下包含连接到RAC不同节点的物理数据源。在发生故障时,连接池会自动将新连接请求路由到存活的节点。
    • FAN(Fast Application Notification,快速应用通知):Oracle RAC通过FAN可以实时将集群事件(如节点故障、服务启停)推送到应用服务器。应用服务器接收事件后,可以立即终止到故障节点的无效连接,并快速将负载切换到健康节点。
    • TAF(Transparent Application Failover,透明应用故障转移):配置在客户端连接串中,使客户端的查询在连接断开时可以被透明地重新执行。

    # tnsnames.ora中配置TAF
    ORCL_TAF =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = prod-scan.com)(PORT = 1521))
    (CONNECT_DATA =
    (SERVICE_NAME = orcl_service)
    (FAILOVER_MODE =
    (TYPE = SELECT) — 故障转移类型:SESSION或SELECT
    (METHOD = BASIC) — 方法:BASIC或PRECONNECT
    (RETRIES = 20) — 重试次数
    (DELAY = 15) — 重试间隔(秒)
    )
    )
    )

    6. 端到端负载均衡最佳实践架构

    一个真正健壮的企业级Oracle负载均衡方案,会组合使用上述所有层级的策略,形成一个纵深防御的流量调度体系。

    #publish-mermaid-1784268287215-2{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-1784268287215-2 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-1784268287215-2 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-1784268287215-2 .error-icon{fill:#552222;}#publish-mermaid-1784268287215-2 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-1784268287215-2 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-1784268287215-2 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-1784268287215-2 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-1784268287215-2 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-1784268287215-2 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-1784268287215-2 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-1784268287215-2 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-1784268287215-2 .marker.cross{stroke:#333333;}#publish-mermaid-1784268287215-2 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-1784268287215-2 p{margin:0;}#publish-mermaid-1784268287215-2 .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#publish-mermaid-1784268287215-2 .cluster-label text{fill:#333;}#publish-mermaid-1784268287215-2 .cluster-label span{color:#333;}#publish-mermaid-1784268287215-2 .cluster-label span p{background-color:transparent;}#publish-mermaid-1784268287215-2 .label text,#publish-mermaid-1784268287215-2 span{fill:#333;color:#333;}#publish-mermaid-1784268287215-2 .node rect,#publish-mermaid-1784268287215-2 .node circle,#publish-mermaid-1784268287215-2 .node ellipse,#publish-mermaid-1784268287215-2 .node polygon,#publish-mermaid-1784268287215-2 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#publish-mermaid-1784268287215-2 .rough-node .label text,#publish-mermaid-1784268287215-2 .node .label text,#publish-mermaid-1784268287215-2 .image-shape .label,#publish-mermaid-1784268287215-2 .icon-shape .label{text-anchor:middle;}#publish-mermaid-1784268287215-2 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#publish-mermaid-1784268287215-2 .rough-node .label,#publish-mermaid-1784268287215-2 .node .label,#publish-mermaid-1784268287215-2 .image-shape .label,#publish-mermaid-1784268287215-2 .icon-shape .label{text-align:center;}#publish-mermaid-1784268287215-2 .node.clickable{cursor:pointer;}#publish-mermaid-1784268287215-2 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#publish-mermaid-1784268287215-2 .arrowheadPath{fill:#333333;}#publish-mermaid-1784268287215-2 .edgePath .path{stroke:#333333;stroke-width:1px;}#publish-mermaid-1784268287215-2 .flowchart-link{stroke:#333333;fill:none;}#publish-mermaid-1784268287215-2 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-1784268287215-2 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#publish-mermaid-1784268287215-2 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-1784268287215-2 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#publish-mermaid-1784268287215-2 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#publish-mermaid-1784268287215-2 .cluster text{fill:#333;}#publish-mermaid-1784268287215-2 .cluster span{color:#333;}#publish-mermaid-1784268287215-2 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#publish-mermaid-1784268287215-2 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#publish-mermaid-1784268287215-2 rect.text{fill:none;stroke-width:0;}#publish-mermaid-1784268287215-2 .icon-shape,#publish-mermaid-1784268287215-2 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-1784268287215-2 .icon-shape p,#publish-mermaid-1784268287215-2 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#publish-mermaid-1784268287215-2 .icon-shape .label rect,#publish-mermaid-1784268287215-2 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-1784268287215-2 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#publish-mermaid-1784268287215-2 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#publish-mermaid-1784268287215-2 .node .neo-node{stroke:#9370DB;}#publish-mermaid-1784268287215-2 [data-look=\”neo\”].node rect,#publish-mermaid-1784268287215-2 [data-look=\”neo\”].cluster rect,#publish-mermaid-1784268287215-2 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1784268287215-2 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-1784268287215-2 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-1784268287215-2 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1784268287215-2 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-1784268287215-2 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1784268287215-2 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-1784268287215-2 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1784268287215-2 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1784268287215-2 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}存储层Oracle RAC 集群应用服务器层

    互联网用户

    F5/LVS 硬件负载均衡器

    WebLogic 集群连接池+FAN

    WebLogic 集群连接池+FAN

    SCAN Listener服务端智能路由

    实例1 首选

    实例2 首选

    实例3 备用

    ASM共享存储

    各层职责总结:

    | 层级 | 技术/组件 | 职责 |

    | :— | :— | :— |

    | 网络层 | F5/LVS等 | 硬件级流量分发,健康检查,防止单点 |

    | Oracle Net层 | TNS配置 | 客户端的随机分发和故障转移 |

    | RAC集群层 | SCAN + Service | 基于节点真实负载和响应时间的智能路由 |

    | 应用层 | 连接池 + FAN | 连接复用,快速感知集群事件,透明重试 |

    总结

    Oracle数据库的负载均衡是一门贯穿多个技术栈的艺术。从一个简单的tnsnames.ora配置,到复杂的SCAN智能路由,再到应用层连接池的深度整合,每一层都在为“将请求送到最合适的节点”这一目标贡献力量。

    理解和掌握这四层负载均衡机制,并能在实际架构中灵活组合它们,是确保您的Oracle RAC集群真正实现高性能和高可用的关键所在。

    赞(0)
    未经允许不得转载:171主机测评 » Oracle数据库负载均衡:流量指挥官的调度艺术
    分享到: 更多 (0)

    评论 抢沙发

    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址