8

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.

  • 1
    I think nothing bad will happen if you install it from trusty repo to vivid. – Pilot6 Jun 13 '15 at 19:48
13

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
  • 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 – Pilot6 Jun 13 '15 at 19:58
  • @Pilot6 Therefore sudo dpkg -i mongodb-org_3.0.3_amd64.deb as last command – A.B. Jun 13 '15 at 19:59
  • Just a suggestion. And it is easier as one command. If you install multiple packages in one command, dependencies are resolved. – Pilot6 Jun 13 '15 at 20:01
  • @Pilot6 added and linked =) – A.B. Jun 13 '15 at 20:05
  • Ok, I used the Trusty deb packages and it worked. How do I then get it running as a service so that I can start and stop it using service mongod start? – Hugh Rawlinson Jun 13 '15 at 20:39
4

Successfully installed with mongo version 3.0.6 in my Ubuntu 15.04 using debian wheezy repository - see below steps

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

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

However, after all the steps above and mongodb installed in my machine, now when I tried to start the mongodb service with sudo service mongod start it would fail. Throwing the following error message

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

So here is how I resolved and startup mongodb normally

  • Change MongoDB's default data store files from /var/lib/mongodb to /data/db

  • sudo mkdir -p /data/db

  • sudo gedit /etc/mongod.conf and change the “dbpath” line as below

  • Replace dbpath=/var/lib/mongodb TO dbpath=/data/db and then save the file.

  • Then delete the old default /var/lib/mongodb

  • Now we must make all the directories/files owned by mongod user

  • Run sudo chown -R mongodb:mongodb /data/db

And now finally I can start mongo with sudo service mongod start

And chcek that the service is running with sudo systemctl status mongod - It should show a message similar to below

Loaded: loaded (/etc/init.d/mongod)

Active: active (running) since Thu 2015-09-03 04:57:49 IST; 7s ago

Have detailed my steps in my blog post.

1

As I have said before: The Debian/Ubuntu packages have been patched with systemd service units, to fill the hole left by the stuff that is published directly from mongodb.org. But there's no shortage of mongodb.service unit files on the WWW. It's not hard to write one, either. (I have.)

Specifically: You'll find such a service unit in the mongodb-server version 2.6 package for Ubuntu version 15. There's also a service unit published by mongodb.org, indeed. It is simply the case that the mongodb.org people have mistakenly conflated the use of RPM with the use of systemd in the distribution-specific stuff.

Note that, ironically, the mongodb.org-supplied service units do not apply the systemd service unit directives that mongodb.org itself recommends. Neither do the Debian/Ubuntu-supplied ones. But, again: A hand-written service unit with these directives isn't hard to write; or indeed to modify to add things like numactl. ☺

Further reading

0

Well none of A.B's answer worked. So my only option was to install from the tarball

Follow, instructions on the docs related to this topic.

0

As a short add-on to @A.B.'s excellent answer. On vivid amd64, with a previous install of mongod 2.6.26, simply replacing the existing sources.list.d file with

deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse

followed by a dist-upgrade worked automatically.

sudo apt-get update
sudo apt-get dist-upgrade

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.