For whatever reason, whenever I try to start MongoDB as a service (
sudo service mongod start) I get the following error:
Failed to start mongod.service: Unit mongod.service not found.
I followed the installation guide on the MongoDB site.
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 community
The instructions/packages on the MongoDB site are currently available for LTS Ubuntu 12.04 and 14.04 only. The packages are set up to use upstart instead of systemd. You need to create a systemctl file to be ready for systemd. Create it by
sudo nano /etc/systemd/system/mongodb.service
It will look like
[Unit] Description=High-performance, schema-free document-oriented database After=network.target [Service] User=mongodb ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf [Install] WantedBy=multi-user.target
Now you can start the service and check its state by
sudo systemctl start mongodb sudo systemctl status mongodb
and finally enable it permanently by
sudo systemctl enable mongodb
(Source: How to Install MongoDB on Ubuntu 16.04)