Docker+lvs Configuration

Source: Internet
Author: User
1. Installing LVS:
Install libnl-devel-1.1.4-2.el6.x86_64.rpm, popt-devel-1.13-7.el6.x86_64.rpm, popt-static-1.13-7.el6.x86_64 in turn. RPM three RPM package.

2, TAR-XVF ipvsadm-1.26.tar.gz
CD ipvsadm-1.26
Make;make Install

3. Configure the Director server:
1) Mkdir/usr/local/lvs
2) Vi/usr/local/lvs/directorserver
3) Write the startup script:
Vip= "VIP"
rip1= "Realserverip"
Rip2= "Realserverip"
rip3= "Realserverip"
/etc/rc.d/init.d/functions
Case "$" in
Start
echo "Start LVS of Directorserver"
#Set the Virtual IP Address
/sbin/ifconfig eth2:0 $VIP broadcast $VIP netmask 255.255.255.255 up
/sbin/route add-host $VIP Dev eth2:0
#Clear IPVS Table
/sbin/ipvsadm-c
#Set Lvs
/sbin/ipvsadm-a-T $VIP: 80-s RR
/sbin/ipvsadm-a-T $VIP: 80-r $RIP 1:80-g-W 1
/sbin/ipvsadm-a-T $VIP: 80-r $RIP 2:80-g-W 1
/sbin/ipvsadm-a-T $VIP: 80-r $RIP 3:80-g-W 1
#Run Lvs
/sbin/ipvsadm
;;
Stop
echo "Close LVS directorserver"
/sbin/ipvsadm-c
;;
*)
echo "Usage: $ {start|stop}"
Exit 1
Esac
4) chmod 755/usr/local/lvs/directorserver;cd/usr/local/lvs/directorserver.sh;. /directorserver start
5) Ipvsadm--set 5 100 300

4. Configure the Realserver server:
1) Mkdir/usr/local/lvs
2) Vi/usr/local/lvs/realserver
3) Scripting:
rs_vip= "VIP"

. /etc/rc.d/init.d/functions

Case "$" in
Start
Ifconfig lo:0 $RS _vip netmask 255.255.255.255 broadcast $RS _VIP
/sbin/route add-host $RS _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 >/dev/null 2>&1
echo "Realserver Start OK"
;;
Stop
Ifconfig lo:0 Down
Route del $RS _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: $ {start|stop}"
Exit 1
Esac
Exit 0
4) chmod 755/usr/local/lvs/realserver;cd/usr/local/lvs/;. /realserver start

Attention:
* In the boot Docker container must be the LVS VIP and port and realserver of the RIP and Port are insinuate to the container, otherwise LVS after the DR mode startup is unable to forward successfully.

* In the host where the Docker container resides, you must ensure that the Iptables service starts normally and that the forwarded switch is turned on (refer to the Docker installation documentation).

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.