我无法让会话复制与 Wildfly 10 一起使用

Posted

技术标签:

【中文标题】我无法让会话复制与 Wildfly 10 一起使用【英文标题】:I can not get session replication to work with wildfly 10 【发布时间】:2016-12-25 06:08:35 【问题描述】:

我们已将 httpd 作为负载均衡器放在 Wildfly 前面。我正在使用 Wildfly 10.1.0。

我有 3 台机器,一台主机,两台从机。

在我的主人的 domain.xml 我有:

<subsystem xmlns="urn:jboss:domain:modcluster:2.0">
                <mod-cluster-config proxies="mc-prox1" connector="ajp">
                    <dynamic-load-provider>
                        <load-metric type="busyness"/>
                    </dynamic-load-provider>
                </mod-cluster-config>
            </subsystem>

<socket-binding-groups>
    <socket-binding-group name="full-ha-sockets" default-interface="public">
        <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="iiop" interface="unsecure" port="3528"/>
        <socket-binding name="iiop-ssl" interface="unsecure" port="3529"/>
        <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="mc-prox1">
            <remote-destination host="192.168.2.201" port="8796"/>
        </outbound-socket-binding>


    </socket-binding-group>
</socket-binding-groups>

<server-groups>
        <server-group name="mycluster" profile="full-ha">
            <socket-binding-group ref="full-ha-sockets"/>
            <deployments>
                <deployment name="PATT_EAR.ear" runtime-name="PATT_EAR.ear"/>
            </deployments>
        </server-group>
    </server-groups>

在从属 1 的 hosts.xml 中,我有:

<servers>
    <server name="server-web1" group="mycluster" auto-start="true">
        <jvm name="jvm-web1">
            <heap size="1024m" max-size="3072m"/>
            <permgen size="1024m" max-size="1024m"/>
            <jvm-options>
                <option value="-server"/>
                <option value="-d64"/>
            </jvm-options>
        </jvm>
    </server>
</servers>

在我的从属 2 的 hosts.xml 中,我有:

  <server name="server-web2" group="mycluster" auto-start="true">
            <jvm name="jvm-web2">
                <heap size="1024m" max-size="3072m"/>
                <permgen size="1024m" max-size="1024m"/>
                <jvm-options>
                    <option value="-server"/>
                    <option value="-d64"/>
                </jvm-options>
            </jvm>
        </server>
    </servers>

所有服务器都可以正常启动,并且在我拥有的日志中:

master 的日志

2016-08-18 09:38:06,884 INFO  [org.jboss.as.host.controller] (Controller Boot Thread) WFLYHC0023: Starting server server-web1
2016-08-18 09:38:06,891 WARN  [org.jboss.as.host.controller] (Controller Boot Thread) WFLYHC0011: Ignoring <permgen> for jvm 'SUN' type jvm: jvm-web1
2016-08-18 09:38:06,987 WARN  [org.jboss.as.host.controller] (ProcessControllerConnection-thread - 2) WFLYHC0011: Ignoring <permgen> for jvm 'SUN' type jvm: jvm-web1
2016-08-18 09:38:09,538 INFO  [org.jboss.as.host.controller] (management task-4) WFLYHC0021: Server [Server:server-web1] connected using connection [Channel ID 622b12f8 (inbound) of Remoting connection 124392b0 to /192.168.2.201:42232 of endpoint "master:MANAGEMENT" <67c473e1>]
2016-08-18 09:38:09,633 INFO  [org.jboss.as.host.controller] (Controller Boot Thread) WFLYHC0023: Starting server server-web2
2016-08-18 09:38:09,634 WARN  [org.jboss.as.host.controller] (Controller Boot Thread) WFLYHC0011: Ignoring <permgen> for jvm 'SUN' type jvm: jvm-web1
2016-08-18 09:38:09,685 INFO  [org.jboss.as.host.controller] (server-registration-threads - 1) WFLYHC0020: Registering server server-web1
2016-08-18 09:38:09,753 WARN  [org.jboss.as.host.controller] (ProcessControllerConnection-thread - 2) WFLYHC0011: Ignoring <permgen> for jvm 'SUN' type jvm: jvm-web1
2016-08-18 09:38:16,741 INFO  [org.jboss.as.domain.controller] (Host Controller Service Threads - 34) WFLYHC0019: Registered remote slave host "hostweb2", JBoss WildFly Full 10.1.0.CR1 (WildFly 2.2.0.CR9)
2016-08-18 09:38:19,254 INFO  [org.jboss.as.domain.controller] (Host Controller Service Threads - 36) WFLYHC0019: Registered remote slave host "hostweb1", JBoss WildFly Full 10.1.0.CR1 (WildFly 2.2.0.CR9)
2016-08-18 09:38:20,150 INFO  [org.jboss.as.host.controller] (management task-1) WFLYHC0021: Server [Server:server-web2] connected using connection [Channel ID 05201088 (inbound) of Remoting connection 0d2653a3 to /192.168.2.201:55390 of endpoint "master:MANAGEMENT" <67c473e1>]
2016-08-18 09:38:20,248 INFO  [org.jboss.as.host.controller] (server-registration-threads - 1) WFLYHC0020: Registering server server-web2
2016-08-18 09:38:20,252 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://192.168.2.201:9990/management
2016-08-18 09:38:20,254 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://192.168.2.201:9990
2016-08-18 09:38:20,255 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.1.0.CR1 (WildFly Core 2.2.0.CR9) (Host Controller) started in 17840ms - Started 55 of 57 services (19 services are lazy, passive or on-demand)

