Download - Load Balancing With Apache and Jboss As
Load balancing with
Apache and Jboss AS
cluster Apache HTTP 2.2 server with JBoss 4.2.3
Application Server
[Type the abstract of the document here. The abstract is typically a short
summary of the contents of the document. Type the abstract of the document
here. The abstract is typically a short summary of the contents of the document.]
2009
Kusal Gautamadasa
Version 1.2
8/16/2009
2 Load balancing with Apache and Jboss AS cluster
Tested envirnoment
• Jboss 4.2.3
• Apache HTTP 2.2
• Apache Tomcat Connectors 1.2.28 for WIN32
• Jdk 1.6 update 14
• Windows Xp SP 3
Aproach
Appache HTTP server configuration
� workers.properties
worker.list=loadbalancer,status
# Define Node1
Jboss Node D/192.168.1.4
Jboss Node E /192.168.1.5
File name File location
workers.properties \uriworkermap.properties \mod-jk.config \httpd.config \mod_jk.so \
Load balancing with Apache and Jboss AS cluster
Apache Tomcat Connectors 1.2.28 for WIN32
Appache HTTP server configuration
worker.list=loadbalancer,status
Apaache HTP
Server
Jboss Node A /192.168.1.1
Jboss Node B /192.168.1.2
Jboss Node C /192.168.1.3
Jboss Node D/192.168.1.4
File location
\Apache2.2\conf \Apache2.2\conf \Apache2.2\conf \Apache2.2\conf \Apache2.2\modules
Au
gu
st
1
6,
2
00
9
3 Load balancing with Apache and Jboss AS cluster
Au
gu
st
1
6,
2
00
9
# modify the host as your host IP or DNS name.
worker.nodeA.port=8009
worker.nodeA.host=localhost
worker.nodeA.type=ajp13
worker.nodeA.lbfactor=1
worker.nodeA.prepost_timeout=10000 #Not required if using ping_mode=A
worker.nodeA.connect_timeout=10000 #Not required if using ping_mode=A
# worker.node1.connection_pool_size=10 (1)
# Define Node2
# modify the host as your host IP or DNS name.
worker.nodeB.port=8009
worker.nodeB.host=192.168.1.2
worker.nodeB.type=ajp13
worker.nodeB.lbfactor=1
worker.nodeB.prepost_timeout=10000 #Not required if using ping_mode=A
worker.nodeB.connect_timeout=10000 #Not required if using ping_mode=A
# worker.node1.connection_pool_size=10 (1)
#worker.loadbalancer.sticky_session=1
worker.loadbalancer.balance_workers=nodeA,nodeB
# Status worker for managing load balancer
worker.status.type=status
� uriworkermap.properties
/jmx-console=loadbalancer
/jmx-console/*=loadbalancer
/web-console=loadbalancer
/web-console/*=loadbalancer
/hello/hello=loadbalancer
� mod-jk.conf
# Load mod_jk module
# Specify the filename of the mod_jk lib
4 Load balancing with Apache and Jboss AS cluster
Au
gu
st
1
6,
2
00
9
LoadModule jk_module modules/mod_jk.so
# Where to find workers.properties
JkWorkersFile conf/workers.properties
# Where to put jk logs
JkLogFile logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
# JkOptions indicates to send SSK KEY SIZE
# Notes:
# 1) Changed from +ForwardURICompat.
# 2) For mod_rewrite compatibility, use +ForwardURIProxy (default since 1.2.24)
# See http://tomcat.apache.org/security-jk.html
JkOptions +ForwardKeySize +ForwardURICompatUnparsed -ForwardDirectories
# JkRequestLogFormat
JkRequestLogFormat "%w %V %T"
# Mount your applications
JkMount /__application__/* loadbalancer
# Let Apache serve the images
JkUnMount /__application__/images/* loadbalancer
# You can use external file for mount points.
# It will be checked for updates each 60 seconds.
# The format of the file is: /url=worker
# /examples/*=loadbalancer
JkMountFile conf/uriworkermap.properties
# Add shared memory.
# This directive is present with 1.2.10 and
# later versions of mod_jk, and is needed for
# for load balancing to work properly
# Note: Replaced JkShmFile logs/jk.shm due to SELinux issues. Refer to
# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=225452
JkShmFile run/jk.shm
5 Load balancing with Apache and Jboss AS cluster
Au
gu
st
1
6,
2
00
9
# Add jkstatus for managing runtime data
<Location /jkstatus>
JkMount status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
� httpd.config
# Include mod_jk configuration file
Include conf/mod-jk.conf
� mod_jk.so:
Download the so file from the http://www.apache.org/dist/tomcat/tomcat-
connectors/jk/binaries/win32/jk-1.2.28/ and rename to mod_jk.so and move to apache module
directory.
JBoss Configuration
� Server.xml : \server\all\deploy\jboss-web.deployer
Find line
<Engine name="jboss.web" defaultHost="localhost">
And modify to following in respective envirnoments.
<Engine name="jboss.web" defaultHost="localhost" jvmRoute="nodeA">
For a example
Machine Jboss instance Node
192.168.1.1 4.2.3 Node A
192.168.1.2 4.2.1 Node B
192.168.1.3 4.2.0 Node C
192.168.1.4 5.0.1 Node D
192.168.1.5 5.0.0 Node E
AJP 1.3 connector port is 8009 and the default binding is localhost. If the node located in a
remote environment and required to access the web server jboss default binding should
change to “0.0.0.0” respectively. Afterward the node is transparent to the web server.
6 Load balancing with Apache and Jboss AS cluster
Au
gu
st
1
6,
2
00
9
<Connector port="8009" address="${jboss.bind.address}" protocol="AJP/1.3"
emptySessionPath="true" enableLookups="false" redirectPort="8443" />
and modifiy to following
<Connector port="8009" address="0.0.0.0" protocol="AJP/1.3"
emptySessionPath="true" enableLookups="false" redirectPort="8443" />
� jboss-service.xml : \server\all\deploy\jboss-web.deployer\META-INF
this arrtibute uses only for clustering purpose only
<attribute name="UseJK">false</attribute>
And modify to following
<attribute name="UseJK">true</attribute>
Sample appliaction Deployemnet
Sample appliaction Test