Send message when write monitoring script is out of sync
#!/bin/bash
. /etc/init.d/functions
function Check () {
rep_file=/tmp/rep$ (date +%f). txt
While True
Do
rep= ('/application/mysql/bin/mysql-e ' show slave status\g "|awk '/slave_sql_running:/{print $2};/slave_io_running:/{ Print $2};$1~/seconds_behind_master/{print $ ' |xargs ')
If ["${rep[0]}"! = "yes"]; Then
echo "Slave_io_running:no" > $rep _file
Break 1
Fi
If ["${rep[1]}"! = "yes"]; Then
echo "Slave_sql_running:no" > $rep _file
Fi
If ["${rep[2]}"-ne 0]; Then
echo "Seconds_behind_master delay" > $rep _file
Break 1
Fi
Sleep 3
Done
}
function Main () {
While True
Do
Check
Mail-s "Replication False" [email protected] </tmp/rep$ (date +%f). txt
Internet companies mostly use the database is MySQL, want to stand out from the many IT workers, need to have advanced technology, learning to add value is essential. The way of learning is your insistence.
How to monitor the master-slave fault is normal? MySQL Database learning