从站日志显示

2016-08-18 09:38:15,752 INFO  [org.jboss.as.remoting] (MSC service thread 1-1) WFLYRMT0001: Listening on 192.168.2.202:9999
2016-08-18 09:38:19,273 INFO  [org.jboss.as.host.controller] (Controller Boot Thread) WFLYHC0148: Connected to master host controller at remote://192.168.2.201:9999
2016-08-18 09:38:19,364 INFO  [org.jboss.as.host.controller] (Controller Boot Thread) WFLYHC0023: Starting server server-web1
2016-08-18 09:38:19,366 WARN  [org.jboss.as.host.controller] (Controller Boot Thread) WFLYHC0011: Ignoring <permgen> for jvm 'SUN' type jvm: jvm-web1
2016-08-18 09:38:19,474 WARN  [org.jboss.as.host.controller] (ProcessControllerConnection-thread - 2) WFLYHC0011: Ignoring <permgen> for jvm 'SUN' type jvm: jvm-web1
2016-08-18 09:38:21,912 INFO  [org.jboss.as.host.controller] (management task-10) WFLYHC0021: Server [Server:server-web1] connected using connection [Channel ID 45e867e4 (inbound) of Remoting connection 565bb1dc to /192.168.2.202:56530 of endpoint "hostweb1:MANAGEMENT" <60a9371d>]
2016-08-18 09:38:22,005 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.1.0.CR1 (WildFly Core 2.2.0.CR9) (Host Controller) started in 8419ms - Started 46 of 50 services (18 services are lazy, passive or on-demand)
2016-08-18 09:38:22,034 INFO  [org.jboss.as.host.controller] (server-registration-threads - 1) WFLYHC0020: Registering server server-web1

016-08-18 09:38:13,269 INFO  [org.jboss.as.remoting] (MSC service thread 1-1) WFLYRMT0001: Listening on 192.168.2.203:9999
2016-08-18 09:38:16,763 INFO  [org.jboss.as.host.controller] (Controller Boot Thread) WFLYHC0148: Connected to master host controller at remote://192.168.2.201:9999
2016-08-18 09:38:16,847 INFO  [org.jboss.as.host.controller] (Controller Boot Thread) WFLYHC0023: Starting server server-web2
2016-08-18 09:38:16,850 WARN  [org.jboss.as.host.controller] (Controller Boot Thread) WFLYHC0011: Ignoring <permgen> for jvm 'SUN' type jvm: jvm-web2
2016-08-18 09:38:16,950 WARN  [org.jboss.as.host.controller] (ProcessControllerConnection-thread - 2) WFLYHC0011: Ignoring <permgen> for jvm 'SUN' type jvm: jvm-web2
2016-08-18 09:38:19,968 INFO  [org.jboss.as.host.controller] (management task-10) WFLYHC0021: Server [Server:server-web2] connected using connection [Channel ID 434a7830 (inbound) of Remoting connection 114a8665 to /192.168.2.203:60987 of endpoint "hostweb2:MANAGEMENT" <29b1c4e8>]
2016-08-18 09:38:20,052 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.1.0.CR1 (WildFly Core 2.2.0.CR9) (Host Controller) started in 8883ms - Started 46 of 50 services (18 services are lazy, passive or on-demand)
2016-08-18 09:38:20,083 INFO  [org.jboss.as.host.controller] (server-registration-threads - 1) WFLYHC0020: Registering server server-web2

