This configuration uses Apache mod jk plug-in to load balance
JBoss cluster on AJP protocol. It provides support for the Apache
JServ Protocol (AJP).
Perform following steps to configure:
-
From the Apache Tomcat Connector site, download the mod_jk
plug-in file for your operating system.
Note:
Ensure that your Apache
server supports downloaded mod_jk plug-in file.
-
Rename the downloaded file to mod_jk.so and save it in the
APACHE_HOME/modules/ directory
.
-
In a text editor, open the httpd.conf file located in APACHE_HOME/conf
and add the following line at the end of the file:
Include conf/mod-jk.conf
-
Create a new file
APACHE_HOME/conf/mod-jk.conf
with
the following content :
# Load mod_jk module
# Specify the filename of the mod_jk lib
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
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat
JkRequestLogFormat "%w %V %T"
# Mount your applications
JkMount /* 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 load balancing to work properly
JkShmFile logs/jk.shm
# Add jkstatus for managing run-time data
<Location /jkstatus/>
JkMount status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
-
Create a file at conf/workers.properties with following content
# for mapping requests
worker.list=loadbalancer,status
# Define Node1
# modify the host as your host IP or DNS name.
worker.node1.port=8009
worker.node1.host=node1.mydomain.com
worker.node1.type=ajp13
worker.node1.lbfactor=1
worker.node1.cachesize=10
# Define Node2
# modify the host as your host IP or DNS name.
worker.node2.port=8009
worker.node2.host= node2.mydomain.com
worker.node2.type=ajp13
worker.node2.lbfactor=1
worker.node2.cachesize=10
# Load-balancing behavior
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=1
#worker.list=loadbalancer
# Status worker for managing load balancer
worker.status.type=status
-
In the file, define following items:
-
Each node
of the cluster (in this example, two nodes named node1 and node2)
-
Add all the nodes defined in the file to the
worker.loadbalancer.balance_workers
entry.
-
For each node in the cluster, open the server.xml file located
at
[appserver root]/server/<profile_name>/deploy/jbossweb.sar
for editing.
-
Search the server.xml file for the Engine name element and
add a
jvmRoute
attribute. For example, on a node
named node1 should be:
<Engine name="jboss.web" defaultHost="localhost" jvmRoute="node1">
-
Save the edited server.xml file.
Note:
For each cluster node
value of jvmRoute must be unique and match to the value of the worker
that connects to the respective JBoss.
|
|
|