程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> 主備-keepalived 備機啟動自動從backup切換成master

主備-keepalived 備機啟動自動從backup切換成master

編輯:編程綜合問答
keepalived 備機啟動自動從backup切換成master

按照網上的教程搭建,兩台服務器,主機ip:10.1.21.211,備機ip:10.1.21.212,虛ip:10.1.21.213。搭完後備用機一**啟動keepalived就自動從BACKUP切換到MASTER(另一機並未關keepalived服務)**,正常主機沒有down之前備機應該是backup狀態才對啊,用ip a查看時發現備用機的IP也包含虛擬IP。

主機配置:
! Configuration File for keepalived
global_defs {
notification_email {
[email protected]
}
notification_email_from [email protected]
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id node1
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.1.21.213
}
}
備機配置:
! Configuration File for keepalived

global_defs {
notification_email {
[email protected]
}
notification_email_from [email protected]
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id node1
}

vrrp_instance VI_1 {
state BACKUP
interface eth1 #這裡備機的網卡就是eth1
virtual_router_id 51
priority 50
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.1.21.213
}
}

備機啟動日志:
Apr 21 17:22:37 PEK1-OAHolidaySearch-02 Keepalived_healthcheckers[27471]: Using LinkWatch kernel netlink reflector...
Apr 21 17:22:37 PEK1-OAHolidaySearch-02 Keepalived_vrrp[27472]: VRRP_Instance(VI_1) Entering BACKUP STATE
Apr 21 17:22:37 PEK1-OAHolidaySearch-02 Keepalived_vrrp[27472]: VRRP sockpool: [ifindex(2), proto(112), fd(10,11)]
Apr 21 17:22:41 PEK1-OAHolidaySearch-02 Keepalived_vrrp[27472]: VRRP_Instance(VI_1) Transition to MASTER STATE
Apr 21 17:22:42 PEK1-OAHolidaySearch-02 Keepalived_vrrp[27472]: VRRP_Instance(VI_1) Entering MASTER STATE
Apr 21 17:22:42 PEK1-OAHolidaySearch-02 Keepalived_vrrp[27472]: VRRP_Instance(VI_1) setting protocol VIPs.
Apr 21 17:22:42 PEK1-OAHolidaySearch-02 Keepalived_vrrp[27472]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 10.1.21.213
Apr 21 17:22:42 PEK1-OAHolidaySearch-02 Keepalived_healthcheckers[27471]: Netlink reflector reports IP 10.1.21.213 added

tcpdump vrrp結果:
18:09:44.834042 IP 10.1.21.211 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 100, authtype simple, intvl 1s, length 20
18:09:45.331753 IP 10.1.21.212 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 50, authtype simple, intvl 1s, length 20
18:09:45.835228 IP 10.1.21.211 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 100, authtype simple, intvl 1s, length 20
18:09:46.332927 IP 10.1.21.212 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 50, authtype simple, intvl 1s, length 20

這是什麼情況? 求教各位大神解決方法或思路,謝謝

最佳回答:


關掉主備服務器的防火牆,備用服務器就可以進入BACKUP狀態,而且啟動關閉主服務器keepalived也可以實現主備切換。但正常情況下防火牆是不能關閉的,求高手最佳解決辦法

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved