/usr/bin/slonik_move_set is in slony1-2-bin 2.2.5-2+b1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #!/usr/bin/perl
#
# Author: Christopher Browne
# Copyright 2004-2009 Afilias Canada
use Getopt::Long;
# Defaults
$CONFIG_FILE = '/etc/slony1/slon_tools.conf';
$SHOW_USAGE = 0;
# Read command-line options
GetOptions("config=s" => \$CONFIG_FILE,
"help" => \$SHOW_USAGE);
my $USAGE =
"Usage: move_set [--config file] set# from_node# to_node#
Change a set's origin.
";
if ($SHOW_USAGE) {
print $USAGE;
exit 0;
}
require '/usr/share/slony1/slon-tools.pm';
require $CONFIG_FILE;
my ($set, $node1, $node2) = @ARGV;
die $USAGE unless $set;
$set = get_set($set) or die "Non-existent set specified.\n";
if ($node1 =~ /^(?:node)?(\d+)$/) {
$node1 = $1;
} else {
print "Valid node names are node1, node2, ...\n\n";
die $USAGE;
}
if ($node2 =~ /^(?:node)?(\d+)$/) {
$node2 = $1;
} else {
print "Valid node names are node1, node2, ...\n\n";
die $USAGE;
}
my $slonik = '';
$slonik .= genheader();
$slonik .= " echo 'Locking down set $set on node $node1';\n";
$slonik .= " lock set (id = $set, origin = $node1);\n";
$slonik .= " sync (id = $node1);\n";
$slonik .= " wait for event (origin = $node1, confirmed = $node2, wait on = $node2);\n";
$slonik .= " echo 'Locked down - moving it';\n";
$slonik .= " move set (id = $set, old origin = $node1, new origin = $node2);\n";
$slonik .= " echo 'Replication set $set moved from node $node1 to $node2. Remember to';\n";
$slonik .= " echo 'update your configuration file, if necessary, to note the new location';\n";
$slonik .= " echo 'for the set.';\n";
run_slonik_script($slonik, 'MOVE SET');
|