- 论坛徽章:
- 2
|
环境:virtual box
OS:CentOS 6.6
MASTER:192.168.1.100
SLAVE:192.168.1.101
RS01:192.168.1.102
RS02:192.168.1.103
VIP:192.168.1.200
MASTER配置:
[root@HA-A ~]# more /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
591527272@qq.com
}
notification_email_from root@ha.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL_MASTER
}
vrrp_instance VI_1 {
state MASTER
interface eth1
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.1.200
}
}
virtual_server 192.168.1.200 80 {
delay_loop 6
lb_algo wlc
lb_kind DR
persistence_timeout 50
protocol TCP
real_server 192.168.1.102 80 {
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 192.168.1.103 80 {
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
SLAVE配置:
[root@HA-B ~]# vi /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
591527272@qq.com
}
notification_email_from root@ha.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL_BACKUP
}
vrrp_instance VI_1 {
state BACKUP
interface eth1
virtual_router_id 51
priority 50
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.1.200
}
}
virtual_server 192.168.1.200 80 {
delay_loop 6
lb_algo wlc
lb_kind DR
persistence_timeout 50
protocol TCP
real_server 192.168.1.102 80 {
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 192.168.1.103 80 {
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
RS配置:
[root@RealServer01 ~]# cat /root/lvs_real.sh
#!/bin/bash
VIP=192.168.1.200
/etc/rc.d/init.d/functions
case "$1" in
start)
/sbin/ifconfig lo:0 $VIP netmask 255.255.255.255 broadcast $VIP
/sbin/route add -host $VIP dev lo:0
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
sysctl -p >/dev/null 2>&1
echo "realserver start ok!"
;;
stop)
/sbin/ifconfig lo:0 down
/sbin/route del $VIP >/dev/null 2>&1
echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce
sysctl -p >/dev/null 2>&1
echo "realserver stop ok!"
;;
*)
echo "usage 0{start|stop}"
exit 1
esac
exit 0
状态:
master:
[root@HA-A ~]# ipvsadm
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress ort Scheduler Flags
-> RemoteAddress ort Forward Weight ActiveConn InActConn
TCP 192.168.1.200:http wlc persistent 50
-> 192.168.1.102:http Route 100 0 0
-> 192.168.1.103:http Route 100 0 0
slaver:
[root@HA-B ~]# ipvsadm
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress ort Scheduler Flags
-> RemoteAddress ort Forward Weight ActiveConn InActConn
TCP 192.168.1.200:http wlc persistent 50
-> 192.168.1.102:http Route 100 0 0
-> 192.168.1.103:http Route 100 0 0
RS:
[root@RealServer01 ~]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet 192.168.1.200/32 brd 192.168.1.200 scope global lo:0
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:b0:a1:bb brd ff:ff:ff:ff:ff:ff
inet 192.168.1.102/24 brd 192.168.1.255 scope global eth1
inet6 fe80::a00:27ff:feb0:a1bb/64 scope link
valid_lft forever preferred_lft forever
[root@RealServer01 ~]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet 192.168.1.200/32 brd 192.168.1.200 scope global lo:0
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:b0:a1:bb brd ff:ff:ff:ff:ff:ff
inet 192.168.1.102/24 brd 192.168.1.255 scope global eth1
inet6 fe80::a00:27ff:feb0:a1bb/64 scope link
valid_lft forever preferred_lft forever
我在局域网里面一台pc访问RS服务器httpd服务 www.192.168.1.102 和www.192.168.1.103都是正常
但是访问www.192.168.1.200失败,
注意:四台的iptables和selinux都关闭了。
我在访问VIP的httpd服务时候,master是有数据跑的:
[root@HA-A ~]# ipvsadm
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress ort Scheduler Flags
-> RemoteAddress ort Forward Weight ActiveConn InActConn
TCP 192.168.1.200:http wlc persistent 50
-> 192.168.1.102:http Route 100 0 0
-> 192.168.1.103:http Route 100 0 3
但是无法反馈回来。。。。。
请问是什么原因呢?
|
|