温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

mysql innodb异常如何处理

发布时间:2023-05-10 09:12:19 来源:亿速云 阅读:148 作者:zzz 栏目:MySQL数据库

这篇文章主要讲解了“mysql innodb异常如何处理”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“mysql innodb异常如何处理”吧!

一、回退重新装mysql

为避免再从其他地方导入这个数据的麻烦,先对当前库的数据库文件做了个备份(/var/lib/mysql/位置)。接下来将Percona server 5.7包进行了卸载,重新安装原先老的5.1.71的包,启动mysql服务,提示Unknown/unsupported table type: innodb,无法正常启动。

110509 12:04:27 InnoDB: Initializing buffer pool, size = 384.0M
110509 12:04:27 InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 157286400 bytes!
110509 12:04:27 [ERROR] Plugin 'InnoDB' init function returned error.
110509 12:04:27 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
110509 12:04:27 [ERROR] Unknown/unsupported table type: innodb
110509 12:04:27 [ERROR] Aborting
110509 12:04:27 [Note] /usr/sbin/mysqld: Shutdown complete

删除/var/lib/mysql/目录,重新启动数据库服务,并初始化,发现正常,show engines能发现有innodb引擎。再将数据库停掉,将之前备份的/var/lib/mysql/目录的内容覆盖当前位置的内容,重启。又发现不能进行启动,报错内容和刚刚一样。

/var/lib/mysql目录内容的结构如下:

-rw-rw---- 1 mysql mysql 10485760 2月 26 18:10 ibdata1
-rw-rw---- 1 mysql mysql 5242880 2月 26 18:10 ib_logfile0
-rw-rw---- 1 mysql mysql 5242880 2月 26 17:20 ib_logfile1
drwx------ 2 mysql mysql 4096 2月 26 17:20 mysql
drwx------ 2 mysql mysql 4096 2月 26 17:24 wiki

wiki目录是测试数据的库,ibdata1文件为数据文件,ib开头的两个文件为日志文件,mysql 目录下为系统库相关的东西 。再次使用初始化的数据,并将wiki目录和ibdata1文件覆盖到/var/lib/mysql 目录下,可以正常启动,也可以正常登录。

二、innodb模块重装

不过在通过mysqldump备份时,又提示unknow table engine “Innodb” 。登录后,查看当前所有的引擎类型,发现其中果然不存在innodb类型:

mysql innodb异常如何处理

通过alter命令修改其中一个表的类型为MyISAM ,发现仍然报错。

mysql innodb异常如何处理

通过 find 查找发现/usr/lib64/mysql/plugin/目录下有ha_innodb_plugin.so文件。印象中mysql5以后的版本支持在线插件安装 。通过下面查看确认,果然支持:

mysql innodb异常如何处理

使用如下命令加载时,发现不成功:

install plugin innodb soname 'ha_innodb.so';
三、备份

在/etc/my.cnf中增加如下配置:

plugin-load=innodb=ha_innodb_plugin.so
plugin_dir=/usr/lib64/mysql/plugin/
default-storage-engine=InnoDB

发现仍启动失败。查看mysql-error.log发现有如下内容:

InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 7.
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.1/en/forcing-innodb-recovery.html

打开forcing-innodb-recovery官方页面,发现可以通过指定innodb_force_recovery参数,进行强制启动和恢复。在/etc/my.cnf中增加如下内容:

innodb_force_recovery=6

重新启动成功了。通过mysqldump备份也没有问题,将备份数据导入其他主机发现也正常可以测试。

这下就好搞了,将mysql彻底删除,重新安装Percona server 5.7,安装完后,建库,还原数据,程序重新连接,一切OK。

感谢各位的阅读,以上就是“mysql innodb异常如何处理”的内容了,经过本文的学习后,相信大家对mysql innodb异常如何处理这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI