LB load Balancer cluster-DR

Source: Internet
Author: User

Premise

Dir IP eth0 192.168.0.198

Rs1 IP eth0 192.168.0.207

RS2 IP eth0192.168.0.208


The client 192.168.0.200 is also the fourth IP.

These three networks should be regarded as the IP of the public network

Compared with the previous NAT mode, it is a waste of public network IP.

1. Before doing lb NAT mode now empty mode

Dir on the host

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/76/41/wKiom1ZN42jAjlaIAAA3XlQ1Oxc933.png "title=" Image.png "alt=" Wkiom1zn42jajlaiaaa3xlq1oxc933.png "/>

[Email protected] ~]# ipvsadm-c
[Email protected] ~]# IPVSADM-LN
IP Virtual Server version 1.2.1 (size=4096)
Prot Localaddress:port Scheduler Flags
Remoteaddress:port Forward Weight activeconn inactconn
[Email protected] ~]# iptables-t nat-f

Two x RS Server

RS1:

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/76/40/wKioL1ZN49zgpqePAABCTRJjQK4565.png "title=" Image.png "alt=" Wkiol1zn49zgpqepaabctrjjqk4565.png "/>

The same operation is also done on RS2:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/76/41/wKiom1ZN456SFcQFAAA5hpa7R0c039.png "title=" Image.png "alt=" Wkiom1zn456sfcqfaaa5hpa7r0c039.png "/>

Dir on the host

Director on vim/usr/local/sbin/lvs_dr.sh//increase

! /bin/bash
echo 1 >/proc/sys/net/ipv4/ip_forward #打开端口转发功能
Ipv=/sbin/ipvsadm
vip=192.168.0.198
rs1=192.168.0.207
rs2=192.168.0.208
Ifconfig eth0:0 $VIP broadcast $VIP netmask 255.255.255.255 up
Route add-host $vip Dev eth0:0
$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 #-g Dr Mode-M is NAT mode


650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/76/41/wKiom1ZN47jyhxWSAABf2LqptzM814.png "title=" Image.png "alt=" Wkiom1zn47jyhxwsaabf2lqptzm814.png "/>

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/76/40/wKioL1ZN5BuAIXO3AABYZm_jt-U188.png "title=" Image.png "alt=" Wkiol1zn5buaixo3aabyzm_jt-u188.png "/>

Rs1 on RS2 Host:

Two rs: vim/usr/local/sbin/lvs_dr_rs.sh
#! /bin/bash
vip=192.168.0.220               # Add previous vip 
ifconfig lo:0 $vip broadcast $vip netmask 255.255.255.255 up 
Route add-host $vip lo:0< Br>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

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/76/40/wKioL1ZN5DLTvzbjAAA54hdf6RE067.png "title=" Image.png "alt=" Wkiol1zn5dltvzbjaaa54hdf6re067.png "/>

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/76/41/wKiom1ZN4-uB3Wp2AAA4ueD-jnY872.png "title=" Image.png "alt=" Wkiom1zn4-ub3wp2aaa4ued-jny872.png "/>

Then start the script separately on rs1 rs2:

[Email protected] ~]# sh/usr/local/sbin/lvs_dr_rs.sh

[Email protected] ~]# sh/usr/local/sbin/lvs_dr_rs.sh

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/76/41/wKiom1ZN5A7gXmi6AACSntDUeXk582.png "title=" Image.png "alt=" Wkiom1zn5a7gxmi6aacsntduexk582.png "/>

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/76/40/wKioL1ZN5HLSAiYdAABsZHI2wjQ921.png "title=" Image.png "alt=" Wkiol1zn5hlsaiydaabszhi2wjq921.png "/>

You can see that rs1 and rs2 on lo:0 have started this VIP.


Test:

Fourth machine

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/76/40/wKioL1ZN5I7i3OiLAAEmHfJOJIQ417.png "title=" Image.png "alt=" Wkiol1zn5i7i3oilaaemhfjojiq417.png "/>

Or we modify the dir parameter modification.

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/76/41/wKiom1ZN5E-BlKU9AABxyOzJQvQ126.png "title=" Image.png "alt=" Wkiom1zn5e-blku9aabxyozjqvq126.png "/>

Then execute this script!

[Email protected] ~]# sh/usr/local/sbin/lvs_dr.sh
Siocaddrt:file exists

After the implementation of the problem, it is because we have just executed, opened the eth0:0 so we have to shut down the network and then open.

Continue to modify Dir's configuration file:

vim/usr/local/sbin/lvs_dr.sh

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/76/41/wKiom1ZN5GbzCfSIAABgktjISUY699.png "title=" Image.png "alt=" Wkiom1zn5gbzcfsiaabgktjisuy699.png "/>

1 >/proc/sys/net/ipv4/ip_forward
Ipv=/sbin/ipvsadm
vip=192.168.0.220
rs1=192.168.0.207
rs2=192.168.0.208
Ifconfig eth0:0 down #先关闭
Ifconfig eth0:0 $VIP broadcast $VIP netmask 255.255.255.255 up
Route add-host $vip Dev eth0:0
$IPV-C
$IPV-A-t $VIP: 80-s WRR
$IPV-A-t $vip: 80-r $rs 1:80-g-W 3
$IPV-A-t $vip: 80-r $rs 2:80-g-W 1

Then execute the script again!

[Email protected] ~]# sh/usr/local/sbin/lvs_dr.sh

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/76/41/wKiom1ZN5H3yWol9AABHJf9VRio678.png "title=" Image.png "alt=" Wkiom1zn5h3ywol9aabhjf9vrio678.png "/>

Then the fourth host is the client test:

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/76/40/wKioL1ZN5OqioQcxAADvuIrKMqo009.png "title=" Image.png "alt=" Wkiol1zn5oqioqcxaadvuirkmqo009.png "/>



LB load Balancer cluster-DR

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.