先说一个坑:
192.168.65.110为虚拟ip,在主节点设置(ifconfig eth0:8 192.168.65.110/24),其他子节点要与主节点保持一致(ifconfig lo:3 192.168.65.110 netmask 255.255.255.255)
node01:
ifconfig eth0:8 192.168.65.110/24
node02~node03:
1)先修改内核: echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore echo 2 > /proc/sys/net/ipv4/conf/eth0/arp_announce echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
2)再设置隐藏的vip: ifconfig lo:3 192.168.65.110 netmask 255.255.255.255
RS中的服务: node02~node03: yum install httpd -y service httpd start vi /var/www/html/index.html node02节点html写入: from 192.168.65.20 node03节点html写入: from 192.168.65.30
LVS服务配置
node01: yum install ipvsadm
ipvsadm -A -t 192.168.65.110:80 -s rr
ipvsadm -a -t 192.168.65.110:80 -r 192.168.65.20 -g -w 1
ipvsadm -a -t 192.168.65.110:80 -r 192.168.65.30 -g -w 1
ipvsadm -ln
验证:
浏览器访问 192.168.65.110 看到负载 疯狂F5
node01:
netstat -natp 结论看不到socket连接
node02~node03:
netstat -natp 结论看到很多的socket连接
node01:
ipvsadm -lnc 查看偷窥记录本
FIN_WAIT: 连接过,偷窥了所有的包
SYN_RECV: 基本上lvs都记录了,证明lvs没事,一定是后边网络层出问题