Keepalived 2 active servers

I used Centos6 and keepalived from EPEL repo

This configuration keep two active servers in same time, if first server goes down, second server gets his ip and if second server goes down first server get his ip. I used this config with two haproxy servers.

1. On director 1

global_defs {
notification_email {
sysadmin@example.com
}
notification_email_from keepalived@haproxy01.example.com
smtp_server 192.168.1.119
smtp_connect_timeout 30
router_id LVS_SERVER_1
}

vrrp_instance D1 {
state MASTER
smtp_alert
interface eth0
virtual_router_id 51
priority 150
advert_int 1
authentication {
auth_type AH
auth_pass TEST
}
virtual_ipaddress {
10.0.0.110
}
}

vrrp_instance D2 {
state BACKUP
smtp_alert
interface eth0
virtual_router_id 52
priority 100
advert_int 1
authentication {
auth_type AH
auth_pass TEST
}
virtual_ipaddress {
10.0.0.111 <= IP must be different...
}
}

2. On director 2

global_defs {
notification_email {
sysadmin@example.com
}
notification_email_from keepalived@haproxy01.example.com
smtp_server 192.168.1.119
smtp_connect_timeout 30
router_id LVS_SERVER_2
}

vrrp_instance D1 {
state BACKUP
smtp_alert
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type AH
auth_pass TEST
}
virtual_ipaddress {
10.0.0.110
}
}

vrrp_instance D2 {
state MASTER
smtp_alert
interface eth0
virtual_router_id 52
priority 150
advert_int 1
authentication {
auth_type AH
auth_pass TEST
}
virtual_ipaddress {
10.0.0.111
}
}

By andrykondratiev Posted in highload

One comment on “Keepalived 2 active servers

  1. Are the virtual_ipaddress the address on the same network as the native ip of the servers? I have tried similar config but when an IP transitions to another node the default route gets removed.

Leave a comment