How To Install MongoDB On CentOS 7

From Wikipedia,

MongoDB (from “humongous”) is a cross-platform document-oriented database. Classified as a NoSQL database, MongoDB eschews the traditional table-based relational database structure in favor of JSON-like documents with dynamic schemas (MongoDB calls the format BSON), making the integration of data in certain types of applications easier and faster. Released under a combination of the GNU Affero General Public License and the Apache License, MongoDB is free and open-source software.

First developed by the software company 10gen (now MongoDB Inc.) in October 2007 as a component of a planned platform as a service product, the company shifted to an open source development model in 2009, with 10gen offering commercial support and other services.Since then, MongoDB has been adopted as backend software by a number of major websites and services, including Craigslist, eBay, Foursquare, SourceForge, Viacom, and the New York Times, among others. MongoDB is the most popular NoSQL database system.

1 – Add MongoDB to Yum repo

vim /etc/yum.repos.d/mongodb.repo
name=MongoDB repo

 2 – Install Mongodb packages

[[email protected] ~]# yum install mongodb-org
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base:
 * extras:
 * updates:
Resolving Dependencies
--> Running transaction check
---> Package mongodb-org.x86_64 0:2.6.4-1 will be installed
--> Processing Dependency: mongodb-org-mongos = 2.6.4 for package: mongodb-org-2.6.4-1.x86_64
--> Processing Dependency: mongodb-org-server = 2.6.4 for package: mongodb-org-2.6.4-1.x86_64
--> Processing Dependency: mongodb-org-tools = 2.6.4 for package: mongodb-org-2.6.4-1.x86_64
--> Processing Dependency: mongodb-org-shell = 2.6.4 for package: mongodb-org-2.6.4-1.x86_64
--> Running transaction check
---> Package mongodb-org-mongos.x86_64 0:2.6.4-1 will be installed
---> Package mongodb-org-server.x86_64 0:2.6.4-1 will be installed
---> Package mongodb-org-shell.x86_64 0:2.6.4-1 will be installed
---> Package mongodb-org-tools.x86_64 0:2.6.4-1 will be installed
--> Finished Dependency Resolution

3 – Enable and Start Mongodb Server

[[email protected] ~]# chkconfig  mongod  on
[[email protected] ~]# service   mongod start
Starting mongod (via systemctl):                           [  OK  ]

 4 – check if its running

[[email protected] ~]# ps -ef  |  grep   mongo
mongod    2587     1  1 05:24 ?        00:00:08 /usr/bin/mongod -f /etc/mongod.conf
root      2984  2270  0 05:34 pts/1    00:00:00 grep --color=auto mongo
[[email protected] ~]# netstat  -an  |  grep   27017
tcp        0      0*               LISTEN
unix  2      [ ACC ]     STREAM     LISTENING     20600    /tmp/mongodb-27017.sock
[[email protected] ~]#

5 – Open the port on firewall

[[email protected] ~]# firewall-cmd --zone=public --add-port=27017/tcp --permanent
[[email protected] ~]# firewall-cmd --reload

6 – check from other machine

[[email protected] ~]# telnet  27017
Connected to
Escape character is '^]'.