Article Title: DR configuration instance of LinuxVirtualServer Server Load balancer. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
1. Install ipvsadm
When downloading ipvsadm, pay attention to the corresponding kernel version.
Ipvsadm download URL: linuxvirtualserver.org/software/ "> http://www.linuxvirtualserver.org/software/
This document uses the FC8 system, kernel version 2.6.23.1, and ipvsadm version 1.24.
The Linux kernel source code is required during installation. if the system is not installed with the source code, you need to download the kernel source code. This document uses linux-2.6.23.1.tar.bz2. Unzip the kernel to/usr/src/linux-2.6.23.1. Compile and install the tool as follows:
Kernel creation shortcut: ln-s/usr/src/linux-2.6.23.1/usr/src/linux
Unzip ipvsadm:
Tar zxvf ipvsadm-1.24.tar.gz
Install ipvsadm:
Cd ipvsadm-1.24
Make
Make install
After the installation is complete, we will start to configure IPVS. This article mainly introduces the configuration of Direct Routing.
2. Configure IPVS (Direct Routing)
2. 1. Network Structure
Three computers, one Director installed Linux as the Load balancer, and the other two Real servers provide services.
Director: eth0 = 192.168.34.40, eth0: 0 (Virtual IP) = 192.168.34.41
RealServer1: IP = 192.168.34.26
RealServer2: IP = 192.168.34.27
Port: 443
The customer accesses the server through Virtual IP 192.168.34.41. Load Balancer distributes access requests from customers to the actual servers 192.168.34.26 and 192.168.34.27 based on a certain Load balancing mechanism.
2.2.Load Balancer Configuration
Step 1: Configure Director IP
Configure the eth0 IP address (192.168.34.40) on ctor, and add an IP address (192.168.34.41) on eth0, named eth0: 0 as the Virtual IP address.
Step 2: configure the IPVS Table script
Write the sh script as follows:
VIP = 192.168.34.41 # Vritual IP Address
RIP1 = 192.168.34.27 # Real Server 1 IP
RIP2 = 192.168.34.26 # Real Server 2 IP
GW = 192.168.34.1 # Real Server gateway IP Address
# Clearing IPVS Table
Ipvsadm-C
# Setting IPVS Table
Ipvsadm-A-t $ VIP: 443-s wlc
Listen SADM-a-t $ VIP: 443-r $ RIP1: 443-g-w 1
Listen SADM-a-t $ VIP: 443-r $ RIP2: 443-g-w 1
# Save the s Table to/etc/sysconfig/ipvsadm
/Etc/rc. d/init. d/ipvsadm save
# Start IPVS
Service ipvsadm start # or/etc/rc. d/init. d/ipvsadm start.
# Display the s status
Ipvsadm-l
# Script end ----------------------------
This script configures s Table and saves the configuration to the/etc/sysconfig/ipvsadm file. You can modify the ipvs table directly later. Of course, you can also directly edit the file to implement the s Table configuration.
After the configuration is complete, run/etc/rc. d/init. d/ipvsadm start (or service ipvsadm start) to start IPVS.
The slb ipvs configuration is completed through the above two steps.
2.3.Real Server Configuration
Real Server mainly implements two configurations: one is to add a virtual IP address and the other is to disable the ARP response of the IP address.
2.3.1.Windows
For a Windows server, you only need to add a Loopback Nic, set the IP address to a virtual IP address (192.168.34.41), set the subnet mask to 255.255.255.255, and leave the gateway address blank.
Operation:
L select to add hardware from the control panel;
L select "Yes, the hardware is connected ";
L select "Add new hardware device ";
L select "Install the hardware I manually selected from the list ";
L select "network adapter ";
L select "Microsoft" from the vendor list and "Microsoft Loopback Adapter" from the NIC list ";
Click Next to start hardware installation. After the installation is complete, a new Nic is displayed, and the IP address and subnet mask are configured. Windows subnet mask cannot be configured as 255.255.255.255. We can save the configuration by default and then modify the subnet mask from the registry.
Modify the subnet mask of the registry:
From Registry
Find the corresponding Nic under [HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ Tcpip \ Parameters \ Interfaces] and change SubnetMask to 255.255.255.255. Disable and enable the NIC.
2.3.2.Linux
(Omitted)
3. Configure LDirectord RealServer fault detection and management
The LDirectord Process regularly checks the running status of each Real Server. When a Real Server fault is detected, the LDirectord Server is deleted from the Server Load balancer scheduling list and then added when it returns to normal.
3. 1. Install LDirectord
The LDirectord package is included in the HeartBeat package. LDirectord is installed at the same time when HeartBeat is installed.
Download HeartBeat at: http://www.linuxvirtualserver.org/software /.
To install HeartBeat, you also need to install software packages such as libnet. You can download these software packages online for installation.
Libnet download URL: http://www.packetfactory.net/libnet/dist/libnet.tar.gz
Install libnet:
Tar zxf libnet.tar.gz
Cd libnet
./Configure
Make
Make install
Install HeartBeat:
./ConfigureMe configure
Make
Make install
After installation, run the following command to add the auto-start item:
Chkconfig? Add ldirectord
3. 2. Configure LDirectord
The heartbeat/ldirectord directory contains an ldirectord. cf file. This file is an example of ldirectord configuration.
Create an ldirectord. cf file in the/etc/ha. d/directory and configure it according to the configuration sample format. The main configuration items are as follows:
Checktimeout = 3 # detection timeout 3 s
Checkinterval = 1 # detection interval 1 s
Fallback = 127.0.0.1: 443 # access to this server when all servers fail
Autoreload = yes # automatically loaded when the configuration file changes
Logfile = "/var/log/ldirectord. log" # log File
Quiescent = yes
Virtual = 192.168.34.41: 443 # virtual IP
Real = 192.168.34.26: 443 gate
Real = 192.168.34.27: 443 gate
Fallback = 127.0.0.1: 443 # access to this server when all servers fail
Service = none
Schedlc = wlc
Perpersistent = 600
Protocol = tcp
Checktype = on
3. Start ldirectord
/Etc/rc. d/init. d ldirectord start
Note: if an error occurs in a line of ldirectord during startup, it is generally because some required software is not installed, most of which are software packages starting with perl.
Net-snmp-5.3-4.2.i386.rpm
Net-snmp-libs-5.3-4.2.i386.rpm
Perl-Compress-Zlib-1.41-1.2.2.i386.rpm
Perl-HTML-Parser-3.50-1.i386.rpm
Perl-HTML-Tagset-3.10-2.1.noarch.rpm
Perl-libwww-perl-5.805-1.1.noarch.rpm
Perl-MailTools-1.74-1.fc5.noarch.rpm
Perl-TimeDate-1.16-3.2.noarch.rpm
Perl-URI-1.35-2.2.noarch.rpm