April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Mysql Replication status notification

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

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>