Monitor Dual Master Mysql Replication
Here are shell script for monitoring replication, resetting replication if failed, logging if replication occured. Write a file name mysqlslave.sh on /tmp directory. #!/bin/sh user=mysql_root_username passwd=mysql_root_passwd repuser=mysql_replica_username reppasswd=mysql_replica_passwd GO=1 while [ $GO=1 ]; do rf=$(mktemp) /usr/local/mysql/bin/mysql -u$user -p$passwd -e "show slave status \G" > $rf 2>&1 repl_IO=$(cat $rf|grep "Slave_IO_Running"|cut -f2 -d':') repl_SQL=$(cat $rf|grep "Slave_SQL_Running"|cut -f2 -d':') if [ "$repl_IO" != " Yes" -o "$repl_SQL" != " Yes" ] ; then /usr/local/mysql/bin/mysql -u$user -p$passwd -e "stop slave" /usr/local/mysql/bin/mysql -u$user -p$passwd -e "reset slave" rg=$(mktemp) /usr/local/mysql/bin/mysql -hserverb -u$repuser -p$reppasswd -e "show master status \G" > $rg 2>&1 filemaster=$(cat $rg|grep "File"|cu...