Keepalived Master/Slave Server Load balancer, based on the lamp Platform

Source: Internet
Author: User


1. Introduction to the basic principles of keepalived

Keepalived was initially designed to achieve high availability and lightweight LVS front-end ctor. Vrrp protocol.

Vrrp is a fault tolerance protocol that ensures that when the next hop router of the host fails, another router is used to replace the faulty router, this ensures the continuity and reliability of network communication.

Vrrp has the following advantages:
  • Simplified Network Management: In a LAN with multicast or broadcast capabilities (such as Ethernet), vrrp can still provide highly reliable default links when a device fails, this effectively prevents network interruptions after a single link failure. You do not need to modify the dynamic routing protocol, routing discovery protocol, and other configuration information, or modify the default gateway configuration of the host.

  • Strong adaptability: vrrp packets are encapsulated in IP packets and support various upper-layer protocols.

  • Low network overhead: vrrp only defines one type of packet-vrrp announcement packet, and only a vro in the master state can send vrrp packets.

The lamp platform has been built .. For more information, see the previous article. Yum is easy to build and mainly wants to demonstrate keepalived.

Master server 192.168.1.111 eth0

Backup Server 192.168.1.10 eth0

VIP 192. 168.1.222



Yum-y install GCC *

Yum install-y OpenSSL-devel poptpopt-devel 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/

Mkdir/etc/keepalived

CP/usr/local/keepalived/etc/keepalived. CONF/etc/keepalived/


CP/usr/local/keepalived/sbin/keepalived/usr/sbin/

Chkconfig -- add keepalived

Chkconfig keepalived on

Vim/etc/keepalived. conf -- edit the host configuration file

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/54/30/wKiom1R7SBjDw-oZAAIE7SDPFh4930.jpg "Title =" bb.png "alt =" wKiom1R7SBjDw-oZAAIE7SDPFh4930.jpg "/>

Service keepalived restart

Use ip A for viewing.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/54/2E/wKioL1R7SNrjk_scAAGsCZs7c3s795.jpg "Title =" aha .png "alt =" wkiol1r7snrjk_scaagsczs7c3s795.jpg "/>

The method for installing keepalived on the backup is the same as that on the host ..

The configuration file of the backup server must also be modified:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/54/30/wKiom1R7SajyxTYxAAKGzpi-WfA202.jpg "Title =" cc.png "alt =" wKiom1R7SajyxTYxAAKGzpi-WfA202.jpg "/>

Ip addr show Dev eth0

View the associated IP Address

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/54/2E/wKioL1R7SxCycLt_AAInxBM9rAA493.jpg "Title =" broken. PNG "alt =" wkiol1r7sx1_t_aainxbm9raa493.jpg "/>


Let's test:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/54/30/wKiom1R7SveA8OIWAAHzVmEXU1s839.jpg "Title =" .png "alt =" wkiom1r7svea8oiwaahzvmexu1s839.jpg "/>

Next we will simulate host downtime.

Service keepalived stop

View the associated IP address on the slave machine.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/54/2F/wKioL1R7TGfAErb6AAJAw47UE4I269.jpg "Title =" ee.png "alt =" wkiol1r7tgfaerb6aajaw47ue4i269.jpg "/>


View on the browser

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/54/30/wKiom1R7TCahZkwRAAFCm6IKzio325.jpg "Title =" q.png "alt =" wkiom1r7tcahzkwraafcm6ikzio325.jpg "/>

Complete. The experiment on the master and slave machines is complete, which is very simple .. There is also the service load balancing of the primary node. I will give you a demonstration in the next day.

This article is from the "disconnected man in Tianya" blog and will not be reproduced!

Keepalived Master/Slave Server Load balancer, based on the lamp 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.