机房停电导致mysql启动不起来

报错

2021-06-03 15:12:36 45183 [Note] Plugin 'FEDERATED' is disabled.
2021-06-03 15:12:36 45183 [Note] InnoDB: Using atomics to ref count buffer pool pages
2021-06-03 15:12:36 45183 [Note] InnoDB: The InnoDB memory heap is disabled
2021-06-03 15:12:36 45183 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-06-03 15:12:36 45183 [Note] InnoDB: Memory barrier is not used
2021-06-03 15:12:36 45183 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-06-03 15:12:36 45183 [Note] InnoDB: Using Linux native AIO
2021-06-03 15:12:36 45183 [Note] InnoDB: Using CPU crc32 instructions
2021-06-03 15:12:36 45183 [Note] InnoDB: Initializing buffer pool, size = 512.0M
2021-06-03 15:12:37 45183 [Note] InnoDB: Completed initialization of buffer pool
2021-06-03 15:12:37 45183 [Note] InnoDB: Highest supported file format is Barracuda.
2021-06-03 15:12:37 45183 [Note] InnoDB: The log sequence numbers 1203350238 and 1203350238 in ibdata files do not match the log sequence number 1210486286 in the ib_logfiles!
2021-06-03 15:12:37 45183 [Note] InnoDB: Database was not shutdown normally!
2021-06-03 15:12:37 45183 [Note] InnoDB: Starting crash recovery.
2021-06-03 15:12:37 45183 [Note] InnoDB: Reading tablespace information from the .ibd files...
2021-06-03 15:12:37 45183 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace duoshanghu/promotion_discount_goods uses space ID: 295 at filepath: ./duoshanghu/promotion_discount_goods.ibd. Cannot open tablespace gzhgl/hjmall_action_log which uses space ID: 295 at filepath: ./gzhgl/hjmall_action_log.ibd
2021-06-03 15:12:37 2b82c2fadcc0 InnoDB: Operating system error number 2 in a file operation.
InnoDB: The error means the system cannot find the path specified.
InnoDB: If you are installing InnoDB, remember that you must create
InnoDB: directories yourself, InnoDB does not create them.
InnoDB: Error: could not open single-table tablespace file ./gzhgl/hjmall_action_log.ibd
InnoDB: We do not continue the crash recovery, because the table may become
InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.
InnoDB: To fix the problem and start mysqld:
InnoDB: 1) If there is a permission problem in the file and mysqld cannot
InnoDB: open the file, you should modify the permissions.
InnoDB: 2) If the table is not needed, or you can restore it from a backup,
InnoDB: then you can remove the .ibd file, and InnoDB will do a normal
InnoDB: crash recovery and ignore that table.
InnoDB: 3) If the file system or the disk is broken, and you cannot remove
InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf
InnoDB: and force InnoDB to continue crash recovery here.

修改

my.ini中加入

innodb_force_recovery = 1

启动后,值改为0

注:

  • 1 (SRV_FORCE_IGNORE_CORRUPT):   即使服务器检测到损坏的页仍让它运行。试图使SELECT* FROM tbl_name跳过损坏的索引记录和页,这样有助于转储表。
  • 2 (SRV_FORCE_NO_BACKGROUND):   阻止主线程和任何清除线程的运行。如果崩溃会在清除操作中发生,该恢复值会阻止它。
  • 3 (SRV_FORCE_NO_TRX_UNDO):         不要在崩溃恢复后运行事务回滚。
  • 4 (SRV_FORCE_NO_IBUF_MERGE):      阻止插入缓冲合并操作。如果它们会导致崩溃,不要做这些。不计算表统计。这个值可以永久损坏数据文件。使用这个值后,准备号删除并重建所有辅助索引。在MySQL5.6.15中,设置InnoDB为只读。
  • 5(SRV_FORCE_NO_UNDO_LOG_SCAN):在启动数据库时不查看撤消日志:InnoDB将即使未完成的事务也作为已提交。这个值可以永久损坏数据文件。在MySQL5.6.15中,设置InnoDB为只读
  • 6(SRV_FORCE_NO_LOG_REDO):          不要通过恢复对重做日志进行前滚。这个值可能永久损坏数据文件。数据库页被留在一个陈旧的状态,这反过来又可能带给B-trees和其它数据库结构更多的损坏。在MySQL5.6.15中,设置InnoDB为只读。

 

警告

只有在紧急情况下将innodb_force_recovery设为大于0的值,你才能启动InnoDB并转储表。在进行此操作之前,确保你有数据库的备份副本,以备需要重建它。4及以上的值可以永久破坏数据文件。只有在数据库的独立物理副本的成功地测试了设置,才能在生产服务器实例使用4及以上的innodb_force_recovery设置。当强制InnoDB恢复,你应该总是以innodb_force_recovery=1启动,且仅在需要时增加值。

innodb_force_recovery默认为0(没有强制恢复的正常启动)。对于innodb_force_recovery允许的非零值是1至6。较大值包括较小值的功能

posted @ 2021-06-03 15:22  叫我亚庆  阅读(278)  评论(0)    收藏  举报