首页 > 数据库 >mysql突然断电,无法启动问题, redo log 无法恢复 mysqld启动不了 Plugin 'InnoDB' init function returned error 找到

mysql突然断电,无法启动问题, redo log 无法恢复 mysqld启动不了 Plugin 'InnoDB' init function returned error 找到

时间:2023-08-07 09:36:05浏览次数:27  
标签:03 log 启动 21T05 30 InnoDB ib redo

环境:CentOS 7.x、MySQL 5.7

其实造成这种问题的原因有很多种,但是不管是什么问题,最终的原因一般是 redo log 造成的问题。

为什么说是 redo log 造成的呢,因为 redo log 对应的文件就是两个 ib_logfile 开头的文件:ib_logfile0、ib_logfile1;下面的问题都是和 ib_logfile 有关。
MySQL 引擎的具体原理,这里暂不深究了,等后续再详细整理。

下面是实际遇到的造成 InnoDB 引擎不能启动的场景:

由于测试环境经常折腾,对于下面的场景而言,更多的是测试环境出现的问题;生产的话一般操作很谨慎,也不会频繁关机,所以还没有在生产上折腾过。

场景一:服务器突然重启,未正常关闭 MySQL
在测试环境中,服务器直接强制断电(Power Off),并没有手动的关闭 MySQL,再次启动的时候就会发生这样的问题。

2023-03-21T05:30:22.710453Z 0 [ERROR] InnoDB: Ignoring the redo log due to missing MLOG_CHECKPOINT
between the checkpoint 9156630714 and the end 9156630528.
2023-03-21T05:30:22.710511Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2023-03-21T05:30:23.311477Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2023-03-21T05:30:23.311521Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2023-03-21T05:30:23.311534Z 0 [ERROR] Failed to initialize plugins.
2023-03-21T05:30:23.311542Z 0 [ERROR] Aborting
1
2
3
4
5
6
7
问题的主要原因:

InnoDB: Ignoring the redo log due to missing MLOG_CHECKPOINT between the checkpoint 9156630714 and the end 9156630528.
# InnoDB:忽略重做日志,因为检查点 9156630714 和结束 9156630528 之间缺少 MLOG_CHECKPOINT。
1
2
场景二:服务器正常关机关不掉,然后强制 kill 掉 MySQL 进程
就说巧不巧吧,再测试环境中,上面是直接断电有问题,然而本想正常关机,结果也不行;MySQL 一直卡在那里,尝试 kill 还是无法停止,无奈只好 kill -9 (强制退出)掉 MySQL。

服务器启动后,开始启动 MySQL,然后报错如下:

2023-03-21T05:30:22.710511Z InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
2023-03-21T05:30:22.710511Z InnoDB: than specified in the .cnf file 0 104857600 bytes!
2023-03-21T05:30:22.710511Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2023-03-21T05:30:23.311477Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2023-03-21T05:30:23.311521Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2023-03-21T05:30:23.311534Z 0 [ERROR] Failed to initialize plugins.
2023-03-21T05:30:23.311542Z 0 [ERROR] Aborting
1
2
3
4
5
6
7
主要原因:

InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 104857600 bytes!

# 看问题是因为 ib_logfile0 实际的大小 5242880 与 cnf 文件中指定的 104857600 不一致;
# 大概率是丢数据造成的。
1
2
3
4
5
解决方案
看错误是 redo log 有问题;如果不知道这个日志文件存放在哪里,可以全局搜索一下:

# 从根目录开始搜索 ib_logfile 开头的文件
find ./ -name ib_logfile*

./var/lib/mysql/ib_logfile1
./var/lib/mysql/ib_logfile0


# 在 /var/lib/mysql 目录下;将文件改个名字备份一下
cd /var/lib/mysql
mv ib_logfile0 ib_logfile0.bak
mv ib_logfile1 ib_logfile1.bak


# 启动 mysql
systemctl start mysqld
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
【注】直接删除 ib_logfile 文件,可能会造成部分数据丢失,建议操作之前先备份一下;万一出问题还能进行一下还原。


标签:03,log,启动,21T05,30,InnoDB,ib,redo
From: https://www.cnblogs.com/ruiy/p/17610612.html

相关文章

  • linux启动服务配置详解
    init进程是所有进程的发起者和控制者。因为在任何基于Unix的系统(比如 linux)中,它都是第一个运行的进程,所以init进程的编号(ProcessID,PID)永远是1。如果init出现了问题,系统的其余部分也就随之而垮掉了。init服务init进程是所有进程的发起者和控制者。因为......
  • PostgreSQL-unlogged table
    PostgreSQL中,有一种表的类型为unloggedtable,该种类型的表不会写入wal日志中,所以在写入的速度上比普通的堆表快很多,但是该表在数据库崩溃的时候,会被truncate,数据会丢失,而且该表也不支持流复制,所以在standby节点是无法查到该表数据的。在该表上创建的索引也是unlogged索引。创建un......
  • error log1
    errorlog1 #AfatalerrorhasbeendetectedbytheJavaRuntimeEnvironment:##SIGSEGV(0xb)atpc=0x00007f6dfd313cb0,pid=47650,tid=47655##JREversion:Java(TM)SERuntimeEnvironment(17.0.8+9)(build17.0.8+9-LTS-211)#JavaVM:JavaHotSpot......
  • Python logging模块怎么使用,你会了吗?
    Pythonlogging模块使用在开发和维护Python应用程序时,日志记录是一项非常重要的任务。Python提供了内置的logging模块,它可以帮助我们方便地记录应用程序的运行时信息、错误和调试信息。本文将介绍如何使用Pythonlogging模块进行日志记录。logging模块logging是Python自带的用于记......
  • 在macOS上启动AutoCAD软件时显示“许可检出超时“的解决方法
    Macos上使用AutoCAD时,弹出茶品许可超市,AutoCAD即将关闭的情况怎么办呢,到底是哪里出现了问题呢?不妨试试下面这种方法。AutoCAD204forMac最新安装Issue:在macOS上启动Autodesk软件产品时,显示类似以下内容的消息,且程序必须关闭:产品许可证-超时许可检出超时。您要执行什么......
  • centos7安装后无法启动
    1、Centos7开机无法正常启动?2、centos7虚拟机进不去一直ok3、服务器centos7开机卡住Centos7开机无法正常启动?kernelpanic该主机硬件不兼容该系统请更换其他版本系统尝试安装。CentOS是免费的、开源的、可以重新分发的开源操作系统,CentOS(CommunityEnterpriseOperati......
  • docker容器中tomcat启动out of memory
    docker容器中tomcat启动outofmemory宿主机KylinV10容器centos7tomcat启动报错libraryinitializationfailed-unabletoallocatefiledescriptortable-outofmemory宿主机ulimit-n65535容器内ulimit-n1073741816解决方案容器内修改/etc/profile添......
  • SQLServer 2000 服务不能启动的多种解决办法43.240.156.X
    一、在服务器上以管理员帐户登录操作系统。43.240.156.2二、尝试通过操作系统中的服务来启动SQLServer服务:43.240.156.3  1、在“我的电脑”上点击右键,选择“管理”菜单。43.240.156.4  2、在“计算机管理”程序中,依次展开服务和应用程序->服务。43.240.156.5  3、......
  • nvidia-docker启动容器报错 Unknown runtime specified nvidia
    使用nvidia-docker创建容器时报错:Errorresponsefromdaemon:Unknownruntimespecifiednvidia.See'dockerrun--help'.主要原因在于配置docker镜像时,daemon.json文件被修改了。只要添加对应内容即可。vim /etc/docker/daemon.json原文件:{"registry-mirr......
  • 查看bin_log是否状态
    showVARIABLESlike'%expire%';showVARIABLESlike'%log_bin%';......