By the end of this tutorial, you should be comfortable with accessing and installing MongoDB on a remote VM. Furthermore, the VM is interchangeable with any remote server, which means after you SSH in, all of the remaining steps are identical.
- A 32-bit or 64-bit computer with at least 8GB of RAM. 16GB or more is recommended.
- At least 50GB of free disk space.
Now, that we have our Vagrant VM running, we can SSH into it like any other remote server we have SSH access to.
# SSH in (password is "vagrant") ssh vagrant@MY.VM.IP.ADDRESS
Now we can perform the MongoDB installation. Follow any onscreen prompts and enter a new MongoDB root password. You will be using this same password to access the DB, later on.
sudo apt-get update sudo apt-get install mongodb
You'll want to comment out the
bind_ip line for now. This is only to make testing easier.
# Update the mongodb.cnf and save your settings sudo nano /etc/mongodb.cnf # Restart mongodb sudo service mongodb restart
Before deploying to production, you'll want to uncomment the
bind_ip line and add in the IP addresses any authorized servers that need to access the DB.
First exit the VM
mongodb-clients on the host.
sudo apt-get install mongodb
And access MongoDB.
If everything went well, you should now be able to connect to your virtual machine's MongoDB database from the host machine. If at any point, you want to start over from scratch, run
vagrant destroy from the same directory as the
Vagrantfile, and the virtual machine will be deleted.