Thursday, July 21, 2011

Tomcat-Apache load balancing: Load balance tomcats

Tomcat-Apache load balancing: Load balance tomcats: "Load balancing 2 tomcats Requisites 1) 2 tomcat servers (version5.5) Download Tomcat 2) 1 Apache httpd server (version2.2) Download Apach..."

Tuesday, February 22, 2011

Load balance tomcats


Load balancing 2 tomcats

Requisites
1) 2 tomcat servers (version5.5) Download Tomcat
2) 1 Apache httpd server (version2.2) Download Apache


Step1: Configure MOD-JK tomcat connector

a. Download mod_jk-1.2.9-apache-2.0.53.so for apache2.x version from here
b. Rename to mod_jk.so and copy to %APACHE_HTTP_HOME%\modules
c. Add following lines to %APACHE_HTTP_HOME%\conf\httpd.conf






LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkShmFile logs/mod_jk.shm
JkLogFile logs/mod_jk.log
JkMount /* lbworker1
JkMount /jkstatus/ stworker1


Step2: Configure workers

a. Create new file workers.properties under %APACHE_HTTP_HOME%\conf\
b. Add following lines in workers.properties





# Configure the list of load balancer worker and status worker
worker.list= lbworker1 , stworker1

# Configure the individual tomcat server workers
worker.ajpworker1.host=localhost
worker.ajpworker1.port=8009
worker.ajpworker1.type=ajp13
worker.ajpworker1.lbfactor=1
# worker.ajpworker1.mount=/contexta /contexta/* /contextb /contextb/*

worker.ajpworker2.host=localhost
worker.ajpworker2.port=8010
worker.ajpworker2.type=ajp13
worker.ajpworker2.lbfactor=1
# worker.ajpworker2.mount=/contexta /contexta/* /contextb /contextb/*

# Configure the load balancer worker
worker.lbworker1.type=lb
worker.lbworker1.balance_workers= ajpworker1,ajpworker2

# Configure the load balanacer status worker
worker.stworker1.type= status



Step3: Configure tomcats

Open server.xml
a. Comment out the http connector

b. Comment out the default Catalina Engine

c. Remove comments from the load balancer Catalina Engine jvmRoute

d. Name the jvmRoute as the respective ajp worker name. This should be unique amongst servers
e. Change the AJP port number and redirect port to keep it unique amongst different tomcats
f. Repeat the steps for the other tomcat.


Step 4: Start the tomcats and then the httpd apache