1. download apache 2.2
2. download mod_jk1.2.x
3. 修改APACH_HOME\conf\httpd
加入 Include conf/mod-jk.conf
4. 於APACHE_HOME\conf\ 新增 mod-jk.conf ,內容如下:
# Load mod_jk module
# Specify the filename of the mod_jk lib
LoadModule jk_module modules/mod_jk.so
# Where to find workers.properties
JkWorkersFile conf/workers.properties
# Where to put jk logs
JkLogFile logs/mod_jk.log
# 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
# Notes:
# 1) Changed from +ForwardURICompat.
# 2) For mod_rewrite compatibility, use +ForwardURIProxy (default since 1.2.24)
# See http://tomcat.apache.org/security-jk.html
JkOptions +ForwardKeySize +ForwardURICompatUnparsed -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
JkMountFile conf/uriworkermap.properties
# 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
# Note: Replaced JkShmFile logs/jk.shm due to SELinux issues. Refer to
# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=225452
JkShmFile run/jk.shm
#JkMountCopy all
# Add jkstatus for managing runtime data
JkMount status
Order deny,allow
Deny from all
Allow from all
5. 於APACHE_HOME\conf\ 下新增 workers.properties , 內容如下: (更改各node的ip)
# Define list of workers that will be used
# for mapping requests
# The configuration directives are valid
# for the mod_jk version 1.2.18 and later
#
worker.list=loadbalancer,status
# Define Node1
# modify the host as your host IP or DNS name.
worker.node1.port=8009
worker.node1.host=172.16.1.40
worker.node1.type=ajp13
worker.node1.lbfactor=1
# worker.node1.connection_pool_size=10 (1)
# Define Node2
# modify the host as your host IP or DNS name.
worker.node2.port=8009
worker.node2.host=172.16.1.46
worker.node2.type=ajp13
worker.node2.lbfactor=1
# worker.node1.connection_pool_size=10 (1)
# Load-balancing behaviour
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
# Status worker for managing load balancer
worker.status.type=status
6. 於APACHE_HOME\conf\ 下新增 uriworkermap.properties , 內容如下: (/DynWebProject是我的web application的webcontent)
# Simple worker configuration file
#
# Mount the Servlet context to the ajp13 worker
/jmx-console=loadbalancer
/jmx-console/*=loadbalancer
/web-console=loadbalancer
/web-console/*=loadbalancer
/DynWebProject/=loadbalancer
/DynWebProject/*=loadbalancer
7.重啟APACHE
8. 如要設定sticky session mode, 可於各台JBoss的JBOSS_HOME\server\your Configuration\deploy\jboss-web.deployer\server.xml設定jvmRoute(對應node)
Engine name="jboss.web" defaultHost="localhost" jvmRoute="nodeX"
沒有留言:
張貼留言