您好,登錄后才能下訂單哦!
MySQL 5.6復制報錯
Slave_IO_Running: Yes Slave_SQL_Running: No Replicate_Do_DB: app_push_center Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 1032 Last_Error: Could not execute Update_rows event on table app_push_center.app_device; Can't find record in 'who_app_device', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.000693, end_log_pos 28549933 Skip_Counter: 0 Exec_Master_Log_Pos: 28549155 Relay_Log_Space: 37322136 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: 0 Last_IO_Error: Last_SQL_Errno: 1032 Last_SQL_Error: Could not execute Update_rows event on table who_app_push_center.app_device; Can't find record in 'who_app_device', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.000693, end_log_pos 28549933 Replicate_Ignore_Server_Ids:
報錯原因:
從庫上面執行更新語句時,找不到對應的記錄。
修復方法:
去主庫上面找到對應的記錄,手動插入缺少的條目到從庫對應的表中。
使用mysqlbinlog解析binlog日志,找到從庫停止的記錄點,進而找到對應的語句(找到更新的主鍵條件@1=96029227)。
# cp /data/mysql3308/mysql-bin.000693 . # mysqlbinlog mysql-bin.000693 -v > 20181025.log # grep -B50 28549933 20181025.log gwAMU2F1ZGkgQXJhYmlhAmVuAAAAIHOBCw== '/*!*/; ### UPDATE `app_push_center`.`app_device` ### WHERE ### @1=99457133 ### @2=47189303 ### @3='e-s-Zv-0FRs:APA91bHgKnXcKClKisl3P1KWiii0SuQtWsNrTRpwyByz86Sa8d2Vzj5g8LTMWeot0ue1g26fQnLpl1gmZVONKpIrLqbVS7GGuxdn6wgn0vewntMW-mQowZibAZ1jvJB41ThrAgIWQQMu' ### @4=1 ### @5=0 ### @6='2018-09-13 06:21:24' ### @7='2018-10-25 13:23:43' ### @8=1 ### @9='c5051a9f-a54c-49a0-80a3-2290d14a5397' ### @10='7.4.1' ### @11=1 ### @12=3.00 ### @13='Saudi Arabia' ### @14='en' ### @15=0 ### @16=0 ### @17=0 ### SET ### @1=99457133 ### @2=47189303 ### @3='e-s-Zv-0FRs:APA91bHgKnXcKClKisl3P1KWiii0SuQtWsNrTRpwyByz86Sa8d2Vzj5g8LTMWeot0ue1g26fQnLpl1gmZVONKpIrLqbVS7GGuxdn6wgn0vewntMW-mQowZibAZ1jvJB41ThrAgIWQQMu' ### @4=1 ### @5=0 ### @6='2018-09-13 06:21:24' ### @7='2018-10-25 13:24:08' ### @8=1 ### @9='c5051a9f-a54c-49a0-80a3-2290d14a5397' ### @10='7.4.1' ### @11=1 ### @12=3.00 ### @13='Saudi Arabia' ### @14='en' ### @15=0 ### @16=0 ### @17=0 # at 28549124 #181025 13:24:08 server id 4024108 end_log_pos 28549155 CRC32 0x1df3385b Xid = 5088151913 COMMIT/*!*/; # at 28549155 #181025 13:24:08 server id 4024108 end_log_pos 28549247 CRC32 0xaf120f59 Query thread_id=12489417 exec_time=0 error_code=0 SET TIMESTAMP=1540445048/*!*/; BEGIN /*!*/; # at 28549247 #181025 13:24:08 server id 4024108 end_log_pos 28549351 CRC32 0xd609f120 Table_map: `who_app_push_center`.`who_app_device` mapped to number 180 # at 28549351 #181025 13:24:08 server id 4024108 end_log_pos 28549933 CRC32 0xbe120930 Update_rows: table id 180 flags: STMT_END_F -- ZGV2aWNlABEDAw8DAxISAQ8PAfYP/gEBAQ79AgAAlgAeAAQC8AD+CXpIACDxCdY= eFPRWx8sZz0ARgIAAC2jswEAALQAAAAAAAEAAgAR////////AAD+K0q5BbVqkAKuAGRQOE9TRDFf NFU4OkFQQTkxYkc1b1FXUHMwcl95aW9ORmZadlkxaHFoY1RsOUowUGZocU5EaGRISEh3Mm54eFh0 dWt2azZjTE00U25uRTZuT1hVbFZDSTNDZUhkQ25YZmx3VC1sSjJCLTBpUXh5ZUcwdnVwRlF1Rmh3 c2Q2dVQxUDFTTjNlaDBvLU1tMl9fRjMtWEZXNU1XZHR4WERLZGpvTzRkWUhkT1NCamhmQQEAAAAA AAAAmaCgm1GZoS8b0AEkNjFlN2U2NWEtZTFlYi00OTA3LWIyMzEtOGVkZmZmYjI2NDMwBTcuNC4x AYMADFNhdWRpIEFyYWJpYQJhcgAAAAAA/itKuQW1apACrgBkUDhPU0QxXzRVODpBUEE5MWJHNW9R V1BzMHJfeWlvTkZmWnZZMWhxaGNUbDlKMFBmaHFORGhkSEhIdjJueHhYdHVrdms2Y0xNNFNubkU2 bk9YVWxWQ0kzQ2VIZENuWGZsd1QtbEoyQi0waVF4eGVHMHZ1cEZRdUZodnNkNnVUMVAxU04zZWgw by1NbTJfX0YzLVhGVzVNV2R0eFhES2Rqb080ZFlIZE9TQmpoZkEBAAAAAAAAAJmgoJtRmaEy1ggB JDYxZTdlNjVhLWUxZWItNDkwNy1iMjMxLThlZGZmZmIyNjQzMAU3LjQuMQGDAAxTYXVkaSBBcmFi aWECYXIAAAAwCRK+ '/*!*/; ### UPDATE `who_app_push_center`.`who_app_device` ### WHERE ### @1=96029227 ### @2=43018933 ### @3='dP8OSD1_4U8:APA91bG5oQWPs0r_yioNFfZvY1hqhcTl9J0PfhqNDhdHHHv2nxxXtukvk6cLM4SnnE6nOXUlVCI3CeHdCnXflwT-lJ2B-0iQxxeG0vupFQuFhvsd6uT1P1SN3eh0o-Mm2__F3-XFW5MWdtxXDKdjoO4dYHdOSBjhfA' ### @4=1 ### @5=0 ### @6='2018-08-16 09:45:17' ### @7='2018-10-23 17:47:16' ### @8=1 ### @9='61e7e65a-e1eb-4907-b231-8edfffb26430' ### @10='7.4.1' ### @11=1 ### @12=3.00 ### @13='Saudi Arabia' ### @14='ar' ### @15=0 ### @16=0 ### @17=0 ### SET ### @1=96029227 ### @2=43018933 ### @3='dP8OSD1_4U8:APA91bG5oQWPs0r_yioNFfZvY1hqhcTl9J0PfhqNDhdHHHv2nxxXtukvk6cLM4SnnE6nOXUlVCI3CeHdCnXflwT-lJ2B-0iQxxeG0vupFQuFhvsd6uT1P1SN3eh0o-Mm2__F3-XFW5MWdtxXDKdjoO4dYHdOSBjhfA' ### @4=1 ### @5=0 ### @6='2018-08-16 09:45:17' ### @7='2018-10-25 13:24:08' ### @8=1 ### @9='61e7e65a-e1eb-4907-b231-8edfffb26430' ### @10='7.4.1' ### @11=1 ### @12=3.00 ### @13='Saudi Arabia' ### @14='ar' ### @15=0 ### @16=0 ### @17=0 # at 28549933
主庫執行查詢
mysql> select * from device where id=96029227\G *************************** 1. row *************************** id: 96029227 user_id: 43018933 register_id: dP8OSD1_4U8:APA91bG5oQWPs0r_yioNFfZvY1hqhcTl9J0PfhqNDhdHHHv2nxxXtukvk6cLM4SnnE6nOXUlVCI3CeHdCnXflwT-lJ2B-0iQxxeG0vupFQuFhvsd6uT1P1SN3eh0o-Mm2__F3-XFW5MWdtxXDKdjoO4dYHdOSBjhfA type: 1 is_start: 0 create_time: 2018-08-16 09:45:17 update_time: 2018-10-25 13:24:08 status: 1 cookie_id: 61e7e65a-e1eb-4907-b231-8edfffb26430 app_version: 7.4.1 receive_notification: 1 timezone: 3.00 country_name: Saudi Arabia lang: ar push_flag: 0 app_id: 0 pkg: 0 1 row in set (0.00 sec)
從庫執行查詢
mysql > select * from app_device where id=96029227\G Empty set (0.00 sec)
之后手動在從庫上面插入缺少的記錄,之后重啟復制。
使用下面的條目,作為插入條件,按照字段順序寫一條SQL,在從庫上面執行。
### UPDATE `who_app_push_center`.`who_app_device` ### WHERE ### @1=96029227 ### @2=43018933 ### @3='dP8OSD1_4U8:APA91bG5oQWPs0r_yioNFfZvY1hqhcTl9J0PfhqNDhdHHHv2nxxXtukvk6cLM4SnnE6nOXUlVCI3CeHdCnXflwT-lJ2B-0iQxxeG0vupFQuFhvsd6uT1P1SN3eh0o-Mm2__F3-XFW5MWdtxXDKdjoO4dYHdOSBjhfA' ### @4=1 ### @5=0 ### @6='2018-08-16 09:45:17' ### @7='2018-10-23 17:47:16' ### @8=1 ### @9='61e7e65a-e1eb-4907-b231-8edfffb26430' ### @10='7.4.1' ### @11=1 ### @12=3.00 ### @13='Saudi Arabia' ### @14='ar' ### @15=0 ### @16=0 ### @17=0 ### SET ### @1=96029227 ### @2=43018933 ### @3='dP8OSD1_4U8:APA91bG5oQWPs0r_yioNFfZvY1hqhcTl9J0PfhqNDhdHHHv2nxxXtukvk6cLM4SnnE6nOXUlVCI3CeHdCnXflwT-lJ2B-0iQxxeG0vupFQuFhvsd6uT1P1SN3eh0o-Mm2__F3-XFW5MWdtxXDKdjoO4dYHdOSBjhfA' ### @4=1 ### @5=0 ### @6='2018-08-16 09:45:17' ### @7='2018-10-25 13:24:08' ### @8=1 ### @9='61e7e65a-e1eb-4907-b231-8edfffb26430' ### @10='7.4.1' ### @11=1 ### @12=3.00 ### @13='Saudi Arabia' ### @14='ar' ### @15=0 ### @16=0 ### @17=0
那么為什么會出現數據條目缺失呢?
報錯的從庫所使用的備份是在備份從庫上面做的。
檢查備份從庫的復制參數,發現參數里面有復制報錯跳過參數。
這是導致發生復制中斷的原因。去掉復制報錯跳過參數,重新搭建備份從庫。
mysql> show global variables like 'slave_skip_errors'; +-------------------+-----------+ | Variable_name | Value | +-------------------+-----------+ | slave_skip_errors | 1032,1062 | +-------------------+-----------+ 1 row in set (0.00 sec)
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。