Home > bash, linux > [mongodb] mongorestore crashes

[mongodb] mongorestore crashes

Yesterday I bought a Digital Ocean VPS with MongoDB preinstalled. I chose the cheapest one, which is $5 / month. With FileZilla, using the SFTP protocol, I uploaded a Mongo dump that I wanted to restore with the “mongorestore” command. Mongorestore terminated halfway and it also made the MongoDB server crash! WTF?

It turned out that mongorestore didn’t have enough memory, but it didn’t print an error message about it! It just stopped and said that the server is not running. Yeah, it was not running because it just crashed because of you, you dumb program…

So, the cheapest DO VPS has 512 MB RAM, which is not much for MongoDB. By default, this cheapest VPS has no swap at all. So the solution is the following: add a swap file. I created a swap file of size 2 GB (maybe 1 GB is also enough) and retried mongorestore. This time it was successful. During the import process I was checking “htop” and the swap file was used indeed.

How to create a swap file?
Check out this article: http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/. It explains the process step by step.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: