博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
keepalived instance priority don't impact by track script|interface weight when 255
阅读量:7113 次
发布时间:2019-06-28

本文共 9538 字,大约阅读时间需要 31 分钟。

前面我在写keepalived优先级动态调整时, 写到关于初始优先级设置为255的instance不被动态调整的内容, 原因参考本文末尾部分. 因为
if (vrrp->base_priority == VRRP_PRIO_OWNER) {
/* we will not run a PRIO_OWNER into a non-PRIO_OWNER */
vrrp->effective_priority = VRRP_PRIO_OWNER;
本文主要就是实际验证一下.
用的例子参考
把192.168.173.204的初始优先级调整为255.
把192.168.173.203的初始优先级调整为254.
keepalived启动后, 192.168.173.204是MASTER.
Aug 21 13:59:03 192_168_173_203 Keepalived[421]: Starting Keepalived v1.2.13 (08/19,2014)Aug 21 13:59:03 192_168_173_203 Keepalived[422]: Starting Healthcheck child process, pid=423Aug 21 13:59:03 192_168_173_203 Keepalived[422]: Starting VRRP child process, pid=424Aug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: Netlink reflector reports IP 192.168.173.203 addedAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: Netlink reflector reports IP 192.168.173.156 addedAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: Netlink reflector reports IP fe80::f6ce:46ff:fe86:4234 addedAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: Registering Kernel netlink reflectorAug 21 13:59:03 192_168_173_203 Keepalived_healthcheckers[423]: Netlink reflector reports IP 192.168.173.203 addedAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: Registering Kernel netlink command channelAug 21 13:59:03 192_168_173_203 Keepalived_healthcheckers[423]: Netlink reflector reports IP 192.168.173.156 addedAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: Registering gratuitous ARP shared channelAug 21 13:59:03 192_168_173_203 Keepalived_healthcheckers[423]: Netlink reflector reports IP fe80::f6ce:46ff:fe86:4234 addedAug 21 13:59:03 192_168_173_203 Keepalived_healthcheckers[423]: Registering Kernel netlink reflectorAug 21 13:59:03 192_168_173_203 Keepalived_healthcheckers[423]: Registering Kernel netlink command channelAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: Opening file '/opt/keepalived/etc/keepalived/keepalived.conf'.Aug 21 13:59:03 192_168_173_203 Keepalived_healthcheckers[423]: Opening file '/opt/keepalived/etc/keepalived/keepalived.conf'.Aug 21 13:59:03 192_168_173_203 Keepalived_healthcheckers[423]: Configuration is using : 7937 BytesAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: Configuration is using : 69311 BytesAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: Using LinkWatch kernel netlink reflector...Aug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: VRRP sockpool: [ifindex(2), proto(112), unicast(1), fd(10,11)]Aug 21 13:59:03 192_168_173_203 Keepalived_healthcheckers[423]: Using LinkWatch kernel netlink reflector...Aug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: VRRP_Script(nag) succeededAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: VRRP_Script(zero) succeededAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: VRRP_Script(pos) succeededAug 21 13:59:04 192_168_173_203 Keepalived_vrrp[424]: VRRP_Instance(vi_1) Transition to MASTER STATEAug 21 13:59:05 192_168_173_203 Keepalived_vrrp[424]: VRRP_Instance(vi_1) Entering MASTER STATEAug 21 13:59:05 192_168_173_203 Keepalived_vrrp[424]: VRRP_Instance(vi_1) setting protocol VIPs.Aug 21 13:59:05 192_168_173_203 Keepalived_vrrp[424]: VRRP_Instance(vi_1) Sending gratuitous ARPs on eth0 for 172.16.173.100Aug 21 13:59:05 192_168_173_203 Keepalived_healthcheckers[423]: Netlink reflector reports IP 172.16.173.100 addedAug 21 13:59:06 192_168_173_203 rgmanager[652]: [script] Executing /usr/local/bin/pgctl.sh statusAug 21 13:59:10 192_168_173_203 Keepalived_vrrp[424]: VRRP_Instance(vi_1) Sending gratuitous ARPs on eth0 for 172.16.173.100Aug 21 13:59:26 192_168_173_203 rgmanager[1041]: [script] Executing /usr/local/bin/pgctl.sh statusAug 21 13:59:29 192_168_173_203 Keepalived_vrrp[424]: VRRP_Instance(vi_1) Received higher prio advertAug 21 13:59:29 192_168_173_203 Keepalived_vrrp[424]: VRRP_Instance(vi_1) Entering BACKUP STATEAug 21 13:59:29 192_168_173_203 Keepalived_vrrp[424]: VRRP_Instance(vi_1) removing protocol VIPs.Aug 21 13:59:29 192_168_173_203 Keepalived_healthcheckers[423]: Netlink reflector reports IP 172.16.173.100 removedAug 21 13:59:03 192_168_173_203 Keepalived[421]: Starting Keepalived v1.2.13 (08/19,2014)Aug 21 13:59:03 192_168_173_203 Keepalived[422]: Starting Healthcheck child process, pid=423Aug 21 13:59:03 192_168_173_203 Keepalived[422]: Starting VRRP child process, pid=424Aug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: Netlink reflector reports IP 192.168.173.203 addedAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: Netlink reflector reports IP 192.168.173.156 addedAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: Netlink reflector reports IP fe80::f6ce:46ff:fe86:4234 addedAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: Registering Kernel netlink reflectorAug 21 13:59:03 192_168_173_203 Keepalived_healthcheckers[423]: Netlink reflector reports IP 192.168.173.203 addedAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: Registering Kernel netlink command channelAug 21 13:59:03 192_168_173_203 Keepalived_healthcheckers[423]: Netlink reflector reports IP 192.168.173.156 addedAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: Registering gratuitous ARP shared channelAug 21 13:59:03 192_168_173_203 Keepalived_healthcheckers[423]: Netlink reflector reports IP fe80::f6ce:46ff:fe86:4234 addedAug 21 13:59:03 192_168_173_203 Keepalived_healthcheckers[423]: Registering Kernel netlink reflectorAug 21 13:59:03 192_168_173_203 Keepalived_healthcheckers[423]: Registering Kernel netlink command channelAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: Opening file '/opt/keepalived/etc/keepalived/keepalived.conf'.Aug 21 13:59:03 192_168_173_203 Keepalived_healthcheckers[423]: Opening file '/opt/keepalived/etc/keepalived/keepalived.conf'.Aug 21 13:59:03 192_168_173_203 Keepalived_healthcheckers[423]: Configuration is using : 7937 BytesAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: Configuration is using : 69311 BytesAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: Using LinkWatch kernel netlink reflector...Aug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: VRRP sockpool: [ifindex(2), proto(112), unicast(1), fd(10,11)]Aug 21 13:59:03 192_168_173_203 Keepalived_healthcheckers[423]: Using LinkWatch kernel netlink reflector...Aug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: VRRP_Script(nag) succeededAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: VRRP_Script(zero) succeededAug 21 13:59:03 192_168_173_203 Keepalived_vrrp[424]: VRRP_Script(pos) succeededAug 21 13:59:04 192_168_173_203 Keepalived_vrrp[424]: VRRP_Instance(vi_1) Transition to MASTER STATEAug 21 13:59:05 192_168_173_203 Keepalived_vrrp[424]: VRRP_Instance(vi_1) Entering MASTER STATEAug 21 13:59:05 192_168_173_203 Keepalived_vrrp[424]: VRRP_Instance(vi_1) setting protocol VIPs.Aug 21 13:59:05 192_168_173_203 Keepalived_vrrp[424]: VRRP_Instance(vi_1) Sending gratuitous ARPs on eth0 for 172.16.173.100Aug 21 13:59:05 192_168_173_203 Keepalived_healthcheckers[423]: Netlink reflector reports IP 172.16.173.100 addedAug 21 13:59:10 192_168_173_203 Keepalived_vrrp[424]: VRRP_Instance(vi_1) Sending gratuitous ARPs on eth0 for 172.16.173.100Aug 21 13:59:29 192_168_173_203 Keepalived_vrrp[424]: VRRP_Instance(vi_1) Received higher prio advertAug 21 13:59:29 192_168_173_203 Keepalived_vrrp[424]: VRRP_Instance(vi_1) Entering BACKUP STATEAug 21 13:59:29 192_168_173_203 Keepalived_vrrp[424]: VRRP_Instance(vi_1) removing protocol VIPs.Aug 21 13:59:29 192_168_173_203 Keepalived_healthcheckers[423]: Netlink reflector reports IP 172.16.173.100 removed
当我把192.168.173.204的nag.var调成1, nag.sh脚本检查失败, 日志如下
Aug 21 13:59:43 192_168_173_204 Keepalived_vrrp[13887]: VRRP_Script(nag) failed
但是不影响
192.168.173.204的优先级, 所以它还是master.
[root@192_168_173_204 ~]# ifconfigeth0      Link encap:Ethernet  HWaddr F4:CE:46:85:15:FC            inet addr:192.168.173.204  Bcast:192.168.173.255  Mask:255.255.255.0          inet6 addr: fe80::f6ce:46ff:fe85:15fc/64 Scope:Link          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1          RX packets:10360595 errors:0 dropped:0 overruns:0 frame:0          TX packets:4714379 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:1000           RX bytes:1469576774 (1.3 GiB)  TX bytes:661681617 (631.0 MiB)eth0:1    Link encap:Ethernet  HWaddr F4:CE:46:85:15:FC            inet addr:172.16.173.100  Bcast:172.16.173.255  Mask:255.255.255.0          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1lo        Link encap:Local Loopback            inet addr:127.0.0.1  Mask:255.0.0.0          inet6 addr: ::1/128 Scope:Host          UP LOOPBACK RUNNING  MTU:16436  Metric:1          RX packets:163476 errors:0 dropped:0 overruns:0 frame:0          TX packets:163476 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:0           RX bytes:8835522 (8.4 MiB)  TX bytes:8835522 (8.4 MiB)
[参考]
1. 
2. 
动态调整优先级的范围 : 
如果配置的instance的初始优先级是255的话, 则不受track weight的影响. 见vrrp_update_priority函数的内容.
if (vrrp->base_priority == VRRP_PRIO_OWNER) {		/* we will not run a PRIO_OWNER into a non-PRIO_OWNER */		vrrp->effective_priority = VRRP_PRIO_OWNER;	} else {		/* WARNING! we must compute new_prio on a signed int in order		   to detect overflows and avoid wrapping. */		new_prio = vrrp->base_priority + prio_offset;		if (new_prio < 1)			new_prio = 1;		else if (new_prio > 254)			new_prio = 254;		vrrp->effective_priority = new_prio;	}keepalived / include / vrrp.h#define VRRP_PRIO_OWNER		255		/* priority of the ip owner -- rfc2338.5.3.4 */
换句话说, 只有初始优先级配置<255的instance, 才可以动态调整优先级. 并且动态调整后的优先级范围是1到254.
priority 
# VRRP PRIO

转载地址:http://ebzel.baihongyu.com/

你可能感兴趣的文章
《软件性能测试与LoadRunner实战教程》新书上市
查看>>
Windows批处理中的等待技巧
查看>>
艾伟_转载:使用AOP动态调用WebService
查看>>
C#收发邮件(Jmail+Professional+v4.4+特别版)
查看>>
How to inject a new Action into existing Node?
查看>>
官方数据:程序员年纪越大越出色、越稀有
查看>>
windbg .cmdtree
查看>>
嵌入式计算机与PC机的区别
查看>>
FastReport微调
查看>>
nginx下的文件下载防盗链(HttpAccessKeyModule)
查看>>
Linq延迟执行(转)
查看>>
Django实战(3):Django也可以有scaffold
查看>>
简单缓存 datatable
查看>>
MFC界面的完善
查看>>
WPF&SL之Basic MVVM
查看>>
On :target
查看>>
最新30幅动人心脾的优秀摄影作品欣赏
查看>>
Map 3D 2013 新功能和新API WebCast视频下载
查看>>
2012年7月感想
查看>>
Memcached的分布式算法-Consistent Hashing
查看>>