How to Install MongoDB 3.2 on CentOS/RHEL

By | November 5, 2016

This article will help you to install MongoDB 3.2.X on CentOS, and RHEL . MongoDB is a free, cross-platform, open source, NoSQL document-oriented database. MongoDB is available as two editions, Community and Enterprise edition. MongoDB community edition is free for personal usage, whereas enterprise edition is paid version that have more features and support than the community edition.

In this article, we will walk you through the process of installing MongoDB 3.2.x Community Edition on RHEL and  CentOS Linux  servers with the help of official MongoDB repository using .rpm and .deb packages on 64-bit systems only.

 

Run MongoDB on CentOS and RHEL  Through Binaries

(Manual Installation)

Step 1: Download MongoDB  installation file

Download mongoDB  installation file  from  (https://www.mongodb.com) and copy  cp mongodb-linux-x86_64-3.2.10.tgz fils to /opt Folder and unzip/untar  the file.

[root@localhost Downloads]# cp mongodb-linux-x86_64-3.2.10.tgz /opt/

[root@localhost Downloads]# cd /opt/

[root@localhost opt]# ls

mongodb-linux-x86_64-3.2.10.tgz

[root@localhost opt]#

Step 2: UnZip/Untar the file

[root@localhost opt]# tar -xvf mongodb-linux-x86_64-3.2.10.tgz 
mongodb-linux-x86_64-3.2.10/README
mongodb-linux-x86_64-3.2.10/THIRD-PARTY-NOTICES
mongodb-linux-x86_64-3.2.10/MPL-2
mongodb-linux-x86_64-3.2.10/GNU-AGPL-3.0
mongodb-linux-x86_64-3.2.10/bin/mongodump
mongodb-linux-x86_64-3.2.10/bin/mongorestore
mongodb-linux-x86_64-3.2.10/bin/mongoexport
mongodb-linux-x86_64-3.2.10/bin/mongoimport
mongodb-linux-x86_64-3.2.10/bin/mongostat
mongodb-linux-x86_64-3.2.10/bin/mongotop
mongodb-linux-x86_64-3.2.10/bin/bsondump
mongodb-linux-x86_64-3.2.10/bin/mongofiles
mongodb-linux-x86_64-3.2.10/bin/mongooplog
mongodb-linux-x86_64-3.2.10/bin/mongoperf
mongodb-linux-x86_64-3.2.10/bin/mongod
mongodb-linux-x86_64-3.2.10/bin/mongos
mongodb-linux-x86_64-3.2.10/bin/mongo
[root@localhost opt]#

Step 3: Move to untar/unzip  files into MongoDB folder

Step 4: Create data directory and Run MongoDB server

[root@localhost /]# mkdir -p /data/db
[root@localhost bin]# ./mongod

 

Install MongoDB on CentOS and RHEL  as a service (With Scripts)

Step 1 – Add MongoDB Yum Repository

Create a /etc/yum.repos.d/mongodb-org-3.2.repo file so that you can install MongoDB directly, using yum.

[root@localhost bin]#  vi   /etc/yum.repos.d/mongodb-org-3.2.repo

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

Step 2 .Install the MongoDB packages and associated tools

yum install -y mongodb-org

Step 3 – Start MongoDB

Package mongodb-org-server provided MongoDB init script, Use that script to start service

service mongod start

 

Install and run mongoDB through configuration file

[root@localhost srv]# mkdir -p mongodb_data/db
[root@localhost bin]# ./mongod --dbpath /srv/mongodb_data/ --logpath /srv/mongodb_log --port 5000

Create < xyz.conf> files into bin directory 
[root@localhost bin]# vi test.conf
dbpath=/srv/test_date
logpath=/srv/test_log
port=5001

[root@localhost bin]# ./mongod --config  test.conf

References:
MongoDB  :

Leave a Reply

Your email address will not be published. Required fields are marked *