Monday, 7 March 2016

How to Install MongoDB 3.0 on CentOS


Step 1: Add MongoDB Yum Repository


Add following content in yum repository configuration file,  as per your required MongoDB version and system architecture. For this article we are using MongoDB 3.0 repository.


vim /etc/yum.repos.d/mongodb.repo


For MongoDB 3.0.X


For 64bit Systems:


[mongodb-org-3.0]

name=MongoDB 3.0 Repository

baseurl=http://repo.mongodb.org/yum/redhat/6/mongodb-org/stable/x86_64/

gpgcheck=0

enabled=1


For MongoDB 2.6.X


For 64bit Systems:


[MongoDB]

name=MongoDB Repository

baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/

gpgcheck=0

enabled=1


For 32bit Systems:


[MongoDB]

name=MongoDB Repository

baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686/

gpgcheck=0

enabled=1


:wq


Step 2: Install MongoDB


yum install mongodb-org


Step 3: Start MongoDB


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


# /etc/init.d/mongod restart


Configure MongoDB to auto start on system boot.


# chkconfig mongod on



Step 4: Check MongoDB Version and Test Setup


Use following command to check installed mongodb version


[root@tecadmin ~]#  mongo --version


MongoDB shell version: 3.0.0



Connect MongoDB using command line and execute some test commands for checking proper working.


[root@tecadmin ~]#  mongo


> use mydb;

> db.test.save( { a: 1 } )

> db.test.find()


  { "_id" : ObjectId("54fc2a4c71b56443ced99ba2"), "a" : 1 }


Congratulation’s You have successfully installed mongodb server on your system



Configure MongoDB For connection:


vim  /etc/mongod.conf


Uncomment this line : we can set optional port here:


port=27017


Below line looks like this: add bind ip: 0.0.0.0

#bind_ip=127.0.0.1

bind_ip=0.0.0.0


:wq



service mongod restart



telnet localhost 27017



For Web Base UI: install robomongo  package


Ref :


http://docs.mongodb.org/v3.0/release-notes/3.0/

http://tecadmin.net/install-mongodb-on-centos-rhel-and-fedora/


No comments: