user2481422
user2481422

Reputation: 868

How to solve lack of space issue in mongodb

I am getting the following error in mongod.log file:

journal dir=/var/lib/mongodb/journal
Mon Jan 20 15:10:19.742 [initandlisten] recover : no journal files present, no recovery needed
Mon Jan 20 15:10:19.742 [initandlisten] 
Mon Jan 20 15:10:19.742 [initandlisten] ERROR: Insufficient free space for journal files
Mon Jan 20 15:10:19.742 [initandlisten] Please make at least 3379MB available in /var/lib/mongodb/journal or use --smallfiles
Mon Jan 20 15:10:19.742 [initandlisten] 
Mon Jan 20 15:10:19.743 [initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating
Mon Jan 20 15:10:19.743 dbexit: 

This demonstrates that the server has no more space available for journal. Will allocating more space to the server automatically solve the problem or do I need to manually do something to commit the new allocated space?

Upvotes: 0

Views: 5323

Answers (3)

yǝsʞǝla
yǝsʞǝla

Reputation: 16412

You don't need to recover your DB. Here are your options:

  • If you don't have more space to add and don't care about durability of writes you can disable journalling by setting configuration option journal = false.
  • You can set smallfiles = true to make journal files smaller.
  • Allocate more disk space or move data directory to a larger disk.

In either case you don't have to really restart the server. Just shutdown mongod, fix the problem and start it up.

Example 1:

I'm running Linux VM on AWS and I have only 8GB in my root '/' where mongo places it data files by default. I create a new EBS partition or attach some other partition, format it and mount it. Next I edit mongod config to place my data directory on this new drive/partition. I also move all the files from the old directory to that new place. I startup mongo and it should work fine. Don't forget to set correct directory permissions, etc.

Example 2:

I shutdown my VM or Server and resize disk. If you use LVM, etc you might not need to shutdown - depends. Start mongod - all works.

Upvotes: 4

mjkaufer
mjkaufer

Reputation: 4206

Short answer: Yes.

You can simply increase your system's storage so you can store all of your journals.

Alternately, if you enable --smallfiles, it will reduce the max journal size to 512mb. I'm not sure if you want this or not, however, but it will probably clear up enough space for you not to need to extend your system's storage.

Upvotes: 0

Sammaye
Sammaye

Reputation: 43884

That is not a lack of memory but hard disk space.

Yes, just resizing the server and then restarting mongod should do it.

Upvotes: 1

Related Questions