What is the correct way to ensure `mongod` starts on system startup in 16.04?
Installing
This is the method I ended up using (from user Adam C's comment re: using more up to date version of mongodb). It worked for me but I'm not an authority on the matter.
https://askubuntu.com/a/757385/367134
Then I had to make a service file, see:
https://askubuntu.com/a/694226/367134
And edit the path in that service file from:
/etc/mongodb.conf
to:
/etc/mongod.conf
And then make mongodb start on system startup with:
sudo systemctl enable mongodb
see:
https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
Now mongodb is starting on 16.04 system startup.
Uninstalling Old MongoDB
Before I did that however, I had to remove the existing installs and directories, which i did like this (steps mainly from https://askubuntu.com/a/497144/367134):
# go to /etc/apt/sources.list.d and remove any mongodb lists, then:
# sanity check - see what is installed
sudo dpkg -l | grep mongo
# remove all packages
sudo apt-get remove mongodb* --purge
sudo apt-get autoremove
# remove old directories
sudo rm -r -f /var/lib/mongodb/
sudo rm -r -f /var/log/mongodb/