/[rserv]/bin/Replicate
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /bin/Replicate

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14 by dpavlin, Fri Oct 31 00:06:11 2003 UTC revision 1.17 by dpavlin, Sun Nov 2 15:43:05 2003 UTC
# Line 18  use RServ; Line 18  use RServ;
18    
19  $| = 1;  $| = 1;
20    
21  my ($debug,$verbose) = (0,0);  #my ($debug,$verbose) = (0,0);
22  my ($help,$masterhost,$masterport,$masteruser,$masterpassword,  my ($help,$masterhost,$masterport,$masteruser,$masterpassword,
23          $slavehost,$slaveport,$slaveuser,$slavepassword);          $slavehost,$slaveport,$slaveuser,$slavepassword);
24  my $snapshot = ".__Snapshot";  my $snapshot = ".__Snapshot";
# Line 48  Options: Line 48  Options:
48  $snapshot .= '.' . $$;  $snapshot .= '.' . $$;
49    
50  $RServ::quiet = !$verbose;  $RServ::quiet = !$verbose;
51  if ($debug) {  #if ($debug) {
52          $RServ::quiet = 0;  #print "## q:$RServ::quiet v:$RServ::verbose d:$RServ::debug\n";
53          no warnings 'vars';  #       $RServ::quiet = 0;
54          $RServ::debug = $debug;  #       no warnings 'vars';
55  }  #       $RServ::debug = $debug;
56    #print "## q:$RServ::quiet v:$RServ::verbose d:$RServ::debug\n";
57    #}
58    
59  my $master = $ARGV[0] || "master";  my $master = $ARGV[0] || "master";
60  my $slave = $ARGV[1] || "slave";  my $slave = $ARGV[1] || "slave";
# Line 94  sub mydie { Line 96  sub mydie {
96          exit 1;          exit 1;
97  }  }
98    
99    my $minfo = MkInfo($master,$masterhost,$masterport,$masteruser,$masterpassword);
100  my $minfo = "dbname=$master";  my $sinfo = MkInfo($slave,$slavehost,$slaveport,$slaveuser,$slavepassword);
 $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));  
101    
102  print "Master connection is $minfo\n" if ($debug);  print "Master connection is $minfo\n" if ($debug);
103  print "Slave connection is $sinfo\n" if ($debug);  print "Slave connection is $sinfo\n" if ($debug);
# Line 138  SyncSync($mconn, $sconn); Line 130  SyncSync($mconn, $sconn);
130    
131  my $masterId = 0;  my $masterId = 0;
132  if ($multiplemaster || $slaveId == 0) {  if ($multiplemaster || $slaveId == 0) {
133          $masterId = GetServerId($sconn, $master, $masterhost);          $masterId = GetServerId($mconn, $master, $masterhost);
134    
135          die "\n>>>>>>>>>>>>> ERROR: Can't GetServerId for $sinfo\n" if (! defined($masterId));          die "\n>>>>>>>>>>>>> ERROR: Can't GetServerId for $sinfo\n" if (! defined($masterId));
136    
# Line 149  if ($multiplemaster || $slaveId == 0) { Line 141  if ($multiplemaster || $slaveId == 0) {
141          SyncSync($sconn, $mconn);          SyncSync($sconn, $mconn);
142  }  }
143    
144    print "Using snapshot file: $snapshot\n" if ($debug);
145    
146  my $outf = new IO::File;  my $outf = new IO::File;
147  open $outf, ">$snapshot";  open $outf, ">$snapshot";
148  print "\n>>>>>>>>>>>>> Prepare Snapshot\n\n" if ($verbose);  print "\n>>>>>>>>>>>>> Prepare Snapshot\n\n" if ($verbose);
149  print "master id: $masterId slave id: $slaveId\n" if ($debug);  print "master id: $masterId slave id: $slaveId\n" if ($debug);
150  my $res = PrepareSnapshot($mconn, $sconn, $outf, $masterId, $slaveId, $tables);  my $res = PrepareSnapshot($mconn, $sconn, $outf, $masterId, $slaveId, $multiplemaster, $tables);
151  close $outf;  close $outf;
152  if ($res < 0) {  if ($res < 0) {
153      unlink $fname;      unlink $fname;
# Line 170  if ($res == 0) Line 164  if ($res == 0)
164  my $inpf = new IO::File;  my $inpf = new IO::File;
165  open $inpf, "<$snapshot";  open $inpf, "<$snapshot";
166  print "\n>>>>>>>>>>>>> Apply Snapshot\n\n" if ($verbose);  print "\n>>>>>>>>>>>>> Apply Snapshot\n\n" if ($verbose);
167  $res = ApplySnapshot($sconn, $inpf, $tables);  $res = ApplySnapshot($sconn, $inpf, $multiplemaster, $tables);
168  close $inpf;  close $inpf;
169  if ($res < 0) {  if ($res < 0) {
170      unlink $fname;      unlink $fname;

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.26