Friday, 6 September 2013

Apache Tomcat Clustering 1

                              Apache Tomcat Clustering


Hi Readers,

This is my very first post. I am going to start with Apache Tomcat clustering and session replication mechanism.

A clustering  is defined as a group of application servers that transparently run a J2EE application as it were a single entity.

There are two types of clustering  Horizontal Clustering and Vertical Clustering.

Horizontal Clustering is running multiple java application servers that are run on two or more separate physical machines.

Vertical Clustering consists of multiple java application servers on a single physical machine.

Here  I am providing the detail configuration of Vertical Tomcat Clustering.

Java And Tomcat System Configuration

We need to change the environmental variable JAVA_HOME to C:\Java\jdk 1.6

Install Apache 2
  1.    Download Apache 2 binary for windows. We can get it from the site
                                http://httpd.apache.org/download.cgi.
  2.  First you make sure that no web server running in the port 80 of your local machine. 

Install Apache Tomcat
   Download Apache Tomcat from Apache site.
              http://tomcat.apache.org/download-70.cgi
    Change the environmental variable CATALINA_HOME 

Install JK Connector
 1.Download the JK Connector from site
 http://jakarta.apache.org/builds/jakarta- tomcat-connectors/jk/release/v1.2.1/bin/win32/
  2. JK Connector is used to connect  Apache with tomcat. We will download mod_jk.so file.

Tomcat Configuration

Change CATALINA_HOME in startup.bat file in each Apache Tomcat instance.

Tomcat 1 :  set CATALINA_HOME=C:/Tomcat1
Tomcat 2 :  set CATALINA_HOME=C:/Tomcat2


Change the Connector port for HTTP in server.xml file in Apache Tomcat and add  
different port for different Tomcat instance. So, no port conflict will occur.
    
 Change the Connector port for AJP Connector through which Apache will talk to
  tomcat. Use different AJP Connector port for different tomcat instances.

  <Connector port="8109" protocol="AJP/1.3" redirectPort="8443">
   <Connector port="8209" protocol="AJP/1.3" redirectPort="8443">

Add jvmRoute attribute for AJP Connector pointing to each tomcat instance.

Tomcat1: <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" jvmRoute=" Tomcat1"/>
Tomcat2: <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"jvmRoute=" Tomcat2"/>

UnComment  the clustering tag  in server.xml file in tomcat.

<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>

Edit Tomcat's configuration in both C:\tomcat1\conf\server.xml  and 
          C:\tomcat2\conf\server.xml file.

<Listener className="org.apache.ajp.tomcat4.conf.ApacheConf" 
          forwardAll="false" append="true"
          modJk="C:/Program Files (x86)/Apache Software Foundation/Apache2.2/modules/mod_jk.so">

Add above modjk Listener in server.xml below shutdown port

<Server port="8005" shutdown="SHUTDOWN" debug="0">

Edit Tomcat configuration in both C:\tomcat1\conf\server.xml  & C:\tomcat2\conf\server.xml file.


<Listener className="org.apache.ajp.tomcat4.conf.ApacheConf"
        forwardAll="false"  append="true"
        modJk=" C:/Program Files (x86)/Apache Software Foundation/Apache2.2/
                     modules/mod_jk.so ">
      Add above modJk Listener in the server.xml below 

<Host name="localhost"  debug="0"  appBase="webapps"   
         unpackWARs="true"  autoDeploy="true">

Run both the tomcats 
Tomcat 1 :

Tomcat 2 :


I will continue the remaining setup in next post....

No comments:

Post a Comment

Spring 3 Rest Web Service Batch Update with JQuery & Ajax Integration

                      Spring 3  Rest Web Service Batch Update with JQuery & Ajax Integration Hi     In this blog I will describe the...