Wed Jun 30 07:37:49 PDT 2010
- Previous message: [Slony1-commit] slony1-engine/tools/altperl slonik_add_node.pl slonik_drop_node.pl slon_kill.pl
- Next message: [Slony1-commit] slony1-engine INSTALL
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /home/cvsd/slony1/slony1-engine/tools/altperl In directory main.slony.info:/tmp/cvs-serv28708 Modified Files: slonik_drop_node.pl slon_kill.pl Added Files: slonik_add_node.pl Log Message: -Added slonik_add_node altperl script -Slonik_drop_node now takes an event node -Changes to the message printed in slon_kill. Patch by Gurjeet Singh Merged from 2.0 branch Index: slon_kill.pl =================================================================== RCS file: /home/cvsd/slony1/slony1-engine/tools/altperl/slon_kill.pl,v retrieving revision 1.14 retrieving revision 1.15 diff -C 2 -d -r1.14 -r1.15 *** slon_kill.pl 17 Aug 2009 17:25:50 -0000 1.14 --- slon_kill.pl 30 Jun 2010 14:37:47 -0000 1.15 *************** *** 42,47 **** # kill the watchdog open(PSOUT, ps_args() . " | egrep '[s]lon_watchdog' | sort -n | awk '{print \$2}'|"); ! shut_off_processes(); close(PSOUT); if ($found eq 'n') { --- 42,49 ---- # kill the watchdog + my $watchdog_suffix = '_watchdog'; open(PSOUT, ps_args() . " | egrep '[s]lon_watchdog' | sort -n | awk '{print \$2}'|"); ! shut_off_processes($watchdog_suffix); ! $watchdog_suffix = ''; close(PSOUT); if ($found eq 'n') { *************** *** 55,59 **** $found="n"; open(PSOUT, ps_args() . " | egrep \"[s]lon .*$CLUSTER_NAME\" | sort -n | awk '{print \$2}'|"); ! shut_off_processes(); close(PSOUT); if ($found eq 'n') { --- 57,61 ---- $found="n"; open(PSOUT, ps_args() . " | egrep \"[s]lon .*$CLUSTER_NAME\" | sort -n | awk '{print \$2}'|"); ! shut_off_processes($watchdog_suffix); close(PSOUT); if ($found eq 'n') { *************** *** 62,75 **** } ! sub shut_off_processes { $found="n"; while ($pid = <PSOUT>) { chomp $pid; if (!($pid)) { ! print "No slon_watchdog is running for the cluster $CLUSTER_NAME!\n"; } else { $found="y"; kill 9, $pid; ! print "slon_watchdog for cluster $CLUSTER_NAME killed - PID [$pid]\n"; } } --- 64,79 ---- } ! sub shut_off_processes($) { ! my $watchdog_suffix=$_; ! $found="n"; while ($pid = <PSOUT>) { chomp $pid; if (!($pid)) { ! print "No slon_watchdog $watchdog_suffix is running for the cluster $CLUSTER_NAME!\n"; } else { $found="y"; kill 9, $pid; ! print "slon_watchdog $watchdog_suffix for cluster $CLUSTER_NAME killed - PID [$pid]\n"; } } --- NEW FILE: slonik_add_node.pl --- #!@@PERL@@ # $Id: slonik_add_node.pl,v 1.2 2010-06-30 14:37:47 ssinger Exp $ # Author: Gurjeet Singh use Getopt::Long; # Defaults $CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf'; $SHOW_USAGE = 0; # Read command-line options GetOptions("config=s" => \$CONFIG_FILE, "help" => \$SHOW_USAGE); my $USAGE = "Usage: add_node [--config file] node# event_node# adds a node to the cluster. event_node is the node number of the currnet origin node. "; if ($SHOW_USAGE) { print $USAGE; exit 0; } require '@@PERLSHAREDIR@@/slon-tools.pm'; require $CONFIG_FILE; my ($addnode, $current_origin) = @ARGV; if ($addnode =~ /^(?:node)?(\d+)$/) { $addnode = $1; } else { die $USAGE; } if ($current_origin =~ /^(?:node)?(\d+)$/) { $current_origin = $1; } else { die $USAGE; } my ($dbname, $dbhost) = ($DBNAME[$addnode], $HOST[$addnode]); my $slonik = ''; $slonik .= "\n# ADD NODE\n"; $slonik .= genheader(); $slonik .= " try {\n"; $slonik .= " store node (id = $addnode, event node = $current_origin, comment = 'Node $addnode - $dbname\@$dbhost');\n"; $slonik .= " } on error {\n"; $slonik .= " echo 'Failed to add node $node to cluster';\n"; $slonik .= " exit 1;\n"; $slonik .= " }\n"; # STORE PATH $slonik .= "\n# STORE PATHS\n"; foreach my $node (@NODES) { my $adddsn = $DSN[$addnode]; if ($node != $addnode) { # skip the master node; it's already initialized! my ($dbname, $dbhost, $nodedsn) = ($DBNAME[$node], $HOST[$node], $DSN[$node]); $slonik .= " store path (server = $addnode, client = $node, conninfo = '$adddsn');\n"; $slonik .= " store path (server = $node, client = $addnode, conninfo = '$nodedsn');\n"; } } $slonik .= " echo 'added node $addnode to cluster';\n"; $slonik .= " echo 'Please start a slon replication daemon for node $addnode';\n"; run_slonik_script($slonik, 'ADD NODE'); Index: slonik_drop_node.pl =================================================================== RCS file: /home/cvsd/slony1/slony1-engine/tools/altperl/slonik_drop_node.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -C 2 -d -r1.5 -r1.6 *** slonik_drop_node.pl 17 Aug 2009 17:25:50 -0000 1.5 --- slonik_drop_node.pl 30 Jun 2010 14:37:47 -0000 1.6 *************** *** 15,22 **** my $USAGE = ! "Usage: drop_node [--config file] node# Drops a node. This will lead to Slony-I dropping the triggers (generally that deny the ability to update data), restoring the \"native\" triggers, dropping the --- 15,26 ---- my $USAGE = ! "Usage: drop_node [--config file] node# event_node# Drops a node. + node# is the id of the node in config file you wish to remove from cluster. + + event_node# is the node number of the current origin node; the one capable of + sending notification to other nodes. This will lead to Slony-I dropping the triggers (generally that deny the ability to update data), restoring the \"native\" triggers, dropping the *************** *** 43,47 **** require $CONFIG_FILE; ! my ($node) = @ARGV; if ($node =~ /^(?:node)?(\d+)$/) { $node = $1; --- 47,51 ---- require $CONFIG_FILE; ! my ($node, $event_node) = @ARGV; if ($node =~ /^(?:node)?(\d+)$/) { $node = $1; *************** *** 50,58 **** } my $slonik = ''; $slonik .= genheader(); $slonik .= " try {\n"; ! $slonik .= " drop node (id = $node, event node = $MASTERNODE);\n"; $slonik .= " } on error {\n"; $slonik .= " echo 'Failed to drop node $node from cluster';\n"; --- 54,69 ---- } + if ($event_node =~ /^(?:node)?(\d+)$/) { + $event_node = $1; + } else { + print "Need to specify event node!\n"; + die $USAGE; + } + my $slonik = ''; $slonik .= genheader(); $slonik .= " try {\n"; ! $slonik .= " drop node (id = $node, event node = $event_node);\n"; $slonik .= " } on error {\n"; $slonik .= " echo 'Failed to drop node $node from cluster';\n";
- Previous message: [Slony1-commit] slony1-engine/tools/altperl slonik_add_node.pl slonik_drop_node.pl slon_kill.pl
- Next message: [Slony1-commit] slony1-engine INSTALL
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list