mysql報錯Ignoring the redo log due to missing MLOG_CHECKPOINT between
mysql版本:5.7.19
系統版本:centos7.3
由於周未公司斷電,跑在vmware虛擬機上的mysql掛掉,無法重啟
啟動mysql的時候,error log的信息如下
2017-11-15T11:44:46.562061+08:00 0 [ERROR] InnoDB: Ignoring the redo log due to missing MLOG_CHECKPOINT between the checkpoint 63593957 and the end 63593472. 2017-11-15T11:44:46.562090+08:00 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error 2017-11-15T11:44:47.062885+08:00 0 [ERROR] Plugin 'InnoDB' init function returned error. 2017-11-15T11:44:47.062936+08:00 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 2017-11-15T11:44:47.062945+08:00 0 [ERROR] Failed to initialize plugins. 2017-11-15T11:44:47.062951+08:00 0 [ERROR] Aborting 2017-11-15T11:44:47.062962+08:00 0 [Note] Binlog end
在redo log里找不到checkpoint點,innodb引擎啟動失敗
解決辦法有兩個
第一個
設置innodb_force_recovery=6,然后啟動mysql,能夠順利啟動mysql
error log信息如下
2017-11-15T12:07:25.235397+08:00 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode. 2017-11-15T12:07:25.235408+08:00 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode. 2017-11-15T12:07:25.235540+08:00 0 [ERROR] InnoDB: Failed to find tablespace for table `mysql`.`time_zone_leap_second` in the cache. Attempting to load the tablespace with space id 46 2017-11-15T12:07:25.256456+08:00 0 [ERROR] InnoDB: Failed to find tablespace for table `mysql`.`time_zone_name` in the cache. Attempting to load the tablespace with space id 47 2017-11-15T12:07:25.258414+08:00 0 [ERROR] InnoDB: Failed to find tablespace for table `mysql`.`time_zone` in the cache. Attempting to load the tablespace with space id 45 2017-11-15T12:07:25.263576+08:00 0 [ERROR] InnoDB: Failed to find tablespace for table `mysql`.`time_zone_transition_type` in the cache. Attempting to load the tablespace with space id 49 2017-11-15T12:07:25.267569+08:00 0 [ERROR] InnoDB: Failed to find tablespace for table `mysql`.`time_zone_transition` in the cache. Attempting to load the tablespace with space id 48 2017-11-15T12:07:25.272648+08:00 0 [ERROR] InnoDB: Failed to find tablespace for table `mysql`.`servers` in the cache. Attempting to load the tablespace with space id 41 2017-11-15T12:07:25.276466+08:00 0 [ERROR] InnoDB: Failed to find tablespace for table `mysql`.`slave_master_info` in the cache. Attempting to load the tablespace with space id 42 2017-11-15T12:07:25.280225+08:00 0 [ERROR] InnoDB: Failed to find tablespace for table `mysql`.`slave_relay_log_info` in the cache. Attempting to load the tablespace with space id 43 2017-11-15T12:07:25.286619+08:00 0 [ERROR] InnoDB: Failed to find tablespace for table `mysql`.`slave_worker_info` in the cache. Attempting to load the tablespace with space id 44 2017-11-15T12:07:25.292450+08:00 0 [ERROR] Error writing master configuration. 2017-11-15T12:07:25.292468+08:00 0 [ERROR] Error reading master configuration. 2017-11-15T12:07:25.294535+08:00 0 [Warning] Recovery from master pos 1065 and file mysql-bin.000003 for channel ''. Previous relay log pos and relay log file had been set to 4, /data/mysql/mysql3306/logs/mysql-relay.000003 respectively. 2017-11-15T12:07:25.294643+08:00 0 [ERROR] Error writing relay log configuration. 2017-11-15T12:07:25.294656+08:00 0 [ERROR] Error reading relay log configuration. 2017-11-15T12:07:25.294983+08:00 0 [ERROR] Slave: Failed to initialize the master info structure for channel ''; its record may still be present in 'mysql.slave_master_info' table, consider deleting it. 2017-11-15T12:07:25.294996+08:00 0 [ERROR] Failed to create or recover replication info repositories. 2017-11-15T12:07:25.295000+08:00 0 [Note] Some of the channels are not created/initialized properly. Check for additional messages above. You will not be able to start replication on those channels until the issue is resolved and the server restarted.
由於損壞的這個庫是從庫,所以顯示無法初始化master info表
由於mysql庫里有幾個表都顯示找不到表空間,那么會存在丟失數據的風險
第二個
按照網上說的,把實例的所有ib_logfilex文件刪除,再啟動mysql,能夠順利啟動
參照:http://blog.csdn.net/weiwangsisoftstone/article/details/52954228
error log信息如下
2017-11-15T11:54:17.694175+08:00 0 [Note] Server socket created on IP: '::'. 2017-11-15T11:54:17.696000+08:00 0 [ERROR] InnoDB: Page [page id: space=40, page number=3] log sequence number 3725922 is in the future! Current system log sequence number 2440232. 2017-11-15T11:54:17.696018+08:00 0 [ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery. 2017-11-15T11:54:17.696287+08:00 0 [ERROR] InnoDB: Page [page id: space=40, page number=1] log sequence number 3720522 is in the future! Current system log sequence number 2440232. 2017-11-15T11:54:17.696300+08:00 0 [ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery. 2017-11-15T11:54:17.696535+08:00 0 [ERROR] InnoDB: Page [page id: space=40, page number=2] log sequence number 3724576 is in the future! Current system log sequence number 2440232. 2017-11-15T11:54:17.696551+08:00 0 [ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery. 2017-11-15T11:54:17.697469+08:00 0 [ERROR] InnoDB: Page [page id: space=32, page number=3] log sequence number 2483079 is in the future! Current system log sequence number 2440232. 2017-11-15T11:54:17.697485+08:00 0 [ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery. 2017-11-15T11:54:17.697809+08:00 0 [ERROR] InnoDB: Page [page id: space=32, page number=1] log sequence number 2479069 is in the future! Current system log sequence number 2440232. 2017-11-15T11:54:17.697821+08:00 0 [ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery. 2017-11-15T11:54:17.698049+08:00 0 [ERROR] InnoDB: Page [page id: space=32, page number=2] log sequence number 2482784 is in the future! Current system log sequence number 2440232. 2017-11-15T11:54:17.698061+08:00 0 [ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery. 2017-11-15T11:54:17.700092+08:00 0 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode. 2017-11-15T11:54:17.700140+08:00 0 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode. 2017-11-15T11:54:17.700153+08:00 0 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode. 2017-11-15T11:54:17.701714+08:00 0 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode. 2017-11-15T11:54:17.701727+08:00 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode. 2017-11-15T11:54:17.701881+08:00 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode. 2017-11-15T11:54:17.702485+08:00 0 [ERROR] InnoDB: Page [page id: space=46, page number=3] log sequence number 3754946 is in the future! Current system log sequence number 2440232. 2017-11-15T11:54:17.702502+08:00 0 [ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery. 2017-11-15T11:54:17.702718+08:00 0 [ERROR] InnoDB: Page [page id: space=46, page number=1] log sequence number 3751039 is in the future! Current system log sequence number 2440232. 2017-11-15T11:54:17.702741+08:00 0 [ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery. 2017-11-15T11:54:17.702962+08:00 0 [ERROR] InnoDB: Page [page id: space=46, page number=2] log sequence number 3754946 is in the future! Current system log sequence number 2440232. 2017-11-15T11:54:17.702974+08:00 0 [ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery.
按照報錯信息,數據庫也是無法回滾到之前一致性狀態,有丟數據風險
總結
一般來說,mysql有壞塊或者服務器異常關機
解決方法
1、在my.cnf里設置innodb_force_recovery=1 ,如果1不行改成2,最大是6 ,然后啟動mysql, 將數據dump出來再 導入到新的實例
2、根據主鍵id ,逐個區間去導出,用mysqldump -w where條件,再導入到新實例
innodb_force_recovery影響整個innodb存儲引擎的恢復狀況,該值默認為0,表示當需要恢復時,需要執行所有的恢復操作,當不能進行有效恢復時,如數據頁發生了corruption,mysql數據庫可能宕機,並把錯誤寫入錯誤日志中。
innodb_force_recovery=6表示mysql數據庫已經有比較嚴重的損壞,就算把數據dump出來也不能保證dump出來的數據是沒有問題的
最后建議選擇第一個解決辦法修改innodb_force_recovery的方法來恢復mysql,而不要選擇第二個辦法