Three LVs: Dr Model (implemented by script)

Source: Internet
Author: User

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6C/50/wKioL1VGQBfwCnoTAAHTHrrfBdg088.jpg "title=" Dr (2). PNG "width=" "height=" 365 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:700px;height:365px; "alt=" Wkiol1vgqbfwcnotaahthrrfbdg088.jpg "/>

Example of a configuration script for the Dr Type, director and Realserver:


Director script:

#!/bin/bash## lvs script for vs/dr# chkconfig: - 90 10#. /etc/ rc.d/init.d/functions#vip=192.168.11.100dip=192.168.11.11rip1=192.168.11.12rip2=192.168.11.13port=80rsweight1= 2rsweight2=4#case  "$"  instart)               /sbin/ifconfig eth0:1  $VIP  broadcast  $VIP  netmask 255.255.255.255  up  /sbin/route add -host  $VIP  dev eth0:1# Since this  is the director we must be able to forward packets   echo 1 > /proc/sys/net/ipv4/ip_forward# clear all iptables rules.   /sbin/iptables -F# Reset iptables counters.  /sbin/iptables -Z#  Clear all ipvsadm rules/services.  /sbin/ipvsadm -c# add an ip  virtual service for vip 192.168.0.219 port 80# in this recipe, we will  use the round-robin scheduling method. # in production, however,  you should use a weighted, dynamic scheduling method.    /sbin/ipvsadm -A -t  $VIP: 80 -s wrr# now direct packets for  this VIP to# the real server IP  (RIP)  inside the  cluster  /sbin/ipvsadm -a -t  $VIP:80 -r  $RIP 1 -g -w $ rsweight1  /sbin/ipvsadm -a -t  $VIP:80 -r  $RIP 2 -g -w $ rsweight2  /bin/touch /var/lock/subsys/ipvsadm &> /dev/null;;  stop) # stop forwarding packets  echo 0 > /proc/sys/net/ipv4/ Ip_forward# reset ipvsadm  /sbin/ipvsadm -c# bring down the vip interface  /sbin/ifconfig eth0:0  down  /sbin/route del  $VIP     /bin/rm -f /var/lock/ subsys/ipvsadm    echo  "ipvs is stopped ...";; Status)   if [ ! -e /var/lock/subsys/ipvsadm ]; then     echo  "ipvsadm is stopped&nbsp, ..."   else    echo  "Ipvs  IS RUNNING&NBSP: "    ipvsadm -L -n  fi;; *)   echo  "usage: $0 {start|stop|status}";; Esac


Realserver script:

#!/bin/bash## script to start lvs dr real server.# chkconfig: -  90 10# description: lvs dr real server#.  /etc/rc.d/init.d/ functionsvip=192.168.11.100host= '/bin/hostname ' case  "$"  instart)         # Start LVS-DR real server on this machine.         /sbin/ifconfig lo down         /sbin/ifconfig lo up        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        /sbin/ifconfig lo:0  $VIP   broadcast  $VIP  netmask 255.255.255.255 up        / sbin/route add -host  $VIP  dev lo:0;; Stop)         # Stop LVS-DR real server  Loopback device (s).         /sbin/ifconfig lo:0 down         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;; Status)         # status of lvs-dr real server.         Islothere= '/sbin/ifconfig lo:0 | grep  $VIP '          isrothere= ' netstat -rn | grep  "lo:0"  | grep  $VIP          if [ !  "$islothere"  -o !  "Isrothere"  ];then             # either the route  or the lo:0 device             # not found.            echo  "Lvs-dr real server stopped."         else             echo  "lvs-dr real server running."         fi;; *)             # Invalid entry.             echo  "$0: usage: $0 { Start|status|stop} "            exit 1;; Esac


This article is from the "Anka" blog, make sure to keep this source http://anka0501.blog.51cto.com/10129669/1641513

Three LVs: Dr Model (implemented by script)

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.