Skip to main content
AI
  • Get started with AI

    • Red Hat AI

      Accelerate the development and deployment of enterprise AI solutions.

    • AI learning hub

      Explore learning materials and tools, organized by task.

    • AI interactive demos

      Click through scenarios with Red Hat AI, including training LLMs and more.

    • AI/ML learning paths

      Expand your Red Hat OpenShift AI knowledge using these learning resources.

    • AI quickstarts

      Focused AI use cases designed for fast deployment on Red Hat AI platforms.

    • No-cost AI training

      Foundational Red Hat AI training.

  • Featured resources

    • Red Hat OpenShift AI
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

Red Hat AI Factory with NVIDIA

Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.

Learn
  • Self-guided

    • Documentation

      Find answers, get step-by-step guidance, and learn how to use Red Hat products.

    • Learning paths

      Explore curated walkthroughs for common development tasks.

    • Guided learning

      Receive custom learning paths powered by our AI assistant.

    • See all learning
  • Hands-on

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

    • Interactive labs

      Learn by doing in these hands-on, browser-based experiences.

    • Interactive demos

      Click through product features in these guided tours.

  • Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics
  • Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
Build
  • Get started

    • Red Hat build of Podman Desktop

      A downloadable, local development hub to experiment with our products and builds.

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

  • Download products

    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products
  • Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset
  • References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
Community
  • Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions
  • Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github
  • Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

Join the Red Hat Developer program

Download Red Hat products and project builds, access support documentation, learning content, and more.

ConsoleDocsSupport Search
New For you

Recommended

We'll recommend resources you may like as you browse. Try these suggestions for now.

  • Product downloads
  • Cheat sheets
  • Red Hat Developer learning portal
  • Developer blog
  • E-books
  • Developer Sandbox
Log in

Get more with a Red Hat Developer account

  • Product downloads
  • Console access
  • Event registration
  • Training & trials
Explore more account benefitsLog in or register

A subscription may be required for some services.

Contact us

Installing MongoDB on Red Hat Enterprise Linux

June 2, 2016
Hemant Jain
Related topics:
DatabasesLinux
Related products:
Red Hat Enterprise Linux

    MongoDB has evolved into one of the most popular open source "NoSQL" databases—so-called because they dispense with the tabular storage schema of relational databases like MySQL and Postgres. NoSQL databases offer a variety of advantages in many cases

    The biggest advantage is that MongoDB databases don't require developers to define schemas before adding data to a database. Instead, they use a flexible document-based model, similar to Python dictionaries or Ruby hashes. With MongoDB, you don't need to spend time creating tables before you can process your data. That makes the NoSQL approach ideal for situations where you don't know how much data you have to handle, what form it is in, or how quickly it is going to move around.

    There's a lot more to say about what makes MongoDB, and NoSQL in general, a better fit for some situations. (I could also write a great deal about when not to use NoSQL—and that’s  important, because despite NoSQL's current trendiness, it's not better in all contexts.)

    But that's all fodder for a separate blog post. For now, let's move onto the meat of this post, which is how to install MongoDB on Red Hat Enterprise Linux (RHEL) in order to take advantage of NoSQL databases.

    Preliminary Notes on MongoDB Installation

    Before delving into the installation steps, we should go over some prerequisites. First, know that this guide applies to systems running RHEL 6 or later. (MongoDB does not support RHEL 5 or earlier.) It probably works pretty well for CentOS and other RHEL derivatives, but I haven’t tested those.

    I also assume you want to install MongoDB using RPM packages and the yum package manager, which ships with RHEL. You could also compile MongoDB from source, but that is a lot more complicated and, for my money, not worth the trouble (pace, Gentoo fans).

    You should also know that MongoDB no longer supports 32-bit systems. While it's technically possible to install MongoDB on a 32-bit RHEL system using outdated, archived versions of MongoDB packages, you probably don't want to do that—certainly not if you have any intention of using MongoDB in a production environment. So your RHEL server needs to be running a 64-bit kernel to follow this guide.

    Note also that this guide is designed to allow you to install the latest stable version of MongoDB on RHEL. At the time of this writing, that's version 3.2, which debuted in early 2016 (and has had a few minor updates since). MongoDB 3.2 offers a number of features not present in earlier releases, such as a totally new default storage engine (WildTiger) and a lot of handy new programming operators. For details, check out the MongoDB 3.2 release notes.

    Lastly, the steps below cover installation of both the Community Edition and Enterprise versions of MongoDB. (The Community Edition is free; the Enterprise option, which offers some extra features, requires a commercial license.) The installation steps are basically the same, but the specifics vary, as noted below.

    Step 1. Prepare Your Package Manager

    Now that the boring stuff is out of the way, let's install MongoDB.

    The first step is to configure the yum package manager. This is pretty simple. First, create a file called /etc/yum.repos.d/mongodb-org-3.2.repo (for the Community Edition of MongoDB) or /etc/yum.repos.d/mongodb-enterprise.repo (for Enterprise).

    Next, open up that file in your favorite text editor (on RHEL, I prefer gedit when working from the GUI, or vi if I'm on the CLI), and populate it with the following lines for the Community Edition:

    [mongodb-org-3.2]
    name=MongoDB Repository
    baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
    gpgcheck=1
    enabled=1
    gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc

    Or, for the Enterprise version, fill the file with:

    [mongodb-enterprise]
    name=MongoDB Enterprise Repository
    baseurl=https://repo.mongodb.com/yum/redhat/$releasever/mongodb-enterprise/stable/$basearch/
    gpgcheck=1
    enabled=1
    gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc

    Step 2: Install MongoDB

    If you thought that was easy, the next step was even easier (thanks to the magic of yum). Just run one of the following yum commands as root. The first command will install the Community release; the second one is for Enterprise:

    sudo yum install -y mongodb-org
    sudo yum install -y mongodb-enterprise

    This will download the latest stable version of MongoDB from the official MongoDB repositories.

    Step 3: Enjoy

    That's it. Now you can fire up a mongo shell and see for yourself just how fun and useful NoSQL can be for your massively scalable development needs. Check out the MongoDB documentation for details.

    You can also connect your apps directly to MongoDB storage both locally and over the network (in the latter case, you'll need to configure the firewall as needed, of course), although this generally requires the installation of language-specific plugins. (The links in this sentence provide instructions for using MongoDB with Java, Python, Node.js and Ruby, to name just a few frameworks.)

    Package Management Quirks

    Before you go, here are a couple of quick tips you might want to know regarding package management and your MongoDB installation:

    1. For those readers visiting from the future, I should note that yum may be superseded in newer versions of RHEL with dnf, the next-generation version of yum. However, based on all indications available to us here in 2016, it looks like the dnf interface will behave very similarly to yum, so the commands above should work if you simply swap out the name of one tool for the other.
    2. If you install MongoDB using the steps above, yum will automatically upgrade MongoDB to a newer version whenever one appears. If you don't want this to happen, there's an easy solution—simply "pin" the MongoDB packages, which tells yum not to upgrade them automatically. You do this by adding a line like the following to your /etc/yum.conf:
    exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools

    This will pin the Community Edition packages for MongoDB. If you're working with MongoDB Enterprise, just modify that line with the appropriate package names: mongodb-enterprise instead of mongodb-org, and so on.


    Another recommended route for installing MongoDB on RHEL is to use Red Hat Software Collections (RHSCL), which simplifies package management, and allows developers to run multiple versions of packages on the same system. Learn how to install MongoDB on RHEL with RHSCL, and learn more about installing Red Hat Software Collections itself. 


    Hemant Jain

    Hemant Jain is the founder and owner of Rapidera Technologies, a full service software development shop. He and his team focus a lot on modern software delivery techniques and tools. Prior to Rapidera he managed large scale enterprise development projects at Autodesk and Deloitte.

    Last updated: October 29, 2024

    Recent Posts

    • A day in the life of an NVIDIA H100 on Red Hat OpenShift 5

    • Migrate BuildConfigs to builds for Red Hat OpenShift with one plug-in install

    • Run Red Hat Enterprise Linux CoreOS on NVIDIA BlueField DPUs

    • Agent harness engineering: Separating model capabilities from enforcement

    • What's new for developers in Red Hat Enterprise Linux 10.3 and 9.9

    Red Hat Developers logo

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    Red Hat Developer

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility
    Ask AI