Quantcast
Channel: StackExchange Replication Questions
Viewing all articles
Browse latest Browse all 17268

Tracking Slave Replication Errors in Mysql

$
0
0

I am currently trying to set a script up to monitor whether or not my mySQL databases are having any slave replication errors. I have implemented the following code.

MYSQL_HOST=10.11.12.13
MYSQL_USER=root
MYSQL_PASS=password
EMAILTO=email@email.com
MYSQL_CONN="-h${MYSQL_HOST} -u${MYSQL_USER} -p${MYSQL_PASS}"

MSG=`mysql ${MYSQL_CONN} -e 'show slave status\G' | grep Last_SQL_Error | sed -e 's/ *Last_SQL_Error: //'`

if [ -n "$MSG" ]; then
    echo $MSG | mailx -s "MySQL Replication Error" ${EMAILTO}
fi

I am looking to check slave status every so often using a cron table, and if there are any replication errors send an email to the designated address. My current iteration results in empty messages with the heading being sent all the time, rather then only when an error is present.

Any help would be greatly appreciated.


Viewing all articles
Browse latest Browse all 17268

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>