modcluster(Wildfly)没有检测到Apache的广告

时间:2014-07-26 20:40:12

标签: java apache wildfly-8 mod-cluster

我正在尝试使用mod_cluster配置WildFly 8.1.0。 WildFly和Apache都在同一台机器上运行。该机器是带有Apache 2.2.x的Ubuntu 12.04

Apache设置正确(我相信)。我通过运行mod_proxy源代码(github)中的测试类Advertise测试了广告模块是否正常工作。 apache日志中没有错误。

我按如下方式启动服务器:./ standalone.sh -c standalone-ha.xml

如果任何人可以看到下面的配置有问题并帮助我摆脱痛苦的日子,我会非常感激....

Apache配置

CreateBalancers 1

<IfModule manager_module>

    #Listen 127.0.1.1:6666
    Listen *:6666
    ManagerBalancerName mycluster

    <VirtualHost *:6666> 

        KeepAliveTimeout 300
        MaxKeepAliveRequests 0
        AdvertiseFrequency 5
        ServerAdvertise On
        AllowDisplay On

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

       <Location /mod_cluster_manager>
            SetHandler mod_cluster-manager
            Order deny,allow
            #Deny from all
            #Allow from 127.0.1
            Allow from all
        </Location>
     </VirtualHost>
</IfModule>

VirtualHost配置

<VirtualHost *:80>

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

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

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Advertize测试类的结果

received from /178.62.50.xxx:23364
received: HTTP/1.0 200 OK
Date: Sat, 26 Jul 2014 20:03:12 GMT
Sequence: 121
Digest: 4dedd3761d451227f36534b63ca2a8a1
Server: b23584e2-314f-404d-8fde-05069bfe5dc7
X-Manager-Address: 127.0.1.1:6666
X-Manager-Url: /b23584e2-314f-404d-8fde-05069bfe5dc7
X-Manager-Protocol: http
X-Manager-Host: 127.0.1.1

从mod_cluster_manager打印出来(178.62.50.xxx:6666/mod_cluster_manager)

mod_cluster/1.2.6.Final
start of "httpd.conf" configuration
mod_proxy_cluster.c: OK
mod_sharedmem.c: OK
Protocol supported: http AJP 
mod_advertise.c: OK
Server: 127.0.1.1 
Server: 127.0.1.1 VirtualHost: *:80
Server: 127.0.1.1 VirtualHost: *:6666 Advertising on Group 224.0.1.105 Port 23364 for http://127.0.1.1:6666 every 5 seconds
end of "httpd.conf" configuration

最后,这里是从standalone-ha.xml

获取的相关位
<subsystem xmlns="urn:jboss:domain:modcluster:1.2">
    <mod-cluster-config advertise-socket="modcluster" connector="ajp">
        <dynamic-load-provider>
            <load-metric type="cpu"/>
        </dynamic-load-provider>
    </mod-cluster-config>
</subsystem>

<socket-binding name="modcluster" port="0" multicast-address="224.0.1.105" multicast-port="23364"/>

<interfaces>
    <interface name="management">
        <inet-address value="178.62.50.xxx"/>
    </interface>
    <interface name="public">
        <inet-address value="127.0.1.1"/>
    </interface>
    <interface name="unsecure">
        <inet-address value="${jboss.bind.address.unsecure:127.0.1.1}"/>
    </interface>
</interfaces>

服务器日志中与modcluster(服务器启动期间的输出)相关的唯一部分

15:53:29,805 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017519: Undertow HTTP listener default listening on /127.0.1.1:8080
15:53:29,811 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) JBAS017519: Undertow AJP listener ajp listening on /127.0.1.1:8009
15:53:29,905 INFO  [org.jboss.modcluster] (ServerService Thread Pool -- 54) MODCLUSTER000001: Initializing mod_cluster version 1.3.0.Final
15:53:29,967 INFO  [org.jboss.modcluster] (ServerService Thread Pool -- 54) MODCLUSTER000032: Listening to proxy advertisements on /224.0.1.105:23364

2 个答案:

答案 0 :(得分:1)

我终于找到了问题。公共接口还需要引用服务器IP,而不是127.0.1.1。

更新的界面配置为:

<interfaces>
    <interface name="management">
        <inet-address value="178.62.50.xxx"/>
    </interface>
    <interface name="public">
        <inet-address value="178.62.50.xxx"/>
    </interface>
    <interface name="unsecure">
        <inet-address value="${jboss.bind.address.unsecure:127.0.1.1}"/>
    </interface>
</interfaces>

答案 1 :(得分:1)

你需要:

  • EnableMCPMReceive中使用<VirtualHost *:6666>,以便允许它从WildFly中消费MCMP消息

  • 启用<Location />的VirtualHost中的
  • EnableMCPMReceive必须允许WildFly服务器的IP地址

  • 使用WildFly,从不绑定到localhost - 它在mod_cluster环境中没有任何意义,除非框(Apache和WildFly实例)是位于一个盒子里;这可能只是一个地方发展情况

  • 整个事件链如下:

    1. Apache发送UDP多播消息,说明其位置(默认情况下,启用广告的VirtualHost)
    2. WildFly捕获消息并且mod_cluster子系统发送包含其JvmRoute(instance-id),Host,Port,protocol ...,load ...的CONFIG和STATUS消息...主机和端口必须是可以从Apache HTTP Server访问。
    3. Apache HTTP Server在其主机上与WildFly服务器通信:端口包含STATUS-RSP消息等。通信是双向的。

请不要将此与请求路由混淆,默认情况下,客户端请求从Apache HTTP Server传递到WildFly并通过AJP返回,而MCMP消息使用HTTP。

HTH K