Tomcat5.5.12配置负载均衡
参考:http://raibledesigns.com/tomcat/
[@more@]1:安装准备
下载Tomcat5.5.12.zip;apache_2.0.55-win32-x86-no_ssl;mod_jk.dll;
2:解压缩Tomcat5.5.12.zip设置环境变量(JAVA_HOME=C:Program FilesJavajdk1.5.0_02),安装apache_2.0.55-win32-x86-no_ssl(安装时需要填写本机的计算机名!!)
3:把mod_jk.dll COPY到..Apache2modules下,在..Apache2conf下建新文件workers.properties,文件内容:
#
# workers.properties
#
# In Unix, we use forward slashes:
ps=/
# list the workers by name
worker.list=tomcat1, tomcat2, loadbalancer
# ------------------------
# First tomcat server
# ------------------------
worker.tomcat1.port=11009
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13
# Specify the size of the open connection cache.
#worker.tomcat1.cachesize
#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
# ----> lbfactor must be > 0
# ----> Low lbfactor means less work done by the worker.
worker.tomcat1.lbfactor=100
# ------------------------
# Second tomcat server
# ------------------------
worker.tomcat2.port=12009
worker.tomcat2.host=localhost
worker.tomcat2.type=ajp13
# Specify the size of the open connection cache.
#worker.tomcat2.cachesize
#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
# ----> lbfactor must be > 0
# ----> Low lbfactor means less work done by the worker.
worker.tomcat2.lbfactor=100
# ------------------------
# Load Balancer worker
# ------------------------
#
# The loadbalancer (type lb) worker performs weighted round-robin
# load balancing with sticky sessions.
# Note:
# ----> If a worker dies, the load balancer will check its state
# once in a while. Until then all work is redirected to peer
# worker.
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=tomcat1, tomcat2
#
# END workers.properties
#
4:设置confhttpd.config文件
在# Example:
# LoadModule foo_module modules/mod_foo.so
#下添加
LoadModule jk_module modules/mod_jk.dll
#
# Configure mod_jk
#
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
在DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"下添加:
JkMount /*.jsp loadbalancer
JkMount /* loadbalancer
JkMount /servlet/* loadbalancer
5:配置tomcat的server.xml文件
(1)把改成
tomcat1:
tomcat2:
(2)把tomcat1:tomcat2:
(3)把tomcat1: tomcat2:
(4)把改成
(5)去掉注释
……………………
className="org.apache.catalina.cluster.tcp.ReplicationListener"
tcpListenAddress="auto"
tomcat1: tcpListenPort="4001"
tomcat2: tcpListenPort="4002"
tcpSelectorTimeout="100"
tcpThreadCount="6"/>
……………………
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/300209/viewspace-810968/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/300209/viewspace-810968/