Lesson 1: Managing MongoDB Servers / Learn
Code Summary: Managing MongoDB Servers
Review the following code, which demonstrates how to install, start, and stop mongod.
Install MongoDB Community Edition
Follow these steps to install MongoDB 6.0 Community Edition on LTS (long-term support) releases of Ubuntu Linux, using the apt package manager.
- In the terminal, use the following command to import the public key that’s used by the package management system:
- Create a list file for MongoDB:
- Reload the local package database:
- Install the latest stable version of MongoDB Community Edition:
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
echo “deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
Start, Stop, and Check the Status of mongod
To start the mongod service, use the following command:
sudo systemctl start mongod
To check the status of a mongod service, use the following command:
sudo systemctl status mongod
To stop a mongod service from running, use the following command:
sudo systemctl stop mongod