The LVS configuration in Linux is edited and collected by the Chinese Network (linux521.com) of the Linux system. Except for the original article in linux521, The LVS configuration is copyrighted by the original author. If you have any questions during study, please leave a message in the following comments. We will try our best to answer your questions. My configuration environment is VMware and the system is rhel5,
1. Environment description. This article uses four Linux instances when configuring LVS,
Virtual VIP: 192.168.0.254
One is used as the directorserver (192.168.0.54), and the operating system rhel5
Heartbeat
Two RealServer (192.168.0.100, 192.168.0.101) Operating Systems rhel5
2. Network Configuration:
Virtual IP: 192.168.0.254
DR: eth0: 192.168.0.54
Real Server 1: eth0: 192.168.0.100
Real Server 2: eth0: 192.168.0.101
3. Software List:
Ipvsadm-1.24.tar.gz:
[Url] http://www.linuxvirtualserver.org/software/kernel-2.6/?sadm-1.24.tar.gz#/url]
Ipvsadm-1.24-8.1.i386.rpm
[Url] URLs
Libnet.tar:
[Url] http://www.packetfactory.net/libnet/#/url] stable version: 1.1.2.1
Heartbeat-2.0.2.tar.gz:
[Url] http://linux-ha.org/download/heartbeat-2.0.8.tar.gz#/url]
2.6 The kernel has been integrated with the ipvs kernel, so you do not need to re-compile the kernel.
My ipvsadm package comes with rhel5, and others come with my own package.
Configure a dr-mode LVS Cluster
1. Download The ipvsadm Management Program
[Url] http://www.linuxvirtualserver.org/software/#/url]
Note that the corresponding kernel version
Ipvsadm-1.24.tar.gz
Tar zxvf ipvsadm-1.24.tar.gz
CD ipvsadm-1.24
Make & make install
Note that many errors may occur during make. follow the steps below to compile properly.
Ln-S/usr/src/kernels/2.6.9-22. EL-i686 // usr/src/Linux
CD ipvsadm-1.24
Make & make install
2. Configure the VIP script
# Vi/etc/init. d/lvsdr
#! /Bin/sh
VIP = 192.168.0.254
Rip1 = 192.168.0.100
Rip2 = 192.168.0.101
/Etc/rc. d/init. d/functions
Case "$1" in
Start)
Echo "Start LVS of directorserver"
# Set the virtual IP Address
/Sbin/ifconfig eth0: 1 $ VIP broadcast $ VIP netmask 255.255.255.255 up
/Sbin/route add-host $ VIP Dev eth0: The LVS configuration in 1 Linux is edited and collected by the Chinese Network (linux521.com) of the Linux system. Except for the original article in linux521, the copyright belongs to the original author. If you have any questions during study, please leave a message in the following comments. We will try our best to answer your questions.
# Clear ipvs table
/Sbin/ipvsadm-C
# Set LVS
/Sbin/ipvsadm-a-t $ VIP: 80-s rr
/Sbin/ipvsadm-a-t $ VIP: 80-r $ rip1: 80-G
/Sbin/ipvsadm-a-t $ VIP: 80-r $ rip2: 80-G
# Run LVS
/Sbin/ipvsadm
;;
Stop)
Echo "Close LVS directorserver"
/Sbin/ipvsadm-C
;;
*)
Echo "Usage: $0 {START | stop }"
Exit 1
Esac
Note: (-s RR uses the wheel call algorithm. You can select the corresponding algorithm. The default value is-wlc, and-G uses the direct routing mode of LVS working dr, ipvsadm-h to view help ).
# Chmod u x lvsder
3. Configure the RealServer script (on the other two realservers)
# Vi/etc/init. d/RealServer
#! /Bin/sh
VIP = 192.168.0.254
/Sbin/ifconfig lo: 0 $ VIP broadcast $ VIP netmask 255.255.255.255 up
/Sbin/route add-host $ 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
# Chmod u x RealServer
If there are multiple realservers, you can directly add them, and then start this script.
Iv. Verification
#/Etc/init. d/lvsdr start; start dr
#/Etc/init. d/RealServer; Start RealServer
Test: Start the HTTPd service on the RealServer respectively.
Run echo "Hello, welcome to access R1! In realserver1 !!! ">/Var/www/html/index.html
In realserver2, execute echo "Hello, welcome to access R2 !!! ">/Var/www/html/index.html
Open the IE browser and enter [url] http: // 10.10.10.100 [/url]. You can see hello, welcome to access R1 !!! And hello, welcome to access R2 !!! Webpage