不少時候,就算thread 正在進行,也不表明沒有錯誤,必定要看看具體表示錯誤的變量html
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Connecting to master
Master_Host: 192.168.1.107
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000045
Read_Master_Log_Pos: 107
Relay_Log_File: CENTOS6-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: mysql-bin.000045
Slave_IO_Running: Connecting
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: 107
Relay_Log_Space: 107
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: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 1045
Last_IO_Error: error connecting to master 'repl@192.168.1.107:3306' - retry-time: 60 retries: 86400
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 0
row in set (0.00 sec)mysql
一個變量可能承載不了那麼多的錯誤信息,要看詳細的錯誤信息就要看錯誤日誌sql
160204 18:27:37 [Note] Error reading relay log event: slave SQL thread was killed 160204 18:27:37 [Note] Slave I/O thread killed while connecting to master 160204 18:27:37 [Note] Slave I/O thread exiting, read up to log 'mysql-bin.000045', position 107 160204 18:27:48 [Note] 'CHANGE MASTER TO executed'. Previous state master_host='centos7', master_port='3306', master_log_file='', master_log_pos='4'. New state master_host='192.168.1.107', master_port='3306', master_log_file='mysql-bin.000045', master_log_pos='107'. 160204 18:27:52 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.000045' at position 107, relay log '/usr/local/mysql/data/CENTOS6-relay-bin.000001' position: 4 160204 18:27:52 [ERROR] Slave I/O: error connecting to master 'repl@192.168.1.107:3306' - retry-time: 60 retries: 86400, Error_code: 1045
不過也沒有更多的信息,查一下錯誤代號centos
查詢了一下master的登錄表centos7
這句話的意思是,來自192.168.1.108這個地方的人,可使用master機器上的一個叫作repl的帳號,可是‘repl’@'192.168.1.108'這個帳號能夠作一些什麼東西,不能作一些什麼東西呢,這個須要看他的權限,也就是他的能力,由於可能不止一項權利,因此用了複數grantsspa
能夠看到它是沒有通過受權的,咱們如今能夠對他受權,僅僅是一個「進行復制」的權利,受權完之後須要確認一下日誌
如今從新使用replication功能,其實不須要start slave去開啓,它本身就會自動開啓的code
mysql> show slave status\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.1.107 Master_User: repl Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000045 Read_Master_Log_Pos: 3220 Relay_Log_File: CENTOS6-relay-bin.000002 Relay_Log_Pos: 3366 Relay_Master_Log_File: mysql-bin.000045 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: 3220 Relay_Log_Space: 3524 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: 1 1 row in set (0.00 sec)原文來自https://www.cnblogs.com/hellotracy/articles/5183057.html