<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Re: More JBoss-AS 5 clusters and more Apache Virtual Hosts
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/willemnoorduin">Willem Noorduin</a> in <i>Beginner's Corner</i> - <a href="http://community.jboss.org/message/576920#576920">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Okay, here it goes (sorry for the length of this post (<span> :| </span>):</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>We have three seperate servers in our setup:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>192.168.0.1 webserver<br/>192.168.0.2 appserver1<br/>192.168.0.3 appserver2</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>We configured the DNS such that <a class="jive-link-external-small" href="http://www.application1.nl">www.application1.nl</a> and <a class="jive-link-external-small" href="http://www.application2.nl">www.application2.nl</a> are landing on the webserver. The aim is to get application contexts /application1 and /application2 mapped to there own cluster:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>cluster1 contains JBoss instances application1_i1, application1_i2, running on respectively</p><p>appserver1 and appserver2, and reacheable via <a class="jive-link-external-small" href="http://appserver1:8009/application1">http://appserver1:8009/application1</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>cluster2 contains JBoss instances application2_i1, application2_i2, running on respectively</p><p>appserver1 and appserver2, and reacheable via <a class="jive-link-external-small" href="http://appserver2:8109/application2">http://appserver2:8109/application2</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>-------------------------------------------------------------------------------------------</p><p>On webserver, we have the following configuration items:</p><p>In the first conf (placed in the conf.d directory) the modules needed for mod_cluster are<br/>loaded into httpd:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>$ cat mod_cluster.conf</p><p>LoadModule proxy_module modules/mod_proxy.so<br/>LoadModule proxy_ajp_module modules/mod_proxy_ajp.so<br/>LoadModule slotmem_module modules/mod_slotmem.so<br/>LoadModule manager_module modules/mod_manager.so<br/>LoadModule proxy_cluster_module modules/mod_proxy_cluster.so<br/>LoadModule advertise_module modules/mod_advertise.so</p><p>At the end of the httpd.conf, we load the conf files of the virtual host. We do this to <br/>establish an order (naming them 0.conf etc works in the same way):</p><p><br/>$ tail httpd.conf</p><p>Include "conf/virtual_hosts/jboss.conf"<br/>Include "conf/virtual_hosts/default.conf"<br/>Include "conf/virtual_hosts/application1conf"<br/>Include "conf/virtual_hosts/application2.conf"</p><p><br/>The vitrual host confs are the following:</p><p>$ cat jboss.conf</p><p>Listen 192.168.0.1:7777</p><p><VirtualHost 192.168.0.1:7777><br/>    KeepAliveTimeout 60<br/>    MaxKeepAliveRequests 0</p><p>    ManagerBalancerName mycluster<br/>    AdvertiseFrequency 5<br/>    ServerAdvertise Off</p><p>    Createbalancers 1<br/></VirtualHost></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>$ cat default.conf</p><p><VirtualHost *:80><br/>    ServerAdmin <a class="jive-link-email-small" href="mailto:unix@tntpost.nl">unix@tntpost.nl</a><br/>    DocumentRoot /apps/nlptc27b14/data<br/>    ServerName nlptc27b14.nlptc27.post.tnt:80<br/>    ErrorLog logs/nlptc27b14-error_log<br/>    CustomLog logs/nlptc27b14-access_log combined<br/>    LogLevel debug</p><p>    # mod_cluster defaults</p><p>    <Location /mcm><br/>       SetHandler mod_cluster-manager<br/>    </Location></p><p></VirtualHost></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>$ cat application1.nl.post.tnt.conf</p><p><VirtualHost *:80><br/>    ServerAdmin <a class="jive-link-email-small" href="mailto:unix@tntpost.nl">unix@tntpost.nl</a><br/>    DocumentRoot /apps/www.application1.nl/data<br/>    ServerName <a class="jive-link-external-small" href="http://www.application1.nl:80">www.application1.nl:80</a><br/>    ErrorLog logs/www.application1.nl-error_log<br/>    CustomLog logs/www.application1.nl-access_log combined<br/>    LogLevel debug</p><p>    ProxyPass / balancer://cluster1/application1 stickysession=JSESSIONID|jsessionid</p><p>nofailover=On<br/>    ProxyPassReverse / balancer://cluster1/application1</p><p></VirtualHost></p><p><br/>$ cat application2.nl.post.tnt.conf</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><VirtualHost *:80><br/>    # Begin rewriting TRACK/TRACE<br/>    RewriteEngine on<br/>    RewriteCond %{REQUEST_METHOD} ^TRACK<br/>    RewriteRule .* - [F]<br/>    RewriteCond %{REQUEST_METHOD} ^TRACE<br/>    RewriteRule .* - [F]<br/>    # End rewriting TRACK/TRACE</p><p>    ServerAdmin <a class="jive-link-email-small" href="mailto:unix@tntpost.nl">unix@tntpost.nl</a><br/>    DocumentRoot /apps/www.application2.nl/data<br/>    ServerName <a class="jive-link-external-small" href="http://www.application2.nl:80">www.application2.nl:80</a><br/>    ErrorLog logs/www.application2.nl-error_log<br/>    CustomLog logs/www.application2.nl-access_log combined</p><p>    ProxyPass / balancer://cluster2/application2 stickysession=JSESSIONID|jsessionid</p><p>nofailover=On<br/>    ProxyPassReverse / balancer://cluster2/</p><p></VirtualHost></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>-----------------------------------------------------------------------------------------</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>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:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>1. mod-cluster.sar is deployed in application1_i1.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>2. application1 is deployed in application1_i1.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>3. In the mod-cluster.sar/META-INF/mod-cluster-jboss-beans.xml we added the following <br/> propeties to the "HAModClusterConfig" and the "ModClusterService":</p><p>    <property name="balancer">cluster1</property><br/>    <property name="proxyList">${jboss.modcluster.proxyList:}</property></p><p> The variable ${jboss.modcluster.proxyList:} is given during startup via a -D option.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>4. In the jbossweb.sar/server.xml we added the following things:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>a. Added the following listener:</p><p>   <Listener</p><p>className="org.jboss.web.tomcat.service.deployers.MicrocontainerIntegrationLifecycleListener" delegateBeanName="HAModClusterService"/></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>b. added jvmRoute="${jboss.jvmRoute}" to the jboss.web Engine entry</p><p> The variable ${jboss.jvmRoute} is given during startup via a -D option.</p><p>--------------------------------------------------------------------------------------------</p><p>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.</p><p>--------------------------------------------------------------------------------------------</p><p>On appserver2 we have the same configuration, only now that instances are called application1_i2 and application2_i2</p><p>--------------------------------------------------------------------------------------------</p><p>On appserver1, we can now start (for example) instance application1_i1 as follows:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>cd /opt/jboss/jboss-as/bin; /opt/jboss/jboss-as/bin/run.sh -c application1_i1 -b appserver1 -g</p><p>cluster1 -u 239.255.100.100 -m 60100 -Djboss.messaging.ServerPeerID=0</p><p>-Djboss.service.binding.set=ports-default -Djboss.server.log.dir=/apps/data/test/fbewbrpp/logs/</p><p>-Djboss.jvmRoute="appserver1" -Djboss.Domain=cluster1</p><p>-Djboss.modcluster.proxyList="192.168.0.1:7777"</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>On appserver2, we can now start (for example) instance application1_i2 as follows:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>cd /opt/jboss/jboss-as/bin; /opt/jboss/jboss-as/bin/run.sh -c application1_i2 -b appserver2 -g</p><p>cluster1 -u 239.255.100.100 -m 60100 -Djboss.messaging.ServerPeerID=1</p><p>-Djboss.service.binding.set=ports-default -Djboss.server.log.dir=/apps/data/test/fbewbrpp/logs/</p><p>-Djboss.jvmRoute="appserver1" -Djboss.Domain=cluster1</p><p>-Djboss.modcluster.proxyList="192.168.0.1:7777"</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Now these form one cluster. We can do the same with cluster2 = (application2_i1,</p><p>application2_i2).</p><p>-------------------------------------------------------------------------------------------</p><p>Problem is still: When I run the configuration with 1 apache virtual host (<a class="jive-link-external-small" href="http://www.application1.nl">www.application1.nl</a>), then <a class="jive-link-external-small" href="http://www.application1.nl/application1">www.application1.nl/application1</a> is available and the cluster manager at <a class="jive-link-external-small" href="http://webserver/mcm">http://webserver/mcm</a> give two active nodes.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>When I run the configuration with 2 apache virtual hosts (<a class="jive-link-external-small" href="http://www.application1.nl">www.application1.nl</a> and <a class="jive-link-external-small" href="http://www.application2.nl">www.application2.nl</a>), then <a class="jive-link-external-small" href="http://www.application1.nl/application1">www.application1.nl/application1</a> is unavailable (Temporary unavailable while lynx <a class="jive-link-external-small" href="http://appserver1:8080/application1">http://appserver1:8080/application1</a> from the webserver gives the application1), and <br/><a class="jive-link-external-small" href="http://www.application2.nl/application2">www.application2.nl/application2</a> 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.</p><p><br/> </p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/576920#576920">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in Beginner's Corner at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>