LVS-DR负载均衡-02
来源:互联网 发布:云视通电脑版mac怎么用 编辑:程序博客网 时间:2024/06/09 23:49
LB及其RS配置 3.1 负载均衡器配置配置停止路由转发功能[root@lvs01 linux]# sysctl -w net.ipv4.ip_forward=0net.ipv4.ip_forward = 0[root@lvs01 linux]# sysctl -w net.ipv4.conf.all.send_redirects=1net.ipv4.conf.all.send_redirects = 1[root@lvs01 linux]# sysctl -w net.ipv4.conf.default.send_redirects=1net.ipv4.conf.default.send_redirects = 1通过eth0绑定[root@lvs01 linux]# sysctl -w net.ipv4.conf.eth0.send_redirects=1net.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 -nIP 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 -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface192.168.2.111 0.0.0.0 255.255.255.255 UH 0 0 0 eth0192.168.28.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth00.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 -nIP Virtual Server version 1.2.1 (size=4096)Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConnTCP 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=2net.ipv4.conf.lo.arp_announce = 2[root@rs01 ~]# sysctl -w net.ipv4.conf.all.arp_ignore=1net.ipv4.conf.all.arp_ignore = 1[root@rs01 ~]# sysctl -w net.ipv4.conf.all.arp_announce=2net.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 -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface192.168.28.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth00.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 -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface192.168.28.111 0.0.0.0 255.255.255.255 UH 0 0 0 lo192.168.28.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth00.0.0.0 192.168.28.2 0.0.0.0 UG 0 0 0 eth0虚拟IP已添加进来 注:RS02 配置过程与RS01一致,参照RS01配置