In this article, we will have explained the necessary steps to install MongoDB on CentOS 8. 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 an open source NoSQL database system written in C++ designed to ensure scalability, high performance, and availability. MongoDB common use case is storage and management of Big Data-sized collections of literal documents like text documents, email messages, XML documents, and many others.
Install MongoDB on CentOS
Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.
sudo dnf update
Step 2. Install MongoDb on CentOS 8.
First, we need to create a repo file:
nano /etc/yum.repos.d/mongodb.repo
[mongodb-org-4.2] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/8/mongodb-org/testing/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc
Once the MongoDB repository, you can install the MongoDB using following command:
sudo dnf install mongodb-org
Now, let’s start the MongoDB service and enable it upon system boot with this command:
systemctl start mongod.service systemctl enable mongod.service systemctl status mongod.service
Step 3. Configure firewall.
If you have firewalld running on your server and would like MongoDB service to be accessible over the network, open it on the firewall:
sudo firewall-cmd --add-port=27017/tcp --permanent sudo firewall-cmd --reload
Congratulation, you have learned how to install MongoDB on CentOS 8. If you have any question, please leave a comment below.