keepalived 双机热备两节点出现双VIP问题

使用keepalived 实现双机热备时,主从节点配置分别如下

主机: 192.168.159.128

global_defs {
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

vrrp_script chk_nginx {
  script "/usr/local/src/nginx_check.sh"
  interval 2
  weight -2  
}

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 {
        192.168.159.10/32
    }
}

从节点:192.168.159.129

global_defs {
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

vrrp_script chk_nginx {
  script "/usr/local/src/nginx_check.sh"
  interval 2
  weight -2  
}

vrrp_instance VI_1 {
    state BACKUP  
    interface eth0  
    virtual_router_id 51 
    priority 10
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.159.10/32
    }
}

 

分别启动两个节点后

主节点: ip a

 

 

从节点: ip a 

 

 注:上图只做参考,为了说明问题

 

解决方法

分别在主机和从机keepalived.conf配置文件中做以下修改

主机:192.168.159.128

priority 100
unicast_src_ip  192.168.159.128   
unicast_peer {
       192.168.159.129
}

备机:192.168.159.129

priority 10
unicast_src_ip  192.168.159.129   
unicast_peer {
       192.168.159.128
}

 

重启keepalived服务后,重新查看问题得到解决,详情请参考https://www.cnblogs.com/netonline/p/7642595.html

 

posted on 2020-08-05 22:13  arsn  阅读(635)  评论(0编辑  收藏  举报

导航