Install MongoDB on Fedora 24

The steps to install MongoDB on Fedora 24 is pretty simple.

 

First, login to the server as root user.

Then, we should add the repository to download the package. Open a new repo file ‘mongodb.repo’ using below command.

root@fedora # vi /etc/yum.repos.d/mongodb.repo

Option A: If you are running a 64-bit system, add the following information to the file you’ve created, using i to insert:

[mongodb]

name=MongoDB Repository

baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/

gpgcheck=0

enabled=1

Then exit and save the file with the command :wq.

Option B: If you are running a 32-bit system, add the following information to the file you’ve created, using i to insert:

[mongodb]

name=MongoDB Repository

baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686/

gpgcheck=0

enabled=1

Then exit and save the file with the command :wq .

Once you have done this, installing MongoDB is now one command away.

dnf install mongodb-org mongodb-org-server

Now you should get output similar to below. When rompted with Y / n, enter yes or y to download and install the package

[root@fedora]# dnf install mongodb-org mongodb-org-server

Last metadata expiration check: 0:00:17 ago on Thu Aug 4 19:34:04 2016.

Dependencies resolved.

======================================================================================================================================================

Package Arch Version Repository Size

======================================================================================================================================================

Installing:

mongodb-org x86_64 2.6.12-1 mongodb 4.6 k

mongodb-org-mongos x86_64 2.6.12-1 mongodb 6.9 M

mongodb-org-server x86_64 2.6.12-1 mongodb 9.1 M

mongodb-org-shell x86_64 2.6.12-1 mongodb 4.3 M

mongodb-org-tools x86_64 2.6.12-1 mongodb 90 M


Transaction Summary

======================================================================================================================================================

Install 5 Packages


Total size: 110 M

Installed size: 279 M

Is this ok [y/N]:

Once installed,

Start-Up MongoDB

[root@fedora]#systemctl start mongod

Check MongoDB Service Status

[root@fedora]#systemctl status mongod

Start the MongoDB Service at Boot

[root@fedora]#systemctl enable mongod

Summary List of Status Statistics (Continuous)

[root@fedora]#mongostat

Summary List of Status Statistics (5 Rows, Summarized Every 2 Seconds)

[root@fedora]#mongostat –rowcount 5 2

Enter the MongoDB Command Line

[root@fedora]#mongo

By default, running this command will look for a MongoDB server listening on port 27017 on the localhost interface.

If you’d like to connect to a MongoDB server running on a different port, then use the –port option. For example, if you wanted to connect to a local MongoDB server listening on port 23456, then you’d issue the following command:

[root@fedora]#mongo –port 23456

Shutdown MongoDB

[root@fedora]#systemctl stop mongod

You may also like...

6 Responses

  1. bob otter says:

    To get the latest mongodb
    baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/3.4/x86_64/

  2. Darius says:

    Hi,
    Thank you for the great tutorial !!! systemctl start mongod this is what i been looking for two days….Good luck sir!

  3. Martin says:

    Hi peopleI actually I’ll , I’m not really a devops sort of bloke but I’m trying to upgrade from mongDB 3.2 to 3.4 but when I run the yum command after updating the config to get the latest mongodb (Thanks Bob Otter, much appreciated) I get the message that essentially I need to run yum with –best –erasing to force the ugrade.
    This clearly says erase the old Mongo and install the new version.
    I have people that depend upon the database so you can appreciate I feel a little concerned about running the command. Is my concern justified or is it just a formality?
    If anyone can give any advice I would be eternally grateful.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.