Run MongoDB service as daemon of SystemD on Ubuntu 15.10

I managed start the MongoDB service with SystemD on boot:

I uninstalled the official meta-package (mongodb-org) v3.2, then I installed the meta-package (mongodb) v2.6 from Ubuntu repository:

> sudo apt-get remove mongodb-org
> sudo apt-get install mongodb

Create the service config file as shown below:

> cd /lib/systemd/system
> sudo touch mongodb.service
> sudo nano mongodb.service
[Unit]
Description=An object/document-oriented database
Documentation=man:mongod(1)
After=network.target

[Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf

[Install]
WantedBy=multi-user.target

Verify in the list if the service is enabled or disabled using the command below:

> systemctl list-unit-files --type=service
...
mongodb.service             disabled
...

If it is disabled or not in the list, enable it:

> sudo systemctl enable mongodb.service

Check again:

> systemctl list-unit-files --type=service 
...
mongodb.service             enabled
...

Now you can managing the service on SystemD init process:

> systemctl status mongodb
> sudo systemctl stop mongodb
> sudo systemctl start mongodb
> sudo systemctl restart mongodb

Enjoy!


On default install from MongoDB repository, in order to have automatic startup of mongod service, all you need to do is enable system.d service:

systemctl enable mongod.service (pay attention to mongod service name, not mongodb)

NOTE: this is tested on both Debian/GNU Jessie 8.x with systemd and Ubuntu Xerus 16.04 LTS.