How to configure same context applications to use different machines with ModCluster and Wildfly10

天涯浪子 提交于 2019-12-05 06:48:36

问题


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:

Profile > URLA-HA / URLB-HA > Subsystems > ModCluster.

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!


回答1:


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


Apache Using 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.



来源:https://stackoverflow.com/questions/46330132/how-to-configure-same-context-applications-to-use-different-machines-with-modclu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!