I wrote a script to check whether MySQLREPLICATION's SLAVE is normal in Linux, which is relatively simple. If you want to run it with CRONTAB, remove the Read part. 1. Script
I wrote a script to check whether the SLAVE of MySQL REPLICATION is normal in Linux, which is relatively simple. If you want to run it with CRONTAB, remove the Read part. 1. Script
I wrote a script to check whether the SLAVE of MySQL REPLICATION is normal in Linux, which is relatively simple.
If you want to run it with CRONTAB, remove the Read part.
1. Run the MYSQL Command show status to View Script 1.
[Root @ localhost ~] # Cat slave_is_running
#! /Bin/sh
#
# Created by david yeung
#
# To determine whether slave is running or not.
Echo "Enter your Username"
Read USERNAME
Echo "Enter your password"
Stty-echo
Read PASSWD
Stty echo
Cd/usr/local/mysql/bin
RESULT = './mysql-u $ USERNAME-p $ PASSWD-e' show status like "Slave_running" '-ss | awk' {print $2 }''
If ["$ RESULT" = 'on']
Then
Echo "Slave is running! ">/Var/log/mysql_slave.log
Else
Echo "Slave is not running! ">/Var/log/mysql_slave.log
Fi
2. Script 2 is implemented through the MYSQL Command show slave status \ G
#! /Bin/sh
#
# Created by david yeung
#
# To determine whether slave is running or not.
Echo "Enter your Username"
Read USERNAME
Echo "Enter your password"
Stty-echo
Read PASSWD
Stty echo
Cd/usr/local/mysql/bin
RESULT = '. /mysql-u $ USERNAME-p $ PASSWD-e 'show slave status \ G'-ss | awk' {print $2} '| head-n 13 | tail-n2'
If ["$ RESULT" = 'yes yes']
Then
Echo "Slave is running! ">/Var/log/mysql_slave.log
Else
Echo "Slave is not running! ">/Var/log/mysql_slave.log
Fi
3. Test
[Root @ localhost ~] #./Slave_is_running
Enter your Username
Root
Enter your password
[Root @ localhost ~] # Cat/var/log/mysql_slave.log
Slave is running!
I stopped SLAVE.
[Root @ localhost ~] # Cat/var/log/mysql_slave.log
Slave is not running!