Keepalived Primary and Standby service load balancing, lamp based platform

Source: Internet
Author: User

I. Introduction to the basic principles of keepalived

Keepalived was originally designed to achieve the high availability of the LVS front-end director, which is very lightweight. The main implementation of the VRRP protocol.

VRRP is a fault-tolerant protocol that guarantees the continuity and reliability of network communication when the host's next-hop router fails, and another router works in place of the failed router.

VRRP has the following advantages:
  • Simplify network management: In a LAN with multicast or broadcast capability (such as Ethernet), with VRRP can still provide a high reliable default link in the event of a device failure, effectively avoid the problem of network interruption after single link failure, without modifying the configuration information such as dynamic routing protocol, routing Discovery Protocol, etc. There is no need to modify the host's default gateway configuration.

  • Adaptable: VRRP packets are encapsulated in IP packets and support a variety of upper layer protocols.

  • Small Network overhead: VRRP only defines a message--VRRP notification message, and only routers in the master state can send VRRP messages .

The lamp platform is built. Please refer to the previous article if necessary. Yum is fast, and wants to demonstrate keepalived.

Primary server 192.168.1.111 eth0

Standby server 192.168.1.10 eth0

VIP 192. 168.1.222



Yum-y Install gcc*

Yum install-y OpenSSL openssl-devel poptpopt-devel libnl libnl-devel kernel-devel

Mkdir/usr/local/keepalived

Yum Install Popt-devel-y

MV desktop/keepalived-1.2.2.tar.gz/home/

cd/home/

TAR-ZXVF keepalived-1.2.2.tar.gz

CD keepalived-1.2.2

./configure--prefix=/usr/local/keepalived

Make && make install

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

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

Mkdir/etc/keepalived

cp/usr/local/keepalived/etc/keepalived/keepalived.conf/etc/keepalived/


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

Chkconfig--add keepalived

Chkconfig keepalived on

Vim/etc/keepalived/keepalived.conf--Edit the configuration file of the host

Service keepalived Restart

Use IP a for viewing.

The standby machine installs the keepalived the same way as the host, does not explain.

The configuration file of the standby machine should also be modified:

IP addr Show Dev eth0

View the associated IP


OK we test:

Below, we simulate the mainframe down a bit.

Service keepalived Stop

Then view the associated IP on the standby machine


Viewing on the browser

Done. The experiment on the main standby machine is complete, and it's simple. There is also a service load balancer for the main owner, and we'll show you another day.

Moe's IT People

Keepalived Primary and Standby service load balancing, lamp based platform

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.