centos6.7基于lvs的负载均衡的实现(DR模式)
实践LVS的DR模式
1、实验环境
三台机器:
Director节点: (eth0 10.0.172.182 vip eth0:0 10.0.172.185)
Real server1: (eth0 10.0.172.183 vip lo:0 10.0.172.185 )
Real server2: (eth0 10.0.172.184 vip lo:0 10.0.172.185)
2、安装
# 为三台服务器安装nginx,步骤可参考lvs-nat模式
#https://blog.****.net/pastu_****/article/details/83178505
#Director 上安装 ipvsadm
yum install -y ipvsadm
三台服务器ip配置
Lb:
RS1:
RS2:
3、Director 上配置脚本
Vim /usr/local/sbin/lvs_dr.sh
#执行脚本:
bash /usr/local/sbin/lvs_dr.sh
4、在2台 rs 上配置脚本:
vim /usr/local/sbin/lvs_dr_rs.sh
|
|
rs 上分别执行脚本:
bash /usr/local/sbin/lvs_dr_rs.sh
5、实验测试
测试方式同上,浏览器访问 http://10.0.172.185
注意:在 DR 模式下,2台 rs 节点的 gateway 不需要设置成 dir 节点的 IP 。