**
windows环境下的负载均衡搭建
**
1:从官方网站下载httpd-2.2.29-x64-r4.zip
2:将其直接解压当根目录下
3:加载模块信息修改(Apache22\conf\httpd.conf)
mod_proxy.so
mod_proxy_ajp.so
mod_proxy_balancer.so
mod_proxy_http.so
4:添加负载均衡配置属性
ProxyRequests Off
<Proxy balancer://mycluster/>
BalancerMember http://192.168.0.4:8282/api/router loadfactor=5
BalancerMember http:/192.168.6.5:8282/api/router loadfactor=5
</Proxy>
ProxyPass /api/router/ balancer://mycluster/
ProxyPassReverse /api/router/ balancer://mycluster/
**
Linux环境下的负载均衡搭建
1: 编译和安装 apr
./configure –prefix=/usr/local/apr/
make
make install
2:编译和安装 apr-util
cd ../apr-util
./configure –prefix=/usr/local/apr-util-httpd/ –with-apr=/usr/local/apr-httpd/
make
make install
3:编译和安装 pcre
cd pcre
./configure –prefix=/usr/local/pcre/
make
make install
4: 配置 httpd
4.1 ./configure –prefix=/usr/local/httpd/ –with-apr=/usr/local/apr-httpd/ –with-apr-util=/usr/local/apr-util-httpd/ –with-pcre=/usr/local/perl/ –enable-rewrite=shared –enable-speling=shared
4.2 ./configure –prefix=/usr/local/apache/httpd/ –with-included-apr –with-pcre=/usr/local/pcre/ –enable-rewrite=shared –enable-speling=shared
以上俩种方法任选一种即可。
make
make install
5:配置文件修改
修改路径为 /usr/local/httpd/conf/httpd.conf
5.1 负载均衡需要依赖的模块
请添加以下模块
mod_proxy.so
mod_proxy_ajp.so
mod_proxy_balancer.so
mod_proxy_http.so
mod_lbmethod_byrequests.so
mod_slotmem_shm.so
5.2均衡配置
ProxyRequests Off
ProxyVia On
<Proxy balancer://mycluster/>
BalancerMember http://192.168.6.4:8080/api/router loadfactor=5
BalancerMember http://192.16.8.4:8080/api/router loadfactor=5
</Proxy>
ProxyPass /api/router/ balancer://mycluster/
ProxyPassReverse /api/router/ balancer://mycluster/