Tomcat

Home | About me

 

Tomcat Clustering with Apache server: 

Installation of Apache Server:

         bala@bala-desktop:/usr/src/httpd-2.2.3$ ./configure --enable-mods-shared=all --with-apxs --enable-ssl=shared --enable-proxy=shared --prefix=/etc/apache2.2.3

        bala@bala-desktop:/usr/src/httpd-2.2.3$ make

        bala@bala-desktop:/usr/src/httpd-2.2.3$ make install

 

Installation of Tomcat: 

  • Get Tomcat 5.5.0 and create 2 instances named as tomcatA and tomcatB.
  • Uncomment the "Cluster" entry in server.xml for both instances. 
  • Change all the ports in conf/server.xml for tomcatB so that they will run on different ports. 
          For tomcatA:
            ConnectorPort: 8080 
            AJP ConnectorPort: 8009
            Proxied Http connector port: 8082
            shutdown port: 8005
            tcpListenPort: 4001
         For tomcatA:
        ConnectorPort: 8081
        AJP ConnectorPort: 8010
        Proxied Http connector port: 8083
        shutdown port: 8006
        tcpListenPort: 4002

Installation of JKConnector from source:

  • Download jakarta-tomcat-connectors-jk2-2.0.4-src.zip from http://www.apache.org/dist/tomcat/tomcat-connectors/jk2/source/ 
  • Extract the jakarta-tomcat-connectors-jk2-2.0.4-src.zip inside /usr/src directory(Here after we will mention the extracted folder as JK_HOME).  
  • Create the mod_jk2.so by executing following command inside ${JK_HOME}/jk/native2/ 

            bala@bala-desktop: native2]$  ./configure –with-apxs2=/etc/apache2.2.3/bin/apxs 

  • Copy generated mod_jk2.so file from ${JK_HOME}/jk/build/jk2/apache2/ to /etc/apache2.2.3/modules directory.
  •  Create a file called workers2.properties inside /etc/apache2.2.3/conf directory with the following content.

    # Define the communication channel

    [channel.socket:localhost:8009]

    info=Ajp13 forwarding over socket

    tomcatId=localhost:8009

     

    [channel.socket:localhost:8010]

    info=Ajp13 forwarding over socket

    tomcatId=localhost:8010

    # Map the Tomcat examples webapp to the Web server uri space

    [uri:/*]

    info=Map the whole webapp

  • Add the following lines at the end of /etc/apache2.2.3/conf/httpd.conf

                LoadModule jk2_module modules/mod_jk2.so

                     JkSet config.file /etc/apache2.2.3/conf/workers2.properties

 

Restart the apache server and start both instances of tomcat. 

Now you can access all the applications inside Tomcat instances through Apache webserver as http://localhost/jsp-examples :)


Note: web.xml of your application should have <distributable/> entry, so that session replication will work.