Ubuntu – How to install MongoDB 3.0 in Vivid

javamongodbsoftware installation

The official vivid package for mongodb is 2.x, and the packages that MongoDB provide themselves on http://repo.mongodb.org/apt/ubuntu/dists/trusty/ are only available for LTS releases.

An alternative is that I could switch back to 14.04 LTS, but I would need to install openjdk-8-jdk, which is only available for vivid.

Best Answer

It's possible, that MongoDB doesn't start if you use the Trusty packages:

Failed to start mongod.service: Unit mongod.service failed to load: No such file or directory.

In this case, install the Debian Wheezy packages as described at the end.

Install the Trusty DEB packages

Download the DEB files

cd
wget http://repo.mongodb.org/apt/ubuntu/dists/trusty/mongodb-org/3.0/multiverse/binary-amd64/mongodb-org-mongos_3.0.3_amd64.deb
wget http://repo.mongodb.org/apt/ubuntu/dists/trusty/mongodb-org/3.0/multiverse/binary-amd64/mongodb-org-server_3.0.3_amd64.deb
wget http://repo.mongodb.org/apt/ubuntu/dists/trusty/mongodb-org/3.0/multiverse/binary-amd64/mongodb-org-shell_3.0.3_amd64.deb
wget http://repo.mongodb.org/apt/ubuntu/dists/trusty/mongodb-org/3.0/multiverse/binary-amd64/mongodb-org-tools_3.0.3_amd64.deb
wget http://repo.mongodb.org/apt/ubuntu/dists/trusty/mongodb-org/3.0/multiverse/binary-amd64/mongodb-org_3.0.3_amd64.deb

And install with (in this order)

sudo dpkg -i mongodb-org-server_3.0.3_amd64.deb
sudo dpkg -i mongodb-org-tools_3.0.3_amd64.deb
sudo dpkg -i mongodb-org-shell_3.0.3_amd64.deb
sudo dpkg -i mongodb-org-mongos_3.0.3_amd64.deb
sudo dpkg -i mongodb-org_3.0.3_amd64.deb

And taken from the comments, thank you @Pilot6:

They may have dependencies to each other. That's why installation packages one by one may give errors. I suggest sudo dpkg -i mongodb*.deb


Use the Trusty PPA

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org

Use the Debian Wheezy packages

It's possible, that MongoDB doesn't start if you use the Trusty packages:

Failed to start mongod.service: Unit mongod.service failed to load: No such file or directory.

In this case, install the Debian Wheezy packages as described below

sudo apt-get remove mongodb-org
sudo apt-get autoremove
sudo rm /etc/apt/sources.list.d/mongodb-org-3.0.list
sudo echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org