|
|
|
@ -8,6 +8,9 @@ use YAML::Tiny;
|
|
|
|
|
use Getopt::Long;
|
|
|
|
|
use Sys::Hostname;
|
|
|
|
|
use Data::Dumper;
|
|
|
|
|
use Socket;
|
|
|
|
|
use List::MoreUtils qw(any);
|
|
|
|
|
use Data::Validate::IP qw(is_ipv4 is_ipv6);
|
|
|
|
|
use IPC::System::Simple qw(system capturex);
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
use constant CONSTANTS_YML => "/etc/ngcp-config/constants.yml";
|
|
|
|
@ -209,6 +212,12 @@ sub sync_repuser {
|
|
|
|
|
my $minfo = "/var/lib/mysql$dbid/master.info";
|
|
|
|
|
my $mhost = $args{mhost};
|
|
|
|
|
my $mport = $args{mport} || 3306;
|
|
|
|
|
my $mhost_ip = $args{mhost};
|
|
|
|
|
|
|
|
|
|
unless ( is_ipv4($mhost) or is_ipv6($mhost) ) {
|
|
|
|
|
$mhost_ip = inet_ntoa(scalar(gethostbyname($mhost)));
|
|
|
|
|
print " --> $mhost => $mhost_ip\n" if $debug;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print " --> syncing replication user '$user' for master host '$mhost'\n" if $debug;
|
|
|
|
|
if(-f $minfo) {
|
|
|
|
@ -220,12 +229,12 @@ sub sync_repuser {
|
|
|
|
|
}
|
|
|
|
|
my @minfo_content = <$mfh>;
|
|
|
|
|
close $mfh;
|
|
|
|
|
unless(grep {/^${mhost}\s*$/}@minfo_content) {
|
|
|
|
|
print STDERR "${mhost} not found at $minfo. Fix replication manually";
|
|
|
|
|
unless(any {/^(${mhost}|${mhost_ip})\s*$/} @minfo_content) {
|
|
|
|
|
print STDERR "${mhost} or ${mhost_ip} were not found at $minfo. Fix replication manually";
|
|
|
|
|
$error = 2;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
unless(grep {/^${pass}\s*$/} @minfo_content) {
|
|
|
|
|
unless(any {/^${pass}\s*$/} @minfo_content) {
|
|
|
|
|
set_master_pass(
|
|
|
|
|
dbh => $dbh,
|
|
|
|
|
user => $user, pass => $pass
|
|
|
|
|