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

Source: Internet
Author: User

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

    Service keepalived restart

    Use ip a for viewing.

    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:

    Ip addr show dev eth0

    View the associated ip Address

     

    Let's test:

    Next we will simulate host downtime.

    Service keepalived stop

    View the associated ip address on the slave machine.

     

    View on the browser

    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.

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.