Pazar, Ocak 05, 2014

Failover With KeepAlived

Network Scenario:
  1. LB1 Server: 192.168.10.111 ( eth1 )
  2. LB2 Server: 192.168.10.112 ( eth1 )
  3. Virtual IP: 192.168.10.121
Install Keepalived

Keepalived is available in centos base repository. Install it using yum command line tool.
# yum install keepalived
Keepalived configuration File: /etc/keepalived/keepalived.conf

Configure Keepalived on LB1.

Edit Keepalived configuration file on LB1 and add following configuration.
vrrp_instance VI_1 {
    interface eth1 state MASTER
    virtual_router_id 10
    priority 101 # 101 on master, 100 on backup
    virtual_ipaddress {
        192.168.10.121
    }
}
Configure Keepalived on LB2.

Edit Keepalived configuration file on LB2 and add following configuration.
vrrp_instance VI_1 {
    interface eth1 state BACKUP
    virtual_router_id 10
    priority 100 # 101 on master, 100 on backup
        virtual_ipaddress {
            192.168.10.121
        }
    }

1. Priority value will be higher on Master server, It doesn’t matter what you used in state. Ifyour state is MASTER but your priority is lower than the router with BACKUP, you will lose the MASTER state.
2. virtual_router_id should be same on both LB1 and LB2 servers.
3. By default single vrrp_instance support up to 20 virtual_ipaddress. In order to add more addresses you need to add more vrrp_instance
Start Keepalived

Start Keepalived service using following command and also configure to auto start on system boot.
# service keepalived start
# chkconfig keepalived on

Hiç yorum yok: