1

My MongoDB had crashed due to out of memory error that occurred when it tried appending to a journal file. At that instance, my mongod.lock file was empty. I restarted mongod without any options. It was accepting connections normally. Then I ran mongo.exe, but was unable to connect to db. It got stuck to "connecting to test" but never connected successfully.

I ended that process and I restarted mongod with --nojournal option. But that didnt help either.

But now I see mongod.lock file non empty. Also,all my journal entries are deleted.

The question is, does --noJournal option deletes existing journal entries? Also, is there a way to recover the journal entries?

4

1 回答 1

1

崩溃后恢复

首先,请阅读这篇文章:

意外关机后恢复数据

崩溃后,您有两种选择:

  • 如果是独立实例,mongod请使用--repair选项运行;
  • 如果实例是副本集的一部分,则擦除所有数据并从备份中恢复或从另一个副本集成员执行初始同步。

--nojournal 选项

运行mongod --nojournal不会删除日志文件。事实上,mongod即使存在日志文件,也不会启动。它将给您以下消息并关闭。

Error: journal files are present in journal directory, yet starting without journaling enabled.
It is recommended that you start with journaling enabled so that recovery may occur.
exception in initAndListen: 13597 can't start without --journal enabled when journal/ files are present, terminating

如果您随后在mongod没有该--nojournal选项的情况下运行,它将应用保存在日志文件中的所有更改并删除文件。只有这样你才能重新启动它--nojournal

我相信这就是你的情况。您无需尝试恢复您的日志文件,因为它们已应用于您的数据。

于 2015-11-05T09:19:19.997 回答