在httpd的配置文件中,我有:

##Creation du load balancer

CreateBalancers 1

<IfModule manager_module>
    Listen PIXID-LBWEB:8796
    ManagerBalancerName mycluster

    <VirtualHost PIXID-LBWEB:8796>
        KeepAliveTimeout 900
        MaxKeepAliveRequests 0
        AdvertiseFrequency 5
        ServerAdvertise off
  EnableMCPMReceive

        <Location />
            Order deny,allow
           Deny from all
     Allow from 192.168.2.202 192.168.2.203 192.168.2.204
        </Location>

  <Location /mod_cluster_manager>
        SetHandler mod_cluster-manager
        Order deny,allow
        Allow from all
  </Location>

     </VirtualHost>
</IfModule>

Listen 8080
ServerName PIXID-LBWEB:8080

NameVirtualHost PIXID-LBWEB:8080
<VirtualHost PIXID-LBWEB:8080>
    ServerAdmin exploitation@abc.com
    ServerName PIXID-LBWEB:8080

    ProxyPass / balancer://mycluster stickysession=JSESSIONID|jsessionid nofailover=off timeout=10
    ProxyPassReverse / balancer://mycluster
    ProxyPreserveHost On

    ErrorLog "|/appli/apache2/bin/rotatelogs /log/apache/error_log_balancer.%Y-%m-%d 86400"
    CustomLog "|/appli/apache2/bin/rotatelogs /log/apache/access_log_balancer.%Y-%m-%d 86400" common

    <Location />
        Order deny,allow
        Allow from All
    </Location>

</VirtualHost>

我遇到的问题是会话不会在两台服务器之间复制。负载平衡没有问题。 如果我停止从站 1,我会切换到从站 2,但会话不存在,第二台服务器会为我创建一个新的会话 ID。

我确实添加了可分发到我的 web.xml。

我是否在配置中遗漏了什么?

感谢您的帮助。

【问题讨论】:

您是否按照指示here ? 【参考方案1】:

问题出在

<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"/>

我必须删除 interface="private" 才能正常工作。

现在的新配置是

<socket-binding name="jgroups-mping" port="0" multicast-address="$jboss.default.multicast.address:230.0.0.201" multicast-port="45700"/>
        <socket-binding name="jgroups-tcp" port="7600"/>
        <socket-binding name="jgroups-tcp-fd" port="57600"/>
        <socket-binding name="jgroups-udp" port="55200" multicast-address="$jboss.default.multicast.address:230.0.0.201" multicast-port="45688"/>
        <socket-binding name="jgroups-udp-fd" port="54200"/>

【讨论】:

我尝试了上述使用 Apache HTTPD 服务器作为负载平衡器的集群配置解决方案,您是否尝试过使用 Apache HTTPD 服务器进行集群部署?你能帮我完成以下集群配置吗:***.com/questions/43454068/…

以上是关于我无法让会话复制与 Wildfly 10 一起使用的主要内容,如果未能解决你的问题,请参考以下文章

无法将 mysql 驱动程序与 Wildfly 9.0.2 一起使用,但它似乎已正确加载

是否可以在 Wildfly 中将数据源部署描述符与驱动程序模块一起使用?

将 WildFly 应用程序服务器与 NetBeans IDE 一起使用

将 JMX Exporter 与 Wildfly 15 一起使用时出现 NoClassDefFoundError

GraphQL Explorer 无法与 Express 会话一起使用

Sql Server JDBC无法在wildfly AS上运行