IP Address Active/Passive Failover Setup in Linux CentOS 6 RHEL 6 using keepalived

Hey everyone out there in BBS land.  Your old friend Max here to dump out some knowledge on you.

Imagine you’re living in a world of two systems and three IP addresses.  One of the IP addresses is really importing and if the system it’s running on explodes, you want it to come back up on trusty old system number two.  We can use a utility for this called keepalived.

The keepalived bits can be found on the base repository for CentOS so if all is connected and such, you can install the software by running this command:

yum -y install keepalived

Master System:

Put the following in your /etc/keepalived/keepalived.conf

Making sure to change the virtual IP and the interface name!

! Configuration File for keepalived

global_defs {
notification_email {
alerts@localhost
}
notification_email_from root@localhost
smtp_server localhost
smtp_connect_timeout 30
router_id LVS_DEVEL
}

vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 101
advert_int 1
authentication {
auth_type PASS
auth_pass passwordhere
}
virtual_ipaddress {
10.0.0.66
}
}

Backup Machine: 

Put the following in your /etc/keepalived/keepalived.conf:

! Configuration File for keepalived

global_defs {
notification_email {
alerts@localhost
}
notification_email_from root@localhost
smtp_server localhost
smtp_connect_timeout 30
router_id LVS_DEVEL
}

vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass password
}
virtual_ipaddress {
10.0.0.66
}
}

Start the service and make sure it starts automatically at system start

service keepalived start && chkconfig keepalived on

You’ll be able to see the IP attached to the specified interface after running

ip addr show eth0

 

Enjoy
Mm.,

Leave a Reply

Your email address will not be published. Required fields are marked *