How to install MongoDB on Fedora 29 / Fedora 28?

2
998
MongoDB
MongoDB

Currently, NoSQL Database managers are being widely used by developers. Since it has many advantages and their projects are the most open source. And MongoDB is one of the most popular managers. So, this article is about how to install MongoDB in Fedora 29.

MongoDB allows your teams to easily organize, use and enrich data – in real time, anywhere. MongoDB is a NoSQL and document-oriented database manager. In short, instead of saving the data in the record as the SQL database, it saves them in documents with BSON format which is a binary representation of JSON.

In the world of unrelated SQL database MongoDB is perhaps the most popular, however, it can be used by very different applications that require a semi-structured data collection. On the other hand, its use in transactional systems is not recommended as MongoDB does not support transactions.

That’s why I’m going to teach you how to install MongoDB on the latest stable version of Fedora, Fedora 29.

Install MongoDB on Fedora 29

There are several ways to install MongoDB. First, you can download the packages individually and then install them from the console. It is not complicated, but there is a problem, when there is an update of the program, you will have to repeat the process.

On the other hand, you can add the MongoDB repository and install it via DNF. The main advantage of this method is that when there is an update, it will be downloaded along with the system updates.

So, I will choose the second option.

First, create a file to add the repository:

:~$ sudo nano /etc/yum.repos.d/mongodb.repo

And add the following:

[Mongodb]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
1.- Adding the MongoDB repository
1.- Adding the MongoDB repository

Press CTRL + X and say yes to save the file.

With this the MongoDB repository is added, now you can install it without problems.

:~$ sudo dnf install mongodb-org
2.- Install MongoDB from the terminal
2.- Install MongoDB from the terminal

Now, it is installed. However, it is a good idea to enable the service. In addition, you have to start the service too.

:~$ sudo systemctl enable mongod
:~$ sudo systemctl start mongod
3.- Enabling the MongoDB service
3.- Enabling the MongoDB service

Finally, check the service status:

:~$ sudo systemctl status mongod
4.- MongoDB is running
4.- MongoDB is running

Checking the installation

To test the installation, check the installed version of MongoDB.

:~$ mongod -version
Checking the installation
5.- Checking the installation

Now access to the console:

:~$ mongo
use mydb;
6.- Using MongoDB
6.- Using MongoDB

As you can see, MongoDB is correctly installed.

Conclusion

MongoDB is a solution that is increasingly being taken into account by many developers worldwide. Its installation in Fedora 29 and Fedora 28 is relatively simple.

Please share this article with your friends.

 

 

2 COMMENTS

  1. I encountered the following problem, how to solve it. Thank you
    root@localhost chagasj]# sudo dnf install mongodb-org
    Fedora Modular 29 – x86_64 – Updates 2.7 kB/s | 8.8 kB 00:03
    Dependencies resolved.
    ================================================================================
    Package Arch Version Repository Size
    ================================================================================
    Installing:
    mongodb-org x86_64 4.0.6-1.amzn1 Mongodb 5.8 k
    Installing dependencies:
    mongodb-org-mongos x86_64 4.0.6-1.amzn1 Mongodb 11 M
    mongodb-org-server x86_64 4.0.6-1.amzn1 Mongodb 20 M
    mongodb-org-shell x86_64 4.0.6-1.amzn1 Mongodb 12 M
    mongodb-org-tools x86_64 4.0.6-1.amzn1 Mongodb 21 M

    Transaction Summary
    ================================================================================
    Install 5 Packages

    Total size: 65 M
    Installed size: 180 M
    Is this ok [y/N]: y
    Downloading Packages:
    [SKIPPED] mongodb-org-4.0.6-1.amzn1.x86_64.rpm: Already downloaded
    [SKIPPED] mongodb-org-mongos-4.0.6-1.amzn1.x86_64.rpm: Already downloaded
    [SKIPPED] mongodb-org-server-4.0.6-1.amzn1.x86_64.rpm: Already downloaded
    [SKIPPED] mongodb-org-shell-4.0.6-1.amzn1.x86_64.rpm: Already downloaded
    [SKIPPED] mongodb-org-tools-4.0.6-1.amzn1.x86_64.rpm: Already downloaded
    warning: /var/cache/dnf/Mongodb-000f68916471abbf/packages/mongodb-org-4.0.6-1.amzn1.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID e52529d4: NOKEY
    MongoDB Repository 0.0 B/s | 0 B 00:05
    Curl error (7): Couldn’t connect to server for https://www.mogodb.org/static/pgp/server-4.0.asc [Failed to connect to http://www.mogodb.org port 443: Connection refused]
    The downloaded packages were saved in cache until the next successful transaction.
    You can remove cached packages by executing ‘dnf clean packages’.

LEAVE A REPLY

Please enter your comment!
Please enter your name here