this is a Perl script, not shell ...

#!/usr/bin/perl
use strict;
use DBI;

# change the next four to match your network
my $SLAVE_IP    = '0.0.0.0';
my $MASTER_IP   = '0.0.0.0';
my $USER                = 'user';
my $PASSWORD    = 'password';

my ( $dbh, $sth, @masterResult, @slaveResult, $i );

$dbh = DBI->connect("dbi:mysql:database=test;host=$MASTER_IP", $USER, $PASSWORD);
$sth = $dbh->prepare("show master status");
$sth->execute();
@masterResult = $sth->fetchrow_array;
$sth->finish;
$dbh->disconnect;


$dbh = DBI->connect("dbi:mysql:database=test;host=$SLAVE_IP", $USER, $PASSWORD);
$sth = $dbh->prepare("show slave status");
$sth->execute();
@slaveResult = $sth->fetchrow_array;
$sth->finish;
$dbh->disconnect;


($masterResult[1] == $slaveResult[16]) ? print 'OK' : print 'Error';


# hcir



Hello, mysql,

I want to write a shell script to check the slave synchronize with master failed or sucessfully.
Any idea to implement this?


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to