Load Balancing in direct routing mode in RedHat

Source: Internet
Author: User
First, the working principle of direct routing load balancing: the client accesses the director machine, and the director machine sends client requests to the Real Server, then, the real server directly responds to the response result of the request to the client. This method can reduce the pressure on director machine and improve efficiency. It is generally applicable to large and medium-sized enterprises. Lab environment: two host servers: 192.168.0.11 and 192.168.0.12 &

First, the working principle of direct routing load balancing: the client accesses the director machine, and the director machine sends client requests to the Real Server, then, the real server directly responds to the response result of the request to the client. This method can reduce the pressure on director machine and improve efficiency. It is generally applicable to large and medium-sized enterprises.

Lab environment: two host servers: 192.168.0.11 and 192.168.0.12
Medium transfer: 192.168.0.13 and 192.168.0.19
Client: 192.168.0.10
(The host name must be consistent with the IP address .)

Tutorial steps:
A. Server:
1. 192.168.0.11
# Yum install-y httpd
# Service httpd start
# Echo "192.168.0.11">/var/www/html/index.html
# Route add default gw 192.168.0.13
# Vim/bin/shutarp
-------------------------------
#! /Bin/bash
VIP = 192.168.0.19
/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
-------------------------------
# Shutarp
2. 192.168.0.12
# Yum install-y httpd
# Service httpd start
# Echo "192.168.0.12">/var/www/html/index.html
# Route add default gw 192.168.0.13
# Vim/bin/shutarp
-------------------------------
#! /Bin/bash
VIP = 192.168.0.19
/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
-------------------------------
# Shutarp
B. Intermediate transfer:
1. Install the ipvs service:
# Yum clean all
# Yum install-y ipvsadm
2. Enable ip Forwarding, disable other services, and set forwarding
# Vim/etc/init. d/lvsDR
---------------------------------
#/Bin/bash
VIP = 192.168.0.19
RIP1 = 192.168.0.11
RIP2 = 192.168.0.12
GW = 192.168.0.254

./Etc/rc. d/init. d/functions

Case "$1" in
Start)
Echo "start LVS of DS"
/Sbin/ifconfig eth0: 0 $ VIP broadcast $ VIP netmask 255.255.255.0 up
/Sbin/route add-host $ VIP dev eth0: 0
/Sbin/ipvsadm-C
/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
/Sbin/ipvsadm
;;
Stop)
Echo "close LVS Directorserver"
/Sbin/ipvsadm-C
;;
*)
Echo "Usage: $0 {start | stop }"
Exit 1
Esac
---------------------------------
# Service lvsDR start (Execution script)

# Vim/bin/shutarp
-------------------------------
#! /Bin/bash
VIP = 192.168.0.19
/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
-------------------------------
# Shutarp

C. Client:
Open http: // 192.168.0.19/in the browser. Refresh the page again. If the page is displayed, the experiment is successful !)

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.