Import the key
[code language=”bash”]sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv EA312927[/code]
create a list file for MongoDB.
[code language=”bash”]sudo 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[/code]
update the packages list.
[code language=”bash”]sudo apt-get update[/code]
install the MongoDB package
[code language=”bash”]sudo apt-get install -y –allow-unauthenticated mongodb-org[/code]
Create a configuration
[code language=”bash”]sudo vi /etc/systemd/system/mongodb.service[/code]
save file with the below content
[code language=”bash”][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
[/code]
save and close the file
start the newly created service with systemctl.
[code language=”bash”]sudo systemctl start mongodb[/code]
you can also use systemctl to check that the service has started properly.
[code language=”bash”]sudo systemctl status mongodb[/code]
enable automatically starting MongoDB when the system starts.
[code language=”bash”]sudo systemctl enable mongodb[/code]