1. 程式人生 > >Keepalived非搶佔模式配置

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

[email protected]
  }

  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 [email protected]
  }

  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、其中一個節點的優先順序必須要高於另外一個節點的優先順序。