Add following content in yum repository configuration file mongodb.repo as per your required MongoDB version and system architecture.
CentOS and RedHat systems Only
Fedora users can install it directory from its official yum repositories.
Step 2 – Install MongoDB Server
Let’s use the yum package manager to install mongodb-org package, it will automatically install all its dependencies. To install any specific revision of MongoDB specify package name with version like mongodb-org-4.0.0. The following command will install latest stable version available.
yuminstallmongodb-org
Step 3 – Start MongoDB Service
Package mongodb-org-server provided MongoDB init script, Use that script to start service.
/etc/init.d/mongodrestart
Configure MongoDB to autostart on system boot.
chkconfigmongodon
Step 4 – Check MongoDB Version
Use the following command to check installed MongoDB version