MT#10695 ngcp-sync-constants: add --pair-repl option

The replication between peers will be set only if this option is set.
If the replication is alredy there, the password of the replication user
will be checked and updated if necessary always. No matter if --pair-repl
is set or not

Change-Id: I2315c8bb316c9348e19cfc3b251a04d4822e0d24
changes/64/664/1
Victor Seva 11 years ago
parent 636289268e
commit 1bab9f97a7

@ -72,6 +72,7 @@ Options:
-no-grant-nodes -- skip copy grants for external nodes
-force-grants -- force grants (remove and create user if exists)
-test|-t -- test mode (no updates)
-pair-repl -- set pair replication
-verbose|-v -- verbose mode
USAGE
exit 0;
@ -89,6 +90,7 @@ my $debug = 0;
my $test_mode = 0;
my $error = 0;
my $force_grants = 0;
my $replication = 0;
GetOptions("h|?|help" => \&Usage,
"i|init-passwords" => \$init_passwords,
@ -97,6 +99,7 @@ GetOptions("h|?|help" => \&Usage,
"no-grant-nodes" => \$skip_grant_nodes,
"t|test" => \$test_mode,
"force-grants" => \$force_grants,
"pair-repl" => \$replication,
"v|verbose" => \$debug);
#----------------------------------------------------------------------
sub pwgen {
@ -225,8 +228,8 @@ sub sync_repuser {
print " --> $mhost => $mhost_ip\n" if $debug;
}
print " --> syncing replication user '$user' for master host '$mhost'\n" if $debug;
if(-f $minfo) {
print " --> syncing replication user '$user' for master host '$mhost'\n" if $debug;
my $mfh;
unless(open $mfh, '<', $minfo) {
print STDERR "Failed to open $minfo for syncing, replication not synced!\n";
@ -249,11 +252,15 @@ sub sync_repuser {
print " --> replication password in master.info already in sync for '$user' at master '$mhost'\n" if $debug;
}
} else {
set_master(
dbh => $dbh,
host => $mhost,
user => $user, pass => $pass
);
print "--> no replication detected\n" if $debug;
if ($replication)
{
set_master(
dbh => $dbh,
host => $mhost,
user => $user, pass => $pass
);
}
}
}
@ -734,6 +741,9 @@ Remove and recreate users for slave hosts
=item B<--test>
No real updates, only for checks
=item B<--pair-repl>
Set replication between peers
=item B<--verbose>
Verbose mode where all changes are written to STDOUT

Loading…
Cancel
Save