users@glassfish.java.net

Re: mod_jk and glassfish cluster

From: <forums_at_java.net>
Date: Wed, 27 Apr 2011 04:57:39 -0500 (CDT)

Hi,

I don't know if this can help but this is how I managed to get a working
load-balancing of my GlassFish v3.1 cluster with mod_jk.

 

*Cluster setup* : localhost with 3 instances and laptop-host with 1 instance
(openssh installed and configured on both hosts)

- asadmin create-cluster cluster1

- asadmin setup-ssh --sshuser fabien laptop-host

- asadmin create-node-ssh --nodehost laptop-host --sshuser fabien
--installdir /home/fabien/glassfish3 node-laptop

- asadmin create-local-instance --cluster cluster1 instance1

- asadmin create-local-instance --cluster cluster1 instance2

- asadmin create-local-instance --cluster cluster1 instance3

- asadmin create-instance --cluster cluster1 --node node-laptop instance4

- asadmin start-cluster cluster1

 

*Cluster configuration for mod_jk :*

- asadmin create-jvm-options --target cluster1
"-DjvmRoute=\${AJP_INSTANCE_NAME}"

- asadmin create-jvm-options --target cluster1
"-Dcom.sun.enterprise.web.connector.enableJK=\${AJP_PORT}"

- asadmin create-system-properties --target instance1
AJP_INSTANCE_NAME=instance1

- asadmin create-system-properties --target instance1 AJP_PORT=8009

- asadmin create-system-properties --target instance2
AJP_INSTANCE_NAME=instance2

- asadmin create-system-properties --target instance2 AJP_PORT=8010

- asadmin create-system-properties --target instance3
AJP_INSTANCE_NAME=instance3

- asadmin create-system-properties --target instance3 AJP_PORT=8011

- asadmin create-system-properties --target instance4
AJP_INSTANCE_NAME=instance4

- asadmin create-system-properties --target instance4 AJP_PORT=8009

 

*httpd.conf* :

<code>

# Load mod_jk module
LoadModule    jk_module 
/usr/local/apache2/lib/mod_jk-1.2.31-httpd-2.2.x.so
# Where to find workers.properties
JkWorkersFile /usr/local/apache2/conf/workers.properties
# Where to put jk shared memory
JkShmFile     /usr/local/apache2/logs/mod_jk.shm
# Where to put jk logs
JkLogFile     /usr/local/apache2/logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel    info
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkMount  /* loadbalancer

</code>

*workers.properties* :

<code>

# Define 1 real worker using ajp13
worker.list=loadbalancer
#Set properties for instance1
worker.instance1.type=ajp13
worker.instance1.host=localhost
worker.instance1.port=8009
worker.instance1.lbfactor=50
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=8010
worker.instance2.lbfactor=50
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=8011
worker.instance3.lbfactor=50
worker.instance3.socket_keepalive=1
worker.instance3.socket_timeout=300
#Set properties for instance4
worker.instance4.type=ajp13
worker.instance4.host=laptop-host
worker.instance4.port=8009
worker.instance4.lbfactor=50
worker.instance4.socket_keepalive=1
worker.instance4.socket_timeout=300
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=instance1,instance2,instance3,instance4

</code>
 

And finally restart GlassFish and Apache.

I have never had any problem with create-system-properties or
create-jvm-options subcommands. What error do you have ?

 

Regards,

Fabien Leroy.


--
[Message sent by forum member 'fleroy41']
View Post: http://forums.java.net/node/795589