最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501
当前位置: 首页 - 科技 - 知识百科 - 正文

实战:mysql5.6复制延迟监控_MySQL

来源:懂视网 责编:小采 时间:2020-11-09 19:43:22
文档

实战:mysql5.6复制延迟监控_MySQL

实战:mysql5.6复制延迟监控_MySQL: #repdelay.sh #!/bin/sh #ocpyang@126.com #查看复制延迟具体多少event #set mysql evn MYSQL_USER_MASTER=root MYSQL_PASS_MASTER='password' MYSQL_HOST_MASTER=192.168.2.188 MYSQL_USER
推荐度:
导读实战:mysql5.6复制延迟监控_MySQL: #repdelay.sh #!/bin/sh #ocpyang@126.com #查看复制延迟具体多少event #set mysql evn MYSQL_USER_MASTER=root MYSQL_PASS_MASTER='password' MYSQL_HOST_MASTER=192.168.2.188 MYSQL_USER

#repdelay.sh
#!/bin/sh
#ocpyang@126.com
#查看复制延迟具体多少event

#set mysql evn
MYSQL_USER_MASTER=root 
MYSQL_PASS_MASTER='password' 
MYSQL_HOST_MASTER=192.168.2.188

MYSQL_USER_SLAVE=root 
MYSQL_PASS_SLAVE='password' 
MYSQL_HOST_SLAVE=192.168.2.14

tmpfile_01="tmp01.`date +%Y%m%d%H%M%S`.txt"
tmpfile_02="tmp02.`date +%Y%m%d%H%M%S`.txt"
mysql -h${MYSQL_HOST_MASTER} -u${MYSQL_USER_MASTER} -p${MYSQL_PASS_MASTER} -e"SHOW BINARY LOGS;" >${tmpfile_01}
mysql -h${MYSQL_HOST_SLAVE} -u${MYSQL_USER_SLAVE} -p${MYSQL_PASS_SLAVE} -e"SHOW SLAVE STATUS\G;" >${tmpfile_02}

#tail -1 ${tmpfile_01} | grep -v "Log_name"
#cat ${tmpfile_02} | grep -E 'Master_Log_File|Read_Master_Log_Pos|Exec_Master_Log_Pos' | grep -v "Relay_Master_Log_File" |sed 's/^[ ]*//g'
a=`tail -1 ${tmpfile_01} | grep -v "Log_name" |awk '{print $1}'|awk -F "." '{print $2}'`
b=`sed -n "/\/p" ${tmpfile_02} |sed 's/^[ ]*//g' |awk -F ":" '{print $2}'|awk -F "." '{print $2}'`
bhtime=`sed -n "/\/p" ${tmpfile_02} |sed 's/^[ ]*//g' |awk -F ":" '{print $2}'`

if [ "$b" = "$a" ];then
	c=`tail -1 ${tmpfile_01} | grep -v "Log_name" |awk '{print $2}'`
	d=`sed -n "/\/p" ${tmpfile_02} |sed 's/^[ ]*//g' |awk -F ":" '{print $2}'`
 e=`expr $c - $d`
	if [ "${e}" -eq 0 -a "${bhtime}" -eq 0 ]; then
	echo "*****************************************************************************"
	echo -e "\e[1;31m &&&&&&&Synchronization has been completed!&&&&&&& \e[0m"
	echo "*****************************************************************************"
	elif [ "${e}" -eq 0 -o "${bhtime}" -eq 0 ];then
	echo "*****************************************************************************"
	echo -e "\e[1;31m Has been synchronized to the same log file! Wait a moment \e[0m"
	echo -e "\e[1;31m Not synchronized binlog events is:${e},behind master tims is ${bhtime} \e[0m"
	echo "*****************************************************************************"
	fi

elif [ ${b} -lt ${a} ];then
	f=`sed -n "/\/p" ${tmpfile_02} |sed 's/^[ ]*//g' |awk -F ":" '{print $2}'`
	g=`awk '$1 >= "$b" {print $2}' ${tmpfile_01} |awk 'BEGIN{total=0}{total+=$1}END{print total}'`
	re=`expr $g - $f`
 echo -e "\e[1;31m There are multiple log files are not synchronized,the events is:${re} \e[0m"

fi

rm -rf ${tmpfile_01}

rm -rf ${tmpfile_02}

声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文档

实战:mysql5.6复制延迟监控_MySQL

实战:mysql5.6复制延迟监控_MySQL: #repdelay.sh #!/bin/sh #ocpyang@126.com #查看复制延迟具体多少event #set mysql evn MYSQL_USER_MASTER=root MYSQL_PASS_MASTER='password' MYSQL_HOST_MASTER=192.168.2.188 MYSQL_USER
推荐度:
标签: 复制 监控 延迟
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top