We have seen how to create clusters in standalone, domain with multicast and unicast protocols also which have been listed below. However in this article we would be seeing how to use mod_cluster with our created clusters in both standalone and domain mode.
Following are the list of article we have created till now for creating a cluster in JBoss AS 7.1.1 Final till now
- How to create cluster in JBoss AS 7.1 in standalone mode?
- How to create cluster in JBoss AS 7.1 in domain mode?
- Creating TCP cluster in JBoss AS 7.1 in standalone mode?
Again we would be using JBoss AS 7.1.1.Final for this article as well so that we are all on the same page, as few things have been change from JBoss AS 7.0 to JBoss AS 7.1.
Changes taken place:
- AJP connector is enabled by default in standalone-ha.xml , standalone-full-ha.xml and domain.xml for ha and full-ha profile.
- Instead of JVMRoute, now we have to use instance-id
Using mod_cluster with JBoss AS 7.1 cluster
For this we would have to modify from both side Apache as well as JBoss AS7 side, hence lets see the configuration one at a time
Apache side configuration
Lets see what all configuration has to be made from Apache side
- You can configure mod_cluster from the below article, just follow the “Apache side configuration” part only
- In the above article you can just add the IP_ADDRESS of the box on which Apache is running which is in the Step-3 something as shown below
How to configure mod_cluster with JBoss ?
############### mod_cluster Setting - STARTED ############### LoadModule slotmem_module modules/mod_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 1.1.1.1:80 <VirtualHost 1.1.1.1:80> <Directory /> Order deny,allow Allow from all </Directory> <Location /mod_cluster-manager> SetHandler mod_cluster-manager Order deny,allow Allow from all </Location> KeepAliveTimeout 60 ManagerBalancerName mycluster ServerAdvertise On </VirtualHost> ############### mod_cluster Setting - ENDED ###############
JBoss side configuration
Now we would see what all changes we have to be done from JBoss end in standalone and domain files
Standalone
- First you would have to follow all the steps given in the link – How to create cluster in JBoss AS 7.1 in standalone mode? and then make the below changes in all the standalone servers.
- Give a unique name in the server element, as shown below .
- As told earlier you would have to add the instance-id attribute in web subsystem as shown below in both the standalone nodes.
- Last you just have to add the proxy-list in the attribute in mod-cluster-config of modcluster subsystem, which would be having IP Address and Port on which your Apache server is running so that JBoss server can communicate with it, as shown below in both the standalone nodes.
standalone-node1
<server name="standalone-node1" xmlns="urn:jboss:domain:1.2">
standalone-node2
<server name="standalone-node2" xmlns="urn:jboss:domain:1.2">
<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" instance-id="${jboss.node.name}" native="false"> <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/> <connector name="ajp" protocol="AJP/1.3" scheme="http" socket-binding="ajp"/> . . . </subsystem>
<subsystem xmlns="urn:jboss:domain:modcluster:1.0"> <mod-cluster-config advertise-socket="modcluster" proxy-list="1.1.1.1:80"> . . . </mod-cluster-config> </subsystem>
If everything is configured properly you can hit the URL = http://1.1.1.1/mod_cluster-manager which would show similar below screen. Below image is showing when cluster is been made in on the same box using standalone mode
Domain
- First you would have to follow all the steps given in the link – How to create cluster in JBoss AS 7.1 in domain mode? and then make the below changes in your domain file.
- We would have to add the instance-id attribute in web subsystem as shown below in domain.xml for the respective profile ha and full-ha which is been used.
- Last you just have to add the proxy-list in the attribute in mod-cluster-config of modcluster subsystem, which would be having IP Address and Port on which your Apache server is running so that JBoss server can communicate with it, as shown below in domain.xml for the respective profile ha and full-ha which is been used.
<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" instance-id="${jboss.node.name}" native="false"> <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/> <connector name="ajp" protocol="AJP/1.3" scheme="http" socket-binding="ajp"/> . . . </subsystem>
<subsystem xmlns="urn:jboss:domain:modcluster:1.0"> <mod-cluster-config advertise-socket="modcluster" proxy-list="1.1.1.1:80"> . . . </mod-cluster-config> </subsystem>
If everything is configured properly you can hit the URL = http://1.1.1.1/mod_cluster-manager which would show similar below screen. Below image is showing when cluster is been made in on the same box as well as in remote box using domain mode.
Same Box
Remote Box
Testing
In all our previous article we had asked you to use one of our application called ClusterWebAp, this is the time when we would be testing if our cluster is working properly with mod_cluster configuration.
- Once everything thing is been configured and have been started up properly you can hit the application using Apache URL as shown below and you would see something like in the snap-shot
- Suppose the first request goes to standalone-node2 , you can see there is a session-id which is been generated. Now you just have to shutdown your standalone-node2 and then click on the link Click Here to move to nextPage sessionCheck.jsp on the same page.
- Once you click on the link, you will notice that the request has been served by the standalone-node1 this time as node2 had been brought down, but the session-id remains the same which was created earlier having the same timestamp as shown below
http://1.1.1.1/ClusterWebApp
With this test it is clear that our cluster is working fine as the session replication is happening properly on JBoss using mod_cluster.
Issues you might face
If you have not given the instance-id in the domain.xml file for ha or full-ha and have a step up a cluster which is having a mod_cluster in front of them you might get the following error in the logs.
[Server:ha-server-1] 20:29:36,429 ERROR [org.jboss.modcluster.mcmp.impl.DefaultMCMPHandler] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) Error [MEM: MEM: Old node still exist: {4}] sending command CONFIG to proxy 10.10.10.10:80, configuration will be reset [Server:ha-server-2] 20:29:37,426 ERROR [org.jboss.modcluster.mcmp.impl.DefaultMCMPHandler] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) Error [MEM: MEM: Can't read node: {4}] sending command STATUS to proxy 10.10.10.10:80, configuration will be reset [Server:ha-server-2] 20:29:47,432 ERROR [org.jboss.modcluster.mcmp.impl.DefaultMCMPHandler] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) Error [MEM: MEM: Old node still exist: {4}] sending command CONFIG to proxy 10.10.10.10:80, configuration will be reset [Server:ha-server-1] 20:29:56,441 ERROR [org.jboss.modcluster.mcmp.impl.DefaultMCMPHandler] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) Error [MEM: MEM: Can't read node: {4}] sending command STATUS to proxy 10.10.10.10:80, configuration will be reset
For this you just have to follow the step-2 of Domain configuration, which would fix this issue.
July 31st, 2012 on 11:18 pm
where is the ClusterWebApp link to download it?
July 31st, 2012 on 11:48 pm
Hi hilner,
ClusterWebApp application can be downloaded from HERE
Regards,
Middleware Magic team
October 31st, 2012 on 5:03 pm
First of all, thank you for the post, it help me configure mod_cluster in domain mode. I am looking for configuring SSL in domain mode while mod_cluster is being used.
I have already used Connector in domain.xml to individually access node on HTTPS with additional offset as 8543 and 8643.
What are additional Apache and Jboss level configuration that needs to be done to allow mod_cluster request and channel to run as HTTPS?
Thank you,
Manish
April 2nd, 2013 on 5:49 pm
Hello,
I set up a similar way but with ssl enabled. But the nodes are not getting listed.
Apache:
LoadModule slotmem_module modules/mod_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 6666
ManagerBalancerName mycluster
<VirtualHost :6666>
Order deny,allow
Allow from all
SetHandler mod_cluster-manager
Order deny,allow
Allow from all
KeepAliveTimeout 300
MaxKeepAliveRequests 0
AdvertiseFrequency 5
EnableMCPMReceive
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
SSLCertificateKeyFile “/apps/apache/conf/ssl.key/dev.corp.adobe.com.key”
SSLCertificateFile “/apps/apache/conf/ssl.crt/dev.corp.adobe.com.crt”
SSLCertificateChainFile “/apps/apache/conf/ssl.crt/intermediate.crt”
SSLOptions +StdEnvVars
SSLOptions +StdEnvVars
AllowOverride None
Order allow,deny
Allow from all
JBoss:
<mod-cluster-config advertise-socket="modcluster" proxy-list=":6666″ balancer=”devbalancer” excluded-contexts=”invoker,jbossws,juddi,console” connector=”ajp”>
Am I missing something?
Thanks,
Hema
July 1st, 2013 on 6:14 pm
hello, I followed your guide for configuring a cluster with jboss in standalone mode, but does not make the session replication, every time I create a new session, I enclose the configuration.
Apache side:
LoadModule proxy_module / usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module / usr/lib/apache2/modules/mod_proxy_http.so
LoadModule proxy_ajp_module / usr/lib/apache2/modules/mod_proxy_ajp.so
LoadModule slotmem_module / usr/lib/apache2/modules/mod_slotmem.so
LoadModule manager_module / usr/lib/apache2/modules/mod_manager.so
LoadModule proxy_cluster_module / usr/lib/apache2/modules/mod_proxy_cluster.so
LoadModule advertise_module / usr/lib/apache2/modules/mod_advertise.so
Listen 192.168.1.119:1515
ServerName actatest.it
ServerAlias www.actatest.it
SetHandler mod_cluster-manager
Order deny, allow
Allow from all
KeepAliveTimeout 60
MaxKeepAliveRequests 0
ManagerBalancerName mycluster
EnableMCPMReceive
jboss side:
July 1st, 2013 on 6:19 pm
you can find the right configuration here
http://www.marcopetrollini.it/configuration.txt
i’m using jboss 7.1.3.Final with mod_cluster 1.2.2.Final
thank you
November 19th, 2013 on 7:29 pm
Thank you very much, the instance-id tip was invaluable and helped me to configure JBoss 7.1.1.Final with httpd 2.2.25 and mod-cluster .1.2.0. I also used the AdvertiseSecurityKey attribute on both the httpd/mod-cluster side and jboss side.
April 17th, 2014 on 12:20 pm
i followed above doc but get same error
[Server:ha-server-1] 20:29:36,429 ERROR [org.jboss.modcluster.mcmp.impl.DefaultMCMPHandler] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) Error [MEM: MEM: Old node still exist: {4}] sending command CONFIG to proxy 10.10.10.10:80, configuration will be reset
2 [Server:ha-server-2] 20:29:37,426 ERROR [org.jboss.modcluster.mcmp.impl.DefaultMCMPHandler] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) Error [MEM: MEM: Can’t read node: {4}] sending command STATUS to proxy 10.10.10.10:80, configuration will be reset
3 [Server:ha-server-2] 20:29:47,432 ERROR [org.jboss.modcluster.mcmp.impl.DefaultMCMPHandler] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) Error [MEM: MEM: Old node still exist: {4}] sending command CONFIG to proxy 10.10.10.10:80, configuration will be reset
4 [Server:ha-server-1] 20:29:56,441 ERROR [org.jboss.
– See more at: http://middlewaremagic.com/jboss/?p=2147#sthash.j3Xyq5w6.dpuf
September 24th, 2016 on 6:54 pm
Hi,
Multiple nodes in the cluster have the same instance-id, which causes conflicts when nodes try to talk to mod_cluster with a instance-id value that is already in use.
-So,make sure to use the unique instance-id within web subsystem for each instance.
Regards,
Pankaj Degave
September 11th, 2014 on 5:40 pm
Hi Thanks for the tutorials. This is helpful.
I am trying to configure it in domain mode and cant get this working.
Would you be able share the relevant configurations please that I can download.
Thanks in Advance.
October 17th, 2014 on 3:28 pm
HI,
Can you pls help me how do we enable sticky sessions.
I am using mod_jk and jboss 6 eap. I have set sticky sessions in mod_jk to true (in worker.properties). Still the sticky sessions doesn’t seem to be working. request will forwarded to different nodes for the same session
April 10th, 2015 on 3:55 pm
Hi,
I am trying to set up the mod cluster load balancer with Apache and Jboss
I have the following set up
Jboss version – jboss-as-7.1.1.Final
Apache – httpd-2.4.12-win32-VC11
mod_cluster-1.3.1.Beta2-windows-x86.zip from http://mod-cluster.jboss.org/downloads/1-3-1-Beta2-bin
httpd configuration
——————–
LoadModule proxy_module modules/mod_proxy.so
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.10.10.107:8888
ManagerBalancerName modcluster
AllowOverride none
Require all granted
KeepAliveTimeout 60
MaxKeepAliveRequests 0
AdvertiseFrequency 5
EnableMCPMReceive On
ServerAdvertise On http://10.10.10.107:8888
AdvertiseGroup 224.0.1.105:23364
SetHandler mod_cluster-manager
Require all granted
————————–
Jboss configuration
I have updated the urn:jboss:domain:modcluster subsyatem with the proxy list 10.10.10.107:8888
But I am getting the following error in Jboss
15:27:40,933 INFO [org.jboss.modcluster.mcmp.impl.DefaultMCMPHandler] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) IO error sending command INFO to proxy 10.10.10.107:8888: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method) [rt.jar:1.7.0_71]
at java.net.SocketInputStream.read(SocketInputStream.java:152) [rt.jar:1.7.0_71]
at java.net.SocketInputStream.read(SocketInputStream.java:122) [rt.jar:1.7.0_71]
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283) [rt.jar:1.7.0_71]
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325) [rt.jar:1.7.0_71]
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177) [rt.jar:1.7.0_71]
at java.io.InputStreamReader.read(InputStreamReader.java:184) [rt.jar:1.7.0_71]
at java.io.BufferedReader.fill(BufferedReader.java:154) [rt.jar:1.7.0_71]
at java.io.BufferedReader.readLine(BufferedReader.java:317) [rt.jar:1.7.0_71]
at java.io.BufferedReader.readLine(BufferedReader.java:382) [rt.jar:1.7.0_71]
at org.jboss.modcluster.mcmp.impl.DefaultMCMPHandler.sendRequest(DefaultMCMPHandler.java:668)
at org.jboss.modcluster.mcmp.impl.DefaultMCMPHandler.status(DefaultMCMPHandler.java:367)
at org.jboss.modcluster.mcmp.impl.DefaultMCMPHandler.status(DefaultMCMPHandler.java:347)
at org.jboss.modcluster.ModClusterService.status(ModClusterService.java:460)
at org.jboss.modcluster.container.catalina.CatalinaEventHandlerAdapter.lifecycleEvent(CatalinaEventHandlerAdapter.java:239)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:115) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590) [jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_71]
15:32:45,061 INFO [org.jboss.as.logging] JBAS011503: Restored bootstrap log handlers
15:32:45,062 INFO [org.apache.coyote.ajp.AjpProtocol] Pausing Coyote AJP/1.3 on ajp–127.0.0.1-8009
15:32:45,064 INFO [com.arjuna.ats.jbossatx] ARJUNA032018: Destroying TransactionManagerService
—————-
In Apache I see that the reponse is being sent back
http_filters.c(1042): [client 10.10.10.107:54741] Response sent with status 200, headers:
http_filters.c(1051): [client 10.10.10.107:54741] Date: Fri, 10 Apr 2015 09:59:21 GMT
http_filters.c(1054): [client 10.10.10.107:54741] Server: Apache/2.4.12 (Win32) mod_cluster/1.3.1.dev
http_filters.c(872): [client 10.10.10.107:54741] Keep-Alive: timeout=60
http_filters.c(872): [client 10.10.10.107:54741] Connection: Keep-Alive
http_filters.c(872): [client 10.10.10.107:54741] Transfer-Encoding: chunked
http_filters.c(872): [client 10.10.10.107:54741] Content-Type: text/plain
—
I even tried with Advertize.java and I get the following response
F:JavaApps>java Advertize 224.0.1.105 23364
ready waiting…
received: HTTP/1.0 200 OK
Date: Fri, 10 Apr 2015 10:06:28 GMT
Sequence: 4
Digest: 01fd9a57d4f1a326dc6d45748c1151d1
Server: a3e8592d-07e8-f746-b8f6-6bd292e20170
X-Manager-Address: localhost:8888
X-Manager-Url: /a3e8592d-07e8-f746-b8f6-6bd292e20170
X-Manager-Protocol: http
Is anybody aware of the issue ? Is this because of the mod-cluster version incompatibility ? Kindly give me some pointers.
-albie