Is there a way to reset the journal file. Will it have any implications ?
Right now i have a journal file of 2GB which is occupying lot of space in ec2.
The long answer: No, deleting the journal file isn't safe. The idea of journalling is this: A write comes in. Now, to make that write persistent (and the database durable), the write must somehow go to the disk.
MongoDB uses write ahead logging to an on-disk journal to guarantee write operation durability. The WiredTiger storage engine does not require journaling to guarantee a consistent state after a crash. The database will be restored to the last consistent checkpoint during recovery.
MongoDB will re-apply the write operations on restart and maintain a consistent state. By default, the greatest extent of lost writes, i.e., those not made to the journal, are those made in the last 100 milliseconds, plus the time it takes to perform the actual journal writes.
At every 100 milliseconds (See storage. journal. commitIntervalMs ). When WiredTiger creates a new journal file.
You should stop the mongodb first:
service mongodb stop
rm -rf /var/lib/mongodb/journal
service mongodb start
Additional hint: you could limit the journal to 128MB by adding smallfiles=true
to the config file /etc/mongodb.conf
.
Solution taken from here and tested on Ubuntu 16.04.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With