Deploying (32-bit) V2 in LVS + keepalived Server Load balancer CentOS5.6

Source: Internet
Author: User
Tags failover
[Configure applications] deploying (32-bit) V2 system environment in LVS + keepalived Server Load balancer CentOS5.6 environment: CentOS5.632-bit (minimum installation) if you try to compile in 64-Bit mode, an error will occur, the system prompts that some kernel library files cannot be found. The file name contains 64 characters, so it is difficult to modify the original installation package one by one because of compilation problems. Other unknown bugs are unknown.

[Configure the application] LVS + keepalivEdServer Load balancerDeploying (32-bit) V2 in CentOS5.6 Environment

System Environment: CentOS 5.6 32-bit (minimum installation)
If you try to compile the package in 64-Bit mode, an error occurs. The system prompts that some kernel library files cannot be found. The file name contains 64 characters. It is troublesome to modify the original installation package one by one. Other unknown bugs are unknown.
Key Point: keepalived runs on LVS. LVS installs ipvsadmin # yum install ipvsadmin (eliminating the need for compiling version matching)
Many of my friends failed to compile and install it because the version of ipvsadmin is different from the Linux kernel you used.
First, check your Linux kernel version.Command:Uname-A command:Cat/Proc/version command:LsB _release-

The following describes how to compile and install the SDK. (I recommend compiling and installing linux applications)

Download ipvsadm
Install ipvsadm. Ipvsadm official http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24.tar.gz,ExtractCreate a link file and set the directory/usr/src/kernels/2.6.18-8. el5-i686/link to/usr/src/linux, if not, run. the/configure script reports an error. Run commandsLn? S/usr/src/kernels/2.6.18-8. el5-i686/usr/src/linux do the link, and then run the script without parameters. /configure, and then execute "make; make install" to complete the installation.

Install ipvsadmin
Make [1]: *** [libipvs. o] Error 1 is reported during compilation.

However, the compilation of ipvsadm failed:
There may be more than one solution:
Ln-s/usr/src/kernels/2.6.x-xx. EL-i686 // usr/src/linux

CdIpvsadm-1.24

Make & make install

Ipvsadmin-v should be able to see the following information:
[Root @ localhost ipvsadm-1.24] # ipvsadm-v
Ipvsadm v1.24 2005/12/10 (compiled with popt and IPVS v1.2.0)

The compilation and installation are successful!
 

In addition, note the keepalived (VRRP) virtual routing redundancy protocol in Linux. keepalived adopts the VRRP mechanism, which will involve the router (switch) connected to the Server Load balancer server)
VRRP virtualizes two or more router devices into one device and provides one or more vroip IP addresses ).
In actual use, you can ignore this problem if the router you connect to is a silly one.
If you use a smart router and set rules, you should note that some rules will block the status detection package issued by VRRP as a virus, the final result is the failure to switch the failover between the keepalived Server Load balancer, which is through VRRPv2 (Virtual Router ReDuNdaNcY ProtoCol) Stack.
It may also cause failure to detect the live status of the real backend server (the status of the web server ).

Easy to understand
1. keepalived implements fault isolation for failed machines/services by performing health check on the server pool objects (the official term "Checkers" is responsible for Real Server health check healthchecking)
2. The failure failover between Server Load balancer instances is implemented through VRRPv2 (Virtual Router Redundancy Protocol) stack.
Not just (LVS-DR, LVS-NAT, LVS-TUN) 3 modes!

(Think of a good person, a caixun company in Guangzhou, who is engaged in the network. How many modes are LVS running and where are the TCP packet formats modified? It seems that he finally said that the DR mode should be changed to MAC! 650) this. wIdTh = 650; \ "> theory is written in books, and practical application is awesome !)

Test environment:
Lvs-master: 192.168.9.201 (master)
Lvs-backup: 192.168.9.202 (backup)
Vip: 192.168.9.200 (virtual ip)
Web1: 192.168.9.203 (backend Real WEB Server 1)
Web2: 192.168.9.204 (backend Real WEB Server 2)
Netmask: 255.255.255.0 (mask)
Gateway: 192.168.9.1 (gateway)

Network Topology: For details, see "LVSClusterThe server Load balancer layer, real server layer, and backend shared storage layer complement each other.
 

Echo \ "================================== update the system time ======== ========================= \"
Yum install-y ntp
NtpDate Time.Nist.gov
Echo \ "00 01 ****/usr/sbin/ntpdate time.nist.gov \"/etc/Crontab

