keepalived vip removed with dhcp renewal【原创】
最近发现公司云平台服务器的vip有丢失的现象,查看keepalived日志
Jun :: lb1 dhclient: DHCPREQUEST of 10.0.0.2 on eth0 to 10.0.0.3 port (xid=0x6deab016)
Jun :: lb1 dhclient: DHCPNAK from 10.0.0.3 (xid=0x6deab016)
Jun :: lb1 dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port interval (xid=0x37e1db6a)
Jun :: lb1 dhclient: DHCPREQUEST of 10.0.0.2 on eth0 to 255.255.255.255 port (xid=0x37e1db6a)
Jun :: lb1 dhclient: DHCPOFFER of 10.0.0.2 from 10.0.0.3
Jun :: lb1 dhclient: DHCPACK of 10.0.0.2 from 10.0.0.3
Jun :: lb1 dhclient: bound to 10.0.0.2 -- renewal in seconds.
Jun :: lb1 ntpd[]: Deleting interface # eth0, 10.0.255.254#, interface stats: received=, sent=, dropped=, active_time= secs
Jun :: lb1 ntpd[]: peers refreshed
发现是云平台DHCP刷新直接把vip删掉,但是由于俩台机器的keepalived vrrp_script监控应用服务都是正常的,所以主备关系没有改变,如果没有特意加ping vip的策略,会导致keepalived没有发现此问题。
解决方法:
1、如果应平台的服务器可以改成固定IP,可以将网卡改为固定IP,这样就不会使用DHCP了
cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=static
IPADDR=10.0.0.2
NETMASK=255.255.255.0
GATEWAY=10.0.0.1
2、如果不可以更改网卡IP,就在keepalived配置文件中增加dont_track_primary参数
vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    dont_track_primary
    virtual_router_id
    priority
    advert_int
    nopreempt
    authentication {
        auth_type PASS
        auth_pass
    }
    virtual_ipaddress {
        10.0.0.17
    }
}
dont track primary:忽略VRRP的interface错误
如果有两块网卡,可以搭配track interface使用
track interface:跟踪接口,设置额外的监控,里面任意一块网卡出现问题,都会进入故障(FAULT)状态,例如,用nginx做均衡器的时候,内网必须正常工作,如果内网出问题了,这个均衡器也就无法运作了,所以必须对内外网同时做健康检查
vrrp_instance http {
state MASTER
interface eth0
dont_track_primary
track_interface {
eth0
eth1
}
官方原文
# Ignore VRRP interface faults (default unset)
dont_track_primary # 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). The weight must be comprised between - and +
# inclusive. 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.
track_interface {
eth0
eth1
eth2 weight <-..>
...
} # add a tracking script to the interface
# (<SCRIPT_NAME> is the name of the vrrp_track_script entry)
# The same principle as track_interface can be applied to track_script entries,
# except that an unspecified weight means that the default weight declared in
# the script will be used (which itself defaults to ).
参考
https://serverfault.com/questions/601670/keepalived-vip-removed-with-dhcp-renewal
https://www.keepalived.org/manpage.html
keepalived vip removed with dhcp renewal【原创】的更多相关文章
- keepalived的vip无法ping通【原创】
		今天收到redis的keepalived vip无法ping通的告警,查看服务器和服务时发现vip在服务器上,服务也正常.只能在本机ping通,跨网段无法ping通.切换keepalived vip至 ... 
- keepalived vip 没有生成或者生成了ping不通?
		1 问题现象:keepalived已启动但vip 没有生成./var/log/messages日志不断刷屏 tail /var/log/messages Nov :: cache-redis- Kee ... 
- OpenStack neutron 环境云主机使用keepalived vip + 给vip绑定浮动IP 步骤及注意事项
		在openstack环境创建的多台云主机配置keepalived作主备,默认情况下无法生效,直接对云主机一张网卡配置两个IP进行测试也是同样结果,因为: 可以看到,port所在的宿主机上iptable ... 
- keepalived vip漂移基本原理及选举算法
		keepalived可以将多个无状态的单点通过虚拟IP(以下称为VIP)漂移的方式搭建成一个高可用服务,常用组合比如 keepalived+nginx,lvs,haproxy和memcached等.它 ... 
- (转)小谈keepalived vip漂移原理与VRRP协议
		背景:之前搭建过keepalived双机热备的集群,但对其中的原理不甚理解,看完就忘了,所有有必要深入的学习下. 简介 什么是keepalived呢?keepalived是实现高可用的一种轻量级的技术 ... 
- 浅析keepalived vip漂移原理与VRRP协议
		2017-01-18 Martin 开源技术社区 简介 什么是keepalived呢?keepalived是实现高可用的一种轻量级的技术手段,主要用来防止单点故障(单点故障是指一旦某一点出现故障就会导 ... 
- Nginx+Keepalived+VIP漂移实现HA高可用技术之详细教程
		https://www.cnblogs.com/zcc666/p/13141626.html 这个是nginx安装教程地址 https://www.cnblogs.com/zcc666/p/1313 ... 
- 三主机配置 keepalived VIP高可用
		三台主机: 192.168.33.134 192.168.33.136 192.168.33.137 实验前: 关闭selinux 和iptables 1). 192.168.33.134 ... 
- Redis主从复制+Keepalived+VIP漂移实现HA高可用技术之详细教程
		1.大家可以先看我的单台Redis安装教程,链接在此点击Redis在CentOS for LInux上安装详细教程 2.第一台redis配置,是正常配置.作为MASTER主服务器,第二台redis的配 ... 
随机推荐
- 计算机网络原理,TCP&UDP
			UDP伪首部:计算校验和时会用到,然后实际传输过程中里包含的IP地址没有什么用. UDP校验和计算:求数值之和,如果溢出回卷,最后求出反码;UDP伪首部,UDP首部,应用层数据相加 tcp报文,最短2 ... 
- prometheus operator 部署
			prometheus operator 部署自定义记录 环境: k8s 1.11集群版本,kubeadm部署 docker 17.3.2版本 Centos 7系统 阿里云服务器 operator 源码 ... 
- 2013.5.4 - KDD第十六天
			昨天下午的时候中秋给我发短信"待会儿上课吧?上课讨论下?",然后我回复"嗯,好的."然后上课的时候中秋说那个方案也许不太好执行,因为他后来看数据了,数据库里面这种"可以从从协同作者进行判断"的例子并不 ... 
- javascript中的var,let,const关键字
			文章:JavaScript 中 var 和 let 和 const 关键字的区别 比较全面的文章. 
- DeferredResult使用方式和场景
			为什么使用DeferredResult? API接口需要在指定时间内将异步操作的结果同步返回给前端时: Controller处理耗时任务,并且需要耗时任务的返回结果时: 当一个请求到达API接口,如果 ... 
- JQuery的入门(二)
			Jquery的遍历 jQuery对象本身就是数组对象,通过jquery选择器获得的都是满足该选择器条件的元素对象的集合体,因此在常常需要对jquery对象进行遍历.这里有三种遍历Jquery的方法. ... 
- destoon二次开发-用户名、邮箱、手机账号中间字符串以*隐藏 扩展
			因为dt里面有用户名.邮箱.手机账号等,所以想办法进行隐藏保护用户隐私,所以个人就试着写了这个代码. 在api/extend.func.php文件下增加以下代码: //用户名.邮箱.手机账号中间字符串 ... 
- HDU2870 Largest Submatrix
			Largest Submatrix Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ... 
- Dobbox
			一.向本地仓库导入Dubbox依赖 1.1解压压缩包 1.2打开cmd窗口切到源码包路径 1.3输入命令行 1.4成功后展示如图 1.5输入命令行 1.6成功后如图 public class DoSo ... 
- 【爬虫】大杀器——phantomJS+selenium
			[爬虫]大杀器——phantomJS+selenium 视频地址 江湖上有一个传说,得倚天屠龙者可称霸武林.爬虫中也有两个大杀器,他们结合在一起时,无往不利,不管你静态网站还是动态网站,通吃. pha ... 
