This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:
Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.
See Instead:
This guide might still be useful as a reference, but may not work on other Ubuntu releases. If available, we strongly recommend using a guide written for the version of Ubuntu you are using. You can use the search functionality at the top of the page to find a more recent version.
MongoDB is a document database used commonly in modern web applications. This tutorial should help you setup a virtual private server to use as a dedicated MongoDB server for a production application environment.
This one's easy. Once you're done, go ahead and `ssh` in.
N.B. :: It is recommended that you configure `ssh` and `sudo` like this
The MongoDB install process is simple enough to be completed with a Bash script. Copy the following into a new file named `mongo_install.bash` in your home directory:
apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | tee -a /etc/apt/sources.list.d/10gen.list apt-get -y update apt-get -y install mongodb-10gen
Here's an explanation of each line in the script:
TIP: At any time, to change to your home directory, simply execute `cd`
Execute the following from your home directory:
$ sudo bash ./mongo_install.bash
If everything is successful, you should see the output contain a PID of the newly started MongoDB process:
mongodb start/running, process 2368
By default with this install method, MongoDB should start automatically when your Droplet is booted. This means that if you need to reboot your Droplet, MongoDB will start right back up.
To start learning about the running `mongod` process, run the following command:
$ ps aux | grep mongo
One line of the output should look like the following:
mongodb 569 0.4 6.4 627676 15936 ? Ssl 22:54 0:02 /usr/bin/mongod --config /etc/mongodb.confWe can see the...
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
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 up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Every now and than it looks like mongodb stops running.
When I
sudo service mongod start
It starts again.
Is there a way to auto start or check and auto start mongodb?
I concur - it would save time to have the last comment appear first.
Thanks for this, but I just tried it and got v2.4.1 installed, not the latest.
The instructions from 10gen here work.
Looks like they changed the name of their package for the latest release.
If you are getting the following error when running the bash script:
“WARNING: The following packages cannot be authenticated!”
Then you simply need to modify the last two lines of the script to:
apt-get -y --force-yes update apt-get -y --force-yes install mongodb-10gen
Everything should work fine after that.
whoops, I got it. it must have been a typo or something like that.
I created the bash script, but upon running it I get the following error:
Package mongodb-10gen is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source
E: Package ‘mongodb-10gen’ has no installation candidate
I then tried using ‘sudo apt-get install mongodb-org’ (with or without -y) but it didn’t work either (E: Unable to locate package mongodb-org).
Maybe the package mongodb-10gen has been obsoleted?
Great tutorial, step 3 seems to be superfluous on ubuntu 12 though. Got a
after running
@grega.vrbancic: This article does not work on Debian. See <a href=“http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian/”>http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian/</a>
Using Debian 3.2.41-2+deb7u2 x86_64 GNU/Linux I got following error.
… electing previously unselected package mongodb-10gen. (Reading database … 26311 files and directories currently installed.) Unpacking mongodb-10gen (from …/mongodb-10gen_2.4.7_amd64.deb) … Processing triggers for man-db … locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory Setting up mongodb-10gen (2.4.7) … Adding system user
mongodb' (UID 105) ... Adding new user
mongodb’ (UID 105) with groupnogroup' ... Not creating home directory
/home/mongodb’. Adding groupmongodb' (GID 111) ... Done. Adding user
mongodb’ to group `mongodb’ … Adding user mongodb to group mongodb Done. invoke-rc.d: unknown initscript, /etc/init.d/mongodb not found. dpkg: error processing mongodb-10gen (–configure): subprocess installed post-installation script returned error exit status 100 Errors were encountered while processing: mongodb-10gen E: Sub-process /usr/bin/dpkg returned an error code (1)Any suggestion?
@Asterix: My bad, the second half of the command got stripped out because of the filtering system.
Is it all fine now?