Linux system Architecture-DR Setup for the LVS of LB cluster

Source: Internet
Author: User

On the basis of the LVS NAT mode

1. Clear the Ipvsadm rule

Ipvsadm--ln

2. Clear the Iptables rule

Iptables-t nat-f

3. Modify the RS network adapter configuration, modify the back gateway

vi/etc/sysconfig/network-scripts/ifcfg-eth0 restart Eth0ifdown eth0; ifup eth0

4.dir NIC

Ifdown eth1

dirip:192.168.1.118 rs1ip:192.168.1.116 rs2ip:192.168.1.115 is considered an extranet IP.

Add a virtual ip,vip above dir

vim/usr/local/sbin/lvs_dr.sh
#! /bin/Bashecho1>/proc/sys/net/ipv4/IP_FORWARDIPV=/sbin/IPVSADMVIP=192.168.1.100rs1=192.168.1.116rs2=192.168.1.115ifconfig eth0:0$VIP Broadcast $VIP netmask255.255.255.255Uproute Add-host $vip Dev eth0:0$IPV-C$IPV-a-t $VIP: the-s RR$IPV-a-t $VIP: the-R $rs 1: the-g-w1$IPV-a-t $VIP: the-R $rs 2: the-g-w1

echo 1 >/proc/sys/net/ipv4/ip_forward//Open port forwarding
Ipv=/sbin/ipvsadm
vip=192.168.1.100
rs1=192.168.1.116
rs2=192.168.1.115
Ifconfig eth0:0 $VIP broadcast $VIP netmask 255.255.255.255 up//VIP Subnet mask is 4 x 255, only issued
Route add-host $VIP Dev eth0:0//Add a route
$IPV-C
$IPV-A-T $VIP: 80-s RR
$IPV-A-t $vip: 80-r $rs 1:80-g-W 1
$IPV-A-t $vip: 80-r $rs 2:80-g-W 1

SH!$
ifconfig Virtual network card has come out eth0: 0    Link encap:ethernet  : 0C::CC: One: E7          inet addr:192.168.  1.100  bcast:192.168.  1.100  Mask:255.255.  255.255up          broadcast RUNNING multicast  MTU:  Metric:1
Ipvsadm-Ln more out of a vipip Virtual Server version1.2.1(size=4096) Prot localaddress:port Scheduler Flags-remoteaddress:port Forward Weight activeconn inactconntcp192.168.1.100: theRR-192.168.1.115: theRoute1      0          0-192.168.1.116: theRoute1      0          0

5.rs1-2 all write a script.

vim/usr/local/sbin/lvs_rs.sh
#! /bin/BASHVIP=192.168.1.100ifconfig lo:0$VIP Broadcast $VIP netmask255.255.255.255Uproute Add-host $vip Lo:0Echo"1">/proc/sys/net/ipv4/conf/lo/Arp_ignoreecho"2">/proc/sys/net/ipv4/conf/lo/Arp_announceecho"1">/proc/sys/net/ipv4/conf/all/Arp_ignoreecho"2">/proc/sys/net/ipv4/conf/all/arp_announce
Ifconfig initiated the loopback virtual network card lo: 0       Link encap:local Loopback          inet addr:192.168.  1.100  Mask:255.255.  255.255up          LOOPBACK RUNNING  MTU:16436  Metric:1

6. Testing

Curl VIP on the fourth machine

Linux system Architecture-DR Setup for the LVS of LB cluster

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.