mongodb, rocky linux,

How to install MongoDB on Rocky Linux 8

Aug 20, 2021 · 1 min read · Post a comment

MongoDB has an attitude to store the data in BSON, which can be searched and indexed, with a way better performance. Installing MongoDB on Rocky Linux can additionally improve the search performances cause Rocky Linux is well known as a minimalistic distro.

Prerequisites

  • Rocky Linux 8
  • sudo privileges

Install MongoDB on Rocky Linux 8

Step 1. First, create the MongoDB repository.

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

Step 2. Copy and paste the following config below, to enable the latest MongoDB version.

[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 3. Update system packages.

sudo dnf update

Step 4. Install the latest version of MongoDB.

sudo dnf install mongodb-org

Step 5. Verify installation.

mongod --version

Output:

db version v5.0.2
Build Info: {
    "version": "5.0.2",
    "gitVersion": "6d9ec525e78465dcecadcff99cce953d380fedc8",
    "openSSLVersion": "OpenSSL 1.1.1g FIPS  21 Apr 2020",
    "modules": [],
    "allocator": "tcmalloc",
    "environment": {
        "distmod": "rhel80",
        "distarch": "x86_64",
        "target_arch": "x86_64"
    }
}

Start and enable the MongoDB service

sudo systemctl start mongod
sudo systemctl enable mongod

To check the status, execute:

sudo systemctl status mongod

Conclusion

As I mentioned previously installing MongoDB on Rocky Linux can additionally improve the search performances, so don’t hesitate to install MongoDB on your new, fresh Rocky Linux instance. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.