Downgrading MongoDB to version 4.4 on CentOS, AlmaLinux, and RockyLinux Print

  • 0

Downgrading MongoDB to version 4.4 on CentOS, AlmaLinux, and RockyLinux

If your server doesn't support AVX instructions, running MongoDB 5.0 or above could cause problems. MongoDB 5.0 requires a CPU with AVX support. However, the previous version, MongoDB 4.4, does not have this requirement.

In such situations, downgrading MongoDB to an older version that doesn't require AVX support can be a viable solution. Here's how you can downgrade MongoDB to version 4.4 on CentOS, AlmaLinux, and RockyLinux.

Warning: Downgrading to an older version may lead to loss of data and functionality, depending on the versions involved and the changes made to the database under the newer version. Always backup your data before proceeding.

Pre-requisites

Before starting, ensure your system meets the following requirements:

  • Operating System: CentOS, AlmaLinux, or RockyLinux
  • User privileges: A user with sudo privileges
  • Network: An active internet connection

Step 1: Uninstall Current MongoDB Version

If you have a later version of MongoDB installed on your system, you'll need to remove it first. Use the following command:


sudo yum remove -y mongodb-org

Step 2: Configure MongoDB 4.4 Repo

Next, you'll need to configure the MongoDB 4.4 repository. You can do this by creating a repo file:


echo "[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" | sudo tee /etc/yum.repos.d/mongodb-org-4.4.repo

 The baseurl in the MongoDB repository configuration is missing the $releasever value. In this context, $releasever is a variable that should contain the version of your operating system.

You need to change: baseurl=https://repo.mongodb.org/yum/redhat/8/mongodb-org/4.4/x86_64/

1. Remove the existing MongoDB repository configuration file:


sudo rm /etc/yum.repos.d/mongodb-org-4.4.repo

2. Recreate the MongoDB repository configuration file with the corrected `baseurl`:


echo "[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/8/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc" | sudo tee /etc/yum.repos.d/mongodb-org-4.4.repo

3. Clean the Yum cache:


sudo yum clean all

Step 3: Install MongoDB 4.4

With the MongoDB 4.4 repo configured, you can now install MongoDB 4.4:


sudo yum install -y mongodb-org

Step 4: Start MongoDB Service

After the installation is complete, you can start the MongoDB service:


sudo systemctl start mongod

To ensure MongoDB starts automatically at boot, you can use:


sudo systemctl enable mongod

Step 5: Verify the Installation

You can verify that the correct version of MongoDB is installed by issuing:


mongo --eval 'db.runCommand({ connectionStatus: 1 })'

or

sudo systemctl status mongod

If MongoDB 4.4 was installed correctly, you should see some JSON output which includes a version number of 4.4.

Conclusion

This guide has shown you how to downgrade MongoDB to version 4.4 on CentOS, AlmaLinux, and RockyLinux. By downgrading MongoDB, you can continue using MongoDB even if your CPU doesn't support AVX instructions. However, please note that by doing so, you may be missing out on the latest features and improvements offered in newer MongoDB versions.

If You are getting MongoDB 6.0 packages when you should be getting 4.4, given the repository file you created. 

One thing you could try is to disable the other MongoDB repositories that may exist in your system. To do this:

1. List all the repositories in your system:

sudo yum repolist

2. Look for any other MongoDB repositories in the list. They might look something like `mongodb-org-<version>`.

3. If you find other MongoDB repositories, disable them with:

sudo yum-config-manager --disable mongodb-org-<version>

Replace `<version>` with the version number of the MongoDB repository you found in the second step.

After disabling the other repositories, try to install MongoDB 4.4 again with:

sudo yum remove -y mongodb-org

sudo yum clean all

sudo yum install -y mongodb-org

If everything goes correctly, MongoDB 4.4 should be installed. You can verify it by running:

mongo --version


Was this answer helpful?

« Back