一. 前情提要
以下試驗以及說明是經過試驗確定了的,准確!!另外,如果想知道每個參數的真正含義,建議看官網
解決的問題:
1,當一個節點(Linux設備)掛了,2個VIP都浮動到一個節點上
2,當這個節點(Linux設備)好了,由於業務有一定的延時,所以還不想浮動IP立馬漂移回來
3,如果一個節點的業務(設備上運行的業務進程)完蛋了,需要自己主動交出VIP
4,等自己節點的業務(設備上運行的業務進程)又好了,那么不能立馬奪權,而是有一個過渡再奪權
二. 官方配置說明
官方文檔:https://www.keepalived.org/manpage.html
概述:
keepalived的具體實現原理這里就不做闡述,但是從其配置文件的角度大致將其工作模塊分成兩部分: 全局部分,和VRRP實例部分。
全局部分,顧名思義就是整體相關的配置;
VRRP實例部分:
首先,keepalived通過創建一個個VRRP實例來實現浮動IP的管理,一個VRRP實例可以看做是一個連接實例(使用VRRP協議);
一個實例對應一個VIP,一台設備可以配置多個VRRP實例即參與多個VIP的搶占;
然后,具有相同VRRP實例配置的一對設備,會因為實例匹配而成功配對;
最后,通過協商得到誰是master誰是slave,以及誰來占有VIP。
全局配置部分
-
預定義一個腳本以及腳本管理方式,之后用於VRRP實例引用
vrrp_script <SCRIPT_NAME> {
#腳本的路徑,或者直接就是腳本本身
script <STRING>|<QUOTED-STRING>
# 間隔多長時間執行一次腳本
interval <INTEGER>
#腳本執行如果沒有正確返回,則這段時間后就算超時,然后算作是failed了
timeout <INTEGER>
# adjust priority by this weight, (default: 0).For description of reverse, see track_script.
# 'weight 0 reverse' will cause the vrrp instance to be down when the script is up, and vice versa.
weight <INTEGER:-253..253> [reverse]
# required number of successes for OK transition
rise <INTEGER>
# required number of successes for KO transition
fall <INTEGER>
# 以哪個用戶身份去執行腳本的人是誰
user USERNAME [GROUPNAME]
# 假設初始時腳本是執行失敗的
init_fail
}
-
VRRP實例部分
# Ignore VRRP interface faults (default unset)
dont_track_primary #表示的含義是,一旦接口有問題,則忽略之,否則keepalived的代碼中對鏈路有做檢查,發現鏈路down則進入fault狀態,於是將放棄所有浮動ip
# optional, monitor these as well. go to FAULT state if any of these go down if unweighted.
# When a weight is specified in track_interface, instead of setting the vrrp instance to the FAULT state in case of failure, its priority will be
# increased by the weight when the interface is up (for positive weights), or decreased by the weight's absolute value when the interface is down
# (for negative weights), unless reverse is specified, in which case the direction of adjustment of the priority is reversed.
# The weight must be comprised between -253 and +253 inclusive.0 is the default behaviour which means that a failure implies a
# FAULT state. The common practice is to use positive weights to count a limited number of good services so that the server with the highest count
# becomes master. Negative weights are better to count unexpected failures among a high number of interfaces, as it will not saturate even with high
# number of interfaces. Use reverse to increase priority if an interfaces is down
track_interface {
eth0
eth1
eth2 weight <-253..253> [reverse]
...
}
# 1 to 255 used to differentiate multiple instances of vrrpd running on the same NIC (and hence same socket).
virtual_router_id 51 #用來區分多VRRP實例?, 是指為一台設備配置多個實例,還是一個局域網中的多個實例? 貌似是后者,待確認!!!
preempt_delay 300 #表示的含義是,我當前是backup身份,但是我發現對方的master不如我,即優先級比我低,那么我不會立馬去搶占,而是等五分鍾后再去搶占
關於weight,rise,fall的綜合用法
A positive weight means that <rise> successes will add <weight> to the priority of all VRRP instances which monitor it.
On the opposite, a negative weight will be subtracted from the initial priority in case of <fall> failures
解析:rise和正數的weight結合使用,如果rise次腳本執行都是成功的(返回0),則增加weight數量的優先級
fall和負數的weight結合使用,如果是fall次腳本執行都是失敗的(返回1),則減少|weight|數量的優先級
其余的組合方式不起任何作用,即不會影響優先級的增減
三. 案例解析
節點1:
簡介:我是backup身份,但因為我的優先級高,所以是實際的掌權者,當我發現我節點上的業務已經掛了那么我就降低我的級別,讓真正的master去掌權直到我的級別又上來了,我也不會立馬奪權,而是等待一段時間后再奪權
vrrp_script chkBackup {
##檢查進程是否存在,如果存在檢查聯通性,如果聯通了。則返回0, 如果不存在或者不聯通則返回1
script "ps -fe|grep tranproxy |grep -v gre; [[ $? -eq 0 ]] && (/usr/local/bin/x.out; [[ $? -eq 0 ]] && exit 0 || exit 1) || exit 1"
interval 30
fall 2 ##2次KO再降級,兩次返回1(即兩次進程不存在)則優先級下降20
weight -20
user root
}
vrrp_instance VI_1 {
state BACKUP
#表示發vrrp包的接口,可以選擇一對專用接口做心跳線,這里千萬注意,網上那些直接抄別人的博客說這個就是綁定vip的接口,真不要臉,簡直誤人子弟
interface eno2
#雖然指定了從eno2上發的包,但是如果想要給他搞一個假的ip就用他
unicast_src_ip 182.168.1.30
unicast_peer {
182.168.1.245
}
#這個也很重要,通常心跳線都是主被之間直連,一旦主機掉電(注意,一定是沒有電的情況),則備機上的心跳接口鏈路成DOWN狀態,於是keepalived進入FAULT狀態,進而放棄了所有vip
dont_track_primary
virtual_ipaddress {
##vip真正綁定再哪個接口上是在這里配置的,當然如果你不指定,可不就綁定到interface那里配置的那個接口了
192.168.1.33/24 brd 192.168.1.255 dev eno1 label eno1:1
}
virtual_router_id 1
priority 110 ##高優先級,實際我是主宰着
track_script
{
chkBackup #如果我發現自己掛了,則立馬降低自己的優先級,master會立刻奪權
}
preempt_delay 300 ##發現優先級比我低的master,不會立馬奪權,而是5分鍾后再奪權
}
節點2:
簡介:我是Master身份,但因為我的優先級低,所以對端才是實際的掌權者,當對端節點上的業務已經掛了那么會降低優先級,於是我開始去掌權
並且我是會立馬掌權的(不確定,記得去環境上看一下)
節點2上的全局配置,節點1上類似,先以這個配置為例進行解析
global_defs {
notification_email {
wuxiaoyun@huanxingnet.com
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id k-two2-fst-hx ##一個局域網上id需要唯一,一般使用hostname。wxy:公司的測試環境中可能有多套測試環境,hostname都一樣,所以還是不要直接用hostname
script_user root
enable_script_security
}
節點2上的實例配置,以其中一個實例為例進行解析
vrrp_instance VI_1 {
state MASTER
interface eno2
unicast_src_ip 182.168.1.30
unicast_peer {
182.168.1.245
}
virtual_router_id 1 ##虛擬路由id,一對vrrp實例使用一個router id,具體什么含義沒再多去研究
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 11111
}
virtual_ipaddress {
192.168.1.33/24 brd 192.168.1.255 dev eno1 label eno1:0
}
}
附:vrrp報文交互,可以看到使用的是182網段(eno2)的地址,交換的是192網段(eno1)的VIp
四. 其他配置方式收集
-
不指定將vip綁定到哪個接口上
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_ipaddress {
192.168.48.232
}
}
此時,使用ifconfig是看不到這個ip地址,需要使用ip a
[root@k8s-master1-192-168-48-231 keepalived]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.48.231 netmask 255.255.255.0 broadcast 192.168.48.255
inet6 fe80::1e63:e31:eb50:4005 prefixlen 64 scopeid 0x20<link>
inet6 fe80::2a6e:d4ff:fe88:c80e prefixlen 64 scopeid 0x20<link>
ether 28:6e:d4:88:c8:0e txqueuelen 1000 (Ethernet)
...
[root@k8s-master1-192-168-48-231 keepalived]# ip a |grep eth0 -A5
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 28:6e:d4:88:c8:0e brd ff:ff:ff:ff:ff:ff
inet 192.168.48.231/24 brd 192.168.48.255 scope global eth0
valid_lft forever preferred_lft forever
inet 192.168.48.232/32 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::2a6e:d4ff:fe88:c80e/64 scope link
...
五. 爬坑
坑1:寫腳本可能遇到的坑:
vrrp_script chkBackup {
script "./keepalived_script.sh 172.18.1.10"
interval 10
fall 2 ##2次KO再降級
weight -20
user root
}
報錯1:Disabling track script chkBackup since not found/accessible
原因:不能使用相對路徑,應該使用絕對路徑,改為:
script "/etc/keepalived/keepalived_script.sh 172.18.1.10"
報錯2:Error exec-ing command '/etc/keepalived/keepalived_script.sh', error 8: Exec format error
直接執行腳本是沒有問題的
原因:直接執行是用#bash /etc/keepalived/keepalived_script.sh 172.18.1.10
所以腳本中必須加上:#!bin/bash
報錯3:本地沒有分到vip,查看日志信息報錯為
Keepalived_vrrp[1884]: Assigned address 182.168.1.245 for interface enp5s0
Aug 20 11:37:31 one1-fst-hx Keepalived_vrrp[1884]: Assigned address fe80::fafd:41aa:f8d4:c6a4 for interface enp5s0
Aug 20 11:37:31 one1-fst-hx Keepalived_vrrp[1884]: (VI_1) entering FAULT state
Aug 20 11:37:31 one1-fst-hx Keepalived_vrrp[1884]: (VI_2) entering FAULT state
解析:我就奇怪了,要么是MASTER要么是SLAVE state,為什么是fault
原因1:網絡問題,找不到被綁定的ip,如下
詳解:
virtual_ipaddress {
192.168.1.51/24 brd 192.168.1.255 dev eno1 label eno1:0 ---要綁定eno1
192.168.2.51/24 brd 192.168.1.255 dev ens1f0 label ens1f0:0 ---要綁定ens1f0
}
[root@two2-asm-hx keepalived]# ip link
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000 -----我是被綁定接口1
link/ether ac:1f:6b:d6:0d:ac brd ff:ff:ff:ff:ff:ff
3: eno2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000 ---我是心跳接口
link/ether ac:1f:6b:d6:0d:ad brd ff:ff:ff:ff:ff:ff
4: ens1f0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT qlen 1000 ---我是被綁定接口2
link/ether 00:1b:21:bf:5c:3c brd ff:ff:ff:ff:ff:ff
9月 24 22:30:02 two2-asm-hx Keepalived_vrrp[22859]: Opening file '/etc/keepalived/keepalived.conf'.
9月 24 22:30:02 two2-asm-hx Keepalived_vrrp[22859]: Assigned address 182.168.1.184 for interface eno2
9月 24 22:30:02 two2-asm-hx Keepalived_vrrp[22859]: (VI_1) entering FAULT state
9月 24 22:30:02 two2-asm-hx Keepalived_vrrp[22859]: (VI_2) entering FAULT state
9月 24 22:30:02 two2-asm-hx Keepalived_vrrp[22859]: Registering gratuitous ARP shared channel
9月 24 22:30:02 two2-asm-hx Keepalived_vrrp[22859]: (VI_1) removing VIPs.
9月 24 22:30:02 two2-asm-hx Keepalived_vrrp[22859]: (VI_2) removing VIPs.
小結:由於被綁定接口沒有全部up,因此就認為我的設備有問題,也因此放權,不占用vip
解決,當然要自己保證想要的接口都是up的,不知道通過配置 track_interface是否可行,簡單試驗是不行的,但是沒有具體的去試驗
原因2:心跳接口down
9月 24 20:07:37 two2-asm-hx Keepalived_vrrp[14273]: Netlink reports eno2 down -----因為心跳接口down掉了
9月 24 20:07:38 two2-asm-hx Keepalived_vrrp[14273]: Netlink reports ens1f0 down
9月 24 20:07:38 two2-asm-hx Keepalived_vrrp[14273]: (VI_1) Entering FAULT STATE
9月 24 20:07:38 two2-asm-hx Keepalived_vrrp[14273]: (VI_1) sent 0 priority
9月 24 20:07:38 two2-asm-hx Keepalived_vrrp[14273]: (VI_1) removing VIPs.
9月 24 20:07:38 two2-asm-hx Keepalived_vrrp[14273]: (VI_2) Entering FAULT STATE
9月 24 20:07:38 two2-asm-hx Keepalived_vrrp[14273]: (VI_2) sent 0 priority
9月 24 20:07:38 two2-asm-hx Keepalived_vrrp[14273]: (VI_2) removing VIPs
詳解1:心跳接口為什么down掉,有一種場景就是因為心跳鏈路是直連,因此當另一端掉電,則本端的鏈路也會呈現DOWN狀態。
詳解2:
9月 24 22:10:42 two2-asm-hx Keepalived_vrrp[12568]: Netlink reports eno2 down ----當發現鏈路斷開后
9月 24 22:10:46 two2-asm-hx Keepalived_vrrp[12568]: Deassigned address 182.168.1.184 from interface eno2 ---我會將心跳接口上的ip地址給去除
9月 24 22:11:04 two2-asm-hx Keepalived_vrrp[12568]: Netlink reports eno2 up ---當發現鏈路ok
9月 24 22:11:04 two2-asm-hx Keepalived_vrrp[12568]: Assigned address 182.168.1.184 for interface eno2 --再添加上
小結:這種就是說arp發不出去了,可以通過添加配置改變:dont_track_primary
此時,就如下log顯示,盡管監測到接口down,但是並不改變浮動ip
wxy:實際上,這個所謂去除ip是針對keepalived,一旦鏈路down,即使沒有keepalived,內核照樣會將ip去掉?
坑2:啟動失敗
[root@89 sbin]# ./opensipsctl start
INFO: Starting OpenSIPS :
ERROR: PID file /var/run/opensips.pid does not exist -- OpenSIPS start failed
原因1:經過各種試驗得知,原因是debug模式就是如此,將debug關閉,ok
原因2:
tail -f /var/log/messages
Sep 24 21:06:16 mail ./opensips[66657]: ERROR:db_mysql:db_mysql_connect: driver error(1045): Access denied for user 'opensips'@'localhost' (using password: YES)
Sep 24 21:06:16 mail ./opensips[66657]: ERROR:db_mysql:db_mysql_new_connection: initial connect failed
Sep 24 21:06:16 mail ./opensips[66657]: ERROR:core:db_do_init: could not add connection to the pool
Sep 24 21:06:16 mail ./opensips[66657]: ERROR:uri:mod_init: Could not connect to database
Sep 24 21:06:16 mail ./opensips[66657]: ERROR:core:init_mod: failed to initialize module uri
Sep 24 21:06:16 mail ./opensips[66657]: ERROR:core:main: error while initializing modules
Sep 24 21:06:16 mail ./opensips[66657]: INFO:core:cleanup: cleanup
Sep 24 21:06:16 mail ./opensips[66657]: NOTICE:core:main: Exiting....
Sep 24 21:06:16 mail opensips: INFO:core:daemonize: pre-daemon process exiting with -1
原來是數據庫沒有創建,或者是創建錯誤了,正是因為參考文檔中寫錯了…….
坑3:客戶端連接超時
定位過程:起初只是抓包udp協議,發現有來自客戶端的注冊請求,沒有應答,所以一位是opensip安裝有惡,於是還重裝等各種操作
之后突然想到,應該不過濾抓包才行
解決:完整抓包發現,有應答,為icmp包:主機不可達, host administratively prohibited
知道多半是iptables的問題,盡管關閉的firewall其實還是有效的,於是增加
# iptables -t filter -IINPUT -p udp --dport 5060 -j ACCEPT
問題解決
或者:
systemctl stop iptables.service
systemctl disable iptables.service
/usr/local/opensips/sbin/opensipsctl start
坑4:其他任何失敗的問題首先檢查防火牆是否關閉!!!
如果是之前沒有關閉防火牆,然后創建了應答綁定,此時是發送不出去的
然后關閉防火牆,此時還是不能發送出去
所以,需要再配置udp之前,關閉防火牆
坑5: ipv6
virtual_ipaddress {
192.168.1.160/24 brd 192.168.1.255 dev eno1 label eno1:1
1::161/64 dev eno1 label eno1:3
}
Nov 2 10:35:54 one1-asm-hx Keepalived_vrrp[17901]: (Line 54) Cannot specify label for IPv6 addresses (1::162/64) - ignoring label
Nov 2 10:35:54 one1-asm-hx Keepalived_vrrp[17901]: (Line 54) (VI_1): address family must match VRRP instance [1::162/64] - ignoring
Nov 2 10:35:54 one1-asm-hx Keepalived_vrrp[17901]: (Line 79) Cannot specify label for IPv6 addresses (1::161/64) - ignoring label
Nov 2 10:35:54 one1-asm-hx Keepalived_vrrp[17901]: (Line 79) (VI_2): address family must match VRRP instance [1::161/64] - ignoring
virtual_ipaddress {
2001:fecc:0:622::a/64 #如果不打標簽,則缺省這個vip是綁定到發送vrrp的那個接口,也就是eno2
}
(VI_2) received lower priority (100) advert from fe80::ae1f:6bff:fed6:de1 - discarding ----接收到來自對端eno2的(fe80...de1)的varp
(VI_2) received lower priority (100) advert from fe80::ae1f:6bff:fed6:de1 - discarding
(VI_2) Receive advertisement timeout
(VI_2) Entering MASTER STATE
(VI_2) using locally configured advertisement interval (1000 milli-sec)
(VI_2) setting VIPs.
Sending unsolicited Neighbour Advert on eno2 for 2001:fecc:0:622::a
(VI_2) Sending/queueing Unsolicited Neighbour Adverts on eno2 for 2001:fecc:0:622::a
Sending unsolicited Neighbour Advert on eno2 for 2001:fecc:0:622::a
Sending unsolicited Neighbour Advert on eno2 for 2001:fecc:0:622::a
Sending unsolicited Neighbour Advert on eno2 for 2001:fecc:0:622::a
Sending unsolicited Neighbour Advert on eno2 for 2001:fecc:0:622::a
Registering new address record for 2001:fecc:0:622::a on eno2.*.
Withdrawing address record for fe80::ae1f:6bff:fe6f:b651 on eno2.
(VI_2) Received advert from fe80::ae1f:6bff:fed6:de1 with lowe
目前的現象是:
虛擬ip各自綁定在了各自的接口上,也就是說接口沒又互相通信,why?
解決:
# ping6 fe80::ae1f:6bff:fed6:de1
解析1:原來缺省情況下,接口會有一個缺省的ipv6的地址,但相連的兩台設備ipv6地址不能ping通,所以要該一下
one1
ip -6 addr add 3ffe:ffff:0:f101::1/64 dev enp5s0
one2
ip -6 addr add 3ffe:ffff:0:f101::2/64 dev eno2
[root@one2-asm-hx keepalived]# ping6 3ffe:ffff:0:f101::1
-------------------------
virtual_ipaddress {
# 192.168.1.166/24 brd 192.168.1.255 dev eno1 label eno1:1
3ffe:ffff:0:f101::33/64
}
結果:
Sending unsolicited Neighbour Advert on eno2 for 3ffe:ffff:0:f101::33
(VI_2) Sending/queueing Unsolicited Neighbour Adverts on eno2 for 3ffe:ffff:0:f101::33
Sending unsolicited Neighbour Advert on eno2 for 3ffe:ffff:0:f101::33
此時查看接口ip,大家都保留了浮動ip
one1:slave(實際的master)
VRRP sockpool: [ifindex(3), family(IPv6), proto(112), unicast(0), fd(14,15)]
Keepalived_vrrp[8358]: VRRP_Script(chkBackupR) succeeded
Keepalived_vrrp[8358]: (VI_2) Changing effective priority from 90 to 110
Keepalived_vrrp[8358]: (VI_2) start preempt delay (60.000000)
Keepalived_vrrp[8358]: (VI_2) received lower priority (100) advert from fe80::ec4:7aff:fe9a:e4a5 - discarding
Keepalived_vrrp[8358]: (VI_2) received lower priority (100) advert from fe80::ec4:7aff:fe9a:e4a5 - discarding
Keepalived_vrrp[8358]: (VI_2) received lower priority (100) advert from fe80::ec4:7aff:fe9a:e4a5 - discarding
Keepalived_vrrp[8358]: (VI_2) Receive advertisement timeout
Keepalived_vrrp[8358]: (VI_2) Entering MASTER STATE
Keepalived_vrrp[8358]: (VI_2) using locally configured advertisement interval (1000 milli-sec)
Keepalived_vrrp[8358]: (VI_2) setting VIPs.
Keepalived_vrrp[8358]: Sending unsolicited Neighbour Advert on enp5s0 for 3ffe:ffff:0:f101::33
Keepalived_vrrp[8358]: (VI_2) Sending/queueing Unsolicited Neighbour Adverts on enp5s0 for 3ffe:ffff:0:f101::33
Keepalived_vrrp[8358]: Sending unsolicited Neighbour Advert on enp5s0 for 3ffe:ffff:0:f101::33
一段時間后,vip確實只被one1搶去了
one1:
enp5s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 182.168.1.245 netmask 255.255.255.0 broadcast 182.168.1.255
inet6 fe80::ec4:7aff:fe49:3d32 prefixlen 64 scopeid 0x20<link>
inet6 3ffe:ffff:0:f101::33 prefixlen 64 scopeid 0x0<global>
inet6 3ffe:ffff:0:f101::1 prefixlen 64 scopeid 0x0<global>
ether 0c:c4:7a:49:3d:32 txqueuelen 1000 (Ethernet)
RX packets 1790 bytes 121503 (118.6 KiB)
one2:
eno2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 182.168.1.30 netmask 255.255.255.0 broadcast 182.168.1.255
inet6 3ffe:ffff:0:f101::2 prefixlen 64 scopeid 0x0<global>
inet6 fe80::ec4:7aff:fe9a:e4a5 prefixlen 64 scopeid 0x20<link>
ether 0c:c4:7a:9a:e4:a5 txqueuelen 1000 (Ethernet)
RX packets 1783 bytes 128639 (125.6 KiB)
RX errors 0 dropped 0 overruns 0 frame
關閉one1的keepalived
浮動ip順利漂移
重新開啟one1的keepalived
浮動ip順利漂移
升級2:將vip綁定到數據接口上
3ffe:ffff:0:f101::33/64 dev eno1
結果:vip漂移正常
恢復也正稱
升級3:將vip綁定到數據接口上,然后打標簽
3ffe:ffff:0:f101::33/64 dev eno1 label eno1:10
結果:失敗
Opening file '/etc/keepalived/keepalived.conf'.
Cannot specify label for IPv6 addresses (3ffe:ffff:0:f101::33/64) - ignoring label
vip在master那邊
升級4:將用於通信的的接口,指定通信地址
unicast_src_ip 182.168.1.30
unicast_peer {
182.168.1.245 ##同上
}
one1:
(VI_2) Receive advertisement timeout
11月 02 17:38:34 one1-asm-hx Keepalived_vrrp[15616]: (VI_2) Entering MASTER STATE
11月 02 17:38:38 one1-asm-hx Keepalived_vrrp[15616]: Sending gratuitous ARP on eno1 for 192.168.1.33
one2:
VRRP_Script(chkBackupR) succeeded
Nov 2 17:38:34 one2-asm-hx Keepalived_vrrp[16898]: (VI_1) Changing effective priority from 90 to 110
Nov 2 17:38:34 one2-asm-hx Keepalived_vrrp[16898]: (VI_1) start preempt delay (60.000000)
Nov 2 17:39:34 one2-asm-hx Keepalived_vrrp[16898]: (VI_1) received lower priority (100) advert from 182.168.1.245 - discarding
Nov 2 17:39:35 one2-asm-hx Keepalived_vrrp[16898]: (VI_1) received lower priority (100) advert from 182.168.1.245 - discarding
Nov 2 17:39:36 one2-asm-hx Keepalived_vrrp[16898]: (VI_1) received lower priority (100) advert from 182.168.1.245 - discarding
Nov 2 17:39:37 one2-asm-hx Keepalived_vrrp[16898]: (VI_1) Receive advertisement timeout
Nov 2 17:39:37 one2-asm-hx Keepalived_vrrp[16898]: (VI_1) Entering MASTER STATE
Nov 2 17:39:37 one2-asm-hx Keepalived_vrrp[16898]: (VI_1) setting VIPs.
結果:
誰都沒有浮動ip
結論:不在指定多播的地址,直接使用缺省值---
坑6:ipv6明明還用,one1和one2之間已經建立了良好的通信,但是two1和two2:
two1:
Nov 18 16:03:27 two1-asm-hx Keepalived_vrrp[792]: (VI_1) Entering FAULT STATE
Nov 18 16:03:27 two1-asm-hx Keepalived_vrrp[792]: (VI_2) Entering FAULT STATE
Nov 18 16:03:27 two1-asm-hx Keepalived_vrrp[792]: (VI_2): send advert error 22 (Invalid argument)
Nov 18 16:03:27 two1-asm-hx Keepalived_vrrp[792]: (VI_2): send advert error 22 (Invalid argument)
Nov 18 16:03:27 two1-asm-hx Keepalived_vrrp[792]: (VI_2) sent 0 priority
Nov 18 16:03:27 two1-asm-hx Keepalived_vrrp[792]: (VI_2) removing VIPs.
Nov 18 16:03:44 two1-asm-hx Keepalived_vrrp[792]: Assigned address fe80:182::96 for interface eno2
Nov 18 16:03:44 two1-asm-hx Keepalived_vrrp[792]: (VI_1) Entering BACKUP STATE
Nov 18 16:03:44 two1-asm-hx Keepalived_vrrp[792]: (VI_2) Entering BACKUP STATE
Nov 18 16:03:44 two1-asm-hx Keepalived_vrrp[792]: (VI_2) start preempt delay (60.000000)
two2:
Nov 18 16:31:39 two2-asm-hx Keepalived_vrrp[22267]: Registering gratuitous NDISC shared channel
Nov 18 16:31:39 two2-asm-hx Keepalived_vrrp[22267]: (VI_1) removing VIPs.
Nov 18 16:31:39 two2-asm-hx Keepalived_vrrp[22267]: (VI_2) removing VIPs.
Nov 18 16:31:39 two2-asm-hx Keepalived_vrrp[22267]: (VI_1) Entering BACKUP STATE (init)
Nov 18 16:31:39 two2-asm-hx Keepalived_vrrp[22267]: (VI_2) Entering BACKUP STATE (init)
Nov 18 16:31:39 two2-asm-hx Keepalived_vrrp[22267]: VRRP sockpool: [ifindex(3), family(IPv6), proto(112), unicast(0), fd(11,12)]
Nov 18 16:31:39 two2-asm-hx Keepalived_vrrp[22267]: VRRP_Script(chkBackupR) succeeded
Nov 18 16:31:39 two2-asm-hx Keepalived_vrrp[22267]: (VI_1) Changing effective priority from 90 to 110
Nov 18 16:31:40 two2-asm-hx ASM_agent[5134]: @2161: Cannot connect through PCIe = 0x40000912 adapterno = 0 nodeid = 4 rint = 13000
Nov 18 16:31:43 two2-asm-hx Keepalived_vrrp[22267]: (VI_2) Receive advertisement timeout
Nov 18 16:31:43 two2-asm-hx Keepalived_vrrp[22267]: (VI_2) Entering MASTER STATE
Nov 18 16:31:43 two2-asm-hx Keepalived_vrrp[22267]: (VI_2) using locally configured advertisement interval (1000 milli-sec)
解析:也就是說本來作為master的two2發現沒有接收到心跳報文,於是無所顧慮的直接成為master,
正常來說,因該接收到two1的高優先級的心跳報文,但是沒有接收到,為啥呢,是被攔截了么?
於是靈光一現,想到了防火牆,於是查看two2的防火牆,果然,開啟着的,MD.....哪個龜孫兒給我開啟的....
應該先發一下廣播報文,然后接收到two1的回應,但是發現應答超時了,所以two2就認為自己再VI_2上成為了master,於是two2占領了兩個vip
原因:
坑7. 同一個局域網中存在相同的virtual_router_id導致網絡沖突
見日志
<待添加>
附1.安裝步驟
參考文檔:https://blog.csdn.net/yiyangtime/article/details/84899536
需要特別注意的是,
1)其中有一處錯誤:創建數據庫,使用的命令是
/usr/local/sbin/opensipsdbctl create
2)利用配置面板配置的時候,如下幾個
/usr/local/sbin/osipsconfig
可以將認證刪除,如果不刪除,則需要如下添加賬戶,然后在客戶端上添加account:帳號/密碼=1000/1000,相當於登陸....
./opensipsctl add 1000 1000
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
new user '1000' added
[root@mail sbin]# ./opensipsctl add 2000 2000
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
new user '2000' added
3)至於tcp,根據自己情況看看是否使用,目前的客戶端都是udp的