Report this

What is the reason for this report?

Block storage and MongoDB

Posted on July 28, 2016

Hello, can someone explain or point me to some solution of how to use MongoDB and new Block Storages. I have existing MongoDB database and I want to enable it to store data on new created and mounted Blocks. Is that even possible and how can be done? Thanks



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!

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.

That is possible and one method of doing this is:

First stop mongodb sudo service mongodb stop

Move your database to block storage. (Depending on the version, your database may be in a different location. Check your MongoDB config file for dbpath option.) sudo mv /usr/local/var/mongodb /block/storage/mongodb/

Create a symlink to the new part of the database. (Depending on the version, your database may be in a different location. Check your MongoDB config file for dbpath option. ) sudo ln -s /block/storage/mongodb/ /var/lib/mongodb

Setting permissions sudo chown mongodb:mongodb /block/storage/mongodb/

Start MongoDB sudo service mongodb start

This is one method of doing it, you can also edit your MongoDB config file and set the dbpath option to block storage.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.