我配置了两台lvs keepalived服务器,第一台为主服务器,ip 10.1.88.76,iptables关闭,第二台为备份服务器,ip 10.1.88.77,iptables关闭,两台服务器之间网络连接正常(ping验证)
但问题是两台服务器都处于 MASTER 状态。我期望一台处于 Master 模式,另一台处于 BACKUP 模式。
我该怎么做才能解决这个问题?谢谢
76服务器中的配置。
! Configuration File for keepalived
global_defs {
notification_email {
[email protected]
[email protected]
[email protected]
}
notification_email_from [email protected]
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 100
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 2013
}
virtual_ipaddress {
10.1.88.81
}
}
virtual_server 10.1.88.81 23 {
delay_loop 6
lb_algo rr
lb_kind DR
nat_mask 255.255.255.0
persistence_timeout 50
protocol TCP
real_server 10.1.88.78 23 {
weight 1
TCP_CHECK {
connect_timeout 3
connect_port 23
}
}
real_server 10.1.88.79 23{
weight 1
TCP_CHECK {
connect_timeout 3
connect_port 23
}
}
real_server 10.1.88.80 23 {
weight 1
TCP_CHECK {
connect_timeout 3
connect_port 23
}
}
}
77服务器中的配置
! Configuration File for keepalived
global_defs {
notification_email {
[email protected]
[email protected]
[email protected]
}
notification_email_from [email protected]
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 101
priority 90
advert_int 1
authentication {
auth_type PASS
auth_pass 2013
}
virtual_ipaddress {
10.1.88.81
}
}
virtual_server 10.1.88.81 23 {
delay_loop 6
lb_algo rr
lb_kind DR
nat_mask 255.255.255.0
persistence_timeout 50
protocol TCP
real_server 10.1.88.78 23 {
weight 1
TCP_CHECK {
connect_timeout 3
connect_port 23
}
}
real_server 10.1.88.79 23{
weight 1
TCP_CHECK {
connect_timeout 3
connect_port 23
}
}
real_server 10.1.88.80 23 {
weight 1
TCP_CHECK {
connect_timeout 3
connect_port 23
}
}
}
来自76服务器的消息
Jun 26 11:06:41 node0 Keepalived_vrrp[1264]: VRRP_Instance(VI_1) sending 0 priority
Jun 26 11:06:41 node0 Keepalived[1262]: Stopping Keepalived v1.2.7 (02/21,2013)
Jun 26 11:07:44 node0 Keepalived[1261]: Starting Keepalived v1.2.7 (02/21,2013)
Jun 26 11:07:44 node0 Keepalived[1262]: Starting Healthcheck child process, pid=1263
Jun 26 11:07:44 node0 Keepalived[1262]: Starting VRRP child process, pid=1264
Jun 26 11:07:44 node0 Keepalived_vrrp[1264]: Interface queue is empty
Jun 26 11:07:44 node0 Keepalived_vrrp[1264]: Netlink reflector reports IP 10.1.88.76 added
Jun 26 11:07:44 node0 Keepalived_vrrp[1264]: Netlink reflector reports IP fe80::5054:ff:fe8f:97f6 added
Jun 26 11:07:44 node0 Keepalived_vrrp[1264]: Registering Kernel netlink reflector
Jun 26 11:07:44 node0 Keepalived_vrrp[1264]: Registering Kernel netlink command channel
Jun 26 11:07:44 node0 Keepalived_vrrp[1264]: Registering gratuitous ARP shared channel
Jun 26 11:07:44 node0 Keepalived_healthcheckers[1263]: Interface queue is empty
Jun 26 11:07:44 node0 Keepalived_healthcheckers[1263]: Netlink reflector reports IP 10.1.88.76 added
Jun 26 11:07:44 node0 Keepalived_healthcheckers[1263]: Netlink reflector reports IP fe80::5054:ff:fe8f:97f6 added
Jun 26 11:07:44 node0 Keepalived_healthcheckers[1263]: Registering Kernel netlink reflector
Jun 26 11:07:44 node0 Keepalived_healthcheckers[1263]: Registering Kernel netlink command channel
Jun 26 11:07:44 node0 Keepalived_healthcheckers[1263]: Opening file '/etc/keepalived/keepalived.conf'.
Jun 26 11:07:44 node0 Keepalived_vrrp[1264]: Opening file '/etc/keepalived/keepalived.conf'.
Jun 26 11:07:44 node0 Keepalived_vrrp[1264]: Configuration is using : 63254 Bytes
Jun 26 11:07:44 node0 Keepalived_vrrp[1264]: Using LinkWatch kernel netlink reflector...
Jun 26 11:07:44 node0 Keepalived_healthcheckers[1263]: Configuration is using : 17141 Bytes
Jun 26 serial8250: too much work for irq4
11:07:44 node0 Keepalived_vrrp[1264]: VRRP sockpool: [ifindex(2), proto(112), fd(11,12)]
Jun 26 11:07:44 node0 Keepalived_healthcheckers[1263]: Using LinkWatch kernel netlink reflector...
Jun 26 11:07:44 node0 Keepalived_healthcheckers[1263]: Activating healthchecker for service [10.1.88.78]:23
Jun 26 11:07:44 node0 Keepalived_healthcheckers[1263]: Activating healthchecker for service [10.1.88.79]:23
Jun 26 11:07:44 node0 Keepalived_healthcheckers[1263]: Activating healthchecker for service [10.1.88.80]:23
Jun 26 11:07:45 node0 Keepalived_vrrp[1264]: VRRP_Instance(VI_1) Transition to MASTER STATE
Jun 26 11:07:46 node0 Keepalived_vrrp[1264]: VRRP_Instance(VI_1) Entering MASTER STATE
Jun 26 11:07:46 node0 Keepalived_vrrp[1264]: VRRP_Instance(VI_1) setting protocol VIPs.
Jun 26 11:07:46 node0 Keepalived_vrrp[1264]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 10.1.88.81
Jun 26 11:07:46 node0 Keepalived_healthcheckers[1263]: Netlink reflector reports IP 10.1.88.81 added
Jun 26 11:07:51 node0 Keepalived_vrrp[1264]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 10.1.88.81
[root@node0 ~]# date
Wed Jun 26 11:08:08 CST 2013
来自77服务器的消息
Jun 26 11:07:50 node1 Keepalived[1284]: Starting Keepalived v1.2.7 (02/21,2013)
Jun 26 11:07:50 node1 Keepalived[1285]: Starting Healthcheck child process, pid=1286
Jun 26 11:07:50 node1 Keepalived[1285]: Starting VRRP child process, pid=1287
Jun 26 11:07:50 node1 Keepalived_vrrp[1287]: Interface queue is empty
Jun 26 11:07:50 node1 Keepalived_vrrp[1287]: Netlink reflector reports IP 10.1.88.77 added
Jun 26 11:07:50 node1 Keepalived_vrrp[1287]: Netlink reflector reports IP fe80::5054:ff:fee6:54b7 added
Jun 26 11:07:50 node1 Keepalived_vrrp[1287]: Registering Kernel netlink reflector
Jun 26 11:07:50 node1 Keepalived_vrrp[1287]: Registering Kernel netlink command channel
Jun 26 11:07:50 node1 Keepalived_vrrp[1287]: Registering gratuitous ARP shared channel
Jun 26 11:07:50 node1 Keepalived_healthcheckers[1286]: Interface queue is empty
Jun 26 11:07:50 node1 Keepalived_vrrp[1287]: Opening file '/etc/keepalived/keepalived.conf'.
Jun 26 11:07:50 node1 Keepalived_healthcheckers[1286]: Netlink reflector reports IP 10.1.88.77 added
Jun 26 11:07:50 node1 Keepalived_healthcheckers[1286]: Netlink reflector reports IP fe80::5054:ff:fee6:54b7 added
Jun 26 11:07:50 node1 Keepalived_healthcheckers[1286]: Registering Kernel netlink reflector
Jun 26 11:07:50 node1 Keepalived_healthcheckers[1286]: Registering Kernel netlink command channel
Jun 26 11:07:50 node1 Keepalived_healthcheckers[1286]: Opening file '/etc/keepalived/keepalived.conf'.
Jun 26 11:07:50 node1 Keepalived_vrrp[1287]: Configuration is using : 63252 Bytes
Jun 26 11:07:50 node1 Keepalived_vrrp[1287]: Using LinkWatch kernel netlink reflector...
Jun 26 11:07:50 node1 Keepalived_healthcheckers[1286]: Configuration is using : 17139 Bytes
Jun 26 11:07:50 node1 Keepalived_vrrp[1287]: VRRP_Instance(VI_1) Entering BACKUP STATE
Jun 26 11:07:50 node1 Keepalived_vrrp[1287]: VRRP sockpool: [ifindex(2), proto(112), fd(11,12)]
Jun 26 11:07:50 node1 Keepalived_healthcheckers[1286]: Using LinkWatch kernel netlink reflector...
Jun 26 11:07:50 node1 Keepalived_healthcheckers[1286]: Activating healthchecker for service [10.1.88.78]:23
Jun 26 11:07:50 node1 Keepalived_healthcheckers[1286]: Activating healthchecker for service [10.1.88.79]:23
Jun 26 11:07:50 node1 Keepalived_healthcheckers[1286]: Activating healthchecker for service [10.1.88.80]:23
Jun 26 11:07:53 node1 Keepalived_vrrp[1287]: VRRP_Instance(VI_1) Transition to MASTER STATE
Jun 26 11:07:54 node1 Keepalived_vrrp[1287]: VRRP_Instance(VI_1) Entering MASTER STATE
Jun 26 11:07:54 node1 Keepalived_vrrp[1287]: VRRP_Instance(VI_1) setting protocol VIPs.
Jun 26 11:07:54 node1 Keepalived_vrrp[1287]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 10.1.88.81
Jun 26 11:07:54 node1 Keepalived_healthcheckers[1286]: Netlink reflector reports IP 10.1.88.81 added
Jun 26 11:07:59 node1 Keepalived_vrrp[1287]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 10.1.88.81
答案1
您需要允许两个主机之间的 vrrp 流量,以便它们可以运行心跳。