How To Use the MongoDB One-Click Application
This article exists for historical reference and is no longer maintained.
Reason: This MongoDB One-Click image for Ubuntu 14.04 is no longer offered. You can use the MongoDB 16.04 image instead.
MongoDB is a highly-scalable NoSQL database with a document-based data model and an expressive query language. DigitalOcean's MongoDB One-Click application allows you to quickly spin up a droplet with MongoDB pre-installed. It aims to help get your application off the ground quickly.
Creating Your MongoDB Droplet
You can launch a new MongoDB instance by selecting MongoDB on Ubuntu 14.04 from the Applications menu during droplet creation:
Once you have created the droplet, connect to it via the web-based console in the DigitalOcean control panel or SSH:
Your MongoDB instance will be available at
127.0.0.1:27017 It is bound to the localhost by default and its configuration details can be found in
/etc/mongod.conf. To connect to the test database with the MongoDB shell, simply run:
You can access your MongoDB instance remotely via an SSH tunnel using:
ssh -L 4321:localhost:27017 firstname.lastname@example.org -f -N mongo --port 4321
This opens an SSH connection which allows you to access port 27017 of the remote server locally on port 4321. This can be useful for securely accessing your MongoDB instance without opening it up to accept connections via the wider internet.
In order to enable access over the internet, modify the value of
/etc/mongod.conf If you do so, you are highly advised to first review the security checklist from the MongoDB documentation. In addition to enabling one of the forms of authentication supported by MongoDB, setting up a firewall that only allows remote connections from specific IP addresses is a good security measure to implement.
Managing an IP Tables firewall is made easy using UFW on Ubuntu. The following commands will erect a firewall which will allow all outgoing connections from your server but only allow incoming connections via SSH or from the specified IP address (ip.address.to.allow).
sudo apt-get install ufw sudo ufw default deny incoming sudo ufw default allow outgoing sudo ufw allow ssh sudo ufw allow from ip.address.to.allow sudo ufw enable
The One-Click application simply provides you with MongoDB as a pre-installed base. It's up to you how you want to use it. Whether you are building out a sharded cluster or simply want to connect it to an app on the same host, we have a number of tutorials which should point you in the right direction:
- How To Implement Replication Sets in MongoDB
- How To Create a Sharded Cluster in MongoDB
- How To Connect Node.js to a MongoDB Database
For more ideas one what is possible, check out the rest of the tutorials under the MongoDB tag here at DigitalOcean.