Check the status of the MySQL master- Slave synchronization architecture (from a master-to-one) from the database server
(IP Authorization, whether the server and Io are normal, from my SQL process is normal)
Master mysql:192.168.1.10
From mysql:192.168.1.20
[Email protected] ~]# VI check_slave.sh
#!/bin/bash
master=192.168.1.10
I=1
Service mysqld Status &>/dev/null
While [true]
Do
Echo $i
Service mysqld Status &>/dev/null
if[$?-ne 0];then
echo "Slave server is down!"
Exit
Fi
Ping-c 3 $master &>/dev/null
if[$?-ne 0];then
echo "Physical link is disconnected!"
Exit
Else
Grant= ' mysql-h$master-uslave-ptarena-bse ' show grants [email protected] '
grant_1= "GRANT REPLICATION SLAVE on * * to ' SLAVE ' @ ' 192.168.1.20 ' identified by PASSWORD ' 3907ff810e745021 '"
If ["$grant"! = "$grant _1"];then
echo "There is no grant for slave server!"
Exit
Fi
Stat_1= ' mysql-bse ' show slave status\g ' | grep slave_io_running | Awk-f ":" ' {print $} '
Stat_2= ' mysql-bse ' show slave status\g ' | grep slave_sql_running | Awk-f ":" ' {print $} '
if [$stat _1! = "Yes"];then
echo "IO progress has something wrong!"
Exit
Fi
if [$stat _2! = "Yes"];then
echo "SQL progress has something wrong!"
Exit
Fi
leti++
Done
This article is from the "Dave-Technology blog" blog, please be sure to keep this source http://davewang.blog.51cto.com/6974997/1855106
Check the state of the database server from the MySQL master-slave synchronization structure-script shell