您的位置:首页 > 其它

keepalived+lvs无法访问vip或访问超时

2017-07-19 14:41 3851 查看
1. 在访问vip的时候,连接被拒绝,但是可以ping通:

[kiosk@foundation67 Desktop]$ curl -I  172.25.67.200
curl: (7) Failed connect to 172.25.67.200:80; Connection refused

[kiosk@foundation67 Desktop]$ ping 172.25.67.200
PING 172.25.67.200 (172.25.67.200) 56(84) bytes of data.
64 bytes from 172.25.67.200: icmp_seq=1 ttl=64 time=0.160 ms
64 bytes from 172.25.67.200: icmp_seq=2 ttl=64 time=0.207 ms
^C


检查配置文件

首先检查防火墙和selinux,都是关闭的。

查看RS端的arptables的策略。

# arptables --list
Chain IN (policy ACCEPT)
target     source-ip            destination-ip       source-hw          destination-hw     hlen   op         hrd        pro
DROP       anywhere             172.25.67.200        anywhere           anywhere           any    any        any        any

Chain OUT (policy ACCEPT)
target     source-ip            destination-ip       source-hw          destination-hw     hlen   op         hrd        pro
mangle     172.25.67.200        anywhere             anywhere           anywhere           any    any        any        any       --mangle-ip-s server3

Chain FORWARD (policy ACCEPT)
target     source-ip            destination-ip       source-hw          destination-hw     hlen   op         hrd        pro


2. 访问VIP超时,但是可以ping通:

客户端返回内容:
[root@foundation67 Desktop]# curl 172.25.67.200
curl: (7) Failed connect to 172.25.67.200:80; Connection timed out
在调度端:
[root@server1 ~]# ipvsadm -l
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  172.25.67.200:http rr
-> server3:http                 Route   1      0          0
-> server4:http                 Route   1      0          1
[root@server1 ~]# ipvsadm -lnc
IPVS connection entries
pro expire state       source             virtual            destination
TCP 00:53  SYN_RECV    172.25.67.250:51808 172.25.67.200:80   172.25.67.4:80


LVS端看到状态是SYN_RECV,说明请求已经到达LVS,但是在发给后端Real Server的时候出现问题。

数据包的进出策略是正确的,但依然无法处理数据包。数据包出去只是发送,肯定是好的,那么就只能是数据包解析出错。数据包在传给RS后,解析ip,如果发现自己的VIP且和解析出的IP一致,那么就没有问题,说明vip和解析的ip不一致,但访问的是VIP,解析出的目的IP一定是VIP,那么只有RS上的VIP有问题,查看的时候发现没有VIP,是因为添加VIP是通过 ‘ip addr add 172.25.67.200/24 dev eth0’命令,而重启两台RS后VIP就没了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  lvs keepalived