本文介绍了如何使用ModCluster和Wildfly10配置相同的上下文应用程序以使用不同的计算机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用ModCluster对某些服务器进行负载平衡.我们只有一个EAR,需要通过不同的DNS进行负载均衡.

我们有这种情况.由于向后兼容,我们需要保持相同的上下文"system1"

  • 4个用于urla.com.br/system1/
  • 的服务器
  • 2个用于urlb.com.br/system1/
  • 的服务器

在域模式下使用Wildfly 10.1.0,它们由两个服务器组分隔: URLA URLB .它们共享相同的配置文件(URL-HA)和套接字绑定(URL-HA-SOCKET).

我有一个带有mod_cluster且配置最少的Apache.

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


Listen 10.90.0.13:7777

<VirtualHost 10.90.0.13:7777>

  <Directory />
      Require all granted
  </Directory>

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

  ManagerBalancerName mybalancer
  ServerAdvertise on
  EnableMCPMReceive On

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

当我访问 http://10.90.0.13:7777/mod_cluster-manager 时,我看到在上下文system1/中注册了6个服务器.顺便说一下,他们使用相同的EAR文件.

但这对我们来说不是理想的情况.访问urla.com.br/system1/的用户不能使用urlb.com.br/system1/的计算机,反之亦然.

我发现做到这一点的唯一方法(我尚未测试...)是为每个服务器组创建一个配置文件,因此我可以在以下位置配置不同的负载平衡组:

但是在这种情况下,我们复制了配置文件中存在的所有配置(DataSources,Queues,MailSession等).维护起来很痛苦.

那么,我有什么选择呢?谢谢!

解决方案

我仅使用一个Wildfly的配置文件即可找到解决问题的方法.

为此,我使用了两个平衡器,并使用ProxyPass来使用特定的平衡器.


Wildfly :在域控制器的控制台管理URL中,转到:

配置:配置文件配置文件:URL-HA子系统:ModCluster

在广告"标签上,更改平衡器"值:

${projectcluster.modcluster.balancer:mybalancer}

将系统属性添加到两个服务器组

运行时->服务器组-> URLA->视图

在系统属性"选项卡上,添加:

Key 'projectcluster.modcluster.balancer' value 'first'

Key 'jboss.modcluster.multicast.address' value '224.0.2.108'

运行时->服务器组-> URLB->视图

在系统属性"选项卡上,添加:

Key 'projectcluster.modcluster.balancer' value 'second'

Key 'jboss.modcluster.multicast.address' value '224.0.2.108'

此后,重新启动服务器组URLA和URLB


Apache 使用示例Apache conf讨论以下问题:

...
...

  ManagerBalancerName mybalancer
  ServerAdvertise on
  EnableMCPMReceive On
  # Defined on Wildfly
  AdvertiseGroup 224.0.2.108:23364

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

Listen 10.90.0.13:8001

<VirtualHost 10.90.0.13:8001>
  ProxyPass        / balancer://first stickysession=JSESSIONID|jsessionid nofailover=On
  ProxyPassReverse / balancer://first
</VirtualHost>

Listen 10.90.0.13:8002

<VirtualHost 10.90.0.13:8002>
  ProxyPass        / balancer://second stickysession=JSESSIONID|jsessionid nofailover=On
  ProxyPassReverse / balancer://second
</VirtualHost>

在10.90.0.13:8001/system1上的所有请求将发送到第一平衡器,在10.90.0.13:8002/system1上的所有请求将发送到第二平衡器

就是这样.

I'm trying to use ModCluster to load balance some servers. We have one single EAR that need to be load balanced by different DNSs.

We have this scenario. We need to maintain the same context 'system1' because of backward compatibility

  • 4 servers for urla.com.br/system1/
  • 2 servers for urlb.com.br/system1/

Using Wildfly 10.1.0 in domain mode, they are separated by two server groups: URLA and URLB. They share the same profile (URL-HA) and socket bindings (URL-HA-SOCKET).

I have an Apache with mod_cluster with a minimal configuration.

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


Listen 10.90.0.13:7777

<VirtualHost 10.90.0.13:7777>

  <Directory />
      Require all granted
  </Directory>

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

  ManagerBalancerName mybalancer
  ServerAdvertise on
  EnableMCPMReceive On

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

When I access http://10.90.0.13:7777/mod_cluster-manager, I see the 6 servers registered with the context system1/. They use the same EAR file, by the way.

But this is not the ideal scenario for us. The users accessing urla.com.br/system1/ cannot use the machines of urlb.com.br/system1/ and vice versa.

The only way that I can found to do this (I not tested yet...) is create one profile for each server group, so I can configure a different load balance group in:

But in this case, we duplicated all configurations that exists in profile (DataSources, Queues, MailSession, etc). This is painful to maintain.

So, what options we have in my case? Thanks!

解决方案

I've found the solution for my problem using only one Wildfly's profile.

For this, I have used two balancers and used ProxyPass to use the specific balancer.


Wildfly: At the Domain Controller's Console admin url, go to:

Configuration: Profiles Profile: URL-HA Subsystem: ModCluster

On the Advertising tab, change the Balancer value:

${projectcluster.modcluster.balancer:mybalancer}

Add System Properties to both the server-groups

Runtime -> Server Groups -> URLA -> View

On the System Properties tab, add:

Key 'projectcluster.modcluster.balancer' value 'first'

Key 'jboss.modcluster.multicast.address' value '224.0.2.108'

Runtime -> Server Groups -> URLB -> View

On the System Properties tab, add:

Key 'projectcluster.modcluster.balancer' value 'second'

Key 'jboss.modcluster.multicast.address' value '224.0.2.108'

After this, restart your server-groups URLA and URLB


ApacheUsing the example Apache conf on the question:

...
...

  ManagerBalancerName mybalancer
  ServerAdvertise on
  EnableMCPMReceive On
  # Defined on Wildfly
  AdvertiseGroup 224.0.2.108:23364

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

Listen 10.90.0.13:8001

<VirtualHost 10.90.0.13:8001>
  ProxyPass        / balancer://first stickysession=JSESSIONID|jsessionid nofailover=On
  ProxyPassReverse / balancer://first
</VirtualHost>

Listen 10.90.0.13:8002

<VirtualHost 10.90.0.13:8002>
  ProxyPass        / balancer://second stickysession=JSESSIONID|jsessionid nofailover=On
  ProxyPassReverse / balancer://second
</VirtualHost>

All the request on 10.90.0.13:8001/system1 will be sent to first balancer and on the 10.90.0.13:8002/system1 will be sent to second balancer

And that is it.

这篇关于如何使用ModCluster和Wildfly10配置相同的上下文应用程序以使用不同的计算机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 19:51