本文介绍了从损坏的MongoDB中抢救数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Mongo数据库已损坏,无论我尝试执行什么操作都无法恢复(尝试运行并进行修复,无法正常工作).

I've a corrupted Mongo database that no matter what I tried cannot be recovered (tried running with repair, didn't work).

问题是,是否仍要挽救收集文件中的至少某些数据?数据库中有大约一千万个文档,我想尽可能地挽救它.

Question is, is there anyway to salvage at least some of the data from the collection files? the database had about 10 millions documents and I'd like to salvage as many as possible.

MongoDump曾经能够直接处理数据库文件,但是从3.0版和WiredTiger版本开始,它不再支持此功能.还有其他方法可以直接处理收集文件并读取至少一些数据吗?

MongoDump used to be able to work directly against the database files, but since version 3.0 and WiredTiger it doesn't support this anymore. is there any other way to work directly against the collection files and read at least some of the data?

推荐答案

好,所以我们找到了一个很棒的解决方案:

Ok, so we found a pretty awesome solution:

  • 下载 WiredTiger源
  • 下载并安装Python
  • 下载 SCONS
  • 下载 Snappy压缩器
  • 将快照头文件放在"WiredTiger源文件夹" \ include下
  • 将快照的dll和lib文件放在"WiredTiger源文件夹" \ lib下

  • Download WiredTiger source
  • Download and install Python
  • Download SCONS
  • Download Snappy compressor
  • Put the snappy header files under "WiredTiger source folder"\include
  • Put the snappy dll and lib files under "WiredTiger source folder"\lib

将snappy dll和lib文件放在"WiredTiger源文件夹" \下(重命名dll时不包含32或64,因此仅此名称:snappy.dll和snappy.lib)

Put the snappy dll and lib files under "WiredTiger source folder"\ (rename the dll without the 32 or 64, so its only: snappy.dll and snappy.lib)

我们必须更新WiredTiger源文件夹中的SConstruct文件,以便代替以下行:

We had to updated the SConstruct file in the WiredTiger source folder so that instead of the following line:

  • 我们使用了以下行:

  • We used the following line:

  • 整个过程的输出是一个wt.exe可执行文件,它支持快速压缩程序

  • The output of this whole process is a wt.exe executable that supports the snappy compressor

    在所有* .wt文件上运行wt.exe打捞后,我们能够再次运行MongoDB.

    After running wt.exe salvage on all *.wt files we were able to run MongoDB again.

    万岁!

    这篇关于从损坏的MongoDB中抢救数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

  • 10-22 00:04