[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-ha-dev
Subject: [Linux-ha-dev] Perl-Script: Taking over the ha-services manually with the option
From: Frank Weiser <frw () ordix ! de>
Date: 2002-01-11 19:49:27
[Download RAW message or body]
Hi there,
Iīve written a little perl-script for the following problem:
Now i have a failover scenario:
clustnode1 clustnode2
heartbeat heartbeat
+-- starts apache +-- starts mail
----- clustnode1 fails over -------------------------------------
clustnode1 clustnode2
defect heartbeat
+-- mail is running
+-- starts apache
----- clustnode1 is booting up ------------------------------
clustnode1 clustnode2
heartbeat heartbeat
+-- mail is running
+-- apache is running
------ clustnode1 is repaired ---------------------
In the file ha.cf (on both sides)is implemented 'nice_failback on'.
Now i want to take-over the apache-service to clustnode, without
influencing the mail-service.
But I donīt want a automatical take over from clustnode1.
---------------------------------------------------------------------
So i wrote that little perl-script for heartbeat I want to call it
"get-ha-service":
#!/usr/bin/perl
##
# description: takes over the heartbeat ha-service(s) after
nice_failback
#
# Copyright (C) 2002, Frank Weiser <frw@ordix.de>.
# Initial author.
#
# Version 0.1 for SuSE 7.3 (Kernel 2.2.19-SMP)
##
# comments the line 'nice_failback on' in ha.cf and creats a temporary
ha.cf.new
$pointer=0; # initializing a new pointer-scalar at field zero
open(HACF,"</etc/ha.d/ha.cf") or die "Input-Error: $!\n"; # read ha.cf
open(HACFNEW,">>/etc/ha.d/ha.cf.new") or die "Input Error: $!\n"; #write
ha.cf.new
@hacfarray = <HACF>;
$length=@hacfarray; # The amount of hacf-array-fields
while ($pointer <= $length)
{
if ( $hacfarray[$pointer] =~/nice_failback/ )
{
chomp($hacfarray[$pointer]);
$hacfarray[$pointer] =~ s/nice_failback on/#nice_failback on/;
}
print HACFNEW $hacfarray[$pointer];
$pointer++; # increase the pointer-scalar with value 1
}
close(HACF);
close(HACFNEW);
# End of changing the line 'nice_failback on'
## make a backup of the old ha.cf
system('cp /etc/ha.d/ha.cf /etc/ha.d/ha.cf.backup');
system('mv /etc/ha.d/ha.cf.new /etc/ha.d/ha.cf');
## heartbeat daemon stop and start
system('/etc/rc.d/heartbeat stop');
system('/etc/rc.d/heartbeat start');
## give the old ha.cf back to heartbeat
system('mv /etc/ha.d/ha.cf.backup /etc/ha.d/ha.cf');
############ End of get-ha-service #####
I think, it is usefull to change some hard-coded pathes to some
environment-variables (e.g. for the heartbeat-daemon).
Hope, it is useful for you.
Frank
["frw.vcf" (text/x-vcard)]
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.community.tummy.com
http://lists.community.tummy.com/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic