如何檢查mysql數據庫中mysql復制是否正常工作?
mysql> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: master1
Master_User: root
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000004
Read_Master_Log_Pos: 931
Relay_Log_File: slave1-relay-bin.000056
Relay_Log_Pos: 950
Relay_Master_Log_File: mysql-bin.000004
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: 931
Relay_Log_Space: 1365
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: 0
Slave_IO_State:代表當前slave的狀態
Slave_IO_Running:代表負責讀取主庫bin log的IO線程是否是運行狀態,正常情況下應
該是YES
Slave_SQL_Running:代表負責執行備庫relay log的SQL線程是否是運行狀態,正常情
況下應該是YES
Last_IO_Error, Last_SQL_Error: 分別代表最後一次IO線程和SQL線程所發生的錯誤,
正常情況下應該是空代表沒有錯誤
Seconds_Behind_Master:代表備庫的SQL線程比主庫的bin log晚多少秒。0代表目前
沒有復制延遲
(Master_Log_file, Read_Master_Log_Pos):表示IO線程在主庫bin log中的坐標位置
(Relay_Master_Log_File, Exec_Master_Log_Pos):表示SQL線程在主庫bin log中的坐
標位置
(Relay_Log_File, Relay_Log_Pos):表示SQL線程在備庫relay log中的坐標位置
在主庫可以通過執行show processlist命令查看主庫的bin log日誌生成進程
mysql> SHOW PROCESSLIST \G;
*************************** 4. row ***************************
Id: 10
User: root
Host: slave1:58371
db: NULL
Command: Binlog Dump
Time: 777
State: Has sent all binlog to slave; waiting for binlog to be updated
Info: NULL
互聯網企業大多用的數據庫是MySQL的,想要眾多的IT工作者中脫穎而出,就需要擁有高深的技術,學習增值是必不可少的。學習之路,是貴在堅持的。老男孩教育MySQL DBA課程,幾經更新課程,杜絕紙上談兵,全企業真實案例結合理論授課,想深入的學習MySQL DBA的知識,可以關註下老男孩教育。
如何檢查mysql數據庫中mysql復制是否正常工作?