keepalived的配置解析&安装与爬坑
目录:
一. 前情提要
二. 官方配置说明
三. 案例解析
四. 其他配置方式收集
五. 爬坑
附1: 安装keepalived
------------------------
一. 前情提要
以下试验以及说明是经过试验确定了的,准确!!另外,如果想知道每个参数的真正含义,建议看官网
解决的问题:
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。
1. 全局配置部分
1. 预定义一个脚本以及脚本管理方式,之后用于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 }
2. 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
四. 其他配置方式收集
1. 不指定将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的