I installed MongoDB 2.6 on clean installed Ubuntu 15.04:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
sudo apt-get install -y mongodb-org
It finished without any problems. However, when I tried to start it, I got the following error:
$ sudo service mongod start
Failed to start mongod.service: Unit mongod.service failed to load: No such file or directory.
How can I fix this?
I installed from the debian wheeze repository and it works fine.
First make sure you remove the mongodb-org package and all its dependencies:
Remove the old mongodb.list you created:
Use the Debian repository instead:
Update and install again:
After that, you can succesffully start the server:
or
(as clarified by Ernie Hershey in reply to Roman Gaufman's comment here: https://jira.mongodb.org/browse/SERVER-17742)
The MongoDB team says they won't support Ubuntu 15.04 and plan to support 16.04 instead (see https://jira.mongodb.org/browse/SERVER-17742).
Ubuntu 15.04 advances the default init system from Upstart to systemd. I had no success starting MongoDB 3.0 with systemd.
You can switch back to Upstart by installing
upstart-sysv
:Then reboot and MongoDB should be up.
I hope to find an easy way to run MongoDB on Ubuntu 15.04 without switching things back in time.
You're installing from the packages published directly from mongodb.org. You should be installing from the packages supplied in the Ubuntu respository. The Debian/Ubuntu packages have been patched with systemd service units, to fill the hole left by mongodb.org.
(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. So just install that package.
(Note that the Debian/Ubuntu-supplied service units do not apply the mongo-recommended systemd service unit directives.)
Further reading
I created a Systemd script that seems to work for Ubuntu 15.04+ and Mongo 3.0+:
https://gist.github.com/benileo/ada486d73f58dd93a0ee
Make sure you set your data directory in
/etc/mongod.conf
Isn't this the best answer? From a duplicate question: https://askubuntu.com/a/694226/255468 by @sclausen
It's just the lack of a service file for systemd. No need to go back to upstart like Kartik did or use a different repository than described in https://docs.mongodb.org/manual/installation/.
Create a file /lib/systemd/system/mongodb.service with the following content:
https://jira.mongodb.org/browse/SERVER-17742
It seems that this possibly won't be fully fixed for >2.6.3 until Ubuntu 16.04, unless there is a strong outcry.
So the solution for me was to issue:
Many of these answers are related to Mongo 3.0, whereas the question asked specifically about 2.6.
I've had success installing 2.6 using the Debian repository from 10gen. This appears to work perfectly with Ubuntu 15.04.
Source: How to Install MongoDB 2.6 on Ubuntu 14.10, 14.04 and 12.04 LTS
While the question is for version 2.6. I was getting the exact same error
Unit mongod.service failed to load
in my Ubuntu 15.04 for version 3.0.6. Ultimately resolved using the same wheezy repository mentioned by Dielson Sales above.And after the installation (following the steps detailed by @Dielson Sales) faced the above error. Here's how I finally resolved.
A) Change MongoDB's default data store files from /var/lib/mongodb to /data/db
First create the new /data/db directory
sudo mkdir -p /data/db
Open mongod.conf file
sudo gedit /etc/mongod.conf
and change the “dbpath” line as belowReplace dbpath=/var/lib/mongodb TO dbpath=/data/db and save the file.
Then delete the old default /var/lib/mongodb
Now we must make all the directories/files owned by mongod user
B) So 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 belowLoaded: 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
First, download mongodb:
extract download:
run the mongod (mongodb-linux-x86_64-3.0.6.tgz/bin/mongod) with -dbpath attribute:
It can be an empty directory any of your choice
and finally, run mongo (mongodb-linux-x86_64-3.0.6.tgz/bin/mongo)
worked on my ubuntu 15 :)
sorry for my bad english , I live in Brazil
After hours from searching, The solution was to upgrade my ubuntu from 15.04 to 16.04 using this command:
Step 1
It will take few minutes so dont panic, than you have to remove mongodb :
Step 2
And now, install mongodb but using this source :
Step 3
And that's it.
Note : If you get an error like ' E: the type 'deb' in the first line . . . in the file mongodb-org-3.0.list
all you have to do is to get in this file using gedit and delete the ‘ in the begin and at the end of the sentence.