zoukankan      html  css  js  c++  java
  • 判断主从延迟

    1)首先看 Relay_Master_Log_File 和 Master_Log_File 是否有差异;
    2)如果Relay_Master_Log_File 和 Master_Log_File 是一样的话,再来看Exec_Master_Log_Pos 和 Read_Master_Log_Pos 的差异,对比SQL线程比IO线程慢了多少个binlog事件;
    3)如果Relay_Master_Log_File 和 Master_Log_File 不一样,那说明延迟可能较大,需要从MASTER上取得binlog status,判断当前的binlog和MASTER上的差距;

    因此,相对更加严谨的做法是:
    在第三方监控节点上,对MASTER和slave同时发起SHOW BINARY LOGS和SHOW slave STATUSG的请求,最后判断二者binlog的差异,以及 Exec_Master_Log_Pos 和Read_Master_Log_Pos 的差异。

    例如:
    在MASTER上执行SHOW BINARY LOGS 的结果是:
    +------------------+--------------+
    | Log_name | File_size |
    +------------------+--------------+
    | mysql-bin.000009 | 1073742063 |
    | mysql-bin.000010 | 107374193 |
    +------------------+--------------+
    而在slave上执行SHOW slave STATUSG 的结果是:

    Master_Log_File: mysql-bin.000009
    Read_Master_Log_Pos: 668711237
    Relay_Master_Log_File: mysql-bin.000009
    slave_IO_Running: Yes
    slave_SQL_Running: Yes
    ***
    Exec_Master_Log_Pos: 654409041

    ***
    Seconds_Behind_Master: 3296
    ***
    这时候,slave实际的延迟应该是:
    mysql-bin.000009 这个binlog中的binlog position 1073742063 和 slave上读取到的binlog position之间的差异延迟,即:
    1073742063 - 654409041 = 419333022 个binlog event
    并且还要加上 mysql-bin.000010这个binlog已经产生的107374193个binlog event,共
    107374193 + 419333022 = 526707215 个binlog event

  • 相关阅读:
    cmd 命令添加防火墙端口
    linux 远程 telnet
    topshelf 服务启动运行
    postfix 邮箱服务器- SPF 防发件人欺骗
    linux 只查看目录下文件夹
    Android中的颜色设置
    thread和runnable
    Handler总结
    Failed to install Intel HAXM.
    Android Studio常见问题总结
  • 原文地址:https://www.cnblogs.com/mhc-fly/p/8057097.html
Copyright © 2011-2022 走看看