--- bin/Replicate 2003/10/31 00:06:11 1.14 +++ bin/Replicate 2003/11/02 15:43:05 1.17 @@ -18,7 +18,7 @@ $| = 1; -my ($debug,$verbose) = (0,0); +#my ($debug,$verbose) = (0,0); my ($help,$masterhost,$masterport,$masteruser,$masterpassword, $slavehost,$slaveport,$slaveuser,$slavepassword); my $snapshot = ".__Snapshot"; @@ -48,11 +48,13 @@ $snapshot .= '.' . $$; $RServ::quiet = !$verbose; -if ($debug) { - $RServ::quiet = 0; - no warnings 'vars'; - $RServ::debug = $debug; -} +#if ($debug) { +#print "## q:$RServ::quiet v:$RServ::verbose d:$RServ::debug\n"; +# $RServ::quiet = 0; +# no warnings 'vars'; +# $RServ::debug = $debug; +#print "## q:$RServ::quiet v:$RServ::verbose d:$RServ::debug\n"; +#} my $master = $ARGV[0] || "master"; my $slave = $ARGV[1] || "slave"; @@ -94,18 +96,8 @@ exit 1; } - -my $minfo = "dbname=$master"; -$minfo = "$minfo host=$masterhost" if (defined($masterhost)); -$minfo = "$minfo port=$masterport" if (defined($masterport)); -$minfo = "$minfo user=$masteruser" if (defined($masteruser)); -$minfo = "$minfo password=$masterpassword" if (defined($masterpassword)); - -my $sinfo = "dbname=$slave"; -$sinfo = "$sinfo host=$slavehost" if (defined($slavehost)); -$sinfo = "$sinfo port=$slaveport" if (defined($slaveport)); -$sinfo = "$sinfo user=$slaveuser" if (defined($slaveuser)); -$sinfo = "$sinfo password=$slavepassword" if (defined($slavepassword)); +my $minfo = MkInfo($master,$masterhost,$masterport,$masteruser,$masterpassword); +my $sinfo = MkInfo($slave,$slavehost,$slaveport,$slaveuser,$slavepassword); print "Master connection is $minfo\n" if ($debug); print "Slave connection is $sinfo\n" if ($debug); @@ -138,7 +130,7 @@ my $masterId = 0; if ($multiplemaster || $slaveId == 0) { - $masterId = GetServerId($sconn, $master, $masterhost); + $masterId = GetServerId($mconn, $master, $masterhost); die "\n>>>>>>>>>>>>> ERROR: Can't GetServerId for $sinfo\n" if (! defined($masterId)); @@ -149,11 +141,13 @@ SyncSync($sconn, $mconn); } +print "Using snapshot file: $snapshot\n" if ($debug); + my $outf = new IO::File; open $outf, ">$snapshot"; print "\n>>>>>>>>>>>>> Prepare Snapshot\n\n" if ($verbose); print "master id: $masterId slave id: $slaveId\n" if ($debug); -my $res = PrepareSnapshot($mconn, $sconn, $outf, $masterId, $slaveId, $tables); +my $res = PrepareSnapshot($mconn, $sconn, $outf, $masterId, $slaveId, $multiplemaster, $tables); close $outf; if ($res < 0) { unlink $fname; @@ -170,7 +164,7 @@ my $inpf = new IO::File; open $inpf, "<$snapshot"; print "\n>>>>>>>>>>>>> Apply Snapshot\n\n" if ($verbose); -$res = ApplySnapshot($sconn, $inpf, $tables); +$res = ApplySnapshot($sconn, $inpf, $multiplemaster, $tables); close $inpf; if ($res < 0) { unlink $fname;