mysql主从延迟判断,监控和问题处理

2021/6/10 19:34:33

本文主要是介绍mysql主从延迟判断,监控和问题处理,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

一、mysql主从延迟的判断指标

        方法一:延迟时间

        Seconds_Behind_Master: 0 此值作为监控主从延迟不是那么准确,可以参考如下链接

        https://www.sohu.com/a/317335842_610509

        方法二: 主库: mysql> show master status ;

                      从库: [root@db01 data]# mysql   -e "show slave status \G"|grep "Master_Log" 已经拿到的主库日志量(master.info):判断传输有没有延时 Master_Log_File: mysql-bin.000004 Read_Master_Log_Pos: 151847

                                 已经执行的主库日志(relay-log.info): 判断回放有没有延时 Relay_Master_Log_File: mysql-bin.000004 Exec_Master_Log_Pos: 141847

                                 计算主从复制延时日志量。

                    从库执行判断脚本(得出的值为Read_Master_Log_Pos-Exec_Master_Log_Pos的值,单位为KB,可以监控此值来判断延迟多少数据量)

                                 /usr/local/mysql/bin/mysql  -uroot -pxxxxxx -e "show slave status \G"  2>/dev/null|grep "Master_Log"|awk '{print $2}'|sed -n '2p;4p'|awk 'NR==1 {tmp=$1} NR>1 {print tmp-$1;tmp=$1}'   

 

 

 



这篇关于mysql主从延迟判断,监控和问题处理的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程