mysql slave 线程 简书_【MySQL】你真的读懂了slave status吗?
前言:大家平時在檢查主從復制的時候基本上都會使用 show slave status來看主從復制的情況,那么你真的讀懂每個指標項了嗎?
一、status指標解讀
root@localhost [(none)]>show slave status\G
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 7
Current database: *** NONE ***
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.50.3
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 728
Relay_Log_File: relay-bin.000002
Relay_Log_Pos: 941
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: 728
Relay_Log_Space: 1142
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: 1003306
Master_UUID: dff47046-3ad5-11e8-86fe-080027de0e0e
Master_Info_File: /storage/mysql/data/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: dff47046-3ad5-11e8-86fe-080027de0e0e:1-3
Executed_Gtid_Set: dff47046-3ad5-11e8-86fe-080027de0e0e:1-3
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)
指標
注釋
Slave_IO_State: Waiting for master to send event
表示IO線程的狀態(tài)
Master_Host: 192.168.50.3
Master的IP地址
Master_User: repl
主從復制的用戶
Master_Port: 3306
Master的端口
Connect_Retry: 60
IO thread重連次數(shù)
Master_Log_File: mysql-bin.000001
IO thread正在讀取的master上的binlog文件
Read_Master_Log_Pos: 728
正在讀取的master上的binlog文件位置
Relay_Log_File: relay-bin.000002
存放的本地relay log文件名
Relay_Log_Pos: 941
存放的本地relay log位置
Relay_Master_Log_File: mysql-bin.000001
SQL線程正在執(zhí)行的master binlog file
Slave_IO_Running: Yes
IO thread狀態(tài)
Slave_SQL_Running: Yes
SQL thread狀態(tài)
Replicate_Do_DB:
指定復制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
跳過復制數(shù)
Exec_Master_Log_Pos: 728
執(zhí)行masterbinlog的位置
Relay_Log_Space: 1142
所有relay log字節(jié)數(shù)總和
Until_Condition: None
指定復制條件
Until_Log_File:
指定復制到某個文件
Until_Log_Pos: 0
指定復制到某個位置
Seconds_Behind_Master: 0
從庫落后主庫時間,單位秒
Last_IO_Errno: 0
最近一次IO thread錯誤
Last_IO_Error
最近一次IO thread錯誤詳細信息
Last_SQL_Errno: 0
最近一次sql thread錯誤
Last_SQL_Error:
最近一次sql thread錯誤詳細信息
Replicate_Ignore_Server_Ids:
復制忽略server_id為xxx的實例
Master_Server_Id: 1003306
master server_id
Master_UUID: dff47046-3ad5-11e8-86fe-080027de0e0e
master uuid
Master_Info_File: /storage/mysql/data/master.info
記錄master信息文件
SQL_Delay: 0
sql延遲多少時間,延遲復制會用到
SQL_Remaining_Delay: NULL
當sql thread狀態(tài)為Waiting until MASTER_DELAY seconds after master executed event,那么該值表示剩下延遲多少時間
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
sql thread狀態(tài)
Master_Retry_Count: 86400
主從復制斷開時slave最多能嘗試重新連接的次數(shù)
Master_Bind:
綁定網卡
Last_IO_Error_Timestamp:
io thread 最近一次的錯誤時間
Last_SQL_Error_Timestamp:
sql thread 最近一次的錯誤時間
Retrieved_Gtid_Set: dff47046-3ad5-11e8-86fe-080027de0e0e:1-3
IO thread獲取到的GTID
Executed_Gtid_Set: dff47046-3ad5-11e8-86fe-080027de0e0e:1-3
SQL thread執(zhí)行的GTID
Auto_Position: 1
使用auto_position,建議還是開啟比較方便
Replicate_Rewrite_DB:
復制DB對應關系
Channel_Name:
多源復制的channel name
下面我們逐個來解讀一下:
指標
注釋
Slave_IO_State: Waiting for master to send event
表示IO線程的狀態(tài)
Master_Host: 192.168.50.3
Master的IP地址
Master_User: repl
主從復制的用戶
Master_Port: 3306
Master的端口
Connect_Retry: 60
IO thread重連次數(shù)
Master_Log_File: mysql-bin.000001
IO thread正在讀取的master上的binlog文件
Read_Master_Log_Pos: 728
正在讀取的master上的binlog文件位置
Relay_Log_File: relay-bin.000002
存放的本地relay log文件名
Relay_Log_Pos: 941
存放的本地relay log位置
Relay_Master_Log_File: mysql-bin.000001
SQL線程正在執(zhí)行的master binlog file
Slave_IO_Running: Yes
IO thread狀態(tài)
Slave_SQL_Running: Yes
SQL thread狀態(tài)
Replicate_Do_DB:
指定復制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
跳過復制數(shù)
Exec_Master_Log_Pos: 728
執(zhí)行masterbinlog的位置
Relay_Log_Space: 1142
所有relay log字節(jié)數(shù)總和
Until_Condition: None
指定復制條件
Until_Log_File:
指定復制到某個文件
Until_Log_Pos: 0
指定復制到某個位置
Seconds_Behind_Master: 0
從庫落后主庫時間,單位秒
Last_IO_Errno: 0
最近一次IO thread錯誤
Last_IO_Error
最近一次IO thread錯誤詳細信息
Last_SQL_Errno: 0
最近一次sql thread錯誤
Last_SQL_Error:
最近一次sql thread錯誤詳細信息
Replicate_Ignore_Server_Ids:
復制忽略server_id為xxx的實例
Master_Server_Id: 1003306
master server_id
Master_UUID: dff47046-3ad5-11e8-86fe-080027de0e0e
master uuid
Master_Info_File: /storage/mysql/data/master.info
記錄master信息文件
SQL_Delay: 0
sql延遲多少時間,延遲復制會用到
SQL_Remaining_Delay: NULL
當sql thread狀態(tài)為Waiting until MASTER_DELAY seconds after master executed event,那么該值表示剩下延遲多少時間
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
sql thread狀態(tài)
Master_Retry_Count: 86400
主從復制斷開時slave最多能嘗試重新連接的次數(shù)
Master_Bind:
綁定網卡
Last_IO_Error_Timestamp:
io thread 最近一次的錯誤時間
Last_SQL_Error_Timestamp:
sql thread 最近一次的錯誤時間
Retrieved_Gtid_Set: dff47046-3ad5-11e8-86fe-080027de0e0e:1-3
IO thread獲取到的GTID
Executed_Gtid_Set: dff47046-3ad5-11e8-86fe-080027de0e0e:1-3
SQL thread執(zhí)行的GTID
Auto_Position: 1
使用auto_position,建議還是開啟比較方便
Replicate_Rewrite_DB:
復制DB對應關系
Channel_Name:
多源復制的channel name
二、日常運維注意點
在GTID環(huán)境下,主從同步延遲觀察就非常簡單了,我們只需要觀察Retrieved_Gtid_Set表示的就是io thread讀取到的位置,Executed_Gtid_Set表示的就是sql thread執(zhí)行到的位置
在非GTID環(huán)境下,主從復制觀察相對來說稍微麻煩一些,(Master_Log_file, Read_Master_Log_Pos): 表示io thread讀取到的master binlog位置;
Relay_Master_Log_File, Exec_Master_Log_Pos): 表示sql thread已經執(zhí)行到的位置;
(Relay_Log_File, Relay_Log_Pos): 表示sql thread執(zhí)行到的relay log位置
Seconds_Behind_Master表示slave延遲master的時間數(shù),并不是很準確,計算公式是:io_thread.timestamp-sql_thread.timestamp
總結
以上是生活随笔為你收集整理的mysql slave 线程 简书_【MySQL】你真的读懂了slave status吗?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 《python算法教程》个人学习心得之(
- 下一篇: 字符串截取后两位,字符串转成数组,再转换