docs
uhost
Linux Service Configuration Guide
Configuring Keepalived VIP under CentOS 6.X

Configuring Keepalived VIP under CentOS 6.X

I. Apply for an internal network VIP

  1. After the user logs into the console and selects the data center, click on the "Elastic IP" function button under the main tag of Uhost, and click on "Apply for Internal Network IP" under the "Apply IP" button.
  1. Select the number of internal network elastic IPs to apply for, and click "OK" to complete the application process.
  1. After the page returns, it displays the information of the applied internal network elastic IP.

II. Install keepalived

Directly use yum to install under CentOS

# yum install -y keepalived

III. Configure VIP

The meanings of variables in the following steps are as follows (using root permission by default):

$node1: Internal IP of Server A

$node2: Internal IP of Server B

$vip: Internal network VIP

Server A (node1)

  1. Edit /etc/keepalived/keepalived.conf
    global_defs {
      router_id LVS_DEVEL
    }
    vrrp_instance VI_1 {
      state MASTER
      interface eth0
      # The format of unicast peer must match perfectly! Otherwise it won't start. It must be written in three lines.
      unicast_peer {
            $node2
      }
      virtual_router_id 51
      priority 100 
      advert_int 1
      authentication {
        auth_type PASS
        auth_pass 1111
      }
      virtual_ipaddress {
            $vip dev eth0
      }
    }
  1. Start keepalived
  # service keepalived start

Server B (node2)

  1. Edit /etc/keepalived/keepalived.conf
    global_defs {
      router_id LVS_DEVEL
    }
    vrrp_instance VI_1 {
      state BACKUP
      interface eth0
      # The format of unicast peer must match perfectly! Otherwise it will not start. It must be written in three lines.
      unicast_peer {
          $node1
      }
      virtual_router_id 51
      priority 90
      advert_int 1
      authentication {
        auth_type PASS
        auth_pass 1111
      }
      virtual_ipaddress {
          $vip dev eth0
      }
    }
  1. Start keepalived
  # service keepalived start

IV. Test VIP

  1. Check the system log and observe whether keepalived is successful
  # tail /var/log/messsages
  1. Stop keepalived on node1, and then observe the IP information on node1 and node2 separately
  # service keepalived stop
  # ip a
  • Company
  • ContactUs
  • Blog
Copyright © 2024 SurferCloud All Rights Reserved