
Here’s a guide to installing the popular NoSQL database, MongoDB, on a Rocky Linux 8 system. This process is straightforward and involves adding the MongoDB repository to your system, installing the necessary packages, and starting the service. MongoDB is a powerful, flexible database often used for applications requiring dynamic schema and high scalability.
Before you begin, ensure you have administrative privileges (sudo access) on your Rocky Linux 8 server.
Step 1: Add the MongoDB Repository
MongoDB is not included in the default Rocky Linux repositories. You need to create a repository file to tell your system where to download the MongoDB packages. Use a text editor like nano
or vim
to create a file named /etc/yum.repos.d/mongodb-org-6.0.repo
(or the latest version available).
You will need to add configuration details specific to the MongoDB version you wish to install. For MongoDB 6.0, the content of the file should typically look like this:
[mongodb-org-6.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/6.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc
Note: Replace 6.0
and the gpgkey
URL with the desired MongoDB version if different.
Step 2: Install the MongoDB Packages
Once the repository is configured, you can install the MongoDB database server and related tools. Open your terminal and run the following command:
sudo dnf install mongodb-org
This command will download and install the mongodb-org
package, which is a meta-package that includes the core MongoDB server daemon (mongod
), the shell (mongo
), and other essential tools. You might be prompted to accept the GPG key; confirm to proceed.
Step 3: Start the MongoDB Service
After the installation is complete, you need to start the MongoDB service. Use the systemctl
command for this:
sudo systemctl start mongod
Step 4: Verify the Service Status
To check if MongoDB is running correctly, you can use the status
command:
sudo systemctl status mongod
You should see output indicating that the service is active and running.
Step 5: Enable MongoDB to Start on Boot (Optional but Recommended)
If you want MongoDB to automatically start every time your server boots, use the enable
command:
sudo systemctl enable mongod
This command creates the necessary symbolic links to ensure the service starts automatically.
Security Considerations:
By default, MongoDB installations might allow connections from anywhere. For production environments, it is crucial to configure your firewall (firewalld
on Rocky Linux) to restrict access to the MongoDB port (default 27017) only to trusted IP addresses or subnets. Additionally, secure your MongoDB deployment by enabling authentication and creating user accounts with specific roles and permissions. Consult the official MongoDB documentation for comprehensive security guidelines.
By following these steps, you will have successfully installed and configured MongoDB on your Rocky Linux 8 system, ready for developing and deploying your NoSQL applications.
Source: https://kifarunix.com/install-mongodb-on-rocky-linux-8/