Keepalived非抢占模式配置

一、前言

HA的实际运行过程中,当主机发生异常,且后期恢复正常后,存在抢占或非抢占两种情况。

结合实际需求,可能有很多用户需要非抢占的HA工作模式。keepalived能够很好的支持这一需求。

 

二、keepalived非抢占配置

下面直接展示keepalived的非抢占配置。

主机配置如下:

vrrp_instance VI_1
{
  state BACKUP
  nopreempt
  priority 100

  advert_int 1
  virtual_router_id 1
  interface eth0

  authentication
  {
    auth_type PASS
    auth_pass abcd@hehe
  }

  virtual_ipaddress
  {
    100.92.2.110
  }
}

 

备机配置如下:

vrrp_instance VI_1
{
  state BACKUP
  nopreempt
  priority 90

  advert_int 1
  virtual_router_id 1
  interface eth0

  authentication
  {
    auth_type PASS
    auth_pass abcd@hehe
  }

  virtual_ipaddress
  {
    100.92.2.110
  }
}

 

重点:

1、两个节点的state都必须配置为BACKUP

2、两个节点都必须加上配置 nopreempt

引用官方文档对nopreempt字段的说明:

"nopreempt" allows the lower priority machine to maintain the master role, even when a higher priority machine comes back online. 

NOTE: For this to work, the initial state of this entry must be BACKUP.

根据上述描述,第一点提到的state必须配置为BACKUP就明白了。

3、其中一个节点的优先级必须要高于另外一个节点的优先级。

 

本文来自博客园,作者:T-BARBARIANS,转载请注明原文链接:https://www.cnblogs.com/t-bar/p/9940085.html 谢谢

posted @ 2018-11-10 17:48  T-BARBARIANS  阅读(7405)  评论(3编辑  收藏  举报