Friday January 30, 2009
TOTD #67: How to front-end a GlassFish Cluster with Apache + mod_jk on Mac OSX Leopard ?
GlassFish
provides support for High Availability by creating a cluster of server
instances and session state replication. This enhances the
scalability and availability of your application and is a critical
piece of decision making critieria when selecting an Application
Server. Clustering
in GlassFish Version 2 provides comprehensive introduction to
clustering, high availability and load balancing in GlassFish.
GlassFish provides out-of-the-box support for load-balancing HTTP(S),
JMS,
and RMI/IIOP
traffic and front-ended by Sun Java System Web Server, Apache Web
Server, and Microsoft IIS (more
details here) using the Load
Balancer plug-in. This plug-in however is not available for
Mac OS X and a popular technique used on that platform for front-ending
is to use Apache httpd
+ mod_jk.
This is exactly what this TOTD (Tip
Of The Day) is going to
describe.
This TOTD is going to explain how to front-end a 3-instance GlassFish
cluster with Apache httpd and mod_jk on Mac OS X.
This blog is using information from the following blogs:

| ~/samples/v2/clustering/glassfish/bin
>./asadmin
create-jvm-options --target cluster1
"-DjvmRoute=\${AJP_INSTANCE_NAME}" Command create-jvm-options executed successfully. ~/samples/v2/clustering/glassfish/bin >./asadmin create-jvm-options --target cluster1 "-Dcom.sun.enterprise.web.connector.enableJK=\${AJP_PORT}" Command create-jvm-options executed successfully. |
| ~/samples/v2/clustering/glassfish/bin
>./asadmin
create-system-properties --target instance1
AJP_INSTANCE_NAME=instance1 Command create-system-properties executed successfully. ~/samples/v2/clustering/glassfish/bin >./asadmin create-system-properties --target instance1 AJP_PORT=9090 Command create-system-properties executed successfully. ~/samples/v2/clustering/glassfish/bin >./asadmin create-system-properties --target instance2 AJP_INSTANCE_NAME=instance2 Command create-system-properties executed successfully. ~/samples/v2/clustering/glassfish/bin >./asadmin create-system-properties --target instance2 AJP_PORT=9091 Command create-system-properties executed successfully. ~/samples/v2/clustering/glassfish/bin >./asadmin create-system-properties --target instance3 AJP_INSTANCE_NAME=instance3 Command create-system-properties executed successfully. ~/samples/v2/clustering/glassfish/bin >./asadmin create-system-properties --target instance3 AJP_PORT=9092 Command create-system-properties executed successfully. |
| httpd: Syntax error on line 116 of /private/etc/apache2/httpd.conf: Cannot load /usr/libexec/apache2/mod_jk-1.2.25-httpd-2.2.4.so into server: dlopen(/usr/libexec/apache2/mod_jk-1.2.25-httpd-2.2.4.so, 10): no suitable image found. Did find:\n\t/usr/libexec/apache2/mod_jk-1.2.25-httpd-2.2.4.so: mach-o, but wrong architecture |
| ~/workspaces/tomcat-connectors-1.2.27-src/native >./configure --with-apxs=/usr/sbin/apxs |
| .
. . checking for target platform... unix no apache given no netscape given configure: creating ./config.status config.status: creating Makefile config.status: creating apache-1.3/Makefile config.status: creating apache-1.3/Makefile.apxs config.status: creating apache-2.0/Makefile config.status: creating apache-2.0/Makefile.apxs config.status: creating common/Makefile config.status: creating common/list.mk config.status: creating common/jk_types.h config.status: creating jni/Makefile config.status: creating common/portable.h config.status: executing depfiles commands |
| ~/workspaces/tomcat-connectors-1.2.27-src/native/apache-2.0 >sudo cp mod_jk.so /usr/libexec/apache2/ |
| LoadModule jk_module libexec/apache2/mod_jk-1.2.25-httpd-2.2.4.so |
| JkWorkersFile
/etc/apache2/worker.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] " # JkRequestLogFormat set the request format JkRequestLogFormat "%w %V %T" # Send all jsp requests to GlassFish JkMount /*.jsp loadbalancer |
| sudo mkdir /var/log/httpd |
| #
Define 1 real worker using ajp13 worker.list=loadbalancer # Set properties for instance1 worker.instance1.type=ajp13 worker.instance1.host=localhost worker.instance1.port=9090 worker.instance1.lbfactor=50 worker.instance1.cachesize=10 worker.instance1.cache_timeout=600 worker.instance1.socket_keepalive=1 worker.instance1.socket_timeout=300 # Set properties for instance2 worker.instance2.type=ajp13 worker.instance2.host=localhost worker.instance2.port=9091 worker.instance2.lbfactor=50 worker.instance2.cachesize=10 worker.instance2.cache_timeout=600 worker.instance2.socket_keepalive=1 worker.instance2.socket_timeout=300 # Set properties for instance3 worker.instance3.type=ajp13 worker.instance3.host=localhost worker.instance3.port=9092 worker.instance3.lbfactor=50 worker.instance3.cachesize=10 worker.instance3.cache_timeout=600 worker.instance3.socket_keepalive=1 worker.instance3.socket_timeout=300 worker.loadbalancer.type=lb worker.loadbalancer.balance_workers=instance1,instance2,instance3 |
| ~/samples/v2/clustering/glassfish/lib
>cp
~/tools/apache-tomcat-5.5.27/server/lib/tomcat-ajp.jar . ~/samples/v2/clustering/glassfish/lib >cp ~/Downloads/commons-logging-1.1.1/commons-logging-1.1.1.jar . ~/samples/v2/clustering/glassfish/lib >cp ~/tools/commons-modeler-2.0.1/commons-modeler-2.0.1.jar . |
| #Listen 12.34.56.78:80 Listen 80 |
| sudo httpd |
| . . . [Thu Jan 29 11:14:16 2009] [warn] Init: Session Cache is not configured [hint: SSLSessionCache] [Thu Jan 29 11:14:16 2009] [warn] No JkShmFile defined in httpd.conf. Using default /usr/logs/jk-run time-status [Thu Jan 29 11:14:16 2009] [warn] No JkShmFile defined in httpd.conf. Using default /usr/logs/jk-run time-status [Thu Jan 29 11:14:16 2009] [notice] Digest: generating secret for digest authentication ... [Thu Jan 29 11:14:16 2009] [notice] Digest: done [Thu Jan 29 11:14:16 2009] [warn] pid file /private/var/run/httpd.pid overwritten -- Unclean shutdow n of previous Apache run? [Thu Jan 29 11:14:16 2009] [notice] Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l DAV/2 mod_jk/1. 2.27 configured -- resuming normal operations |




Posted by Arun Gupta in General | Comments[7]
|
|
|
|
|
Today's Page Hits: 3268
Total # blog entries: 1002
Good page!
Welcome to visit my blog too!
http://www.jewelrypearl.ca
Posted by Pearl jewelry on February 02, 2009 at 02:31 AM PST #
Good blog!
Posted by wholesale jewelry on February 02, 2009 at 06:45 PM PST #
Posted by Arun Gupta's Blog on February 10, 2009 at 05:53 AM PST #
Posted by Arun Gupta's Blog on February 12, 2009 at 12:16 AM PST #
Posted by Arun Gupta's Blog on April 24, 2009 at 01:38 PM PDT #
Posted by Arun Gupta's Blog on August 12, 2009 at 06:10 AM PDT #
Posted by Arun Gupta's Blog on August 12, 2009 at 09:14 AM PDT #