Installing MongoDB on Ubuntu 15.04

Jan 14, 2016

Starting with ubuntu 15.04, Upstart has been replaced with systemd, and whilst installing MongoDB was no issue, there was no way of having it running as a service by default.

First clue comes when installing MongoDB (Install steps) with the following message:

invoke-rc.d: mongod.service doesn't exist but the upstart job does. Nothing to start or stop until a systemd or init job is present.

And indeed service mongod status confirms that the service is not running

● mongod.service
Loaded: not-found (Reason: No such file or directory)
Active: failed (Result: exit-code) since Tue 2016-01-12 17:37:43 GMT; 6min ago
.....

and also, there is no init.d file for mongod

Tried this, doesn’t work

Tried adding back the init.d script which I had found here, but after installing it, there was still no joy.

cd /etc/init.d

wget https://raw.githubusercontent.com/mongodb/mongo/master/debian/init.d -O mongod

chmod +x mongod

./mongod start

resulting in

[....] Starting mongod (via systemctl): mongod.serviceFailed to start mongod.service: Unit mongod.service failed to load: No such file or directory.
failed!

Final solution

I’ve put together an install script that could handle it all for you