How to install MongoDB on CentOS 8 / RHEL 8

2
247

CentOS 8 is just out of the oven and we are still celebrating. It is not in vain that it is one of the most popular Linux distributions on servers along with Debian and Ubuntu Server. It combines everything we want for a server, is stable, well documented, based on a solid rock like RHEL and is easily accessible. That is, all in one place. However, as it has come out recently it is time to give it support. In this post, you will learn how to install MongoDB on CentOS 8. All fast and easy using DNF.

As is well known by many, MongoDB is a NoSQL database management system that is very popular in mobile programming. It is quite fast, allows high performance clustering and was a paradigm shift to traditional databases. For this reason, many developers consider it vital for their projects.

CentOS 8 has just come out and it seems that they still do not give it full support from MongoDB. Something strange, because RHEL 8, which is the base of CentOS 8, was released a few months ago, which has given enough time to adapt the packages. But today we’ll show you how to install it anyway using DNF.

So, let us start to install MongoDB on CentOS 8.

Install MongoDB on CentOS 8

The best way to install MongoDB is using its repositories, but the detail is that it seems that even many packages are not ready for CentOS 8. However, this method shown has proved reliable and effective.

First of all, open a terminal session and we have to configure the MongoDB repository. To do this, open a new file. You can use nano or Vi.

:~$ su
:~# nano /etc/yum.repos.d/mongodb-org-4.2.repo

And add the following:

[mongodb-org-4.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/development/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc
1.- Adding the MongoDB repository for CentOS 8
1.- Adding the MongoDB repository for CentOS 8

Save the changes and close the file.

Now, proceed to install MongoDB with the following command:

:~# dnf install mongodb-org
2.- Install MongoDB on CentOS 8
2.- Install MongoDB on CentOS 8

The next step is to start the MongoDB service using systemctl. So use the following command to do it:

:~# systemctl start mongod

To verify that everything is okay, it is a good idea to check the status of the service.

:~# systemctl status mongod
3.- The MongoDB service status
3.- The MongoDB service status

Finally, you can access to the MongoDB shell by using the following command:

:~# mongo
4.- The MongoDB shell
4.- The MongoDB shell

So, enjoy it.

Conclusion

MongoDB is one of the best NoSQL document-oriented database handlers. However, it seems to have problems adapting its packages to CentOS 8 and RHEL 8 and therefore, it can complicate the installation. But it hasn’t been difficult either and for now it has been stable.

Please share this post with your friends and join our Telegram channel.

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here