码迷,mamicode.com
首页 > 数据库 > 详细

Innodb数据库损坏导致mysql锁死

时间:2020-01-12 09:58:13      阅读:81      评论:0      收藏:0      [点我收藏+]

标签:hal   setting   ssi   var   info   killall   ras   ash   page   

问题
MySQL自3.23.58版本以后,提供了名为InnoDB的引擎提供存储过程等功能
当服务器发生意外断电等错误的时候,可能导致innodb锁死
用top命令查看,发现mysqld进程占用cpu达到100%并无法正常启动、关闭

070316 12:30:43 mysqld started
070316 12:30:43 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
070316 12:30:43 InnoDB: Starting log scan based on checkpoint at
InnoDB: log sequence number 0 2347685.
InnoDB: Doing recovery: scanned up to log sequence number 0 2347685
070316 12:30:43 InnoDB: Error: page 4 log sequence number 0 1516429185
InnoDB: is in the future! Current system log sequence number 0 2347685.
InnoDB: Your database may be corrupt.

解决方案
首先要彻底杀掉所有运行的mysql进程,并暂时停止web服务器,以免再次出发mysql的调用
/etc/init.d/httpd stop
killall -9 mysqld
killall -9 mysqld_safe

现在用ps awxuf命令确认没有mysql相关进程在运行了
到/var/lib/mysql目录下,找到ibdata1、ib_logfile0、ib_logfile1等几个文件,将其改名或者移动走
执行/etc/init.d/mysqld restart重新启动mysqld

这时候再查看log,就会发现innodb的引擎会重建出错的文件
070316 12:41:35 mysqld started
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
070316 12:41:35 InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
070316 12:41:35 InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
070316 12:41:35 InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
070316 12:41:36 InnoDB: Started; log sequence number 0 0
/usr/libexec/mysqld: ready for connections.
Version: ‘4.1.12‘ socket: ‘/var/lib/mysql/mysql.sock‘ port: 3306 Source distribution

现在可以通过top命令确认mysqld是否正常运行。

执行/etc/init.d/httpd start正常启动web服务,并观察mysql是否正常,一般故障可以解决

注意:如果想禁用innodb的功能,可以在/etc/my.cnf里边的[mysqld]部分中,加入如下一行:
skip-innodb
然后重启mysqld服务,即可禁用innodb 。
但是不推荐禁用,如果部分mysql程序调用了存储过程,那么就无法工作了。

Innodb数据库损坏导致mysql锁死

标签:hal   setting   ssi   var   info   killall   ras   ash   page   

原文地址:https://www.cnblogs.com/sfqas/p/12181825.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!