Keepalived configuration

Once Keepalived is installed on each and every one of the machines that make up the load balancing work environment, the file to be configured with a text editor (Vim, Nano, etc.) is as follows:

/etc/keepalived/keepalived.conf

Instance configuration

Floating IP address configuration

In the instance defined, a separate section called virtual_ipaddress will contain the possible IP addresses to be served, for example:

virtual_ipaddress { <vip>/24 }

Security configuration

In the defined instance, a separate section called authentication will contain a password authentication method (auth_type PASS) and the password itself (length of exactly 8 characters), for example:

authentication {
  auth_type PASS
  auth_pass <8_digit_pass>
}

Example

In scheme called VI_1, with a main node called MASTER and a secondary node called BACKUP with fixed IP addresses <ha1_ip> and <ha2_ip>, and a floating IP address (<vip>) to balance its load:

HA1:

vrrp_instance VI_1 {
  state MASTER
  interface <if_name_1>
  virtual_router_id 55
  priority 150
  advert_int 1
  unicast_src_ip <ha1_ip>
  unicast_peer {
    <ha2_ip>
  }

  authentication {
    auth_type PASS
    auth_pass <8_digit_pass>
  }

  virtual_ipaddress {
    <vip>/24
  }
}

HA2:

vrrp_instance VI_1 {
  state BACKUP
  interface <if_name_2>
  virtual_router_id 55
  priority 100
  advert_int 1
  unicast_src_ip <ha2_ip>
  unicast_peer {
    <ha1_ip>
  }

  authentication {
    auth_type PASS
    auth_pass <8_digit_pass>
  }

  virtual_ipaddress {
    <vip>/24
  }
}


Revision #4
Created 9 October 2023 14:21:28 by Jimmy Olano
Updated 6 November 2023 12:27:26 by Laura Cano