专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »数据库 » innodb修复:InnoDB 中文参考手册 --- 15 故障检测与修复 »正文

innodb修复:InnoDB 中文参考手册 --- 15 故障检测与修复

来源: 发布时间:星期五, 2008年9月26日 浏览:51次 评论:0
InnoDB 中文参考手册 --- 犬犬(心帆)翻译

15 故障检测与修复

  • 一个普遍的规则就是当一个操作挫败或你怀疑是一个 bug,你必须查看 MySQL 服务程序 mysqld 的错误日志(error log),通常命名为 \'hostname\'.err,或 Windows 下的 mysql.err
  • 当进行故障检测并修复时,在命令提示符下运行 MySQL 服务程序 mysqld 是一个较好的方式,不要通过 safe_mysqld 的包装(wrapper)或以 Windows 服务启动。你可以看到 mysqld 在命令提示符窗口上的显示,而可以更好地把握什么将要发生。在 Windows 下,你必须以 --console 选项运行 mysqld-max 来使输出直接显示在 MS-DOS 提示符窗口上。
  • 如果问题与性能有关(performance-related),或你的服务看起来将要挂起,你可以使用 innodb_monitor 来显示 InnoDB 内部状态的相关信息。如果问题是由于锁定引起,使用 innodb_lock_monitor。如果问题是在建表时或其它的数据字典操作,使用 innodb_table_monitor 显示 InnoDB 内部数据字典的内容。
  • 如果你怀疑表已损坏,在表上运行 CHECK TABLE

15.1 发现并修复数据字典错误的操作

一个特殊的有关表的问题就是 MySQL 在它自己的数据目录下的 .frm 文件中保存它自己的数据字典信息,然而 InnoDB 将它自己的信息保存在数据文件中 InnoDB 自己的数据字典中。如果你在外部移走了 .frm 文件,或在 MySQL < 3.23.44 的版本中使用了 DROP DATABASE ,或在数据字典操作时服务器崩溃了,那么 .frm 文件可能会因与 InnoDB 内部的数据字典 out-of-sync 而结束。

与数据字典 out-of-sync 的一个故障现象就是 CREATE TABLE 语句的调用失败。那么你必须查看错误日志。如果错误述说为表在 InnoDB 内部数据字典中已存在,那么一定在 InnoDB 的数据文件中存在一个孤表(orphaned table),没有相对应的 .frm 文件。

InnoDB: Error: table test/parent already exists in InnoDB internal InnoDB: data dictionary. Have you deleted the .frm file InnoDB: and not used DROP TABLE? Have you used DROP DATABASE InnoDB: for InnoDB tables in MySQL version <= 3.23.43? InnoDB: See the Restrictions section of the InnoDB manual. InnoDB: You can drop the orphaned table inside InnoDB by InnoDB: creating an InnoDB table with the same name in another InnoDB: database and moving the .frm file to the current database. InnoDB: Then MySQL thinks the table exists, and DROP TABLE will InnoDB: succeed. 
你可以跟从上面错误日志中的提示移除(drop)孤表(orphaned table)。

 

另一个与数据字典 out-of-sync 的故障现象就是 MySQL 提示不能打开一个文件 yourtablename.InnoDB 的错误。

ERROR 1016: Can\'t open file: \'child2.InnoDB\'. (errno: 1) 
在错误日志中可以发现:
InnoDB: Cannot find table test/child2 from the internal data dictionary InnoDB: of InnoDB though the .frm file for the table exists. Maybe you InnoDB: have deleted and recreated InnoDB data files but have forgotten InnoDB: to delete the corresponding .frm files of InnoDB tables? 
意思就是有一个孤的(orphaned) .frm 文件,在 InnoDB 中没有相应的表与之对应。可以通过手工删除 .frm 文件来移除它。

 

如果在一个 ALTER TABLE 操作时 MySQL 崩溃了,你可能会因在 InnoDB 表空间在存在一个孤的临时表而告终。通过 innodb_table_monitor ,你可以发现一个名为 #sql... 的表,但是 MySQL 不允许访问任何一个如此命名的表,你将不能转储(dump)或移除(drop)它。解决办法就是使用从 3.23.48 开始 InnoDB 支持的一个特殊的机制。

如果在表空间内存在一个孤表(orphaned table)

相关文章

读者评论

  • 共0条 分0页

发表评论

  • 昵称:
  • 内容: