Dr Mode configuration for LVS

Source: Internet
Author: User

To simplify the simulation process, all machines are under one network segment and the client IP is 192.168.1.10,load Balancer also provides an externally visible VIP192.168.1.11 with a dip and a real server in a non-segmented LAN, which can be connected using a switch or hub, all pointing to the 192.168.1.1. Of course, your real server can also use the Internet service provided by other routers, just point the gateway to it.

Add:

Host routing: is to go to a host address how to configure routing

/sbin/route add-host 192.168.2.13 Dev eth2

/sbin/route add-host 202.81.11.91 Dev Lo


1. Run the following script on the load balancer:

#!/bin/bash

#---------------Mini-rc.lvs_dr-director------------------------

#set Ip_forward OFF for LVS-DR Director (1 on, 0 OFF)

# (there is no forwarding in the conventional sense for LVS-DR)

Cat/proc/sys/net/ipv4/ip_forward

echo "0" >/proc/sys/net/ipv4/ip_forward


#director is not a GW for realservers:leave ICMP redirects on

echo ' Setting ICMP redirects (1 on, 0 off) '

echo "1" >/proc/sys/net/ipv4/conf/all/send_redirects

Cat/proc/sys/net/ipv4/conf/all/send_redirects

echo "1" >/proc/sys/net/ipv4/conf/default/send_redirects

Cat/proc/sys/net/ipv4/conf/default/send_redirects

echo "1" >/proc/sys/net/ipv4/conf/eth0/send_redirects

Cat/proc/sys/net/ipv4/conf/eth0/send_redirects


#setup DIP

/sbin/ifconfig eth0 192.168.1.101 netmask 255.255.255.0 up


#add Ethernet device and routing for VIP 192.168.1.11

/sbin/ifconfig eth0:0 192.168.1.11 netmask 255.255.255.0 up

/sbin/route add-host 192.168.1.11 Dev eth0:0

#listing ifconfig info for VIP 192.168.1.11

/sbin/ifconfig eth0:0


#check VIP 192.168.1.11 is reachable from self (director)

/bin/ping-c 1 192.168.1.11

#listing Routing info for VIP 192.168.1.11

/bin/netstat-rn


#setup_ipvsadm_table

#clear ipvsadm Table

/sbin/ipvsadm-c

#installing LVS Services with Ipvsadm

#add telnet to VIP with round robin scheduling

/sbin/ipvsadm-a-T 192.168.1.11:80-s RR


#forward telnet to realserver using direct routing with weight 1

/sbin/ipvsadm-a-T 192.168.1.11:80-r 192.168.1.102:80-g-W 1

#check Realserver reachable from director

Ping-c 1 192.168.1.102


#forward telnet to realserver using direct routing with weight 1

/sbin/ipvsadm-a-T 192.168.1.11:80-r 192.168.1.103:80-g-W 1

#check Realserver reachable from director

Ping-c 1 192.168.1.103


#displaying ipvsadm Settings

/sbin/ipvsadm


#not Installing a default GW for Lvs_type VS-DR

#---------------Mini-rc.lvs_dr-director------------------------



2. Run the following script on the first real server:

#!/bin/bash

#----------Mini-rc.lvs_dr-realserver------------------

#setup IP

/sbin/ifconfig eth0 192.168.1.102 broadcast 192.168.1.255 netmask 255.255.255.0

#installing default GW 192.168.1.1 for VS-DR

/sbin/route Add default GW 192.168.1.1

#showing routing Table

/bin/netstat-rn

#checking if DEFAULT_GW 192.168.1.1 is reachable

Ping-c 1 192.168.1.1


#set_realserver_ip_forwarding to OFF (1 on, 0 off).

echo "0" >/proc/sys/net/ipv4/ip_forward

Cat/proc/sys/net/ipv4/ip_forward


#looking for DIP 192.168.1.101

Ping-c 1 192.168.1.101


#looking for VIP ('ll is on director)

Ping-c 1 192.168.1.11


#install_realserver_vip

/sbin/ifconfig lo:0 192.168.1.11 broadcast 192.168.1.11 netmask 0xFFFFFFFF up

#ifconfig output

/sbin/ifconfig lo:0

#installing route for VIP 192.168.1.11 on device lo:0

/sbin/route add-host 192.168.1.11 Dev lo:0

#listing Routing info for VIP 192.168.1.11

/bin/netstat-rn


#hiding interface lo:0, would not ARP

echo "1" >/proc/sys/net/ipv4/conf/all/hidden

Cat/proc/sys/net/ipv4/conf/all/hidden

echo "1" >/proc/sys/net/ipv4/conf/lo/hidden

Cat/proc/sys/net/ipv4/conf/lo/hidden


#----------Mini-rc.lvs_dr-realserver------------------


2. Run the following script on the second real server:

#!/bin/bash

#----------Mini-rc.lvs_dr-realserver------------------

#setup IP

/sbin/ifconfig eth0 192.168.1.103 broadcast 192.168.1.255 netmask 255.255.255.0

#installing default GW 192.168.1.1 for VS-DR

/sbin/route Add default GW 192.168.1.1

#showing routing Table

/bin/netstat-rn

#checking if DEFAULT_GW 192.168.1.1 is reachable

Ping-c 1 192.168.1.1


#set_realserver_ip_forwarding to OFF (1 on, 0 off).

echo "0" >/proc/sys/net/ipv4/ip_forward

Cat/proc/sys/net/ipv4/ip_forward


#looking for DIP 192.168.1.101

Ping-c 1 192.168.1.101


#looking for VIP ('ll is on director)

Ping-c 1 192.168.1.11


#install_realserver_vip

/sbin/ifconfig lo:0 192.168.1.11 broadcast 192.168.1.11 netmask 0xFFFFFFFF up

#ifconfig output

/sbin/ifconfig lo:0

#installing route for VIP 192.168.1.11 on device lo:0

/sbin/route add-host 192.168.1.11 Dev lo:0

#listing Routing info for VIP 192.168.1.11

/bin/netstat-rn


#hiding interface lo:0, would not ARP

echo "1" >/proc/sys/net/ipv4/conf/all/hidden

Cat/proc/sys/net/ipv4/conf/all/hidden

echo "1" >/proc/sys/net/ipv4/conf/lo/hidden

Cat/proc/sys/net/ipv4/conf/lo/hidden


#----------Mini-rc.lvs_dr-realserver------------------

Please refer to the Vs/nat mode for script execution methods.

After the run is complete, access the VIP (http://192.168.1.11) and view the results, the first client displays:

The second client displays:

Precautions:

1. Basically most servers with Unices and Microsoft OS can be used as real servers in VS/DR mode.

2. The Load balancer and all real servers must physically have a network card connected via a LAN that is not disconnected.

3, the VIP address on the scheduler is visible externally; The real server must bind the VIP to the NOR-ARP network card, which is not visible to the outside, but is used to spoof the real server for processing the destination address for the VIP Web request.

4, in VS/DR mode, no need to use the Ip_forward function, so for security reasons, closed the function.

5. The real server no longer uses the scheduler as the gateway, so turn on ICMP redirection for the scheduler.

4. You must have an HTTP server already deployed on your real server and write different content for the default home page to test the scheduler schedule results.



This article is from the "Bill Linux Operations Notes" blog, please be sure to keep this source http://chenshoubiao.blog.51cto.com/6159058/1884470

Dr Mode configuration for LVS

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.