JK connector is used to serve request from tomcat webservers. JK module is loaded into Apache Http Server optionally using following lines in httpd.conf file under conf folder of Apache installation directory.
LoadModule jk_module modules/mod_jk.so
Single or Multiple tomcat server (Clustered configurations) can be used to serve request. Tomcat server need to defined in worker.properties files which will be loaded into apache conf file.
workers.tomcat_home=/tomcatA
workers.java_home="/usr/java/jdk1.6.0_06"
ps=/
worker.list=loadbalancer
worker.tomcatA.port=8109
worker.tomcatA.host=192.168.0.11
worker.tomcatA.type=ajp13
worker.tomcatA.lbfactor=1
worker.tomcatA.socket_timeout=1
worker.tomcatA.connect_timeout=1000
worker.tomcatA.prepost_timeout=1000
worker.tomcatA.reply_timeout=600000
worker.tomcatA.socket_keepalive=False
worker.tomcatA.connection_pool_size=5000
worker.tomcatA.connection_pool_minsize=500
worker.tomcatA.connection_pool_timeout=300
worker.tomcatA.redirect=tomcatB
worker.tomcatB.port=8209
worker.tomcatB.host=192.168.0.12
worker.tomcatB.type=ajp13
worker.tomcatB.lbfactor=1
worker.tomcatB.socket_timeout=1
worker.tomcatB.connect_timeout=1000
worker.tomcatB.prepost_timeout=1000
worker.tomcatB.reply_timeout=600000
worker.tomcatB.socket_keepalive=False
worker.tomcatB.connection_pool_size=5000
worker.tomcatB.connection_pool_minsize=500
worker.tomcatB.connection_pool_timeout=300
worker.tomcatB.redirect=tomcatA
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=tomcatA,tomcatB
worker.loadbalancer.sticky_session=True
worker.loadbalancer.retries=2
Configurations for loading worker file into apache conf file.
JkWorkersFile "/etc/httpd/conf/workers.properties"
JkShmFile "/var/log/httpd/mod_jk.shm"
JkLogFile "/etc/httpd/logs/mod_jk.log"
JkLogLevel info
You can mount a particular folder or project or mount all to pass every thing to tomcat. Few sample configuration are listed below.
JkMount /* loadbalancer
JkMount /servlet/* loadbalancer
JkMount /jsp/* loadbalancer
JkMount /project tomcatA
JkMount /project/jsp/* loadbalancer
Filter request from forwarding to tomcat for html, jpg and gif and can be served from apache http server.
JkUnMount /project/*.html loadbalancer
JkUnMount /project/*.jpg loadbalancer
For single tomcat server you don't require loadbalancer configuration. Only tomcatA will server the request and can be used in place of loadbalancer.
Post a Comment