lvs配置

LB01(nginx+keepalived) 192.168.56.11
VIP:192.168.56.21
LB02(nginx+keepalived) 192.168.56.12

WEB1 192.168.56.13 LNMP RS1
WEB2 192.168.56.14 LMMP RS2

 

3.7 安装:lvs软件
yum install ipvsadm -y
[root@lb01 ~]# rpm -qa ipvsadm
ipvsadm-1.26-4.el6.x86_64
[root@lb02 ~]# lsmod |grep ip_vs
ip_vs_rr 1420 0
ip_vs 126534 2 ip_vs_rr
libcrc32c 1246 1 ip_vs
ipv6 335589 137 ip_vs
[root@lb02 ~]# ipvsadm
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
LVS安装小结:
1、 Centos5.X安装LVS,使用1.24版本,不要用1.26.
2、 Centos6.4安装LVS,使用1.26版本,并且需要先安装yum install libnl* popt* -y
3、 安装LVS后,要执行ipvsadm(modprobe ip_vs)把ip_vs模块加载到内核。


-C 清空所有表
-A 添加vserver
-t 指定VIP地址和端口
-s 调试算法
-a 添加一个realserver
-r 指定realserver的IP和端口
-p 会话保持
-g DR


===
[root@lb01 ~]# ipvsadm -C
[root@lb01 ~]# ipvsadm -A -t 192.168.56.21:80 -s rr
[root@lb01 ~]# ipvsadm -a -t 192.168.56.21:80 -r 192.168.56.13:80 -g -w 1
[root@lb01 ~]# ipvsadm -a -t 192.168.56.21:80 -r 192.168.56.14:80 -g -w 1
[root@lb01 ~]# ipvsadm -L -n
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 172.16.1.5:80 wlc
-> 172.16.1.7:80 Route 1 0 0
-> 172.16.1.8:80 Route 1 0 0


[root@lb01 ~]# ipvsadm -Ln
所有RS节点的配置过程:
RS绑定VIP:
ip addr add 192.168.56.21/32 dev lo label lo:1
route add -host 192.168.56.21 dev lo
#抑制ARP:
echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce

posted @ 2019-11-27 15:54  小菜鸟111  阅读(190)  评论(0编辑  收藏  举报