Examples
Index
WORK IN PROGRESS
Sorry, this page is work in progress.
Apache HTTP Server examples
Download mod_proxy_cluster sources, compile and run with your own Apache HTTP Server on Linux platform. The following demo deals with compile dependencies and a basic setup including SELinux.
You can skip directly to compilation on 52s mark.
WildFly examples
Under construction…
Tomcat examples
Under construction…
JBoss AS7 examples
Under construction…
How do I force mod_cluster to use HTTPS instead of AJP?
With JBoss AS7: mod_cluster.conf & standalone-ha.xml
JBoss AS instances in Domain mode with mod_cluster load balancer
Goal: To have Domain Controller and one Host Controller with one server running on a one box and a second Host Controller with second server running on the second box. Both servers should automatically register to the mod_cluster load balancer running on the third box.
This example is valid for JBoss AS 7.x, JBoss EAP 6.x and Apache HTTP Server
2.2.x. It will work for WildFly application server as well.
If you would like to use Apache HTTP Server 2.4.x, mind the slight
configuration changes regarding Allow from...
vs. Requires granted
.
Requirements: 3 virtual machines or physical servers, JBoss AS, Apache HTTP Server and mod_proxy_cluster distributions.
First, we are about to install the Apache HTTP Server to act as mod_proxy_cluster load balancer. Please, note the paths, IP addresses and ports are arbitrary unless stated otherwise.
Apache HTTP Server
Installed in : /opt/load-balancer/jboss-ews-2.x/httpd
box IP: 192.168.122.74
- run
.postinstall
- make sure you have these modules in the appropriate
modules/
directory:- mod_slotmem.so
- mod_proxy_cluster.so
- mod_manager.so
- mod_advertise.so
- comment out mod_proxy_balancer.so (it’s incompatible with our mod_proxy_cluster.so)
- for the sake of this example, comment out any Listen directives in httpd.conf
- LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
/opt/load-balancer/jboss-ews-2.x/httpd/conf.d/mod_cluster.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
LoadModule slotmem_module modules/mod_slotmem.so
LoadModule manager_module modules/mod_manager.so
LoadModule advertise_module modules/mod_advertise.so
Listen 192.168.122.74:2181
MemManagerFile "/opt/load-balancer/jboss-ews-2.x/httpd/cache/mod_cluster"
ServerName 192.168.122.74:2181
<IfModule manager_module>
Listen 192.168.122.74:8847
LogLevel debug
<VirtualHost 192.168.122.74:8847>
ServerName 192.168.122.74:8847
<Directory />
Order deny,allow
Deny from all
Allow from all
</Directory>
AdvertiseGroup 224.0.1.111:23365
EnableMCPMReceive
<Location /mcm>
SetHandler mod_cluster-manager
Order deny,allow
Deny from all
Allow from all
</Location>
</VirtualHost>
</IfModule>
JBoss AS
Unzipped into: /opt/jboss-eap-6.x
- use
/opt/jboss-eap-6.x/bin/add-user.sh
to add these 3 users to ManagementRealm- admin
- machine1
- machine2
Please, note that machine1 and machine2 user names are not arbitrary. Answer yes to all the questions and use the same passwords (this is just for testing):
R3dHatRulezz.
or update the<secret value="
attributes accordingly.
- copy
domain
directory so as to create the following structure: /opt/jboss-eap-6.x/ ├── domain ├── machine1 │ └── domain └── machine2 └── domain
Domain Controller
Edit machine1/domain/configuration/domain.xml
, so as:
Configure the master in machine1/domain/configuration/host-master.xml
:
Host Controller 1
Configure your Host Controller 1 in machine1/domain/configuration/host-slave.xml
. Please, note the name is not arbitrary, it must match the user names created above.
Host Controller 2
Configure your Host Controller 2 machine2/domain/configuration/host-slave.xml
:
Overview of the current layout
Run!
For the sake of this example, let’s suppose you have the Apache HTTP Server residing on the box 192.168.122.74.
Copy your /opt/jboss-eap-6.x
folder to the two boxes that are supposed to act as JBoss AS worker nodes,
e.g. 192.168.122.78 and 192.168.122.204.
- Make sure your firewalls allow UDP multicast between the nodes and that all the used ports are open
- Please, check firewalls and network interfaces again, i.e. Apache HTTP Server must be able to access AJP connector on your JBoss AS workers etc.
- Start Apache HTTP Server on 192.168.122.74
- ./apachectl start in /opt/load-balancer/jboss-ews-2.x/httpd/sbin
- one might appreciate seeing the mod_cluster messages: tail -f /opt/load-balancer/jboss-ews-2.x/httpd/logs/error_log
- Start Domain Controller on 192.168.122.78, /opt/jboss-eap-6.x/bin
- ./domain.sh –host-config=host-master.xml -Djboss.domain.base.dir=/opt/jboss-eap-6.x/machine1/domain -Djboss.bind.address.management=192.168.122.78
- Start Host Controller 1 on 192.168.122.78
- ./domain.sh -Djboss.domain.base.dir=/opt/jboss-eap-6.x/machine1/domain –host-config=host-slave.xml -Djboss.domain.master.address=192.168.122.78 -Djboss.management.native.port=29999 -Djboss.bind.address.management=192.168.122.78 -Djboss.bind.address=192.168.122.78 -Djboss.bind.address.unsecure=192.168.122.78
- Start Host Controller 2 on 192.168.122.204
- ./domain.sh -Djboss.domain.base.dir=/opt/jboss-eap-6.x/machine2/domain –host-config=host-slave.xml -Djboss.domain.master.address=192.168.122.78 -Djboss.bind.address.management=192.168.122.204 -Djboss.bind.address=192.168.122.204 -Djboss.bind.address.unsecure=192.168.122.204
- Access http://192.168.122.74:8847/mcm and wait dozen of seconds for two worker nodes to appear
- Deploy/manage/play with Domain Controller http://192.168.122.78:9990/