Install MongoDB 2.4.4 on Fedora 18/17, CentOS/Red Hat (RHEL) 6.4/5.9

What is MongoDB?

MongoDB (from “humongous”) is a scalable, high-performance, open source, schema-free, document-oriented database. Written in C++. MongoDB bridges the gap between key-value stores (which are fast and highly scalable) and traditional RDBMS systems (which provide structured schemas and powerful queries).

MongoDB is very interesting document-oriented database, because it has really awesome features:

  • Document-oriented storage (the simplicity and power of JSON-like data schemas)
  • Dynamic queries
  • Full index support, extending to inner-objects and embedded arrays
  • Query profiling
  • Fast, in-place updates
  • Efficient storage of binary data large objects (e.g. photos and videos)
  • Replication and fail-over support
  • Auto-sharding for cloud-level scalability
  • MapReduce for complex aggregation
  • Commercial Support, Training, and Consulting

This guide shows howto install MongoDB 2.4.4 on Fedora 18/17/16/15/14/13/12, CentOS 6.4/6.3/6.2/6.1/6/5.9 and Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9. Using MongoDB own YUM repositories. Fedora / CentOS / Red Hat (RHEL) RPM packages are currently available for x86 (32-bit) and x86_64 (64-bit) architectures.

1. Install MongoDB on Fedora 18/17/16/15/14/13/12, CentOS 6.4/5.9 and Red Hat (RHEL) 6.4/5.9

1.1 Change to root User

1.2 Add and enable 10gen MongoDB repository

Select suitable repo for your system and add one of following to /etc/yum.repos.d/10gen-mongodb.repo

Mongodb-repo for Fedora 18/17/16/15/14/13/12, CentOS 6.4/5.9 and Red Hat (RHEL) 6.4/5.9 on i686 (32-bit)

Mongodb-repo for Fedora 18/17/15/14/13/12, CentOS 6.4/5.9 and Red Hat (RHEL) 6.4/5.9 on x86_64 (64-bit)

1.3 Install mongo server and mongo client packages

Install stable version of MongoDB

2. Configure MongoDB Database Server

2.1 Edit /etc/mongod.conf file:

2.2 Check and set basic settings, before starting MongoDB (default settings are good)

2.3 Start MongoDB Server

2.4 Start MongoDB on boot

3. Test MongoDB Server

3.1 Open MongoDB Command Line Client

3.2 Save, Update and Find Some Test Data on MongoDB

4. Open MongoDB Port (27017) on Iptables Firewall (as root user again)

Edit /etc/sysconfig/iptables file:

4.1 Add following line before COMMIT:

4.2 Restart Iptables Firewall:

Note: Open MongoDB port only if you have enabled authentication or operating trusted environment.

4.3 Test remote connection

Share this post


  1. Hi, i’m getting this error:

    MongoDB shell version: 1.8.1
    connecting to:
    Thu May 19 15:36:29 Error: couldn’t connect to server shell/mongo.js:81
    exception: connect failed

  2. This configuration is not working in my fedora 15. Someone clue what the problem is?

    • Hi Roberto,

      Could you post your /etc/sysconfig/iptables file content?

    • Please make sure the “accept” line is before “commit” line **AND** all “reject” lines.

  3. @colin you need to ensure that you add the chain on top of it on /etc/sysconfig/iptables config file.

    like this :

    # Firewall configuration written by system-config-firewall
    # Manual customization of this file is not recommended.
    :INPUT ACCEPT [0:0]
    :OUTPUT ACCEPT [0:0]
    :RH-Firewall-1-INPUT - [0:0]
    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 27017 -j ACCEPT

  4. Thank you for this guide. Works for me on CENTOS 6. I did not use your iptables command, as this is only accessed from the local host, so I can not confirm that working, but it looks sane.


  5. thks again

  6. Thanks! Everything worked perfectly for me on CentOS 6.2.

  7. Hi,

    Nice tutorial.
    But I am running into a dependency problem while running the yum installation.
    –> Processing Dependency: /bin/sh for package: mongo-10gen-server-2.4.4-mongodb_1.x86_64
    –> Finished Dependency Resolution
    mongo-10gen-server-2.4.4-mongodb_1.x86_64 from 10gen has depsolving problems
    –> Missing Dependency: /bin/sh is needed by package mongo-10gen-server-2.4.4-mongodb_1.x86_64 (10gen)
    Error: Missing Dependency: /bin/sh is needed by package mongo-10gen-server-2.4.4-mongodb_1.x86_64 (10gen)
    But I see that sh executable is already present in the /bin directory.
    Could you please help me on this?


    • Hi Deepak,

      Could you first post output of following commands:

  8. Hi JR,

    Please find the details below:

  9. JR,

    Thanks for the help.
    I was doing a silly mistake. Got it.

    • Hi Deepak,

      Okay, nice to hear that you got it working. Btw. this is not best method install mongodb on Ubuntu.

  10. Hello, thanks for great tutorial, I tried alot of tutorials this one is simplest and easiest one.

    Let people know that I was already shut down my iptables due to I have already ddos protection so when I restarted iptables accidently everything stop working, so guys dont forget to check other iptables rules.




  1. Eat.Write.Code. » Blog Archive » MongoDB (Sorta Quickstart Guide) - A blog about eating, writing, and coding. And eating while writing code. Plus some other stuff. - [...] to share some information for those of you starting MongoDB to help save you some time. Read this blog…

Submit a Comment

Your email address will not be published. Required fields are marked *