Tomcat5.5.12配置負載均衡

fsz521job發表於2005-11-30

Tomcat5.5.12配置負載均衡

參考:

[@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:
# ----&gt lbfactor must be > 0
# ----&gt 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:
# ----&gt lbfactor must be > 0
# ----&gt 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:
# ----&gt 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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章