LAMT基于mod_proxy负载均衡

mod_proxy负载均衡
LAMT基于mod_proxy调度使用
基于mod_proxy负载均衡需要proxy_balancer_module (shared)模块的支持

修改mod_proxu.conf文件,添加两台tomcat主机,lb为负载均衡命名

[root@nginx-proxy2 conf.d]# cat mod_proxy.conf 
ProxyVia on
ProxyRequests off
ProxyPreserveHost on
<Proxy balancer://lb>
    BalancerMember http://10.0.0.53:8080 loadfactor=1 route=TomcatA
    BalancerMember http://10.0.0.54:8080 loadfactor=1 route=TomcatB
</Proxy>
ProxyPass / balancer://lb/ stickysession=JSESSIONID
ProxyPassReverse / balancer://lb/

<Location />
    Order Allow,Deny
    Allow from all
</Location>
[root@nginx-proxy2 conf.d]# 

stickysession=JSESSIONID可以实现回话保持
修改 workers.properties ,添加如下内容,分别是8009(mod_proxy可以http和ajp方式)

[root@nginx-proxy2 conf.d]# cat workers.properties 
worker.list=lbcA,statA
worker.TomcatA.port=8009
worker.TomcatA.host=10.0.0.53
worker.TomcatA.type=ajp13
worker.TomcatA.lbfactor=1
worker.TomcatB.port=8009
worker.TomcatB.host=10.0.0.54
worker.TomcatB.type=ajp13
worker.TomcatB.lbfactor=1
worker.lbcA.type=lb
worker.lbcA.sticky_session=0
worker.lbcA.balance_workers = TomcatA,TomcatB
worker.statA.type = status

[root@nginx-proxy2 conf.d]# 

状态信息

[root@nginx-proxy2 conf.d]#  cat mod_proxy.conf
ProxyVia on
ProxyRequests off
ProxyPreserveHost on
<Proxy balancer://lb>
        BalancerMember http://10.0.0.53:8080 loadfactor=1 route=TomcatA
        BalancerMember http://10.0.0.54:8080 loadfactor=2 route=TomcatB
</Proxy>
ProxyPass / balancer://lb/
ProxyPassReverse / balancer://lb/
——————————————————————状态信息—————————————————————————
<Location /lbmanager>
        SetHandler balancer-manager
</Location>
ProxyPass /lbmanager !
————————————————————————————————————————————————————————
<Location />
        Order Allow,Deny
        Allow from all
</Location>

1 分享

您可以选择一种方式赞助本站

支付宝扫码赞助

支付宝扫码赞助

日期: 2016-02-21分类: Tomcat

标签: tomcat

发表评论