Saturday, May 5, 2018

How to Install MongoDB on Centos/RHEL 7

How to Install MongoDB on Centos/RHEL 7

In the previous post we have made about mongoDB, in this post we will discuss about installing mongoDB on centos / RHEL.
Before installation make sure the firewall and selinux have been turned off. If you do not know how to turn off selinux visit the following post (Disable SELinux without reboot in CentOS and RHEL and Disable SELinux without reboot in CentOS and RHEL)

After the firewall and selinux have been shut down, the installation process is ready.

The first step of mongoDB installation is to add mongoDB repository, follow these steps:
For MongoDB 3.6 repository

[root@siskom]# vi /etc/yum.repos.d/mongo-db-org-3.6.repo

[mongodb-org-3.6]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc

For MongoDB 3.4 repository

[root@siskom]# vi /etc/yum.repos.d/mongo-db-org-3.4.repo

[mongodb-org-3.4]
name=MongoDB 3.4 Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
gpgcheck=0
enabled=1
After adding mongoDB repository the next step is the installation process, follow these steps:

[root@siskom]# yum install -y mongodb-org
if you want to install mongodb specifically or not all packages you want to install, follow these steps:

[root@siskom]# yum install -y mongodb-org-3.6.4 mongodb-org-server-3.6.4 mongodb-org-shell-3.6.4 mongodb-org-mongos-3.6.4 mongodb-org-tools-3.6.4
wait a while until mongodb installation is complete.
to run mongoDB, you can use service and systemctl,

Start with systemctl
[root@siskom]# systemctl start mongod
Start with service
[root@siskom]# service mongod start
You can also enable mongodb to auto run at startup or when new server starts / restarts.

with systemctl
[root@siskom]# systemctl enable mongod
with chkconfig
[root@siskom]# chkconfig mongod on
NEXT ARTICLE Next Post
PREVIOUS ARTICLE Previous Post
NEXT ARTICLE Next Post
PREVIOUS ARTICLE Previous Post