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?
First, please read this article:
Recover Data after an Unexpected Shutdown
After a crash, you have two options:
mongod
with the --repair
option;Running mongod --nojournal
will not remove journal files. In fact, mongod
will not even start if there are journal files present. It will give you the following message and shut down.
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
If you then run mongod
without the --nojournal
option, it will apply all changes saved in journal files and remove the files. Only then can you restart it with --nojournal
.
I believe this is what happened in your case. You don't need to attempt to restore your journal files, as they are already applied to your data.