mysql innodb 修复_Mysql入门mysql innodb 异常修复经验分享

文章目录

[隐藏]

一、回退重新装mysql

二、innodb模块重装

三、备份

一套测试用的mysql库,之前用的centos6默认源里的mysql 5.1.71的版本 .后来想试用下Percona server 5.7,由于这套库里没有什么重要数据 .所以操作前也未进行备份,配置好源后,直接就进行了安装.数据文件也存放在默认位置,安装完成后,直接启动mysql,发现启动失败,发现无法启动正常启动.

一、回退重新装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类型:

ac3d7d4a89cce777ccb09e8275589519.png

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

6c4000d98c2d4a1a53a5f06e1036fb71.png

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

0ccb676925fb19dffad6bf7b38661c62.png

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

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数据文件的特性,可以在出现问题,无法正常启动时,先将./ib_logfile0 和 ./ib_logfile1 两个日志文件先移走,再启动,如果还不成功,可以用innodb_force_recovery参数进行强制恢复.除此之外,日志也很重启,有问题先看日志.

原文出处:vephp -> http://www.vephp.com/jiaocheng/1656.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值