CentOS 6.5 high-availability cluster LVS + Keepalived (DR Mode)

Source: Internet
Author: User

Environment Introduction

Operating System: CentOS6.5 _ x64 mini
Load Balancing mode: DR (direct routing)
Brief description of LVS and Keepalived:
LVS is short for Linux Virtual Server, which is a Virtual Server cluster system. The cluster technology and Linux operating system are used to implement a high-performance and high-availability server with good scalability, reliability and management.
The LVS cluster uses IP Server Load balancer technology and content-based request distribution technology. The scheduler has a good throughput rate, which transfers requests evenly to different servers for execution, and the scheduler automatically shields server faults, thus, a group of servers are formed into a high-performance, high-availability virtual server.
Keepalived uses the VRRP (virtual router redundancy protocol, virtual routing redundancy protocol) Hot Backup protocol to implement multi-machine hot backup for linux servers in a software manner. VRRP is a router-specific backup solution. Multiple routers form a hot standby group. Provides external services through the shared virtual IP address. Each hot standby group provides services at the same time with only one master server. Other servers are in the Redundant State. If the current online server fails, other servers will automatically replace (the priority determines the order of replacement) the virtual IP address to continue providing services.

1. Configure the Master/Slave LVS Server

Install the dependency package:

[Root @ localhost ~] # Yum install-y gcc-c ++ makepcre pcre-devel kernel-devel openssl-devel libnl-devel popt-devel

1. Check whether the Linux kernel is integrated with the lvs module: modprobe-l | grep ipvs
2. Enable route forwarding: echo "1">/proc/sys/net/ipv4/ip_forward
3. Install ipvsadm

Wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.26.tar.gz
Tar zxvf ipvsadm-1.26.tar.gz
Cd ipvsadm-1.26
Make & make install

4. Install keepalived

Wget http://www.keepalived.org/software/keepalived-1.2.7.tar.gz
Tar zxvf keepalived-1.2.7.tar.gz
Cd keepalived-1.2.7
./Configure -- prefix =/usr/local/keepalived
Make & make install

Configure keepalived as a system service

Cp/usr/local/keepalived/etc/rc. d/init. d/keepalived/etc/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/

5. Modify the master keepalived configuration file (the slave only modifies router_id, state, and priority)

[Root @ localhost ~] # Vi/etc/keepalived. conf
! Configuration File forkeepalived
Global_defs {
Notification_email {
Test@sina.com # fault acceptance contacts
}
Icationication_email_from admin@test.com # fault sender
Smtp_server 127.0.0.1 # send an email on the local machine
Smtp_connect_timeout 30
Router_id LVS_MASTER # Change BACKUP to LVS_BACKUP
}
Vrrp_instance VI_1 {
State MASTER # BACKUP to BACKUP
Interface eth0
Virtual_router_id 51 # virtual route ID, same as Master/Slave
Priority 100 # modify BACKUP to 90
Advert_int 1
Authentication {
Auth_type PASS
Auth_pass 1111 # Master/Slave authentication passwords must be consistent
}
Virtual_ipaddress {# Web virtual IP (VTP)
172.0.0.10
}
}
Virtual_server 172.0.0.10 80 {# define virtual IP address and port
Delay_loop 6 # Check the Real Server time, in seconds
Lb_algo rr # sets the load scheduling algorithm, and rr is the round training.
Lb_kind DR # Set the LVS Load Balancing DR Mode
Persistence_timeout 50 # connections from the same IP address are allocated to the same real server within 60 seconds.
Protocol TCP # Use the TCP protocol to check the realserver status
Real_server 172.0.0.13 80 {# First web Server
Weight 3 # node weight
TCP_CHECK {# Health Check Method
Connect_timeout 3 # connection timeout
Nb_get_retry 3 # Number of Retries
Delay_before_retry 3 # Retry Interval/S
}
}
Real_server 172.0.0.14 80 {# second web Server
Weight 3
TCP_CHECK {
Connect_timeout 3
Nb_get_retry 3
Delay_before_retry 3
}
}
}

Detailed description of LVS-DR mode configuration

Example of LVS-DR direct routing for Load Balancing

LVS-DR + Heartbeat for High Availability load balancing service

Principles of LVS-DR mode and possible "False load balancing"

Heartbeat + ldirectory high availability for LVS-DR Load balancer

Keepalived + LVS-DR mode configure high-availability Load Balancing Cluster

  • 1
  • 2
  • Next Page

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.