第一次搭建LVS+KEEPALIVED环境时挺顺利的,过一段时间后重新搭建此环境时居然出问题,不管怎么配置修改参数,客户端总是连接不上realserver,通过ipvsadm -lc查看,结果如下:
CP 00:54 SYN_RECV h100:12949 192.168.4.200:5678 h104:5678
通过艰难的对比,查找资料,终于找到了问题的原因,在此鄙视一下百度,找出来的资源一点用都没有。
闲话少说,原因如下:
realserver的服务监听IP我选择了监听指定的IP,即eth0的IP,而未监听lo,即本地地址,那么即使收到了由directoryserver转发的请求,通过本地广播给本机的lo:0,因为服务没有监听lo,所以也不会有响应。
杯具啊,花了我那么多时间..................
realserver的ifconfig结果如下:
eth0 Link encap:Ethernet HWaddr 00:30:48:C8:7D:CA
inet addr:192.168.10.55 Bcast:192.168.15.255 Mask:255.255.240.0
inet6 addr: fe80::230:48ff:fec8:7dca/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5369998 errors:0 dropped:0 overruns:0 frame:0
TX packets:357128 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:493767975 (470.8 MiB) TX bytes:181277721 (172.8 MiB)
Memory:fbee0000-fbf00000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:11414 errors:0 dropped:0 overruns:0 frame:0
TX packets:11414 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3994708 (3.8 MiB) TX bytes:3994708 (3.8 MiB)
lo:0 Link encap:Local Loopback
inet addr:192.168.4.200 Mask:255.255.255.255
UP LOOPBACK RUNNING MTU:16436 Metric:1