Aqui está todo o processo passo a passo para o balanceamento de carga do servidor de aplicativos jboss com o apache usando mod_jk.
etapa 1: configuração do ambiente
Ubuntu 11.04
JBoss AS 5.1-GA
Apache 2
mod_jk 1.2.30
My setup looks something like the following:
Apache Web Server: 192.168.1.12:80 - lb1
JBoss App Server 1: 192.168.1.53:8080 - app1
JBoss App Server 2: 192.168.1.56:8080 - app2
etapa 2: configurando o apache
crie os seguintes arquivos na pasta / etc / apache2 / conf
step -I: create file httpd.conf
# Include mod_jk's specific configuration file
Include conf/mod-jk.conf
e substitua este arquivo por um que esteja lá em / etc / apache
step -II: create file mod-jk.conf
# 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 /application/* 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
# here cluster1 is the name of the test project that i used
JkMountFile conf/uriworkermap.properties
JkMount /cluster1 loadbalancer
JkMount /cluster1/* loadbalancer
# Add shared memory.
# This directive is present with 1.2.10 and
# later versions of mod_jk, and is needed for
# for load balancing to work properly
JkShmFile logs/jk.shm
# Add jkstatus for managing runtime data
<Location /jkstatus/>
JkMount status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
<VirtualHost *:80>
ServerName 192.168.1.53
JkMountFile conf/uriworkermap.properties
</VirtualHost>
passo -III: criar arquivo uriworkermap.properties
# Simple worker configuration file
# Mount the Servlet context to the ajp13 worker
/jmx-console=loadbalancer
/jmx-console/*=loadbalancer
/web-console=loadbalancer
/web-console/*=loadbalancer
/*=loadbalancer
etapa -IV: criar arquivo workers.properties
# Define list of workers that will be used
# for mapping requests
worker.list=loadbalancer,status
# Define Node1
# modify the host as your host IP or DNS name.
worker.worker1.port=8009
worker.worker1.host=192.168.1.53
worker.worker1.type=ajp13
worker.worker1.lbfactor=1
worker.worker1.cachesize=10
# Define Node2
# modify the host as your host IP or DNS name.
worker.worker2.port=8009
worker.worker2.host= 192.168.1.56
worker.worker2.type=ajp13
worker.worker2.lbfactor=1
worker.worker2.cachesize=10
# Load-balancing behaviour
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=worker1,worker2
worker.loadbalancer.sticky_session=1
#worker.list=loadbalancer
# Status worker for managing load balancer
worker.status.type=status
# Simple worker configuration file
# Mount the Servlet context to the ajp13 worker
/jmx-console=loadbalancer
/jmx-console/*=loadbalancer
/web-console=loadbalancer
/web-console/*=loadbalancer
/*=loadbalancer
Passo 3: configurando o jboss
modifique o server.xml do seu jboss da seguinte forma:
<Engine name="jboss.web" defaultHost="localhost" jvmRoute="worker1">
mesmo para o server2 usando worker2 em vez de worker1.
agora inicie o jboss e o apache.
tente localhost em seu navegador na máquina lb1 ele será redirecionado para a página do jboss (na porta 8080) em execução no server1.
para melhor resultado tente usar três máquinas diferentes. Eu tentei no ubuntu-11.04 e centos seu trabalho bem.
é isso.
Obrigado .............