簡體   English   中英

負載平衡集群不適用於 Apache HTTP Server 2.4.6 和 JBoss EAP 7

[英]Load Balancing Cluster not working with Apache HTTP Server 2.4.6 and JBoss EAP 7

我正在 JBoss EAP 7 上認證我的應用程序。我的應用程序在獨立模式下工作,但在集群模式下,我的應用程序已部署,但我無法登錄。 我再次重新路由到登錄網址。
我已經使用 mod_cluster 設置了集群。

Load Balancer Server 日志中沒有錯誤日志,也沒有在集群的各個節點上。
在我的測試環境中,我的負載均衡器和 2 個服務器節點在同一台機器上。 我為 JBoss 節點提供了不同的端口和實例 ID 以區分節點。
我正在從集群中的一個節點共享我的 mod_cluster.conf 和 JBoss standalone-ha.xml 提取物。

以下是 standalone-ha.xml 文件中的片段:

Modcluster 設置是:

    <subsystem xmlns="urn:jboss:domain:modcluster:2.0">
    <mod-cluster-config advertise-socket="modcluster" proxies="proxy1" balancer="testcluster" advertise="true" connector="ajp">
        <dynamic-load-provider>
            <load-metric type="busyness"/>
        </dynamic-load-provider>
    </mod-cluster-config>  
</subsystem> 

暗流設置是:

    <subsystem xmlns="urn:jboss:domain:undertow:3.1" instance-id="node1">
    <buffer-cache name="default"/>
    <server name="default-server">
        <ajp-listener name="ajp" socket-binding="ajp"/>
        <http-listener name="default" socket-binding="http" redirect-socket="https"/>
         <host name="default-host" alias="localhost">
            <location name="/" handler="welcome-content"/>
            <filter-ref name="server-header"/>
            <filter-ref name="x-powered-by-header"/>
        </host>
    </server>
   <servlet-container name="default">
        <jsp-config/>
        <websockets/>
    </servlet-container>
    <handlers>
        <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
    </handlers>
    <filters>
        <response-header name="server-header" header-name="Server" header-value="JBoss-EAP/7"/>
        <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
    </filters>
</subsystem>

Socket Binding Group 的內容是:

<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
    <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
    <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
    <socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
    <socket-binding name="http" port="${jboss.http.port:8080}"/>
    <socket-binding name="https" port="${jboss.https.port:8443}"/>
    <socket-binding name="jgroups-mping" interface="private" port="0" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45700"/>
    <socket-binding name="jgroups-tcp" interface="private" port="7600"/>
    <socket-binding name="jgroups-tcp-fd" interface="private" port="57600"/>
    <socket-binding name="jgroups-udp" interface="private" port="55200" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45688"/>
    <socket-binding name="jgroups-udp-fd" interface="private" port="54200"/>
    <socket-binding name="modcluster" port="0" multicast-address="224.0.1.105" multicast-port="23364"/>
    <socket-binding name="txn-recovery-environment" port="4712"/>
    <socket-binding name="txn-status-manager" port="4713"/>
    <outbound-socket-binding name="mail-smtp">
        <remote-destination host="localhost" port="25"/>
    </outbound-socket-binding>
    <outbound-socket-binding name="proxy1"> 
    <!-- host and port number of the load-balancer.  -->
        <remote-destination host="x.x.x.x" port="81"/>
    </outbound-socket-binding>
 </socket-binding-group>

mod_cluster.conf 的內容如下:

LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
LoadModule cluster_slotmem_module modules/mod_cluster_slotmem.so
LoadModule manager_module modules/mod_manager.so
LoadModule advertise_module modules/mod_advertise.so

MemManagerFile "//httpd2.4.6Home/var/cache/mod_cluster"

<IfModule manager_module>
    Listen 81
    <VirtualHost *:81>
    <Directory />
        Require all granted
    </Directory>
    <Location />
        Require all granted
    </Location>
    <Location /mod_cluster_manager>
        SetHandler mod_cluster-manager
        Require all granted
    </Location>
        KeepAliveTimeout 60
        MaxKeepAliveRequests 0
        ManagerBalancerName testcluster
        AdvertiseFrequency 5
        ServerAdvertise on
        EnableMCPMReceive
    </VirtualHost>
</IfModule>

基本上,您有兩個選擇 - 使用 JBoss 自己的domain模式創建集群或擴展您的獨立配置以包含會話復制和 sso 所需的元素。

在域模式下,大多數配置已經存在於 EAP7 中 - 只需擴展domain-full-ha配置文件。

所需的更改包括在您的 Web 應用程序web.xml啟用可distributable標志 - 只需將<distributable/>添加到您的 web.xml。 接下來將單點登錄標志添加到您的 undertow 系統:

  <host name="default-host" alias="localhost">                                                           
     <location name="/" handler="welcome-content"/>                                                     
     <filter-ref name="server-header"/>                                                                 
     <filter-ref name="x-powered-by-header"/>                                                           
     <single-sign-on/>    <!-- FIXME:  enable SSO here -->                                                                              
   </host>   

並啟用集群 SSO 工作所需的緩存容器 - 這需要 Infinishpan 子系統,如果您只擴展了standalone-ha配置文件,您現在可能擁有該子系統。 如果您沒有看到 Infinispan 子系統,請查看standalone-fullstandalone-full-ha配置文件。 如果您還沒有,請添加web緩存:

 /subsystem=infinispan/cache-container=web/distributed-cache=concurrent:add
 /subsystem=infinispan/cache-container=web/distributed-cache=concurrent/store=file:add 

同樣,如果您使用獨立或域模式的 full-ha 配置文件,您可能已經擁有這些。

你也沒有提到,如果你使用 JBoss 安全域進行授權。 如果您使用某些自定義身份驗證機制,請確保正確設置會話 cookie 或令牌 - 正確的域和上下文等。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM