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

来源:互联网 发布:淘宝联盟为什么要认证 编辑:程序博客网 时间:2024/04/27 19:25
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

InnoDB中文参考手册---犬犬(心帆)翻译

15故障检测修复

一个普遍的规则就是当一个操作挫败或你怀疑是一个bug,你必须查看服务程序mysqld的错误日志(errorlog),通常命名为'hostname'.err,或Windows下的mysql.err。

 当进行故障检测修复时,在命令提示符下运行MySQL服务程序mysqld是一个较好的方式,不要通过safe_mysqld的包装(wrapper)或以Windows服务启动。你可以看到mysqld在命令提示符窗口上的显示,而可以更好地把握什么将要发生。在Windows下,你必须以--console选项运行mysqld-max来使输出直接显示在MS-提示符窗口上。

 如果问题与性能有关(performance-related),或你的服务看起来将要挂起,你可以使用InnoDB_monitor来显示InnoDB内部状态的相关信息。如果问题是由于锁定引起,使用InnoDB_lock_monitor。如果问题是在建表时或其它的数据字典操作,使用InnoDB_table_monitor显示InnoDB内部数据字典的内容。如果你怀疑表已损坏,在表上运行CHECKTABLE。

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

与数据字典out-of-sync的一个故障现象就是CREATETABLE语句的调用失败。那么你必须查看错误日志。如果错误述说为表在InnoDB内部数据字典中已存在,那么一定在InnoDB的数据文件中存在一个孤表(orphanedtable),没有相对应的.frm文件。
InnoDB:Error:tabletest/parentalreadyexistsinInnoDBinternalInnoDB:datadictionary.Haveyoudeletedthe.frmfileInnoDB:andnotusedDROPTABLE?HaveyouusedDROPDATABASEInnoDB:forInnoDBtablesinMySQLversion<=3.23.43?InnoDB:SeetheRestrictionssectionoftheInnoDBmanual.InnoDB:YoucandroptheorphanedtableinsideInnoDBbyInnoDB:creatinganInnoDBtablewiththesamenameinanotherInnoDB:databaseandmovingthe.frmfiletothecurrentdatabase.InnoDB:ThenMySQLthinksthetableexists,andDROPTABLEwillInnoDB:succeed.
你可以跟从上面错误日志中的提示移除(drop)孤表(orphanedtable)。
 

另一个与数据字典out-of-sync的故障现象就是MySQL提示不能打开一个文件yourtablename.InnoDB的错误。
ERROR1016:Can'topenfile:'child2.InnoDB'.(errno:1)
在错误日志中可以发现:
InnoDB:Cannotfindtabletest/child2fromtheinternaldatadictionaryInnoDB:ofInnoDBthoughthe.frmfileforthetableexists.MaybeyouInnoDB:havedeletedandrecreatedInnoDBdatafilesbuthaveforgottenInnoDB:todeletethecorresponding.frmfilesofInnoDBtables?
意思就是有一个孤的(orphaned).frm文件,在InnoDB中没有相应的表与之对应。可以通过手工删除.frm文件来移除它。
 

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

如果在表空间内存在一个孤表(orphanedtable)#sql...,那么调用1<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击