Reputation: 7082
I have set up a fresh installation of Ubuntu 16.04 server on a VirtualBox VM. The only other custom application I have installed in NginX. I want to get MongoDB to launch automatically when the server reboots.
The official MongoDB installation page that I have been following tells me to create a file at /lib/systemd/system/mongod.service
, with the following contents:
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
Documentation=https://docs.mongodb.org/manual
[Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
However, this file already existed, with more entries, so I did not touch it.
The DigitalOcean tutorial tells me to create a file with almost the same contents at /etc/systemd/system/mongod.service
(etc
not lib
and mongodb
rather than mongod
; Documentation and Group are missing). This tutorial also suggests using...
sudo systemctl enable mongodb
... "to enable automatically starting MongoDB when the system starts". But I get this error:
Failed to execute operation: Invalid argument
I have tried both techniques, but when I reboot the server, MongoDB does not start.
I've also seen a mention of a tool to create an init script at /opt/mongodb-mms-automation/bin/mongodb-mms-automation-make-init-scripts
, but this was not installed when I followed the instructions on the MongoDB site.
What am I missing?
Upvotes: 0
Views: 1695
Reputation: 3139
Your error message isn't very helpful but sudo journalctl -f -n 200
will give you some insight into what might go wrong.
Do you have the mongodb
user and group on your system?
Upvotes: 1