From 5c5c4e87c5aa6f1f06aad65d11e71d4c9eb7de0b Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Thu, 14 Aug 2014 13:40:10 +0200 Subject: [PATCH] MT#8623 set the repuser password only if the replication is already set From MYSQL documentation: "If you specify the MASTER_HOST or MASTER_PORT option, the slave assumes that the master server is different from before (even if the option value is the same as its current value.) In this case, the old values for the master binary log file name and position are considered no longer applicable" Change-Id: I9be8e0fdab7ce598343df270c2ade0a5095e1f48 --- sbin/ngcp-sync-constants | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/sbin/ngcp-sync-constants b/sbin/ngcp-sync-constants index fafdd9ae..7b615ff5 100755 --- a/sbin/ngcp-sync-constants +++ b/sbin/ngcp-sync-constants @@ -165,6 +165,28 @@ SQL $sth_master->finish; } +sub set_master_pass { + my %args = @_; + my $dbh = $args{dbh}; + my $user = $args{user}; + my $pass = $args{pass}; + + my $sth_master = $dbh->prepare(< update master info to master_user='$user', master_password='$pass'\n" if $debug; + $dbh->do('SLAVE STOP') unless $test_mode; + unless($test_mode) { + $sth_master->bind_param(1, $user); + $sth_master->bind_param(2, $pass); + $sth_master->execute(); + }; + $dbh->do('SLAVE START') unless $test_mode; + $sth_master->finish; +} + sub get_master_node { my $mhost = get_nodename(); @@ -199,9 +221,8 @@ sub sync_repuser { my @minfo_content = <$mfh>; close $mfh; unless(grep {/^${pass}\s*$/} @minfo_content) { - set_master( + set_master_pass( dbh => $dbh, - host => $mhost, user => $user, pass => $pass ); } else {