How can I run Mongodb, as a service, on Ubuntu 16.04 LTS? A few days ago I had upgrade my server to Ubuntu 16.04. I have noticed the my MongoDB service does not start when I reb
The packages for 3.2+ contain upstart scripts.
First, follow the official instructions to install:
# If you installed the ubuntu package, remove it, if not skip to key import
sudo apt-get remove mongodb
sudo apt-get autoremove
# import key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
# add trusty repos
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
# update apt
sudo apt-get update
# install the package
sudo apt-get install -y mongodb-org
Then unmask the mongodb.service
job (and enable and start it). I believe it was masked because the package includes an upstart jobs as well, so you wouldn't want both of them to start. In our case, however, this is clearly what we want.
sudo systemctl unmask mongodb
sudo service mongod start
References:
relevant JIRA issue
related question on Ask Ubuntu