LVS-DR负载均衡-02

LB及其RS配置
 
3.1 负载均衡器配置配置
停止路由转发功能
[root@lvs01 linux]# sysctl   -w  net.ipv4.ip_forward=0
net.ipv4.ip_forward = 0
[root@lvs01 linux]# sysctl   -w  net.ipv4.conf.all.send_redirects=1
net.ipv4.conf.all.send_redirects = 1
[root@lvs01 linux]# sysctl   -w  net.ipv4.conf.default.send_redirects=1
net.ipv4.conf.default.send_redirects = 1
通过eth0绑定
[root@lvs01 linux]# sysctl   -w  net.ipv4.conf.eth0.send_redirects=1
net.ipv4.conf.eth0.send_redirects = 1
设置虚拟IP地址
[root@lvs01 linux]# ifconfig   eth0:0  192.168.28.111  netmask  255.255.255.0
启用eth0:0
[root@lvs01 linux]# ifconfig  eth0:0  up
清除ipvs规则表
[root@lvs_01 ~]# ipvsadm  -C
查看集群分布
[root@lvs_01 ~]# ipvsadm  -L -n
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
为避免ARP解析 增加主机路由
[root@lvs01 linux]# /sbin/route   add   -host  192.168.28.111  dev  eth0:0
[root@lvs_01 ~]# route  -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.2.111   0.0.0.0         255.255.255.255 UH    0      0        0 eth0
192.168.28.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
0.0.0.0         192.168.28.2    0.0.0.0         UG    0      0        0 eth0
[root@lvs_01 ~]#
[root@lvs01 linux]# ipvsadm  -A  -t  192.168.28.111:80  -s  rr
在LB MASTER中增加真实服务器
[root@lvs01 linux]# ipvsadm  -a  -t  192.168.28.111:80 -r 192.168.28.134 -g -w 1
[root@lvs01 linux]# ipvsadm  -a  -t  192.168.28.111:80 -r 192.168.28.135 -g -w 2
[root@lvs_01 ~]#  ipvsadm  -L -n
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.28.111:80 rr
  -> 192.168.28.135:80            Route   1      0          0        
  -> 192.168.28.134:80            Route   1      0          0        
 
注:Backup LB中安装配置和MASTER一致
 
 
 
 
3.2 RServer 应用真实服务器配置
 
[root@rs01 ~]# sysctl   -w  net.ipv4.ip_forward=0
忽略arp设置
[root@rs01 ~]# sysctl   -w  net.ipv4.conf.lo.arp_ignore=1
设置Arp宣告值
[root@rs01 ~]# sysctl   -w  net.ipv4.conf.lo.arp_announce=2
net.ipv4.conf.lo.arp_announce = 2
[root@rs01 ~]# sysctl -w net.ipv4.conf.all.arp_ignore=1
net.ipv4.conf.all.arp_ignore = 1
[root@rs01 ~]# sysctl -w net.ipv4.conf.all.arp_announce=2
net.ipv4.conf.all.arp_announce = 2
配置RS02中VIP地址
[root@rs01 ~]# /sbin/ifconfig   lo:0  192.168.28.111  netmask 255.255.255.255  broadcast 192.168.28.111 up
查看路由表
[root@localhost html]# route  -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.28.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
0.0.0.0         192.168.28.2    0.0.0.0         UG    0      0        0 eth0
 
增加主机虚拟IP
[root@rs01 ~]# /sbin/route  add  -host  192.168.28.111   dev  lo:0
再次查看路由表
[root@localhost html]# route  -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.28.111  0.0.0.0         255.255.255.255 UH    0      0        0 lo
192.168.28.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
0.0.0.0         192.168.28.2    0.0.0.0         UG    0      0        0 eth0
虚拟IP已添加进来
 
注:RS02 配置过程与RS01一致,参照RS01配置
 
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值