Echo "=======================================install ipvsadm and keepalived ========== ========="
[Root @ master ~] # Cd/usr/local/src
[Root @ master ~] # Wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24.tar.gz
[Root @ master ~] # Wget http://www.keepalived.org/software/keepalived-1.1.17.tar.gz
[Root @ master ~] # Ln-sv/usr/src/kernels/2.6.18-194. el5-i686 // usr/src/linux
[Root @ master ~] # Tar-zxvf ipvsadm-1.24.tar.gz
[Root @ master ~] # Cd ipvsadm-1.24
[Root @ master ~] # Make; make install
[Root @ master ~] # Cd ..
[Root @ master ~] # Tar-zxvf keepalived-1.1.17.tar.gz
[Root @ master ~] # Cd keepalived-1.1.17
[Root @ master ~] #./Configure
Configure: error:
!!! OpenSSL is not properly installed on your system .!!!
!!! Can not include OpenSSL headersFileS.
Solution:
[Root @ master ~] # Yum-y install openssl-devel
[Root @ master ~] #./Configure
[Root @ master ~] # Make; make install
This prompt appears during compilation, indicating that keepalived is combined with the kernel. If not, add this parameter./configure -- with-kernel-dir =/kernel/path.
Keepalived configuration
------------------------
Keepalived version: 1.1.17
Compiler: gcc
Compiler flags:-g-O2
ExTrA Lib:-lpopt-lssl-lcrypto
Use IPVS Framework: Yes
IPVSSyncDaemonSuPport: Yes
Use VRRP Framework: Yes
Use LinkWatch: No
Use Debug flags: No

Echo "================================== configure keepalived ================ ================="
[Root @ master ~] #Cp/Usr/local/etc/rc. d/init. d/keepalived/etc/rc. d/init. d/
[Root @ master ~] # Cp/usr/local/etc/sysconfig/keepalived/etc/sysconfig/
[Root @ master ~] #Mkdir/Etc/keepalived
[Root @ master ~] # Cp/usr/local/sbin/keepalived/usr/sbin/
[Root @ master ~] # Vi/etc/keepalived. conf
! Configuration File for keepalived
 
Global_defs {
Notification_email {
Jimmy.li@linuxidc.com
}
Icationication_email_from jimmy.li@linuxidc.com # http://www.linuxidc.com/
Smtp_server smtp.linuxidc.com
# Smtp_connect_timeout 30
Router_id LVS_DEVEL
}
 
# VIP1
Vrrp_instance VI_1 {
StatE MASTER # change MASTER to BACKUP on the BACKUP server
Interface eth0
Lvs_sync_daemon_inteface eth0
Virtual_router_id 51
Priority 100 # change 100 to 90 on the backup service
Advert_int 5
Authentication {
Auth_type PASS
Auth_pass 1111
}
Virtual_ipaDdRess {
192.168.9.200
# (If there are multiple VIPs, enter the new line .)
}
}
 
Virtual_server 192.168.9.200 80 {
Delay_loop 6 # (query realserver status every 6 seconds)
Lb_algo wlc # (lvs algorithm)
Lb_kind DR # (Direct Route)
Persistence_timeout 60 # (connections from the same IP address are allocated to the same realserver within 60 seconds)
Protocol TCP # (use the TCP protocol to check the realserver status)
 
Real_server 192.168.9.203 80 {
Weight 100 # (weight)
TCP_CHECK {
Connect_timeout 10 # (no response timeout in 10 seconds)
Nb_get_retry 3
Delay_before_retry 3
Connect_port 80
}
}
Real_server 192.168.9.204 80 {
Weight 1, 100
TCP_CHECK {
Connect_timeout 10
Nb_get_retry 3
Delay_before_retry 3
Connect_port 80
}
}
}
[Root @ master ~] # Service keepalived start | stop
[Root @ master ~] #Chkconfig? Level 2345 keepalived on

Echo "================================== configure realserver ================ ============"
[Root @ web_1 ~] # Vi/root/lvs_real.sh
#! /Bin/bash
# Http://www.linuxidc.com/
# Config realserver

SNS_VIP = 192.168.9.200
 
/Etc/rc. d/init. d/functions
 
Case \ "$1 \" in
Start)
/Sbin/IfconfigLo: 0 $ SNS_VIP netmask 255.255.255.255 broadcast $ SNS_VIP
/Sbin/route add-host $ SNS_VIP dev lo: 0
Echo \ "1 \">/proc/sys/net/ipv4/conf/lo/arp_ignore
Echo \ "2 \">/proc/sys/net/ipv4/conf/lo/arp_announce
Echo \ "1 \">/proc/sys/net/ipv4/conf/all/arp_ignore
Echo \ "2 \">/proc/sys/net/ipv4/conf/all/arp_announce
Sysctl-p>/dev/null 2> & 1

Related Article

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.