Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cleanup of Mongo journal file

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.

like image 536
Biscuit Coder Avatar asked Jun 10 '16 11:06

Biscuit Coder


People also ask

Can I delete MongoDB Journal files?

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.

What is Journal folder in MongoDB?

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.

How much time is the journal written again in MongoDB?

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 what frequency by default MongoDB writes are written to the Journal?

At every 100 milliseconds (See storage. journal. commitIntervalMs ). When WiredTiger creates a new journal file.


1 Answers

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.

like image 141
André Düwel Avatar answered Oct 10 '22 22:10

André Düwel