LVS
lvs-users
Google
 
Web LinuxVirtualServer.org

RE: Multiple clusters: second setup overwrites first

To: "LinuxVirtualServer.org users mailing list." <lvs-users@xxxxxxxxxxxxxxxxxxxxxx>
Subject: RE: Multiple clusters: second setup overwrites first
From: Alan Murrell <silkbc@xxxxxxxxx>
Date: Sat, 12 Apr 2003 00:15:07 -0400 (EDT)
Hello Peter,

--- Peter Mueller <pmueller@xxxxxxxxxxxx> wrote:
> Let's just call them VIPs and RIPs.

Fair enough; I will just refer to them as 'VIPs' and
'RIPs' from now on :-)

> Can you post the script and the output of ipvsadm?

As requested.  Please note that for purposes of this
posting, I changed the IP's to private IP's, but all
on the same subnet.  I did keep the last set of digits
in each case the same as what i am currently using,
not that it really matters here :-)

Here is my script:

--- director.sh ---
#!/bin/sh

# -----------------------
#   START CONFIGURATION
# -----------------------

# Linux Web
UNIX_DEV1="eth0:40"
UNIX_DEV2="eth0:39"
VIP_UNIX_WWW="10.10.10.40"
VIP_UNIX_FTP="10.10.10.39"
RIP_UNIX1="10.10.10.21"
RIP_UNIX2="10.10.10.22"

# NT Web - No Database
NTNODB_DEV1="eth0:60"
NTNODB_DEV2="eth0:59"
VIP_NTNODB_WWW="10.10.10.60"
VIP_NTNODB_FTP="10.10.10.59"
RIP_NTNODB1="10.10.10.41"
RIP_NTNODB2="10.10.10.42"

# NT Web - With Database
NTDB_DEV1="eth0:80"
NTDB_DEV2="eth0:79"
VIP_NTDB_WWW="10.10.10.80"
VIP_NTDB_FTP="10.10.10.79"
RIP_NTDB1="10.10.10.61"
RIP_NTDB2="10.10.10.62"

# Mail
MAIL_DEV1="eth0:100"
VIP_MAIL1="10.10.10.100"
RIP_MAIL1="10.10.10.81"
RIP_MAIL2="10.10.10.82"

# ---------------------
#   END CONFIGURATION
# ---------------------

# -------------------
#   START FUNCTIONS
# -------------------

function setup() {
    # Set ip_forward OFF for vs-dr Director (1 on, 0
off)
    echo "0" > /proc/sys/net/ipv4/ip_forward

    # Director is not the GW for the RealServers;
leave ICMP redirects on
    echo "1" >
/proc/sys/net/ipv4/conf/all/send_redirects
    echo "1" >
/proc/sys/net/ipv4/conf/default/send_redirects
    echo "1" >
/proc/sys/net/ipv4/conf/eth0/send_redirects
}

function unix_web() {
    # Add ethernet device and routing
    /sbin/ifconfig ${UNIX_DEV1} ${VIP_UNIX_WWW}
broadcast ${VIP_UNIX_WWW} netmask 255.255.255.255
    /sbin/ifconfig ${UNIX_DEV2} ${VIP_UNIX_FTP}
broadcast ${VIP_UNIX_FTP} netmask 255.255.255.255
    /sbin/route add -host ${VIP_UNIX_WWW} dev
${UNIX_DEV1}
    /sbin/route add -host ${VIP_UNIX_FTP} dev
${UNIX_DEV2}

    # Setup ipvsadm table
    # Clear ipvsadm table
    /sbin/ipvsadm -C

    # Installing LVS services with ipvsadm
    # add services to VIP with round robin scheduling
    /sbin/ipvsadm -A -t ${VIP_UNIX_WWW}:80 -s rr
    /sbin/ipvsadm -A -t ${VIP_UNIX_WWW}:443 -s rr
    /sbin/ipvsadm -A -t ${VIP_UNIX_WWW}:21 -s rr -p
600

    # Forward services to RealServers using direct
routing with weight 1
    /sbin/ipvsadm -a -t ${VIP_UNIX_WWW}:80 -r
${RIP_UNIX1} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_UNIX_WWW}:80 -r
${RIP_UNIX2} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_UNIX_WWW}:443 -r
${RIP_UNIX1} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_UNIX_WWW}:443 -r
${RIP_UNIX2} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_UNIX_WWW}:21 -r
${RIP_UNIX1} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_UNIX_WWW}:21 -r
${RIP_UNIX2} -g -w 1
}

