users@glassfish.java.net

Re: How to set jvmRoute for AJP/mod_jk load balancing

From: <glassfish_at_javadesktop.org>
Date: Thu, 01 Nov 2007 13:46:04 PST

I have installed Glassfish in "/usr/glassfish" if your installation path is different, change any references to "/usr/glassfish" to point to your installation path. My Apache config files are in "/etc/httpd/conf" ... same disclaimer applies. I am running the latest stable version of Glassfish and the version of Apache that comes with Fedora Core 6.

1) I downloaded the patch and put it into /usr/glassfish/lib and renamed it to "jvmroute_patch.jar"

2) I modified my domain.xml file which was located in /usr/glassfish/domains/domain1/config:
2a) The line that beings with '<java-config classpath-suffix="" ' ... I inserted 'classpath-prefix="/usr/glassfish/lib/jvmroute_patch.jar" ' so that it now reads '<java-config classpath-prefix="/usr/glassfish/lib/jvmroute_patch.jar" classpath-suffix="" ' ...
2b) Two lines further down, (right after '<!-- various required jvm-options -->' ) I placed the following two lines:
<jvm-options>-Dcom.sun.enterprise.web.connector.enableJK=8009</jvm-options>
<jvm-options>-DjvmRoute=glassfish1</jvm-options>

3) I have a Glassfish worker on port 8009 and a Tomcat worker listening on 8010. I created the following file as /etc/httpd/conf/workers.properties :
#=======================================
#Define workers using ajp13
worker.list=glassfish1, tomcat1, lb1

# ----------------------
# first glassfish worker
# ----------------------
worker.glassfish1.type=ajp13
worker.glassfish1.host=localhost.localdomain
worker.glassfish1.port=8009
worker.glassfish1.lbfactor=50
worker.glassfish1.socket_keepalive=1
worker.glassfish1.socket_timeout=300
# ----------------------
# first tomcat worker
# ----------------------
worker.tomcat1.type=ajp13
worker.tomcat1.host=localhost.localdomain
worker.tomcat1.port=8010
worker.tomcat1.lbfactor=50
worker.tomcat1.socket_keepalive=1
worker.tomcat1.socket_timeout=300
# ----------------------
# First Load Balancer worker
# ----------------------
worker.lb1.type=lb
worker.lb1.balance_workers=glassfish1,tomcat1
worker.lb1.sticky_session=true
#=======================================

4) Modified my /etc/httpd/conf/httpd.conf file and added the following at the end of the loadmodule section:
#=========================================
LoadModule jk_module /usr/lib/httpd/modules/mod_jk.so
JkWorkersFile /etc/httpd/conf/workers.properties
# Where to put jk logs
JkLogFile /var/log/httpd/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel debug
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"

# Send all app1 requests to the load balancer
JkMount /app1/* lb1
#==========================================

5.) Restart Glassfish, then restart Apache. If Apache's connection with a worker is broken, Apache will wait longer and longer between attempts to reconnect with the worker, so in a test environment the best thing is to just restart Apache so communication starts again right away.
[Message sent by forum member 'jakemann' (jakemann)]

http://forums.java.net/jive/thread.jspa?messageID=243382