mongorestore fails with "out of memory"

I need to import my db from the old hosting. Iv’e already exported it from the old hosting using mongodump and now trying the following:

mongorestore -h -d bassfunk_moscow dump/bassfunk_moscow/

it stops with the fatal error: runtime: out of memory

Here is all the log:

What should be my next steps? I’m lost here. The DB dump is not that big - about 50mb.

uname -a
Linux bassfunk 3.13.0-57-generic #95-Ubuntu SMP Fri Jun 19 09:28:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

This message would indicate that the mongo process itself attempted to allocate more memory but there was none (or not enough) left for the operating system to allocate it. If you are on a 512MB or 1GB droplet I would recommend creating a swap file on your droplet. With a swap file, if your droplet runs out of physical memory it will use the file to swap out memory data to the disk, preventing this type of issue.

While this will prevent the process from crashing (or at least ensure it takes a lot more to get to that point), having a lot of memory swapped out to disk will slow things down as it is much slower for the OS to query the data in a swap file than to do so from RAM. For this reason, I would also recommend running free -m once you have completed your import and your services are running normally in order to ensure that you have enough memory available for normal operation.