HOW TO INSTALL AND CONFIGURE KEEPALIVE BETWEEN TWO SERVERS ON CENTOS/RHEL

 HOW TO INSTALL AND CONFIGURE KEEPALIVE BETWEEN TWO SERVERS ON CENTOS/RHEL

By Rohit !!!!!

Keepalive is use for IP failover between two servers. Its facilitate for load balancing and high availability

on two nodes when one node goes down the virtual IP automatically shift to other nodes to keep your application alive with no downtime.


Network scenario:-

server1. ip:- 192.168.2.207

server2 ip:- 192.168.2.17

Virtualip:- 192.168.2.208

Step 1. Use the following command to install the required packages 

# yum install gcc kernel-headers kernel-devel

Next you have to install keepalive package from below command

# yum install keepalived




Step 2. Now open keepalived configuration file and edit  in server1.

# vim  /etc/keepalived/keepalived.conf

! Configuration File for keepalived


global_defs {

   notification_email {

     rohitk153@gmail.com

   }

   notification_email_from lb1@mydomain.com

   smtp_server localhost

   smtp_connect_timeout 30

}


vrrp_instance VI_1 {

    state MASTER

    interface ens192

    virtual_router_id 51

    priority 101

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.2.208

    }

}

Now go to thesecond server and edit the same configuration file.


! Configuration File for keepalived


global_defs {

   notification_email {

     rohitk153@gmail.com

   }

   notification_email_from lb1@mydomain.com

   smtp_server localhost

   smtp_connect_timeout 30

}


vrrp_instance VI_1 {

    state MASTER

    interface eno16780032

    virtual_router_id 51

    priority 100

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.2.208

    }

}


change the virtual ip address according to your environment and also set priority as i have set priority 101 on server 207 and  set priority 100 to server 17 also set interface as your system have.

Higher priority always comes first 

now save the configuration and restart the service 

# systemctl restart keepalived 

By default virtual ip assigned to the master server in case master server goes down virtual ip automatically shift to secondary server. you can find ip pointing from below command.

#   ip addr show ens192

you will get below output




Now just restart the server/shutdown and check the virtual ip automatically assign to the secondary server.

You can see virtual ip automatically shifted to secondary server.




I hope this tutorial will help you to make your application alive with no downtime 

!!!Thanks 











  

Comments

  1. Thanks, this concept is helpful for my company and setup has been done easily and manage.

    ReplyDelete

Post a Comment

Popular posts from this blog

How To Enable SSH Login for root user in RHEL9/CENTOS9

How to Add Users/Group/OU in OpenLdap

Installing K8s cluster in your local environment

USEFULL COMMANDS TO MANAGE ZIMBRA USERS AND SERVICES

File Permissions in Linux

HOW TO INSTALL AND CONFIGURE HAPROXY ON RHEL/CENTOS