How To Install MongoDB on Fedora 35

Install MongoDB on Fedora 35

In this tutorial, we will show you how to install MongoDB on Fedora 35. For those of you who didn’t know, MongoDB is a free and open-source document database designed for ease of application development and scaling. It is classified as a NoSQL database and thus it stores data in flexible, JSON-like documents, meaning fields can vary from document to document and data structure can be changed over time.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the MongoDB NoSQL database program on a Fedora 35.

Install MongoDB on Fedora 35

Step 1. Before proceeding, update your Fedora operating system to make sure all existing packages are up to date. Use this command to update the server packages:

sudo dnf upgrade
sudo dnf update

Step 2. Installing MongoDB on Fedora 35.

By default, MongoDB is available on Fedora 35 base repository. Now run the following command below to add MongoDB repository on Fedora system:

sudo nano /etc/yum.repos.d/mongodb.repo

Add the below files:

[mongodb-upstream]
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

After that, update packages and install the latest stable version of MongoDB using the following command:

sudo dnf update
sudo dnf install mongodb-org

Once installation is complete we need to start the MongoDB server to start operating. We do that with the following command below:

sudo systemctl start mongod
sudo systemctl enable mongod

You can check the version of MongoDB installed using the following command:

mongod --version

Output:

db version v4.4.4
Build Info: {
    "version": "4.4.4",
    "gitVersion": "8db30abmwe469d84bdcad0c83369623f100120397",
    "openSSLVersion": "OpenSSL 1.1.1l  FIPS 24 Aug 2021",
    "modules": [],
    "allocator": "tcmalloc",
    "environment": {
        "distmod": "rhel80",
        "distarch": "x86_64",
        "target_arch": "x86_64"
    }
}

Step 3. Configure Firewall.

We need to enable the firewall in order to filter traffic into our server. Now we allow port 27017/TCP in the firewall using the following command:

sudo firewall-cmd --add-port=27017/tcp --permanent
sudo firewall-cmd --reload

Step 3. Accessing MongoDB on Fedora.

Now we run the following command to connect to the mongo shell:

mongo

Output:

[[email protected] ~]# mongo

MongoDB shell version v4.4.4
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("Me7b4c9a0-9243-e463-336-920737aG4pa7c") }
MongoDB server version: 4.4.4
Welcome to the MongoDB shell.
For interactive help, type "help".
---

Congratulations! You have successfully installed MongoDB. Thanks for using this tutorial for installing the MongoDB database on your Fedora 35 system. For additional help or useful information, we recommend you check the official MongoDB website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!