一、報(bào)錯(cuò)error connecting to master 'x@x.x.x.x:x' - retry-time: 60 retries: 86400
今天搭建mysql主從復(fù)制,一直報(bào)這個(gè)錯(cuò)。我是在一臺(tái)虛擬機(jī)上使用多實(shí)例創(chuàng)建的2個(gè)不同端口的數(shù)據(jù)庫(kù),查了很久,才解決。
1.檢查主從復(fù)制的用戶名密碼;
2.檢查MASTER_LOG_FILE和MASTER_LOG_POS。
記住配置從庫(kù)的命令,這些參數(shù)都要參考主庫(kù)的配置:
mysql> CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=3308, MASTER_USER='root', MASTER_PASSWORD='oldboy123', MASTER_LOG_FILE='mysql-bin.000007', MASTER_LOG_POS=797;
查詢同步結(jié)果:
mysql> show slave status \G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 127.0.0.1
Master_User: root
Master_Port: 3308
Connect_Retry: 60
Master_Log_File: mysql-bin.000007
Read_Master_Log_Pos: 797
Relay_Log_File: mysql-relay-bin.000002
Relay_Log_Pos: 253
Relay_Master_Log_File: mysql-bin.000007
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: 797
Relay_Log_Space: 409
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: 3308
同步結(jié)果看3項(xiàng):Slave_IO_Running(I/O線程狀態(tài)),Slave_SQL_Running(SQL線程狀態(tài)),Seconds_Behind_Master(復(fù)制過(guò)程中從庫(kù)比主庫(kù)延遲的秒數(shù))。
二、從庫(kù)出現(xiàn)沖突無(wú)法復(fù)制。可以將同步指針向下移動(dòng)一個(gè),如果多次不同步,重復(fù)操作。
mysql> stop slave;
Query OK, 0 rows affected (0.02 sec)
mysql> set global sql_slave_skip_counter=1;
Query OK, 0 rows affected (0.00 sec)
mysql> start slave;
Query OK, 0 rows affected (0.01 sec)
三、當(dāng)前從庫(kù)還要作為其他從庫(kù)的主庫(kù)。在從庫(kù)的my.cnf加入如下參數(shù),并修改server_id和log-bin的配置(去掉注釋,修改默認(rèn)配置),重啟服務(wù)。
log-slave-updates
log-bin = /data/3309/data/mysql-bin #根據(jù)實(shí)際情況寫
expire_logs_days = 7 #相當(dāng)于find /data/3309/data -type f -name "mysql-bin.000* -mtime +7 | xargs rm -f"
總結(jié)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接
您可能感興趣的文章:- Mysql主從復(fù)制作用和工作原理詳解
- MySQL數(shù)據(jù)庫(kù)主從復(fù)制延時(shí)超長(zhǎng)的解決方法
- MYSQL 完全備份、主從復(fù)制、級(jí)聯(lián)復(fù)制、半同步小結(jié)
- 深入理解MySQL主從復(fù)制線程狀態(tài)轉(zhuǎn)變
- MySQL配置SSL主從復(fù)制
- MYSQL的主從復(fù)制知識(shí)點(diǎn)整理