Online Interview Questions

Prepare interviews on Anything, AnyWhere

PHPSCOTS,Blogger, Developer Views: 1060

Follow the below steps to install Mongodb on Ubuntu 16.04.

Step 1: Import the MongoDB public key

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

Step 2: Generate a file with the MongoDB repository url

echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list

Step 3: Refresh the local database with the packages

sudo apt-get update

Step 4: Install the last stable MongoDB version and all the necessary packages on our system

sudo apt-get install mongodb-org

Or

sudo apt-get install -y mongodb

Step 5:Creating new mongodb service file ‘mongod.service’.

cd /lib/systemd/system/
sudo nano mongod.service
[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

Save and exit

Step 6: Updating system services

sudo systemctl daemon-reload

Step 7: Starting service and schedule service to be started at boot time.

sudo systemctl start mongod
sudo systemctl enable mongod