Tuesday 29 January 2013

MongoDB Installation and Configuration on Centos6.3

What is MongoDB?

MongoDB (from “humongous”) is a scalable, high-performance, open source, schema-free, document-oriented database. Written in C++. MongoDB bridges the gap between key-value stores (which are fast and highly scalable) and traditional RDBMS systems (which provide structured schemas and powerful queries).

MongoDB is very interesting document-oriented database, because it has really awesome features:
  •     Document-oriented storage (the simplicity and power of JSON-like data     schemas)
  •     Dynamic queries
  •     Full index support, extending to inner-objects and embedded arrays
  •     Query profiling
  •     Fast, in-place updates
  •     Efficient storage of binary data large objects (e.g. photos and videos)
  •     Replication and fail-over support
  •     Auto-sharding for cloud-level scalability
  •     MapReduce for complex aggregation
  •     Commercial Support, Training, and Consulting

Installing MongoDB

1.Configure Package Management System (YUM)

[root@shankar1 ~]#nano /etc/yum.repos.d/10gen.repo

[10gen]  
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686
gpgcheck=0  
enabled=1

Ctrl +x ----y

2. Install mongo server and mongo client packages

[root@shankar1 ~]#yum install mongo-10gen mongo-10gen-server
 Installed:
 mongo-10gen.i686 0:2.2.2-mongodb_1       mongo-10gen-server.i686 0:2.2.2-  mongodb_1        
3. Configure MongoDB Database Server

 [root@shankar1 ~]#nano -w /etc/mongod.conf

logpath=/var/log/mongo/mongod.log
port=27017
dbpath=/var/lib/mongo

4. Start MongoDB Server

[root@shankar1 ~]#service mongod start 

5.Start MongoDB on boot

 [root@CSSW2013NOC3 ~]# mongo
MongoDB shell version: 2.2.2
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
    http://docs.mongodb.org/
Questions? Try the support group
    http://groups.google.com/group/mongodb-user
> use test
switched to db test
> db.foo.find()
> db.foo.save({a:1})
> db.foo.find()
{ "_id" : ObjectId("5107a0b2ba0599c2355f3d3e"), "a" : 1 }
> db.foo.update({a: 1},{a: 5})
> db.foo.find()
{ "_id" : ObjectId("5107a0b2ba0599c2355f3d3e"), "a" : 5 }


Note:
SELinux Considerations
You must SELinux to allow MongoDB to start on Fedora systems. Administrators have two options:
  • enable access to the relevant ports (e.g. 27017) for SELinux. See Interfaces and Port Numbers for more information on MongoDB’s default ports.
  • disable SELinux entirely. This requires a system reboot and may have larger implications for your deployment.
   

2 comments: