mongoDB
Table of Contents
Install on Ubuntu1
MongoDB only provides packages for 64-bit long-term support Ubuntu releases. Currently, this means 12.04 LTS (Precise Pangolin) and 14.04 LTS (Trusty Tahr).
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 # Ubuntu 12.04 echo "deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list # Ubuntu 14.04 echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" sudo apt-get update sudo apt-get install -y mongodb-org sudo service mongod start
Packages
MongoDB provides officially supported packages in their own repository. This repository contains the following packages:
- mongodb-org A metapackage that will automatically install the four component packages listed below.
- mongodb-org-server Contains the mongod daemon and associated configuration and init scripts.
- mongodb-org-mongos Contains the mongos daemon.
- mongodb-org-shell Contains the mongo shell.
- mongodb-org-tools Contains the following MongoDB tools: mongoimport bsondump, mongodump, mongoexport, mongofiles, mongooplog, mongoperf, mongorestore, mongostat, and mongotop.
These packages conflict with the mongodb, mongodb-server, and mongodb-clients packages provided by Ubuntu.
Pin a specific version of MongoDB.
To prevent unintended upgrades, pin the package. To pin the version of MongoDB at the currently installed version, issue the following command sequence:
echo "mongodb-org hold" | sudo dpkg --set-selections echo "mongodb-org-server hold" | sudo dpkg --set-selections echo "mongodb-org-shell hold" | sudo dpkg --set-selections echo "mongodb-org-mongos hold" | sudo dpkg --set-selections echo "mongodb-org-tools hold" | sudo dpkg --set-selections
Run MongoDB Community Edition
The MongoDB instance stores its data files in /var/lib/mongodb
and its
log files in /var/log/mongodb
by default, and runs using the mongodb
user account. You can specify alternate log and data file directories
in /etc/mongod.conf
.
Start MongoDB
sudo service mongod start
Verify that MongoDB has started successfully
Verify that the mongod process has started successfully by checking
the contents of the log file at /var/log/mongodb/mongod.log
for a line
reading
[initandlisten] waiting for connections on port <port>