判断GTID复制中从库有没有与主库同步
show slave stautus\G中:
当Retrieved_Gtid_Set = Executed_Gtid_Set 表示从库已经和主库完成同步
#!/bin/bash
Exec_num=$(mysql -uroot -p147258 -e "show slave status\G;" 2>/dev/null|grep 'Executed_Gtid_Set'| awk -F":" '{print $3}'|awk -F "-" '{ print $2}'|awk -F"," '{print $1}')
Ret_num=$(mysql -uroot -p147258 -e "show slave status\G;" 2>/dev/null|grep 'Retrieved_Gtid_Set'| awk -F":" '{print $3}'|awk -F "-" '{print $2}')
#判断这俩个数值是否相同,相等输出yes,否则no
if [ $Exec_num -eq $Ret_num ]
then
echo "yes"
else
echo "no"
fi