免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 156513 | 回复: 4
打印 上一主题 下一主题

MYSQL启动后报:ERROR! The server quit without updating PID file错误的问题解决 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-06-10 13:53 |只看该作者 |倒序浏览
单位上周末施工,测试服务器断电两天,今天用到了数据库,启动数据库的时候,出现了很奇怪的问题
[root@dev run]# service mysql restart
ERROR! MySQL server PID file could not be found!
Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/run/mysql.pid).

无法启动mysql,后来上网找了一下解决方法,无非就是以下几种

1. 注释/etc/my.cnf里的skip-federated注释掉即#skip-federated;
2. my.cnf文件配置过高,重新定义其中的参数(根据服务器情况定义);
3. 杀掉mysql_safe和mysqld进程,然后再重启;
4. 当前日志文件过大,超出了my.cnf中定义的大小(默认为64M),删除日志文件再重启;

但是在主机中:

1.        注释中无skip-federated这个选项
2.        My.cnf是自己优化过的,断电之前正常使用,不是这个的问题
3.        Ps –ef | grep mysql  根本就没有mysql的僵尸进程
4.        没有这个问题
基本上网上的所有方式都试过了,都无法解决问题,然后我就打开了error.log,发现了
有些奇怪的地方 vi /var/lib/mysql/log/error.log

2014-06-10 11:52:46 15921 [Note] InnoDB: Database was not shutdown normally!
2014-06-10 11:52:46 15921 [Note] InnoDB: Starting crash recovery.
2014-06-10 11:52:46 15921 [Note] InnoDB: Reading tablespace information from the .ibd files...
2014-06-10 11:52:46 15921 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace raildb/base_company_fullname uses space ID: 4 at filepath: ./raildb/base_company_fullname.ibd. Cannot open tablespace mysql/slave_master_info which uses space ID: 4 at filepath: ./mysql/slave_master_info.ibd
2014-06-10 11:52:46 7ff29246d720  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 ./mysql/slave_master_info.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.
140610 11:52:46 mysqld_safe mysqld from pid file /var/lib/mysql/run/mysql.pid ended

第一处标黄,提示是数据库没有正常关闭
第二处标蓝,提示正在从.ibd files读取tablespace information
第三处标红,就是开始error的地方,大概意思就是读取不到raildb这个库的tablespace
下边说的就是一些处理这个问题的方法,就不一一翻译了

最后我感觉是因为断电之前,mysql没有正常关闭,造成了raildb这个库的一些异常,我采用的解决方法是在innoDB,强制覆盖

Vi /etc/my.cof  增加一行      innodb_force_recovery= 1


然后删除log里边的mysql-bin.index 这个文件           rm -rf mysql-bin.index

之后重启mysql
[root@dev log]# service mysql restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.. SUCCESS!

OH YE!

但是至今我还是有些不解,到底是什么原因造成的这个问题,断电?我不是专门搞数据库的,还希望有人能传授一些经验

论坛徽章:
0
2 [报告]
发表于 2014-06-10 22:09 |只看该作者
机器非正常关闭,数据库文件损坏或丢失,正常现象。
数据库重启时发现上次没有正常关闭,就会启动 crash recovery
走到其中一步执行不下去了,就要使用innodb_force_recovery,从1试到6,能启动起来的话就赶紧导出数据吧

system error 是2 表示找不到文件或目录

论坛徽章:
0
3 [报告]
发表于 2014-06-11 09:15 |只看该作者
回复 2# 逸馆小菜鸟
既然能启动了,为何还要备份数据库?难道还要重装一遍mysql么?

   

论坛徽章:
0
4 [报告]
发表于 2014-06-11 10:31 |只看该作者
innodb_force_recovery是出问题的时候用的,不是说你加上它正常启动了,就一直用着了。
innodb_force_recovery跳过了启动时crash recovery的部分步骤才启动起来的,实际上你数据库中有些数据是有问题的,可能只是极小极小的一点数据吧

论坛徽章:
0
5 [报告]
发表于 2014-06-11 13:48 |只看该作者
回复 4# 逸馆小菜鸟


  那我备份出来的岂不是也是有错误的数据。。。这个问题是mysql的问题,还是说里边数据的问题呢?希望不吝赐教啊~  
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP