= DBI->connect( "dbi:mysql:database=mysql;host=$m_host;port=$m_port", "$m_user", "$m_pass") or die "Can’t connect to source cluster MySQL process! Error: $DBI::errstr
"; ### Connect to replica $dbhS = DBI->connect( "dbi:mysql:database=mysql;host=$s_host", "$s_user", "$s_pass") or die "Can’t connect to replica cluster MySQL process! Error: $DBI::errstr
"; } ################ Disconnect from both databases ################ sub DisconnectFromDatabases { ### Disconnect from source $dbhM->disconnect or warn " Disconnection failed: $DBI::errstr
"; ### Disconnect from replica $dbhS->disconnect or warn " Disconnection failed: $DBI::errstr
"; } ###################### Find the last good GCI ################## sub GetReplicaEpoch { $sth = $dbhS->prepare("SELECT MAX(epoch) FROM mysql.ndb_apply_status;") or die "Error while preparing to select epoch from replica: ", $dbhS->errstr; $sth->execute or die "Selecting epoch from replica error: ", $sth->errstr; $sth->bind_col (1, \$epoch); $sth->fetch; print "	Replica epoch = $epoch
"; $sth->finish; } ####### Find the position of the last GCI in the binary log ######## sub GetSourceInfo { $sth = $dbhM->prepare("SELECT SUBSTRING_INDEX(File, ’/’, -1), Position FROM mysql.ndb_binlog_index WHERE epoch > $epoch ORDER BY epoch ASC LIMIT 1;") or die "Prepare to select from source error: ", $dbhM->errstr; $sth->execute or die "Selecting from source error: ", $sth->errstr; $sth->bind_col (1, \$binlog); $sth->bind_col (2, \$binpos); $sth->fetch; print "	Source binary log file = $binlog
"; print "	Source binary log position = $binpos
"; 

