Muchas veces es necesario que nuestras aplicaciones esten en algun entorno de alta disponibilidad o al menos repartidas en varios servidores para poder soportar la carga.
Si bien lo mejor es tener un balanceador por hardware, una alternativa simple y barata es usar Apache para cumplir esta función.
Para empezar, hay conseguir el paquete mod_jk y copiar mod_jk.so en el directorio modules de Apache.
Luego, agregar mod_jk a la configuración de Apache (httpd.conf) incorporando la línea:
LoadModule jk_module modules/mod_jk-1.2.14-apache-2.0.54.soLuego agregar antes de la Section 3
## Mod_jk settings ## Location of the worker fileJkWorkersFile conf/workers.properties # Location of the log fileJkLogFile logs/mod_jk.log # Log level : debug, info, error or emerg JkLogLevel debug # Shared Memory Filename ( Only for Unix platform ) # required by loadbalancer #JkShmFile $APACHE_HOME/conf/jk/logs/jk.shm # Assign specific URL to Tomcat workers # A mount point from a context to a Tomcat workerJkMount /admin loadbalancer JkMount /admin/* loadbalancer JkMount /examples loadbalancer JkMount /examples/* loadbalancer # A mount point to the status workerJkMount /jkmanager jkstatus JkMount /jkmanager/* jkstatus # Mount point for CASJkMount /cas worker1JkMount /cas/* worker1 # Enable the Jk manager access only from localhost JkMount jkstatus Order deny,allow Deny from all Allow from 127.0.0.1
Luego, en el directorio conf de apache crear un archivo workers.properties y poner:
# workers.properties
# This file should contain the list of workers first:
# worker.list=
# then the properties of each worker:
# worker..=
## The following is an example of a worker.properties file:
# List the workers names
worker.list=worker1,loadbalancer,jkstatus
# ----------------
# First worker
# ----------------
worker.worker1.port=9909
worker.worker1.host=172.30.27.2
worker.worker1.type=ajp13
# Load balance factor
worker.worker1.lbfactor=1
# Define preferred failover node for worker 1
#worker.worker1.redirect=worker2
# ----------------
# Second worker
# ----------------
#worker.worker2.port=9010
#worker.worker2.host=server2
#worker.worker2.type=ajp13
#worker.worker2.lbfactor=1
# Disable worker2 for all requests except failover
#worker.worker2.disabled=True
# ----------------------
# Load Balancer worker
# ----------------------
#worker.loadbalancer.type=lb
#worker.loadbalancer.balanced_workers=worker1,worker2
#Specifies whether requests with session's id should be routed to the same worker
#worker.loadbalancer.sticky_session=false
# ----------------------
# jkstatus worker
# ----------------------
worker.jkstatus.type=statusY en la configuración de Tomcat (/conf/server.xml, o del contenedor Tomcat de Jonas/JBoss) poner:
maxProcessors="75" acceptCount="10" debug="20" protocol="AJP/1.3"/>
Para terminar, arrancar Tomcat/Jonas/JBoss y luego Apache. (siempre en ese orden)
Si todo va bien se podra acceder a CAS desde la url http://localhost/cas.

Esta obra está bajo una licencia de Creative Commons.