七.基于mod_jk实现负载均衡
7.1 注释刚才添加的基于proxy_mod的配置,启用已添加的mod_jk配置
#ProxyRequests Off
#<Proxy balancer://lbcluster>
# BalancerMember ajp://172.16.1.21:8009 loadfactor=10route=TomcatA
# BalancerMember ajp://172.16.1.22:8009 loadfactor=10route=TomcatB
#</Proxy>
#ProxyPass / balancer://lbcluster/
#ProxyPassReverse / balancer://lbcluster/
Include /etc/httpd/extra/httpd-jk.conf
7.2 修改 /etc/httpd/extra/httpd-jk.conf
vi /etc/httpd/extra/httpd-jk.conf
# Load the mod_jk
LoadModule jk_module modules/mod_jk.so
JkWorkersFile /etc/httpd/extra/workers.properties
JkLogFile logs/mod_jk.log
#JkLogLevel debug
JkMount /* cluster1
JkMount /status/ status
7.3 修改/etc/httpd/workers.properties
worker.list = cluster1,status
worker.TomcatA.type = ajp13
worker.TomcatA.host = 172.16.1.21
worker.TomcatA.port = 8009
worker.TomcatA.lbfactor = 5
worker.TomcatB.type = ajp13
worker.TomcatB.host = 172.16.1.22
worker.TomcatB.port = 8009
worker.TomcatB.lbfactor = 5
worker.cluster1.type = lb
worker.cluster1.sticky_session = 0 ##如果为1会绑定session
worker.cluster1.balance_workers = TomcatA, TomcatB
worker.status.type = status
7.4 测试访问 http://balance.linuxidc.com/