Pages

Saturday 22 October 2011

MongoDb: Install

MongoDB: document oriented database management system.

MongoDB is high performance, reliable document oriented dbms, which solve horizontal scaling problem of large database.

Installation steps on window:
Download the zip as per your system configuration. I've downloaded for 32-bit window.
Extract it anywhere on your system.

Pre-Installation Step
MongoDB need to be told where to create and store database files.
so,  create  /data/db directory anywhere on your system.
I've created it inside the mongodb extracted files as it make more sense. :P

mkdir data
mkdir ./data/db



Once done, move inside mongodb /bin directory via command prompt and launch the mongodb daemon .

D:\dev_bin\mongo\bin>mongod --dbpath=./data/db

dbpath : path to your data/db directory which we created above.
NOTE: in some system dbpath may be required or else you'll get some error.

Additional options:>

--logpath /path/to/logFile
  ->to store all detail in a fill

Check it:
NOw, your daemon is up and running, it's time to get a taste of mongodb. So, fire up the mongo shell: javascript shell.
open new command prompt and  make sure you're in the mongo's /bin directory via command prompt. launch the mongo shell as follow:
mongo.exe
>

Now, you're in mongo shell. By default mongodb has an truncated database 'test' already made.  which you can queries as this:

Now, hug yourself , you got your mongodb up and running.
Instead
Issue that might arise:
mongod --help for help and startup options
Sat Oct 22 18:49:26
Sat Oct 22 18:49:26 warning: 32-bit servers don't have journaling enabled by def
ault. Please use --journal if you want durability.
Sat Oct 22 18:49:26
Sat Oct 22 18:49:26 [initandlisten] MongoDB starting : pid=3644 port=27017 dbpat
h=/data/db 32-bit host=naresh-PC
Sat Oct 22 18:49:26 [initandlisten]
Sat Oct 22 18:49:26 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are
limited to about 2 gigabytes of data
Sat Oct 22 18:49:26 [initandlisten] **       see http://blog.mongodb.org/post/13
7788967/32-bit-limitations
Sat Oct 22 18:49:26 [initandlisten] **       with --journal, the limit is lower
Sat Oct 22 18:49:26 [initandlisten]
Sat Oct 22 18:49:26 [initandlisten] db version v2.0.1, pdfile version 4.5
Sat Oct 22 18:49:26 [initandlisten] git version: 3a5cf0e2134a830d38d2d1aae7e88ca
c31bdd684
Sat Oct 22 18:49:26 [initandlisten] build info: windows (5, 1, 2600, 2, 'Service
 Pack 3') BOOST_LIB_VERSION=1_42
Sat Oct 22 18:49:26 [initandlisten] options: {}
Sat Oct 22 18:49:26 [initandlisten] exception in initAndListen: 10296 dbpath (/d
ata/db) does not exist, terminating
Sat Oct 22 18:49:26 dbexit:
Sat Oct 22 18:49:26 [initandlisten] shutdown: going to close listening sockets..
.
Sat Oct 22 18:49:26 [initandlisten] shutdown: going to flush diaglog...
Sat Oct 22 18:49:26 [initandlisten] shutdown: going to close sockets...
Sat Oct 22 18:49:26 [initandlisten] shutdown: waiting for fs preallocator...
Sat Oct 22 18:49:26 [initandlisten] shutdown: closing all files...
Sat Oct 22 18:49:26 [initandlisten] closeAllFiles() finished
Sat Oct 22 18:49:26 dbexit: really exiting now

Cause : This normally occur when  you don't provide mongodb the database saving directory path.
So, instead of making haste, hold a second and as a courtesy to mongodb, please provide dbpath also.
eg:  mongod --dbpath=./data/db





 

No comments:

Post a Comment