MongoDB is a popular open-source NoSQL database that provides high performance, scalability, and flexibility for building modern applications. In this article, we will walk you through the steps to install MongoDB on AlmaLinux 9.
Step 1: Enable MongoDB Repository
First, you need to enable the official MongoDB repository on your AlmaLinux 9 system. To do this, create a new repo file for MongoDB by running the following command:
sudo vi /etc/yum.repos.d/mongodb.repo
Then, paste the following lines into the file and save it:
[mongodb-org-5.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/5.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc
Step 2: Install MongoDB
Next, update the package list and install the MongoDB package by running the following commands:
sudo dnf install mongodb-org
This command will install the MongoDB package along with its dependencies on your AlmaLinux 9 system.
Step 3: Start and Enable MongoDB Service
After the installation is complete, start the MongoDB service and enable it to start automatically at system boot by running the following commands:
sudo systemctl start mongod
sudo systemctl enable mongod
You can also check the status of the MongoDB service by running:
sudo systemctl status mongod
Step 4: Access MongoDB Shell
Once MongoDB is installed and running, you can access its shell by running the following command:
mongo
This will open the MongoDB shell, where you can interact with the database using various commands.
That’s it! You have successfully installed MongoDB on AlmaLinux 9. You can now start using MongoDB to store and manipulate data for your applications. If you encounter any issues during the installation process, you can refer to the official MongoDB documentation for troubleshooting tips and guidelines.