function ntnodb_web() {
    # Add ethernet device and routing
    /sbin/ifconfig ${NTNODB_DEV1} ${VIP_NTNODB_WWW}
broadcast ${VIP_NTNODB_WWW} netmask 255.255.255.255
    /sbin/ifconfig ${NTNODB_DEV2} ${VIP_NTNODB_FTP}
broadcast ${VIP_NTNODB_FTP} netmask 255.255.255.255
    /sbin/route add -host ${VIP_NTNODB_WWW} dev
${NTNODB_DEV1}
    /sbin/route add -host ${VIP_NTNODB_FTP} dev
${NTNODB_DEV2}

    # Setup ipvsadm table
    # Clear ipvsadm table
    /sbin/ipvsadm -C

    # Installing LVS services with ipvsadm
    # add services to VIP with round robin scheduling
    /sbin/ipvsadm -A -t ${VIP_NTNODB_WWW}:80 -s rr
    /sbin/ipvsadm -A -t ${VIP_NTNODB_WWW}:443 -s rr
    /sbin/ipvsadm -A -t ${VIP_NTNODB_WWW}:21 -s rr -p
600

    # Forward services to RealServers using direct
routing with weight 1
    /sbin/ipvsadm -a -t ${VIP_NTNODB_WWW}:80 -r
${RIP_NTNODB1} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_NTNODB_WWW}:80 -r
${RIP_NTNODB2} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_NTNODB_WWW}:443 -r
${RIP_NTNODB1} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_NTNODB_WWW}:443 -r
${RIP_NTNODB2} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_NTNODB_WWW}:21 -r
${RIP_NTNODB1} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_NTNODB_WWW}:21 -r
${RIP_NTNODB2} -g -w 1
}

function ntdb_web() {
    # Add ethernet device and routing
    /sbin/ifconfig ${NTDB_DEV1} ${VIP_NTDB_WWW}
broadcast ${VIP_NTDB_WWW} netmask 255.255.255.255
    /sbin/ifconfig ${NTDB_DEV2} ${VIP_NTDB_FTP}
broadcast ${VIP_NTDB_FTP} netmask 255.255.255.255
    /sbin/route add -host ${VIP_NTDB_WWW} dev
${NTDB_DEV1}
    /sbin/route add -host ${VIP_NTDB_FTP} dev
${NTDB_DEV2}

    # Setup ipvsadm table
    # Clear ipvsadm table
    /sbin/ipvsadm -C

    # Installing LVS services with ipvsadm
    # add services to VIP with round robin scheduling
    /sbin/ipvsadm -A -t ${VIP_NTDB_WWW}:80 -s rr
    /sbin/ipvsadm -A -t ${VIP_NTDB_WWW}:443 -s rr
    /sbin/ipvsadm -A -t ${VIP_NTDB_WWW}:21 -s rr -p
600

    # Forward services to RealServers using direct
routing with weight 1
    /sbin/ipvsadm -a -t ${VIP_NTDB_WWW}:80 -r
${RIP_NTDB1} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_NTDB_WWW}:80 -r
${RIP_NTDB2} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_NTDB_WWW}:443 -r
${RIP_NTDB1} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_NTDB_WWW}:443 -r
${RIP_NTDB2} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_NTDB_WWW}:21 -r
${RIP_NTDB1} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_NTDB_WWW}:21 -r
${RIP_NTDB2} -g -w 1
}

function mail() {
    # Add ethernet device and routing
    /sbin/ifconfig ${MAIL_DEV1} ${VIP_MAIL_WWW}
broadcast ${VIP_MAIL_WWW} netmask 255.255.255.255
    /sbin/ifconfig ${MAIL_DEV2} ${VIP_MAIL_FTP}
broadcast ${VIP_MAIL_FTP} netmask 255.255.255.255
    /sbin/route add -host ${VIP_MAIL_WWW} dev
${MAIL_DEV1}
    /sbin/route add -host ${VIP_MAIL_FTP} dev
${MAIL_DEV2}

    # Setup ipvsadm table
    # Clear ipvsadm table
    /sbin/ipvsadm -C

    # Installing LVS services with ipvsadm
    # add services to VIP with round robin scheduling
    /sbin/ipvsadm -A -t ${VIP_MAIL_WWW}:80 -s rr
    /sbin/ipvsadm -A -t ${VIP_MAIL_WWW}:443 -s rr
    /sbin/ipvsadm -A -t ${VIP_MAIL_WWW}:21 -s rr -p
600

    # Forward services to RealServers using direct
routing with weight 1
    /sbin/ipvsadm -a -t ${VIP_MAIL_WWW}:80 -r
${RIP_MAIL1} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_MAIL_WWW}:80 -r
${RIP_MAIL2} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_MAIL_WWW}:443 -r
${RIP_MAIL1} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_MAIL_WWW}:443 -r
${RIP_MAIL2} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_MAIL_WWW}:21 -r
${RIP_MAIL1} -g -w 1
    /sbin/ipvsadm -a -t ${VIP_MAIL_WWW}:21 -r
${RIP_MAIL2} -g -w 1
}

# -----------------
#   END FUNCTIONS
# -----------------

# -----------------
#   START PROGRAM
# -----------------

# Execute the Functions
setup
unix_web
ntnodb_web
ntdb_web
mail

# Display ipvsadm settings
clear
/sbin/ipvsadm

exit 0

# ---------------
#   END PROGRAM
# ---------------
--- director.sh ---

And here is the output of 'ipvsadm', which gets called
at the end of the script:

--- ipvsadm output ---
IP Virtual Server version 1.0.7 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight
ActiveConn InActConn
TCP  10.10.10.100:pop3 rr
  -> 10.10.10.82:pop3             Route   1      0    
     0
  -> 10.10.10.81:pop3             Route   1      0    
     0
TCP  10.10.10.100:imap rr
  -> 10.10.10.82:imap             Route   1      0    
     0
  -> 10.10.10.81:imap             Route   1      0    
     0
--- ipvsadm output ---

Hopefully this helps!

TIA!

Alan


______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca
<Prev in Thread] Current Thread [Next in Thread>