LVS compilation and installation of Dr Model

Source: Internet
Author: User
Tags fully qualified domain name

I. Environment

System: centos 6.4x64 minimal installation

DR: 192.168.3.20

RS1: 192.168.3.21

Rs2: 192.168.3.22

VIP: 192.168.3.23

2. Configure the HTTPd service on the RealServer for testing.

RS1 Configuration

[[Email protected] ~] # Yum install httpd-y [[email protected] ~] # Service httpd startstarting httpd: apr_sockaddr_info_get () failed for rs1httpd: cocould not reliably determine the server's fully qualified domain name, using 127.0.0.1 for servername [OK] # firewall disabled, avoid impact on the experiment [[email protected] ~] # Service iptables stopiptables: flushing firewall rules: [OK] iptables: Setting chains to policy accept: Filter [OK] iptables: unloading modules: [OK] [email protected] ~] # Echo "RS1 server">/var/www/html/index.html [[email protected] ~] # Curl http: // 127.0.0.1rs1 Server

Rs2 Configuration

[[Email protected] ~] # Yum install httpd-y [[email protected] ~] # Service httpd startstarting httpd: apr_sockaddr_info_get () failed for rs2httpd: cocould not reliably determine the server's fully qualified domain name, using 127.0.0.1 for servername [OK] # firewall disabled, avoid impact on the experiment [[email protected] ~] # Service iptables stopiptables: flushing firewall rules: [OK] iptables: Setting chains to policy accept: Filter [OK] iptables: unloading modules: [OK] [email protected] ~] # Echo "rs2 server">/var/www/html/index.html [[email protected] ~] # Curl rs2 Server

Iii. Dr configuration and installation

Install basic software package

[[email protected] ~]# yum install make popt  libnl  libnl-devel  popt-static gcc* -y

Download and install the software package

[[Email protected] ~] # Wget http://www.linuxvirtualserver.org/software/kernel-2.6/?sadm-1.26.tar.gz##email protected] ~] # Tar xf ipvsadm-1.26.tar.gz [[email protected] ~] # Cd ipvsadm-1.26 [[email protected] ipvsadm-1.26] # Make [[email protected] ipvsadm-1.26] # make install # execute ipvsadm -- help after installation is complete, if the help information output, indicates that the [[email protected] ipvsadm-1.26] # installing SADM -- Help

4. Configure the RealServer VIP

Run the script on RealServer to configure VIP. The script content is as follows:

#!/bin/bashVIP=192.168.3.23source /etc/rc.d/init.d/functionscase "$1" instart)       ifconfig lo:0 $VIP netmask 255.255.255.255 broadcast $VIP       /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       echo "RealServer Start OK"       ;;stop)       ifconfig lo:0 down       route del $VIP >/dev/null 2>&1       echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore       echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce       echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore       echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce       echo "RealServer Stoped"       ;;       *)       echo "Usage: $0 {start|stop}"       exit 1esacexit 0

Execute scripts

[[email protected] ~]# sh realserver.sh startRealServer Start OK[[email protected] ~]# ip a|grep 3.23    inet 192.168.3.23/32 brd 192.168.3.23 scope global lo:0

Perform the same operation on rs2

[[email protected] ~]# sh realserver.sh startRealServer Start OK[[email protected] ~]# ip a |grep 3.23    inet 192.168.3.23/32 brd 192.168.3.23 scope global lo:0

5. Add cluster services on Dr

# Configure VIP on Dr [[email protected] ~] # Ifconfig eth0: 0 192.168.3.23 [[email protected] ~] # IP A1: Lo: <loopback, up, lower_up> MTU 16436 qdisc noqueue state unknown link/loopback 00: 00: 00: 00: 00 BRD 00: 00: 00: 00: 00: 00: 00 Inet 127.0.0.1/8 Scope host lo inet6: 1/128 scope host valid_lft forever preferred_lft forever2: eth0: <broadcast, multicast, up, lower_up> MTU 1500 qdisc pfifo_fast state up qlen 1000 link/ether 00: 0C: 29: E0: CA: 92 brd ff: FF Inet 192.168.3.20/24 BRD 192.168.3.255 Scope global eth0 Inet 192.168.3.23/24 BRD 192.168.3.255 scope global secondary eth0: 0 inet6 fe80: 20c: 29ff: fee0: ca92/64 scope link valid_lft forever preferred_lft forever [[email protected] ~] # Ipvsadm-a-t 192.168.3.23: 80-s RR # description #-A indicates adding #-T indicates adding a VIP record, the listening port is 80 #-s, indicating that the scheduling algorithm is polling [[email protected] ~] # Ipvsadm-a-t 192.168.3.23: 80-r 192.168.3.21-G [[email protected] ~] # Ipvsadm-a-t 192.168.3.23: 80-r 192.168.3.22-G # The preceding command indicates adding the backend RealServer service.-G indicates the Dr mode [email protected] ~] # Ipvsadm-L-nip virtual server version 1.2.1 (size = 4096) prot localaddress: Port sched1_flags-> remoteaddress: port forward weight activeconn inactconntcp 192.168.3.23: 80 rr-> 192.168.3.21: 80 Route 1 0 0-> 192.168.3.22: 80 Route 1 0 0 # disable Dr firewall [email protected] ~] # Service iptables stop

Test 1: Access http: // 192.168.3.23 directly

[[Email protected] ~] # Curl http: // 192.168.3.23rs2 server [[email protected] ~] # Curl http: // 192.168.3.23rs1 server [[email protected] ~] # Curl http: // 192.168.3.23rs2 server [[email protected] ~] # Curl http: // 192.168.3.23rs1 serve # The above results show that the basic functions of LVS have been implemented.

Test 2: delete the backend RS1 and verify that http: // 192.168.3.23 can be accessed.

[[Email protected] ~] # Ipvsadm-D-T 192.168.3.23: 80-r 192.168.3.21 [[email protected] ~] # Ipvsadm-L-nip virtual server version 1.2.1 (size = 4096) prot localaddress: Port sched1_flags-> remoteaddress: port forward weight activeconn inactconntcp 192.168.3.23: 80 rr-> 192.168.3.22: 80 Route 1 0 0 # at this time, RealServer only provides HTTPd service for 192.168.3.22. The access result should be rs2 server # Test Access http: // 192.168.3.23. The result is correct [email protected] ~] # Curl http: // 192.168.3.23rs2 server [[email protected] ~] # Curl http: // 192.168.3.23rs2 Server


This article is from the "ly12743 O & M" blog, please be sure to keep this source http://ly36843.blog.51cto.com/3120113/1653488

LVS compilation and installation of Dr Model

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.