检查从主服务器复制的 MySQL 从服务器状态的最佳方法是什么?

Ian*_*any 3 mysql innodb myisam replication

具体来说,我有一组 InnoDB 表,我们将它们备份到 MyISAM 表中以提供全文搜索。从数据库通常落后于主数据库。我正在寻找有关可用于跟踪滞后的诊断或命令的建议。两台机器在同一个网络上。非常感谢。

Jor*_*nal 8

SHOW SLAVE STATUS是你的命令

mysql> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: localhost
                  Master_User: root
                  Master_Port: 3306
                Connect_Retry: 3
              Master_Log_File: gbichot-bin.005
          Read_Master_Log_Pos: 79
               Relay_Log_File: gbichot-relay-bin.005
                Relay_Log_Pos: 548
        Relay_Master_Log_File: gbichot-bin.005
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 79
              Relay_Log_Space: 552
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: 8
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids: 0
Run Code Online (Sandbox Code Playgroud)

相关部分是:

               Slave_IO_State: Waiting for master to send event
Run Code Online (Sandbox Code Playgroud)

“等主人……”是你平时最想看到的

              Master_Log_File: gbichot-bin.005
          Read_Master_Log_Pos: 79
          Exec_Master_Log_Pos: 79
Run Code Online (Sandbox Code Playgroud)

结合主服务器上的“SHOW MASTER STATUS”,您可以比较已传输和正确复制的数量

             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
Run Code Online (Sandbox Code Playgroud)

复制是否正在运行?

        Seconds_Behind_Master: 8
Run Code Online (Sandbox Code Playgroud)

滞后估计

                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
Run Code Online (Sandbox Code Playgroud)

如果有错误,这显示出了什么问题。还要检查您的错误日志和 SHOW PROCESSLIST 以获取更多信息