我们有一个在Linux上运行InnoDB的MySql 5.5数据库。 一个表(名为table_search)正在运行MyISAM,以便能够执行全文search。 该表有823 368行。
昨天我们有一个服务器崩溃,为了恢复它,我们将原始数据移动到一个新的服务器,现在我们正在运行在新的服务器上。
它起初工作正常,但一小时后,我们在错误日志中得到了类似的东西:
1. Duplicate entry 'XYZ' for key index_titles (where index_titles is an index in table_search) 2. After this there where lots of errors: Incorrect key file for table './database/table_search.MYI'; try to repair it 3. After this there where lots of errors: Table './database/table_search' is marked as crashed and should be repaired
我们尝试使用以下方法修复它:
myisamchk table_search.MYI
我们得到这样的错误:
myisamchk: error: Keypointers and record positions doesn't match MyISAM-table 'table_search.MYI' is corrupted
然后我们试着:
myisamchk -r -o table_search.MYI
现在一切都恢复正常了,直到一个小时前,同样的事情又发生了。 所以我们再次使用myisamchk,它正在工作。
但它再次发生并不稳定。 我们可以做些什么来确保它不会再发生? 为什么会损坏? 解决办法是什么?
解决scheme是另外一回事。 我们已经使用以下命令重新启动服务
ft_min_word_len=3
(抱歉在这个问题中没有提到这个)
通过MySql的这个文档,我们了解到:
如果使用myisamchk执行修改表索引(例如修复或分析)的操作,则除非另行指定,否则将使用缺省全文参数值(最小和最大字长以及停用词文件)重buildFULLTEXT索引。 这可能会导致查询失败。
这是解决scheme:
shell> myisamchk --recover --ft_min_word_len=3 table_search.MYI
现在服务器已经运行了近24小时。
这听起来像是你的表损坏了,超出了myisamchk能够恢复的范围。
我想你最好的尝试是从备份恢复表,或者,如果只有您的search索引受到影响,重新创build并重新填充此表。