MySQL innodb 从数据文件恢复

MySQL innodb 从数据文件恢复

昨晚,我的 MySQL 服务器崩溃了,现在我有几个数据库,其中的数据无法恢复。

根据错误日志,表空间的损坏发生已经有一段时间了(几个月了),但是没有人注意到,而昨天,当 MySQL 崩溃时(完全不同的原因),它只是无法启动并出现以下错误:

2015-06-09 23:09:23 14642 [Note] InnoDB: Starting crash recovery.
2015-06-09 23:09:23 14642 [Note] InnoDB: Reading tablespace information from the .ibd files...
2015-06-09 23:09:24 14642 [ERROR] InnoDB: Tried to read 16384 bytes at offset 0. Was only able to read 0.
2015-06-09 23:09:24 7f648369a7e0  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.
2015-06-09 23:09:24 14642 [ERROR] InnoDB: File (unknown): 'read' returned OS error 71. Cannot continue operation

当数据库启动时innodb-force-recovery设置为 6,服务器启动时,错误日志中出现大量此类消息:

2015-06-09 23:16:50 16659 [ERROR] InnoDB: Failed to find tablespace for table '"db1234"."tbl456"' in the cache. Attempting to load the tablespace with space id 275772.

我设法转储了大多数数据库并将它们导入到干净的数据目录中。但有些数据库的表空间已损坏,我无法转储它们(甚至无法打开其中的任何表)。

因此,现在我有几个(大约一百个)数据库无法加载到实时 MySQL 服务器中。我有它们的数据文件(.frm 和 .ibd 文件),但它们不知何故损坏了,MySQL 无法打开它们:

2015-06-10 18:37:18 3965 [Warning] InnoDB: Cannot open table db123/tbl456 from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.

我尝试将数据文件复制到另一个 MySQL 实例中,但没有成功,我甚至尝试创建新的 .frm 文件(但我不知道表的结构),停止服务器,用正确的文件替换它们,启动服务器并打开它们 - 再次没有成功。

遗憾的是,我没有这些数据库的备份,因为它们很久以前就损坏了,并且备份转储未能保存任何数据。

现在我在 innodb 数据文件中有数据,但无法将它们加载到实时服务器中。有什么方法可以保存它们吗?

我找到了这个工具包:https://www.percona.com/software/mysql-innodb-data-recovery-tools,但我不确定我是否可以使用它,它非常复杂,我不知道如何恢复数百个数据库,其结构对我来说是未知的。

服务器使用MySQL 5.6.17,从源代码编译。

答案1

作为 Percona 数据恢复工具包的作者,我建议你使用TwinDB数据恢复工具包。Percona 的工具包在过去两年中没有任何发展,所有新功能都归 TwinDB 的工具包所有。您的案例在一篇文章中进行了描述恢复损坏的 MySQL 数据库

要恢复表结构,您可以使用mysql框架工具或恢复结构InnoDB 字典

相关内容