apache配置负载均衡:

注: 1、需要3台服务器,1台分发,另2台为实际网站(只需要在分发的服务器上配置) 2、loadfactor为权重 3、balancer-manager为查看负载均衡分配情况

Redhat系统:

vi /etc/httpd/conf.d/web.conf

ProxyRequests Off <Proxy balancer://mycluster> BalancerMember http://10.0.0.3/bugzilla loadfactor=3 BalancerMember http://10.0.0.4/bugzilla loadfactor=1 </Proxy> ProxyPass /bugzilla balancer://mycluster/

<Location /balancer-manager> SetHandler balancer-manager </Location>

:wq

service httpd restart

Ubuntu系统需先启用下面模块,其它不变

a2enmod proxy

a2enmod proxy_balancer

a2enmod proxy_connect

a2enmod proxy_http

a2enmod lbmethod_byrequests