Thursday, 9 May 2013

MongoDB Install and Configure (NO-SQL database)

MongoDB Install and Configure (NO-SQL database)


Description
MongoDB is an opensource document database and the leading NoSQL database. Written in C++.
The Features of MongoDB are as Follows :
1 : Document-oriented storage
2 : Full Index Support
3 : Replication and High availability
4 : Auto sharding
5 : Querying
6 : Map/Reduce
7 : GridFS
8 : Commercial Support.

How to install and configure MongoDB on linux.
MongoDB runs on most platforms, and supports 32-bit and 64-bit architectures. 10gen, the MongoDB makers,
provides both binaries and packages.

The 10gen repository contains two packages :
mongo-10gen-server :
This package contains the mongod and mongos daemons from the latest stable release and associated configuration
and init scripts.
mongo-10gen :
This package contains all MongoDB tools from the latest stable release.
Install MongoDB
Step 1 : Configure Package Management System (YUM)
Create a /etc/yum.repos.d/10gen.repo file to hold information about your repository. If you are running a 64-bit
system (recommended,) place the following configuration in /etc/yum.repos.d/10gen.repo file.

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

If you are running a 32-bit system, which isn’t recommended for production deployments, place the following
configuration in /etc/yum.repos.d/10gen.repo file:

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

Install Packages
Issue the following command (as root or with sudo) to install the latest stable version of MongoDB and
the associated tools.

yum install mongo-10gen mongo-10gen-server

When this command completes, you have successfully installed MongoDB.

Configure MongoDB
You can configure MongoDB using /etc/mongod.conf file. and you can find the control script at
/etc/rc.d/init.d/mongod

This MongoDB instance will store its data files in the /var/lib/mongo and its log files in /var/log/mongo,
and run using the mongod user account.
Note If you change the user that runs the MongoDB process, you will need to modify the access control rights to
the /var/lib/mongo and /var/log/mongo directories.

Start MongoDB
You can start the MongoDB using the following command as

service mongod start

You can verify that the mongod process has started successfully by checking the contents of the log file
at /var/log/mongo/mongod.log

You may optionally, ensure that MongoDB will start following a system reboot, by issuing the following command
(with root privileges:)

chkconfig mongod on

Stop MongoDB
Stop the mongod process by issuing the following command (as root, or with sudo)

service mongod stop

Restart MongoDB
You can restart the mongod process by issuing the following command (as root, or with sudo)

service mongod restart

Using MongoDB

Connect to a mongod as

mongo

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

Select a Database

db

db returns the name of the current database.


No comments:

Post a Comment