Update of /cvsroot/ssic-linux/openssi/openssi-tools/net/ha-lvs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26684
Modified Files:
Tag: OPENSSI-DEBIAN
clusterip.sh interface.c
Log Message:
Configure gateway. This should enable some form of failover. This is needed
even for DR
Index: clusterip.sh
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/openssi-tools/net/ha-lvs/clusterip.sh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- clusterip.sh 13 Jul 2004 06:31:42 -0000 1.3
+++ clusterip.sh 15 Jul 2004 09:25:32 -0000 1.4
@@ -1,10 +1,29 @@
#!/bin/bash
+#$1 -> IP address
+#$2 -> base interface name example eth0. This interface should be
+# configured. We get netmask from there
+function configure_interface()
+{
+ index=`echo $1 | awk -F . '{ print $4 }'`;
+ INTERFACE_NAME=$2:$index
- if [ $# -lt 3 ]; then
- /bin/echo "Usage: clusterip.sh "director/realserver" clusterip
interface";
+ # See any interface is already configured with the IP. If not configure
it
+ /sbin/ifconfig -a | grep $1
+ if [ $? -ne 0 ]; then
+ # Get the netmask
+ mask=`/sbin/ifconfig $2 | grep Mask | awk -F':' '{print $4}'`
+ # Now configure the interface
+ /sbin/ifconfig $INTERFACE_NAME $1 netmask $mask
+ fi
+
+}
+
+if [ $# -lt 4 ]; then
+ /bin/echo "Usage: clusterip.sh "director/realserver" clusterip
interface1 interface2";
/bin/echo "Where clusterip is the dotted IP address ";
- /bin/echo "interface is the interface name that should be configured";
+ /bin/echo "interface1 is the interface name that should be configured
with CVIP";
+ /bin/echo "interface2 is the interface name that should be configured
for cluster internal gateway";
/bin/echo " ";
/bin/echo " ";
/bin/echo " ";
@@ -26,19 +45,24 @@
LVS_ROUTING="DR"
fi
+CVIP=$2;
+index=`echo $CVIP | awk -F . '{ print $4 }'`;
+INTERFACE=$3:$index;
+LO_INTERFACE=lo:$index;
+
# Now let the kernel know the the routing
echo $LVS_ROUTING > /proc/cluster/lvs_routing
if [ x$LVS_ROUTING = xDR ]; then
- CVIP=$2;
- index=`echo $CVIP | awk -F . '{ print $4 }'`;
- INTERFACE=$3:$index;
- LO_INTERFACE=lo:$index;
if [ $DIRECTOR -eq 1 ];then
/bin/echo "Running on the LVS Director";
+
+ if [ -n $LVS_INTERNAL_GW ]; then
+ configure_interface $LVS_INTERNAL_GW $4
+ fi
#Making director reply for ARP on CVIP
/bin/echo "0" >/proc/sys/net/ipv4/conf/all/hidden;
/bin/echo "0" >/proc/sys/net/ipv4/conf/lo/hidden;
@@ -98,6 +122,11 @@
route add -host $CVIP dev $INTERFACE
fi
+ if [ -n $LVS_INTERNAL_GW ]; then
+ #installing default gw
+ /sbin/route add default gw $LVS_INTERNAL_GW
+ fi
+
fi
#set ip_forward OFF for vs-dr director/real server (1 on, 0 off)
/bin/echo "0" >/proc/sys/net/ipv4/ip_forward;
@@ -116,6 +145,8 @@
if [ $DIRECTOR -eq 1 ];then
/bin/echo "Running on the LVS Director";
+
+ configure_interface $LVS_INTERNAL_GW $4
#set ip_forward ON for vs-nat director (1 on, 0 off).
/bin/echo "1" >/proc/sys/net/ipv4/ip_forward
@@ -131,10 +162,14 @@
ipvsadm --set 36000 0 0
# set the director node to forward connection originating from
# real server
- iptables --table nat --append POSTROUTING --out-interface $3
--jump MASQUERADE
+ iptables -t nat -A POSTROUTING -o $3 -j MASQUERADE
elif [ $DIRECTOR -eq 2 ];then
/bin/echo "Running on LVS Director-backup";
+ #installing default gw
+ /sbin/route add default gw $LVS_INTERNAL_GW
+ #set_realserver_ip_forwarding to OFF (1 on, 0 off).
+ /bin/echo "0" >/proc/sys/net/ipv4/ip_forward
else
/bin/echo "Running on node other than LVS Director";
#installing default gw
Index: interface.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/openssi-tools/net/ha-lvs/interface.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- interface.c 9 Jul 2004 08:16:21 -0000 1.5
+++ interface.c 15 Jul 2004 09:25:33 -0000 1.6
@@ -45,7 +45,8 @@
if( (pid = fork()) == 0 ) {
execl(CLUSTERIPCONF_PATH,CLUSTERIP_CONF,
"director",gclist->cvip[i],
-
get_garp_interface(nodenum),(char *) 0);
+ get_garp_interface(nodenum),
+
get_multicast_interface(nodenum), (char *) 0);
/* Just a safe stand */
exit(1);
@@ -91,7 +92,7 @@
if( (pid = fork()) == 0 ) {
execl(CLUSTERIPCONF_PATH,CLUSTERIP_CONF,
node_role,clist->cvip[i],
- "lo",(char *)0);
+ "lo", "lo", (char *)0);
/* Just a safe stand */
exit(1);
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
|