Shrink MongoDB journal files

Trying to get some space in my harddrive I noticed that the journal files of MongoDB where around 3GB.

mongo journal

Fixing this is as simple as stoping MongoDB server, adding the option smallfiles = true in /etc/mongodb.conf file, deleting the journal files and the starting the MongoDB service again.

sudo service mongodb stop
sudo vi /etc/mongodb.conf

At this moment you have to add this to /etc/mongodb.conf:

smallfiles = true

Now just delete the old journal files and restart the service. New journal files will be created:

sudo rm -rf /var/lib/mongodb/journal/*
sudo service mongodb start

mongo journal after


You might also like

MongoDB: Recover Data after an Unexpected Shutdown in Ubuntu
If you try to run mongod but it fails to start and have this error in the log file (/var/log/mongodb/mongodb.log)...

Install MongoDB and the PHP driver in CentOS
Install MongoDB serverCreate the /etc/yum.repos.d/mongodb-org-3.0.repo file with this content:name=MongoDB...

Install MongoDB in Ubuntu 12.04 with PHP driver
Install MongoDB:sudo apt-key adv --keyserver hkp:// --recv 7F0CEB10 echo...

Install and configure MongoDB and PHP driver with MacPorts
Installing and configuring MongoDB with MacPortsInstalling MongoDB with MacPorts is as easy as...

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.