欲忘树 发表于 2019-1-5 14:47:49

LVS-DR负载均衡-02

LB及其RS配置  

  
3.1 负载均衡器配置配置
  
停止路由转发功能
  
# sysctl   -wnet.ipv4.ip_forward=0
  
net.ipv4.ip_forward = 0
  
# sysctl   -wnet.ipv4.conf.all.send_redirects=1
  
net.ipv4.conf.all.send_redirects = 1
  
# sysctl   -wnet.ipv4.conf.default.send_redirects=1
  
net.ipv4.conf.default.send_redirects = 1
  
通过eth0绑定
  
# sysctl   -wnet.ipv4.conf.eth0.send_redirects=1
  
net.ipv4.conf.eth0.send_redirects = 1
  
设置虚拟IP地址
  
# ifconfig   eth0:0192.168.28.111netmask255.255.255.0
  
启用eth0:0
  
# ifconfigeth0:0up
  
清除ipvs规则表
  
# ipvsadm-C
  
查看集群分布
  
# ipvsadm-L -n
  
IP Virtual Server version 1.2.1 (size=4096)
  
Prot LocalAddress:Port Scheduler Flags
  
-> RemoteAddress:Port         Forward Weight ActiveConn InActConn
  
为避免ARP解析 增加主机路由
  
# /sbin/route   add   -host192.168.28.111deveth0:0
  
# 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
  
#
  
# ipvsadm-A-t192.168.28.111:80-srr
  
在LB MASTER中增加真实服务器
  
# ipvsadm-a-t192.168.28.111:80 -r 192.168.28.134 -g -w 1
  
# ipvsadm-a-t192.168.28.111:80 -r 192.168.28.135 -g -w 2
  
#ipvsadm-L -n
  
IP Virtual Server version 1.2.1 (size=4096)
  
Prot LocalAddress:Port Scheduler Flags
  
-> RemoteAddress:Port         Forward Weight ActiveConn InActConn
  
TCP192.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 应用真实服务器配置
  

  
# sysctl   -wnet.ipv4.ip_forward=0
  
忽略arp设置
  
# sysctl   -wnet.ipv4.conf.lo.arp_ignore=1
  
设置Arp宣告值
  
# sysctl   -wnet.ipv4.conf.lo.arp_announce=2
  
net.ipv4.conf.lo.arp_announce = 2
  
# sysctl -w net.ipv4.conf.all.arp_ignore=1
  
net.ipv4.conf.all.arp_ignore = 1
  
# sysctl -w net.ipv4.conf.all.arp_announce=2
  
net.ipv4.conf.all.arp_announce = 2
  
配置RS02中VIP地址
  
# /sbin/ifconfig   lo:0192.168.28.111netmask 255.255.255.255broadcast 192.168.28.111 up
  
查看路由表
  
# 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
  
# /sbin/routeadd-host192.168.28.111   devlo:0
  
再次查看路由表
  
# route-n
  
Kernel IP routing table
  
Destination   Gateway         Genmask         Flags Metric Ref    Use Iface
  
192.168.28.1110.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配置


页: [1]
查看完整版本: LVS-DR负载均衡-02