MySQL 5.6複製報錯Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND;
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 NFU4OkFQQTkxYkc1b1FXUHMwcl95aW9ORmZadlkxaHFoY1RsOUowUGZocU5EaGRISEh2Mm54eFh0 dWt2azZjTE00U25uRTZuT1hVbFZDSTNDZUhkQ25YZmx3VC1sSjJCLTBpUXh4ZUcwdnVwRlF1Rmh2 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)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2217504/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL 5.7從庫報錯exceeds of slave_pending_jobs_size_max. Error_code: 1864MySqlError
- MySQL主從複製報錯:Got fatal error 1236 from master when reading data fromMySqlGoErrorAST
- 半同步複製報錯mysql8.0.25MySql
- MySQL8.0主從複製命中1032案例分析MySql
- GTID複製報錯處理:Last_Error: Error 'Can't drop database 'test';ASTErrorDatabase
- mysql5.6 mysqldump備份報錯MySql
- mysql5.6主主複製及keepalived 高可用MySql
- MySQL5.7半同步複製報錯案例分析MySql
- MySQL 網路導致的複製報錯案例MySql
- MySQL 5.6執行DDL報錯ERROR 1050 (42S01): Table 'sms/#sql-ib752' already existMySqlError
- MySQL 主從複製錯誤1837MySql
- MySQL GTID複製錯誤修復演示MySql
- MySQL 啟動報錯 error while loading shared librariesMySqlErrorWhile
- MySQL error 錯 誤 碼MySqlError
- MySQL複製MySql
- MySQL建立觸發器時報錯Error Code: 1064MySql觸發器Error
- ERROR 1045 (28000): ProxySQL Error: 報錯ErrorSQL
- mysql複製--主從複製配置MySql
- MySQL報錯ERROR 2013 (HY000): Lost connection to MySQL server during queryMySqlErrorServer
- Mysql資料庫報ERROR 1045 (28000)報錯及MySQL忘記密碼找回MySql資料庫Error密碼
- MySQL主從複製錯誤——列型別轉換錯誤MySql型別
- MySQL 8 複製(三)——延遲複製與部分複製MySql
- MySQL主從複製之GTID複製MySql
- MySQL 8 複製(一)——非同步複製MySql非同步
- MySQL 8 複製(二)——半同步複製MySql
- MySQL 8 複製(四)——GTID與複製MySql
- MySQL 8 複製(五)——配置GTID複製MySql
- MySQL8.0.28命中[ERROR][MY-013183]報錯案例分析MySqlError
- mysql匯入sql檔案報錯 ERROR 2013 2006 2002MySqlError
- MySQL 複製全解析 Part 11 使用xtrabackup建立MySQL複製MySql
- mysql多源複製跳過錯誤處理方法MySql
- MySQL主從複製之半同步複製MySql
- MySQL主從複製之非同步複製MySql非同步
- MySQL報錯Table 'plugin' is read only [ERROR] Can't open the mysql.plugin table.MySqlPluginError
- MySQL 報錯 ERROR 1290 (HY000): running with the --secure-file-privMySqlError
- mysql登入報錯提示:ERROR 1045 (28000)的解決方法MySqlError
- Welcome to MySQL Workbench:MySQL 複製表MySql
- MySQL主從複製MySql