Skip to content

Latest commit

 

History

History
112 lines (73 loc) · 2.58 KB

File metadata and controls

112 lines (73 loc) · 2.58 KB

Installation Guide for MongoDB

Sl No Version Operating System
1 latest(v4.2.1) Ubuntu 18.04(BionicBeaver)
2 latest(v4.2.1) Debian/Raspbian Versions


  • Installation of MongoDB(4.2.1) Ubuntu 18.04

  1. Ubuntu’s official software package repositories comes with the latest version of MongoDB, and can be easily installed using the APT package manager.

First update the system software package cache to have the most latest version of the repository listings.

sudo apt update
  1. Next, install MongoDB package that includes several other packages such as mongo-tools, mongodb-clients, mongodb-server and mongodb-server-core.
sudo apt install mongodb
  1. Once you have successfully installed it, the MongoDB service will start automatically via systemd and the process listens on port 27017. You can verify its status using the systemctl command as shown.
sudo systemctl status mongodb

mongoDB-Status

  1. The MongoDB installation comes as a systemd service and can be easily manageable via a standard systemd commands as shown.

To stop running MongoDB service, run the following command.

 sudo systemctl stop mongodb	

To start a MongoDB service, type the following command.

sudo systemctl restart mongodb

To disable automatically started MongoDB service, type the following command.

sudo systemctl disable mongodb	

To enable again MongoDB service, type the following command.

sudo systemctl enable mongodb	


  • Installation of MongoDB(4.2.1) EC2 AMI Linux

  1. For MongoDB 4.2.1, create the below file using VI or any other editor:
vi /etc/yum.repos.d/mongodb-org-3.0.repo 

Add the content below in the above-created file:

[mongodb-org-4.2.1]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/4.2.1/x86_64/
gpgcheck=1
enabled=1
  1. Install MongoDB Using the Below Command
sudo yum install -y mongodb-org
  1. Start MongoDB Service Using the Below Command
sudo service mongod start
  1. Start MongoDB on Reboot

You can optionally ensure that MongoDB will start following a system reboot by issuing the following command:

sudo chkconfig mongod on

Once the service is started, you can check the status of your Mongo shell. To check the Mongo shell status, use the below command:

sudo service mongod status

MongoDB Status Check