Using the script you can get the alert message from the replication server if replication is down or not working.
——————————————————————————————–
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#script checking the replication is running or not.
#If replication is down then sent the alert mail.
slave_server_hostname=192.168.10.1
###check if already notified###
cd /root
if [ -f slave_problem.txt ]; then
rm -rf /root/slave_problem.txt
exit 1;
fi
###Check if slave running###
(
echo “show slave status \G;”
) | mysql -u username -h $slave_server_hostname -ppassword 2>&1 | grep “Slave_IO_Running: No”
if [ “$?” -ne “1” ]; then
echo “Replication Failed”
echo “Replication failed” > /root/slave_problem.txt
fi
###Send notification if replication down###
cd /root
if [ -f slave_problem.txt ]; then
#mail -s “Replication problem” mail_id@domainname.com< /root/slave_problem.txt
echo “Problem in replicaition”
fi
———————————————————————————————-
Setup this script in conrtab of Master server
#chmod +x /path/to/Checkreplication.sh
#crontab -e
* * * * * /path/to/Checkreplication.sh
Recent Comments