主從復制錯誤處理總結


錯誤一

ERROR] Slave I/O: error connecting to master 'replication@VMS00782:3306' - retry-time: 60 retries: 2, Error_code: 1045

錯誤原因:從庫用來連接主庫的用戶權限或者密碼不對

解決方法:首先在主庫上檢查用來主從復制的用戶權限,如果沒有問題在檢查從庫使用的密碼是否正確。

錯誤二

140331 10:08:18 [ERROR] Error reading master configuration
140331 10:08:18 [ERROR] Failed to initialize the master info structure
140331 10:08:18 [Note] Event Scheduler: Loaded 0 events

錯誤原因:這個可能是從庫的master.info文件有損壞。

解決方法:reset slave

錯誤三

Error 'Duplicate entry '1' for key 1' on query. Default database: 'movivi1'. Query: 'INSERT INTO `v1vid0_user_samename` VALUES(null,1,'123','11','4545','123')'

錯誤原因:可能是從庫的約束比主庫更多寫造成的。

解決方法:

Mysql > stop slave;
Mysql > set global sql_slave_skip_counter =1 ;
Mysql > start slave;

錯誤四

Slave SQL: Error 'Table 'xxxx' doesn't exist' on query. Default database: 't591'. Query: 'INSERT INTO `xxxx`(type,post_id,browsenum) SELECT type,post_id,browsenum FROM xxxx WHERE hitdate='20090209'', Error_code: 1146

錯誤原因:slave上缺少錯誤中的表。

解決方法:在slave上添加上對應的表,然后start slave。

錯誤五

Error 'Unknown column 'qdir' in 'field list'' on query. Default database: 'club'. Query: 'insert into club.question_del (id, pid, ques_name, givepoint, title, subject, subject_pid, createtime, approve, did, status, intime, order_d, endtime,banzhu_uid,banzhu_uname,del_cause,qdir) select id, pid, ques_name, givepoint, title, subject, subject_pid, createtime, approve, did, status, intime, order_d, endtime,'1521859','admin0523','無意義回復',qdir from club.question where id=7330212'
1 row in set (0.00 sec)

錯誤原因:從庫上對應的表上缺少字段。

解決方法:根據主庫上表結構,在從庫對應表上添加缺少的字段,然后start slave。

 

錯誤六

mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.60.159
Master_User: backup
Master_Port: 3311
Connect_Retry: 60
Master_Log_File: mysql-bin.000012
Read_Master_Log_Pos: 274863854
Relay_Log_File: mysql-relay-bin.000007
Relay_Log_Pos: 2160037
Relay_Master_Log_File: mysql-bin.000012
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB: 
Replicate_Ignore_DB: 
Replicate_Do_Table: 
Replicate_Ignore_Table: 
Replicate_Wild_Do_Table: 
Replicate_Wild_Ignore_Table: 
Last_Errno: 1146
Last_Error: Error executing row event: 'Table 'panda.t' doesn't exist'
Skip_Counter: 0
Exec_Master_Log_Pos: 2159824
Relay_Log_Space: 274866725

錯誤原因:主庫刪除的表在從庫中不存在,導致從庫在遇到刪除不存在表的錯誤時無法繼續同步。

解決方法:利用slave-skip-errors參數,跳過對於的1146錯誤(這個參數是一個只讀的,需要在配置文件中修改,並重啟從庫)

1、在my.cnf的[mysqld]下面添加slave_skip_errors=1146
2、重啟從庫 service mysql restart

3、在從庫上啟動同步

mysql> start slave ;
Query OK, 0 rows affected (0.01 sec)

mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.60.159
Master_User: backup
Master_Port: 3311
Connect_Retry: 60
Master_Log_File: mysql-bin.000012
Read_Master_Log_Pos: 274863854
Relay_Log_File: mysql-relay-bin.000007
Relay_Log_Pos: 137439021
Relay_Master_Log_File: mysql-bin.000012
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: 137438808
Relay_Log_Space: 274867275
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: 88484
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: 159
Master_UUID: ded30ff9-62b2-11e6-b0d0-f80f41fa11bf
Master_Info_File: /usr/local/mysql-5.7.14-linux-glibc2.5-x86_64/data/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Reading event from the relay log
Master_Retry_Count: 86400
Master_Bind: 
Last_IO_Error_Timestamp: 
Last_SQL_Error_Timestamp: 
Master_SSL_Crl: 
Master_SSL_Crlpath: 
Retrieved_Gtid_Set: 
Executed_Gtid_Set: 
Auto_Position: 0
Replicate_Rewrite_DB: 
Channel_Name: 
Master_TLS_Version: 
1 row in set (0.00 sec)

4、去掉my.cnf中的slave_skip_errors=1146

5、重啟從庫

6、啟動從庫復制
---------------------
原文:https://blog.csdn.net/gua___gua/article/details/52869614


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM