MongoDB, Inc. released their newest version 2.6
of MongoDB at the end of May and the Ubuntu/Debian repositories still provide an older version. To install 2.6
follow this guide.
Register APT Repository
First, you have to add the public key of MongoDB, Inc. to your aptitude repository. You can do with the apt-key
command.
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
Additionally, a MongoDB repository list file has to be created containing the route to MongoDB binaries.
Ubuntu
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
Debian
echo 'deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
Install MongoDB
Before the newest version of MongoDB is installable, update your aptitude repository index.
sudo apt-get update
Now you can install MongoDB and required packages on your system.
sudo apt-get install mongodb-org
Install a specific version of MongoDB and its dependent packages, in this case 2.6.2
:
sudo apt-get install mongodb-org=2.6.2 mongodb-org-server=2.6.2 mongodb-org-shell=2.6.2 mongodb-org-mongos=2.6.2 mongodb-org-tools=2.6.2
This previous command installs the defined version. If you want to install another version than 2.6.2
, change the 2.6.2
to the your required version.
Start/Stop MongoDB Service
The MongoDB system service starts automatically after installation.
By default, MongoDB stores data into the /data/db
(on Windows C:\data\db
) folder of your system. You can specify the storage path by adding the dbpath
variable to the start command.
sudo mongod --dbpath /server/dbdata/mongodb
Additionally, the MongoDB system process starts by default on Port 27017
. To change it, add the port
variable to the server start command
sudo mongod --port 2345
Check Installation
You can verify the installation with this command:
mongo --version
# shell output
MongoDB shell version: 2.6.2
Find further information about the mongodb process, ports and many more in the MongoDB docs.