The principle and script are both very simple, that is, whether the Slave_IO_Running and Slave_ SQL _Running values in the synchronization state are both Yes. If not, send a text message to the police.
The principle and script are both very simple, that is, whether the Slave_IO_Running and Slave_ SQL _Running values in the synchronization state are both Yes. If not, send a text message to the police.
The principle and script are both very simple, that is, whether the Slave_IO_Running and Slave_ SQL _Running values in the synchronization state are both Yes. If not, send a text message to the police.
[Root @ mysqlb script] # cat Check_Mysql_Slave_Replication.sh
#! /Bin/sh
./Etc/profile
Db_user = reed
Db_paasswd = reed
LogPath =/root/script/Check_Mysql_Slave_Replication_Log
[! -D $ LogPath] & mkdir-p $ LogPath
Cd $ LogPath
Slave_IO_Running = $ (/usr/local/mysql/bin/mysql-u $ db_user-p $ db_paasswd-e "show slave status \ G" | grep 'slave _ IO_Running '| cut -d ': '-f 2 | cut-d'-f 2)
Slave_ SQL _Running = $ (// usr/local/mysql/bin/mysql-u $ db_user-p $ db_paasswd-e "show slave status \ G" | grep 'slave _ SQL _Running '| cut-d ': '-f 2 | cut-d'-f 2)
FUNC ()
{
Echo "[INFO] $ (date + '% F % t') begin to monitor mysql replication ..."
If ["$ Slave_IO_Running" = "Yes"] & ["$ Slave_ SQL _Running" = "Yes"]; then
Echo "[INFO] $ (date + '% F % t') mysql replication is OK! "
Else
Echo "[ERROR] $ (date + '% F % t') fuck! Mysql24 replication is failed ..."
# Call your own text message script
/Root/script/info_takeok.sh "fuck! Mysql24 replication is failed"
Fi
}
FUNC> Check_Mysql_Slave_Replication $ (date + '% F'). log
Finally, it is written to crontab and detected once a minute.