[jboss-user] [Beginner's Corner] - Re: More JBoss-AS 5 clusters and more Apache Virtual Hosts

Willem Noorduin do-not-reply at jboss.com
Tue Dec 21 04:10:56 EST 2010


Willem Noorduin [http://community.jboss.org/people/willemnoorduin] created the discussion

"Re: More JBoss-AS 5 clusters and more Apache Virtual Hosts"

To view the discussion, visit: http://community.jboss.org/message/576920#576920

--------------------------------------------------------------
Okay, here it goes (sorry for the length of this post ( :| ):

We have three seperate servers in our setup:

192.168.0.1 webserver
192.168.0.2 appserver1
192.168.0.3 appserver2

We configured the DNS such that  http://www.application1.nl www.application1.nl and  http://www.application2.nl www.application2.nl are landing on the webserver. The aim is to get application contexts /application1 and /application2 mapped to there own cluster:

cluster1 contains JBoss instances application1_i1, application1_i2, running on respectively
appserver1 and appserver2, and reacheable via  http://appserver1:8009/application1 http://appserver1:8009/application1

cluster2 contains JBoss instances application2_i1, application2_i2, running on respectively
appserver1 and appserver2, and reacheable via  http://appserver2:8109/application2 http://appserver2:8109/application2

-------------------------------------------------------------------------------------------
On webserver, we have the following configuration items:
In the first conf (placed in the conf.d directory) the modules needed for mod_cluster are
loaded into httpd:

$ cat mod_cluster.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
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
At the end of the httpd.conf, we load the conf files of the virtual host. We do this to 
establish an order (naming them 0.conf etc works in the same way):

$ tail httpd.conf
Include "conf/virtual_hosts/jboss.conf"
Include "conf/virtual_hosts/default.conf"
Include "conf/virtual_hosts/application1conf"
Include "conf/virtual_hosts/application2.conf"

The vitrual host confs are the following:
$ cat jboss.conf
Listen 192.168.0.1:7777
<VirtualHost 192.168.0.1:7777>
    KeepAliveTimeout 60
    MaxKeepAliveRequests 0
    ManagerBalancerName mycluster
    AdvertiseFrequency 5
    ServerAdvertise Off
    Createbalancers 1
</VirtualHost>

$ cat default.conf
<VirtualHost *:80>
    ServerAdmin  mailto:unix at tntpost.nl unix at tntpost.nl
    DocumentRoot /apps/nlptc27b14/data
    ServerName nlptc27b14.nlptc27.post.tnt:80
    ErrorLog logs/nlptc27b14-error_log
    CustomLog logs/nlptc27b14-access_log combined
    LogLevel debug
    # mod_cluster defaults
    <Location /mcm>
       SetHandler mod_cluster-manager
    </Location>
</VirtualHost>

$ cat application1.nl.post.tnt.conf
<VirtualHost *:80>
    ServerAdmin  mailto:unix at tntpost.nl unix at tntpost.nl
    DocumentRoot /apps/www.application1.nl/data
    ServerName  http://www.application1.nl:80 www.application1.nl:80
    ErrorLog logs/www.application1.nl-error_log
    CustomLog logs/www.application1.nl-access_log combined
    LogLevel debug
    ProxyPass / balancer://cluster1/application1 stickysession=JSESSIONID|jsessionid
nofailover=On
    ProxyPassReverse / balancer://cluster1/application1
</VirtualHost>

$ cat application2.nl.post.tnt.conf

<VirtualHost *:80>
    # Begin rewriting TRACK/TRACE
    RewriteEngine on
    RewriteCond %{REQUEST_METHOD} ^TRACK
    RewriteRule .* - [F]
    RewriteCond %{REQUEST_METHOD} ^TRACE
    RewriteRule .* - [F]
    # End rewriting TRACK/TRACE
    ServerAdmin  mailto:unix at tntpost.nl unix at tntpost.nl
    DocumentRoot /apps/www.application2.nl/data
    ServerName  http://www.application2.nl:80 www.application2.nl:80
    ErrorLog logs/www.application2.nl-error_log
    CustomLog logs/www.application2.nl-access_log combined
    ProxyPass / balancer://cluster2/application2 stickysession=JSESSIONID|jsessionid
nofailover=On
    ProxyPassReverse / balancer://cluster2/
</VirtualHost>

-----------------------------------------------------------------------------------------

On appserver1. we have (for example) instance application1_i1, which is primarily a clone of the production instance (on Redhat JBoss 5, this is the same as a clone of the all instance). The following items are changed:

1. mod-cluster.sar is deployed in application1_i1.

2. application1 is deployed in application1_i1.

3. In the mod-cluster.sar/META-INF/mod-cluster-jboss-beans.xml we added the following 
 propeties to the "HAModClusterConfig" and the "ModClusterService":
    <property name="balancer">cluster1</property>
    <property name="proxyList">${jboss.modcluster.proxyList:}</property>
 The variable ${jboss.modcluster.proxyList:} is given during startup via a -D option.

4. In the jbossweb.sar/server.xml we added the following things:

a. Added the following listener:
   <Listener
className="org.jboss.web.tomcat.service.deployers.MicrocontainerIntegrationLifecycleListener" delegateBeanName="HAModClusterService"/>

b. added jvmRoute="${jboss.jvmRoute}" to the jboss.web Engine entry
 The variable ${jboss.jvmRoute} is given during startup via a -D option.
--------------------------------------------------------------------------------------------
On appserver1, we have instance application2_i1, which is the same as application1_i1. The only difference with application1_i2 is that we deploy application2 in this instance.
--------------------------------------------------------------------------------------------
On appserver2 we have the same configuration, only now that instances are called application1_i2 and application2_i2
--------------------------------------------------------------------------------------------
On appserver1, we can now start (for example) instance application1_i1 as follows:

cd /opt/jboss/jboss-as/bin; /opt/jboss/jboss-as/bin/run.sh -c application1_i1 -b appserver1 -g
cluster1 -u 239.255.100.100 -m 60100 -Djboss.messaging.ServerPeerID=0
-Djboss.service.binding.set=ports-default -Djboss.server.log.dir=/apps/data/test/fbewbrpp/logs/
-Djboss.jvmRoute="appserver1" -Djboss.Domain=cluster1
-Djboss.modcluster.proxyList="192.168.0.1:7777"

On appserver2, we can now start (for example) instance application1_i2 as follows:

cd /opt/jboss/jboss-as/bin; /opt/jboss/jboss-as/bin/run.sh -c application1_i2 -b appserver2 -g
cluster1 -u 239.255.100.100 -m 60100 -Djboss.messaging.ServerPeerID=1
-Djboss.service.binding.set=ports-default -Djboss.server.log.dir=/apps/data/test/fbewbrpp/logs/
-Djboss.jvmRoute="appserver1" -Djboss.Domain=cluster1
-Djboss.modcluster.proxyList="192.168.0.1:7777"

Now these form one cluster. We can do the same with cluster2 = (application2_i1,
application2_i2).
-------------------------------------------------------------------------------------------
Problem is still: When I run the configuration with 1 apache virtual host ( http://www.application1.nl www.application1.nl), then  http://www.application1.nl/application1 www.application1.nl/application1 is available and the cluster manager at  http://webserver/mcm http://webserver/mcm give two active nodes.

When I run the configuration with 2 apache virtual hosts ( http://www.application1.nl www.application1.nl and  http://www.application2.nl www.application2.nl), then  http://www.application1.nl/application1 www.application1.nl/application1 is unavailable (Temporary unavailable while lynx  http://appserver1:8080/application1 http://appserver1:8080/application1 from the webserver gives the application1), and 
 http://www.application2.nl/application2 www.application2.nl/application2 is available. In this case I see two nodes in the cluster manager (I expect 4) and not all the information there can I call reliable.
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/576920#576920]

Start a new discussion in Beginner's Corner at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20101221/58a11216/attachment-0001.html 


More information about the jboss-user mailing list