How to Install MongoDB Community Edition in Red Hat and CentOS 8 Linux.

MongoDB is a document-oriented cross-platform, widely used leading NoSQL database program. NoSQL means no-schema, no concept of relationship  and  not only SQL. There won’t be a rows and columns kind of things. 

MongoDB stores data in key-value pairs.  MongoDB provides agility, scalability, performance and high availability. MongoDB Community Edition is freely available for download on 64bit platform only. Let’s see the MongoDB Community Edition installation steps by steps.
1. Running Instance of CentOS/RedHat Linux
2. Internet Access to Download Packages
3. root or sudo access
Also Read: CentOS Linux 8 Installation with Screenshots
Also Read: Red Hat Enterprise Linux 8.1 Installation with Screenshots
Some of the important features are:

  1. Support ad hoc queries
  2. Indexing
  3. Replication
  4. Data Duplication
  5. Load balancing
  6. Support MatReduce
  7. Javascript in place of procedures.
  8. Support JSON data model
Step 1Download MongoDB from here
Step 2: Add a MongoDB official repository creating a .repo file. 
# vi /etc/yum.repos.d/mongodb-org-4.0.repo
name=MongoDB Repository
Insert the above value into the file and save & exit.
Step 3: Install MongoDB Community Edition
# dnf install -y mongodb-org
If you want to install a specific release of MongoDB, you need to mentioned each packages individually with it’s version number to the packages as shown below.
# dnf install -y mongodb-org-4.2.2 mongodb-org-server-4.2.2 mongodb-org-shell-4.2.2 mongodb-org-mongos-4.2.2 mongodb-org-tools-4.2.2
Default user mongod is created during the installation with having a ownership of the directory.Following are the main directory, log path and config files respectively.
/var/lib/mongo (the data directory)
/var/log/mongodb/ (the log directory)
/etc/mongod.conf (Config file)
Step 4MongoDB default port 27017
# netstat -antp | grep  27017
# ss -antp | grep  27017

Note: Port 27017 need to be open in firewall / security devices if it’s blocked.
————– FirewallD Access ————–
# firewall-cmd –zone=public –add-port=27017/tcp –permanent
# firewall-cmd –reload
Step 5Start MongoDB service and check the running status.
# systemctl status mongod
# systemctl start mongod
# systemctl status mongod

Step 6: Login into MongoDB console and Start using with mongo command. This command will connect to MongoDB console.
#  mongo
Conclusions: In this guide, we have installed MongoDB Community Edition in RHEL and CentOS 8. Kindly share your experience and comment through comment box below. Also Like Our Facebook Page.

Leave a Comment