Keepalived installation configuration

By using Keepalived, the two servers can achieve active-standby failover. When one of the servers fails, the other server can take over.

Tools/Materials

 
  • Centos、Keepalived

method/step

 
  1.  

    First download Keepalived from the official website, and then log in to the Centos system to install the necessary environment: gcc, openssl, pcre.

  2.  

    Copy the downloaded package to the Centos root directory.

    Unzip the package, compile and install:

    tar zxvf keepalived-1.2.18.tar.gz

    cd keepalived-1.2.18

    ./configure

    make

    make install

    Keepalived installation configuration
  3.  

    Configuration file after installation: /usr/local/eth/keepalived/keepalived.conf

    master node:

    Keepalived installation configuration
  4.  

    Standby node:

    Keepalived installation configuration
  5.  

    Modify the configuration to allow binding unknown IPs:

    /etc/sysctl.conf net.ipv4.ip_nonlocal_bind = 1

    sysctl -p

     

    Finally copy the configuration file to the corresponding directory:

    cp /usr/local/sbin/keepalived               /usr/sbin/ 

    cp /usr/local/etc/rc.d/init.d/keepalived /etc/init.d/  

    cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/  

    cp -r /usr/local/etc/keepalived/            /etc/

     

    Restart the service:

    service keepalived restart

     

    Check the binding status:

    Keepalived installation configuration
  6. 6

    In the test, use the machine to ping the virtual address for a long time, and perform the switching test: when the main keepalived is turned off, the backup opportunity will take over, and a packet may be lost at this time.

    Keepalived installation configuration
  7.  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325292814&siteId=291194637