Sunday, November 10, 2024

How to Solve “No Package mongodb-org Available” Issue on CentOS 7 When Installing MongoDB 3.2


Installing MongoDB on CentOS 7 can sometimes throw unexpected errors, especially if you are setting up an older version like MongoDB 3.2. If you’ve followed the MongoDB installation guide carefully but still encounter a "No package mongodb-org available" message, this post will guide you through troubleshooting the issue and implementing the solution.

Problem Overview

You attempted to install MongoDB 3.2 by setting up the repository as follows:


[mongodb-org-3.2] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/ gpgcheck=0 enabled=1

Then, you ran:


sudo yum install mongodb-org

However, you received the error message:


Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.osuosl.org * epel: linux.mirrors.es.net * extras: mirror.lax.hugeserver.com * updates: mirror.hmc.edu No package mongodb-org available. Error: Nothing to do

This error essentially indicates that the mongodb-org package cannot be found in the repositories you specified.

Troubleshooting Steps

  1. Double-Check the Repository File
    Ensure your repository file is correctly formatted and points to the proper MongoDB repository for CentOS 7. The repository file should look like this:


    [mongodb-org-3.2] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/ gpgcheck=0 enabled=1
  2. Check YUM Configuration for Exclusions
    In this case, the problem was found in the YUM configuration file, yum.conf, where certain MongoDB packages were excluded from the installation. The line causing the issue was:


    exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools

    When you exclude specific packages in yum.conf, YUM will ignore them during installation. This exclusion is often added to avoid accidental upgrades or conflicts with other packages.

  3. Remove or Comment Out the Exclusion Line
    To resolve the issue, open the yum.conf file:


    sudo nano /etc/yum.conf

    Find the line starting with exclude=, and either delete or comment it out by adding a # symbol at the beginning:


    #exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools

    Save and close the file.

  4. Clear YUM Cache
    Sometimes, YUM can cache incorrect information. Clear the cache to ensure YUM fetches the latest metadata:


    sudo yum clean all
  5. Re-run the Installation Command
    With the exclusion line removed and the cache cleared, try installing MongoDB again:


    sudo yum install mongodb-org

Solution Recap

This issue highlights the importance of reviewing yum.conf when troubleshooting package installation problems on CentOS. In many cases, seemingly small configurations—like package exclusions—can lead to frustrating errors.

To summarize:

  1. Check that your MongoDB repository file is correctly set up.
  2. Review yum.conf for any exclusion entries that might prevent YUM from finding MongoDB packages.
  3. Clear the YUM cache to ensure all metadata is refreshed.
  4. Retry the installation.

Following these steps should help you successfully install MongoDB 3.2 on CentOS 7 without further issues.

0 comments:

Post a Comment