-->

DEVOPSZONES

  • Recent blogs

    How to setup Keepalived Setup in Linux Server?

    How to setup Keepalived Setup in Linux Server?




    Keepalived  provides simple and robust facilities for load balancing and high availability. Keepalived implements the Virtual Router Redundancy Protocol  VRRPv2) to achieve high availability with director fail-over. The VRRP protocol ensures that one participating node is Master and others are Backup. The backup nodes listen to the multicast packets from Master Node. Of the Backup Node fails to receive VRRP advertisements for a period longer than three times, the backup node takes the master state and assigns the configured IP to itself. In case there are more than one backup nodes with the same priority, the one with the highest IP wins.


     Install:




     yum install keepalived -y



     Configuration: 



     Add the configuration into /etc/keepalived/keepalived.conf




     Master node:


     global_defs {
        router_id nginx03   ----> Router ID
     }
    vrrp_instance nginxS_general {
        state MASTER     ---> Initial State of the Keepalived
        interface eth0
        virtual_router_id 3
        priority 50     ----> Priority .Its higher as it is Master Node.
        advert_int 1
        authentication {
            auth_type PASS
            auth_pass lookbeautiful
        }
        virtual_ipaddress {
            192.168.2.3/24 dev eth0 label eth0:0
        }
    }

     

    Backup Node:


     global_defs {
        router_id nginx03   ----> Router ID
     }
    vrrp_instance nginxS_general {
        state BACKUP   ---> Initial State of the Keepalived,  The state is changed dynamically to MASTER if master Node is down.
        interface eth0
        virtual_router_id 3
        priority 40      ----> Priority .Its Lower as it is BACKUP Node.
        advert_int 1
        authentication {
            auth_type PASS
            auth_pass lookbeautiful
        }
        virtual_ipaddress {
            192.168.2.3/24 dev eth0 label eth0:0
        }
    }



     To check the Advertisement:



     [root@nginx03 ~]# tcpdump -n -v -i eth0 vrrp

    tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
    05:40:47.439160 IP (tos 0x0, ttl 255, id 1791, offset 0, flags [none], proto: VRRP (112), length: 40) 192.168.2.2 > xx.xx.xx.xx: VRRPv2, Advertisement, vrid 3, prio 40,
    authtype simple, intvl 1s, length 20, addrs: 192.168.2.3 auth "lookbeautiful@^@^@"

    No comments