In this article, we will have explained the necessary steps to install MongoDB on CentOS 7. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.
MongoDB is a free, distributed, and an open-source document database at its core that powers high availability, horizontal scaling, and geographic distribution. It stores data in JSON-like documents and supports Ad hoc queries, indexing, and real-time aggregation.
Install MongoDB on CentOS
Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.
sudo yum install epel-release sudo yum update
Step 2. Install MongoDB.
Add the MongoDB repository to your system, open your text editor and create a new YUM repository configuration:
[mongodb-org-4.0] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
Now that the repository is enabled you can install the mongodb-org meta-package using the yum utility:
sudo yum install mongodb-org
Once the installation is completed, start the MongoDB daemon and enable it to start on boot by typing:
sudo systemctl start mongod sudo systemctl enable mongod
Use the following command to check installed MongoDB version:
$ mongod 4.0.1
Congratulation, you have learned how to install MongoDB on CentOS 7. If you have any question, please leave a comment below.