How to Install MongoDB 4.4 on CentOS Stream 8 (Legacy Guide)
Legacy guide for MongoDB 4.4 on CentOS Stream 8. Both releases are out of support; use MongoDB 8.0 on Rocky Linux 9 for a new host.
On this page
Support status: CentOS Stream 8 stopped receiving builds on May 31, 2024, and MongoDB 4.4 reached end of life on February 29, 2024. Keep these steps only for maintaining an existing legacy host. For a supported combination, see our MongoDB 8.0 guide for Rocky Linux 9. See the CentOS Project end-date notice and MongoDB’s lifecycle schedule.
Prerequisites
Before you start, make sure you have the following:
- A system running CentOS Stream 8.
- A user account with sudo privileges.
- An internet connection to download the MongoDB package.
Step 1: Update System Packages
The first step is to ensure that your system’s package list is up to date. Open a terminal and run the following command:
sudo dnf update
This command will refresh the list of available packages and their versions.
Step 2: Install MongoDB
To install MongoDB on CentOS Stream 8, you can use the official MongoDB repository. Follow these steps:
2.1 Add MongoDB Repository
Add the MongoDB repository to your system using the vi text editor:
sudo vi /etc/yum.repos.d/mongodb-org-4.4.repo
Add the following content to the file:
[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
Save and exit the text editor.
2.2 Install MongoDB
Now, you can install MongoDB by running the following command:
sudo dnf install -y mongodb-org
This will install the MongoDB server and related packages.
Step 3: Start and Enable MongoDB
After the installation is complete, you need to start the MongoDB service and enable it to start on boot:
3.1 Start MongoDB
Start the MongoDB service using the following command:
sudo systemctl start mongod
3.2 Enable MongoDB on Boot
To ensure MongoDB starts automatically when the system boots, run this command:
sudo systemctl enable mongod
Step 4: Verify MongoDB Installation
To verify that MongoDB has been successfully installed and is running, you can check its status:
sudo systemctl status mongod
If MongoDB is running correctly, you’ll see the status as “active (running).”
Step 5: Access the MongoDB Shell
You can access the MongoDB shell to interact with the database. Simply open a terminal and run:
mongo
This will open the MongoDB shell, and you can start working with your MongoDB instance.
Conclusion
You have successfully installed MongoDB on your CentOS Stream 8 system. MongoDB is a versatile and scalable NoSQL database that can power your applications. You can now start creating databases, collections, and documents and use MongoDB for your projects. If you encounter any issues or want to learn more about MongoDB, refer to the official MongoDB documentation for detailed information. Enjoy using MongoDB on your CentOS Stream 8 system!