I recently upgraded to Ubuntu 15.10 after which MongoDB 3.0.2 is not starting.
$ sudo service mongod start
which would throw error:
Failed to start mongod.service: Unit mongod.service failed to load: No such file or directory.
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityIt'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:
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf
[Install]
WantedBy=multi-user.target
sudo service...
was silently failing because of permissions issues
/etc/mongod.conf
and not /etc/mongodb.conf
Mar 25, 2016 at 12:36
mongod
because this is what they use on their official site. So mongodb.conf
should be mongod.conf
and the file name should be /lib/systemd/system/mongod.service
This error occurred due to the problem with the new Ubuntu (15 and ahead).
Default init system is systemd which was Upstart previously. So you need to install Upstart, reboot your system and here you go, you can now run mongodb service.
sudo apt-get install upstart-sysv
sudo service mongod start
mongod start/running, process 3371
I used debian package in ubuntu 15.10
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
I had similar issues after upgrading to 15.10.
There could be a lot of issues but depending on what's caused your problem you may be able to get your mongodb running through init.d :
sudo /etc/init.d/mongodb start
That worked for me, but not a long term solution since you need to run that after every restart or add it to your startup tasks. So I followed the following:
1) creating the service file as explained by 'sclausen'.
2) reload the service by running:
sudo systemctl daemon-reload
3) ran sudo service mongodb start
4) The command ran without output. So I tested by running mongo
and got a socket error:
Error: connect ECONNREFUSED 127.0.0.1:27017
at Object.exports._errnoException (util.js:870:11)
at exports._exceptionWithHostPort (util.js:893:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1062:14)
5) Looked through the logs tail -n 50 /var/log/mongodb/
and found out the underlying error :
2016-02-26T14:28:23.538+1100 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
6) deleted the problematic socket file: sudo rm /tmp/mongodb-27017.sock
as suggested on this thread: https://stackoverflow.com/questions/29813648/failed-to-unlink-socket-file-error-in-mongodb-3-0
7) re ran the service: sudo service mongodb start
at that point all was good and Bob returned to his rightful position as my uncle.
In my case, I have Ubuntu 16.04.1, I was installing MongoDB 3.2.11, and I was getting that same error. After several cleaned ups and retry's, it finally worked "enabling" the service:
systemctl enable mongod.service
Then it just worked