Mysql replication check指令碼
#!/usr/bin/env bash
base_dir="/home/mysql/mysql-5.7.20-linux-glibc2.12-x86_64"
mysql_host="10.1.1.1"
mysql_user="bkp_user"
mysql_psw="password"
mysql_port="3306"
function get_v()
{
if test -f /tmp/mysql_slave.txt; then
# for ((i=1;i<6;i++)); do
# args$i=`awk -v i=$1 'NR==i {print $NF}' /tmp/mysql_slave.txt`
case $1 in
1)
args1=`awk 'NR==1 {print $NF}' /tmp/mysql_slave.txt`
;;
2)
args2=`awk 'NR==2 {print $NF}' /tmp/mysql_slave.txt`
;;
3)
args3=`awk 'NR==3 {print $NF}' /tmp/mysql_slave.txt`
;;
4)
args4=`awk 'NR==4 {print $NF}' /tmp/mysql_slave.txt`
;;
5)
args5=`awk 'NR==5 {print $NF}' /tmp/mysql_slave.txt`
;;
*)
echo "usag: sh $0 1~5"
esac
# done
else
echo "something errors!"
exit 0
fi
}
$base_dir/bin/mysql -h$mysql_host -u$mysql_user -p$mysql_psw -Pmysql_port -e 'show slave status\G;' |egrep 'Read_Master_Log_Pos|Exec_Master_Log_Pos|Master_Log_File|Relay_Master_Log_File|Seconds_Behind_Master' >/tmp/mysql_slave.txt
for ((i=1;i<6;i++)); do
get_v $i
done
if [ $args1 == $args3 -a $args2 == $args4 ]; then
echo "slave status ok!"
else
printf "seconds behind master: $args5\n"
printf "+%13s+%11s+\n" ------------- -----------
printf "|%13s|%11s|\n+-------------+-----------+\n" $args1 $args2
printf "|%13s|%11s|\n+-------------+-----------+\n" $args3 $args4
fi
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9522838/viewspace-2285008/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL Group ReplicationMySql
- Build mysql replicationUIMySql
- Mysql Replication(轉)MySql
- mha_replication_check Can't exec "mysqlbinlog": No such file or directoryMySql
- MySQL案例-replication"卡死"MySql
- 【MySQL】Semisynchronous Replication 概述MySql
- MySQL Replication淺析MySql
- On MySQL replication, again…MySqlAI
- MySQL指令碼MySql指令碼
- 【Mysql】MySQL5.7.17- Group Replication搭建MySql
- An Overview of PostgreSQL & MySQL Cross ReplicationViewMySqlROS
- MySQL group replication介紹MySql
- MySQL Group Replication小試MySql
- mysql replication之GTIDMySql
- MySQL 常用指令碼MySql指令碼
- MySQL基於GTIDs的MySQL ReplicationMySql
- mysql replication /mysql 主從複製原理MySql
- 【MySql】MySQL Replication Fatal Error 1236MySqlError
- Mysql Replication學習記錄MySql
- 理解 MySQL(3):複製(Replication)MySql
- MySQL now supports an interface for semisynchronous replication:MySql
- MySQL Replication ConfigurationMySql
- mysql replication常見錯誤MySql
- mysql巡檢指令碼MySql指令碼
- mysql監控指令碼MySql指令碼
- mysql時間指令碼MySql指令碼
- mysql kill程式指令碼MySql指令碼
- mysql備份指令碼MySql指令碼
- MySQL Group Replication 學習(部署篇)MySql
- MySQL Replication常見錯誤整理MySql
- mysql replication複製錯誤(zt)MySql
- MySQL Replication Fatal Error 1236MySqlError
- 【MySQL】Slave can not handle replication events with the checksum ...MySql
- check_postgres指令碼集檢查資料庫健康情況指令碼資料庫
- mysql innobackupex備份指令碼MySql指令碼
- 用指令碼完成mysql工作指令碼MySql
- mysql增量恢復指令碼MySql指令碼
- [Mysql]效能測試指令碼MySql指令碼