How to Install MongoDB on Debian 11 (Community Edition Tutorial). MongoDB is a popular open source NoSQL database. It is a document oriented database that supports structured and unstructured data, including JSON, XML, and organic data.
MongoDB server is highly available and highly scalable. The database stores data in collections of documents, which can include any sort of data (e.g., documents, graphs) that fits into a certain schema.
This tutorial goes through the features, benefits, and installation process of MongoDB Community Edition on Debian 11.
MongoDB is a free and open-source project that lets you store, manage and query data. It’s the leading NoSQL database, and it provides the best of both relational and document stores.
MongoDB uses the BSON format, which is a binary encoded JSON format, to store documents. This means that the information is stored in binary form, which is substantially quicker than JSON.
Additionally, this permits the storage of binary data, which is advantageous for the storage of pictures, films, and other binary data. It can also add indexes to your documents to speed up scans of large collections of data.
Designed for easy scalability MongoDB offers high performance and flexibility. It is an excellent choice for applications that require both ACID transactions (atomicity, consistency, isolation). With MongoDB it can handle very large amounts of data with low latency and high throughput (millions of operations per second).
It is designed to work well with the JavaScript programming language and the NoSQL approach to application design.
MongoDB is written in C++ and is compatible with Linux, macOS, and Windows. It can be installed as a service or as a standalone application.
It supports authentication mechanisms such as HTTP Basic Auth, OAuth 2.0, and Active Directory Federation Services (AD FS).
Next in How to Install MongoDB on Debian 11 we learn what are the MongoDB features.
Run the following commands to ensure all the packages are up-to-date and the server is ready for the MongoDB installation.
sudo apt update
sudo apt dist-upgrade -y
Install Dependent Packages
You will need wget and GnuPG packages to download the MongoDB repository securely. Install these dependency packages with the following commands:
sudo apt install wget
sudo apt install gnupg
Now, you can move on to adding MongoDB Community Edition to your system.
Import MongoDB Repository GPG Key
The MongoDB package is not included by default in the Debian default repository. As a result, you must add and install MongoDB from Debian’s official repository to the sources list.
Import the GPG key of the MongoDB repository with the following command.
Now, run the following command to install MongoDB on your system.
sudo apt install -y mongodb-org
Output:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
mongodb-database-tools mongodb-mongosh mongodb-org-database mongodb-org-database-tools-extra mongodb-org-mongos mongodb-org-server
mongodb-org-shell mongodb-org-tools
…
Enable and Start the MongoDB Service
Now you can enable the MongoDB service to start on boot with the following command.
sudo systemctl enable mongod
Output:
Created symlink /etc/systemd/system/multi-user.target.wants/mongod.service → /lib/systemd/system/mongod.service.
Or you can simply start the service with the following command.
sudo service mongod start
Similarly, you can check the status of your MongoDB service with the following command.
sudo service mongod status
Output:
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2022-07-12 11:44:59 EDT; 17s ago
Docs: https://docs.mongodb.org/manual
Main PID: 9230 (mongod)
Memory: 66.1M
CPU: 1.747s
CGroup: /system.slice/mongod.service
└─9230 /usr/bin/mongod --config /etc/mongod.conf
Jul 12 11:44:59 debian systemd[1]: Started MongoDB Database Server.
Information Security professional with 4+ years of experience. I am interested in learning about new technologies and loves working with all kinds of infrastructures.