show slave status

在從庫上,使用show slave status,可以查看主從複製狀態。
包括主庫定製,IO thread、 SQL thread連接狀態,以及bin log位置等。

>show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: sh-dba-mysql-009
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 10
              Master_Log_File: mysql-bin.000001
          Read_Master_Log_Pos: 525
               Relay_Log_File: relay.000002
                Relay_Log_Pos: 738
        Relay_Master_Log_File: mysql-bin.000001
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 525
              Relay_Log_Space: 935
              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: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 4092246
                  Master_UUID: 456f3e13-6000-11e8-8bda-002272a443bb
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp:
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set: 456f3e13-6000-11e8-8bda-002272a443bb:1-2
            Executed_Gtid_Set: 456f3e13-6000-11e8-8bda-002272a443bb:1-2
                Auto_Position: 1
         Replicate_Rewrite_DB:
                 Channel_Name:
           Master_TLS_Version:
1 row in set (0.00 sec)

Master_Info_File

其中的選項 Master_Info_File 表示master.info 信息的位置,可以是文件,也可以是數據表。
Master_Info_File 爲 mysql.slave_master_info數據表。

日誌位點信息

從以上信息中,可以整理出三套日誌位點信息。

選項 說明
Master_Log_File I/O線程正在讀取的主庫日誌文件
Read_Master_Log_Pos 在當前的主庫日誌文件中,I/O線程已經讀取的日誌位置
Relay_Log_File SQL線程正在讀取和執行的中繼日誌文件
Relay_Log_Pos 在當前的中繼日誌文件中,SQL線程已經讀取和執行的中繼日誌座標
Relay_Master_Log_File SQL線程最近執行的事件所在的主庫日誌文件
Exec_Master_Log_Pos SQL線程已經讀取和執行的主庫日誌位置

Last_IO_Errno 和 Last_IO_Error

Last_IO_Errno 和 Last_IO_Error表示導致IO線程停止的最近的錯誤碼和錯誤信息。

錯誤碼爲0, 錯誤信息爲空, 表示沒有錯誤。如果IO線程出錯,錯誤信息也會出現從庫的錯誤日誌。

Last_IO_Error_Timestamp

Last_IO_Error_Timestamp 是最近一次IO 線程出現錯誤的時間。例如:

Last_IO_Error_Timestamp: 200129 12:29:28

執行 RESET MASTER 或者 RESET SLAVE會清空這些信息。

Last_SQL_Errno,和Last_SQL_Error

表示導致SQL線程停止的最近的錯誤碼和錯誤信息。
錯誤碼爲0, 錯誤信息爲空, 表示沒有錯誤。如果SQL線程出錯,錯誤信息也會出現從庫的錯誤日誌。

Last_SQL_Errno 和Last_SQL_Error 具體定義見鏈接B.3.1 Server Error Message Reference

執行 RESET MASTER 或者 RESET SLAVE會清空這些信息。

Last_SQL_Error_Timestamp

是最近一次SQL線程出現錯誤的時間,格式同IO線程Last_IO_Error_Timestamp 。

Last_Errno和Last_Error

Last_Errno和Last_Error 是Last_SQL_Errno 和 Last_SQL_Error 別名。
執行 RESET MASTER 或者 RESET SLAVE會清空這些信息。

參考

13.7.5.34 SHOW SLAVE STATUS Statement
B.3.1 Server Error Message Reference

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章