<apache的Load Balance架構設置>
目前架構兩個TomCat來進行分流,以apache balancer來進行分配,此架構主要依照不同的port來進行溝通
要修改的地方如下:
1.[TomCat]\conf\server.xml
設定Server.xml中的4個地方
- Shutdown port
-HTTP1.1 port
- AJP/1.3 port
- appBase(webapps)位置,兩個TomCat抓同一個WebApp
2.[apache]\conf\httpd.conf
在最下面增加以下文字
#####負載平衡用#####
# 讀取mod_jk模組,可自行更新路徑
LoadModule jk_module modules/mod_jk.so
# 讀取 workers.properties 設定檔,可自行更新路徑
JkWorkersFile conf/workers.properties
# jk logs的放置路徑
#JkLogFile logs/access.log
JkLogFile "|bin/rotatelogs -l logs/modjkaccess.log.%Y.%m.%d 86400"
# 設定 jk log level [debug/error/info]
JkLogLevel info
# 選擇 log 格式
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# Send everything for context /examples to worker named worker1 (ajp13)
JkMount /* loadbalancer
3.[apache]\conf\workers.properties (如沒有請自行增加)
加入以下文字
# Define 1 real worker using ajp13
worker.list=worker1,worker2 loadbalancer
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=worker1,worker2
######### Set properties for worker1 (ajp13)#########
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8169
worker.worker1.lbfactor=1
# Deprecated worker.worker1.cachesize=10
# Deprecated worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300
######### Set properties for worker2 (ajp13)#########
worker.worker2.type=ajp13
worker.worker2.port=8269
worker.worker2.host=localhost
worker.worker2.lbfactor=1
# Deprecated worker.worker2.cachesize=10
# Deprecated worker.worker2.cache_timeout=600
worker.worker2.socket_keepalive=1
worker.worker2.socket_timeout=300
4.請確認所有的port號是否都已分開並且設定完成
要注意的port部分 :
一、apache入口port (入口網站port號,以後將由此port號進入網頁)
二、Tomcat shutdown port (關閉的port號)
三、Tomcat HTTP1.1 port (主要為TomCat網站入口,可以測試直接由這port號進入網頁)
四、Tomcat AJP/1.3 port (此port為 apache balancer與Tomcat溝通之port號)
留言列表