innodb_force_recovery
mysql 启动报错
InnoDB: Page may be an index page where index id is 8005
InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 84692.
InnoDB: You may have to recover from a backup.
InnoDB: It is also possible that your operating
InnoDB: system has corrupted its own file cache
InnoDB: and rebooting your computer removes the
InnoDB: error.
InnoDB: If the corrupt page is an index page
InnoDB: you can also try to fix the corruption
InnoDB: by dumping, dropping, and reimporting
InnoDB: the corrupt table. You can use CHECK
InnoDB: TABLE to scan your table for corruption.
InnoDB: See also http://dev.mysql.com/doc/refman/5.6/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
InnoDB: Ending processing because of a corrupt database page.
page 已经存在损坏,需要修改innodb_force_recovery=1(通常设置为1),使mysqld跳过恢复步骤,启动后马上逻辑导出数据,重新初始化后再导入。
innodb_force_recovery可以设置为1-6,大的数字包含前面所有数字的影响。
- (SRV_FORCE_IGNORE_CORRUPT):忽略检查到的corrupt页。
- (SRV_FORCE_NO_BACKGROUND):阻止主线程的运行,如主线程需要执行full purge操作,会导致crash。
- (SRV_FORCE_NO_TRX_UNDO):不执行事务回滚操作。
- (SRV_FORCE_NO_IBUF_MERGE):不执行插入缓冲的合并操作。
- (SRV_FORCE_NO_UNDO_LOG_SCAN):不查看重做日志,InnoDB存储引擎会将未提交的事务视为已提交。
- (SRV_FORCE_NO_LOG_REDO):不执行前滚的操作。
注意
当设置参数值大于0后,可以对表进行select,create,drop操作,但insert,update或者delete这类操作是不允许的。
innodb_purge_threads
设置 innodb_force_recovery 为非0后,需要设置下 innodb_purge_thread=0
innodb_force_recovery=1
innodb_purge_thread=0
参考
https://dev.mysql.com/doc/refman/8.0/en/forcing-innodb-recovery.html
https://dev.mysql.com/doc/refman/8.0/en/innodb-parameters.html#sysvar_innodb_force_recovery
https://dev.mysql.com/doc/refman/8.0/en/innodb-parameters.html#sysvar_innodb_purge_threads