MongoDB

Installing MongoDB on Windows 7

MongoDB is a open-source, high performance, NOSQL database. Server (mongod.exe), Client (mongo.exe) by 10gen.com. Installing through binaries is one of the simplest and most easiest way. It’s a zip file contains only binary executable, no installer.

This is a step by step guide to install mongodb on windows 7.

Download Mongodb

Download mongodb from mongodb website. Choose 32/64 bit binary depending on windows OS architecture. Create a folder mongodb and after that unzip and extract to your preferred location. for example.

C:\mongodb\
C:\mongodb\mongodb-2.4>

The bin folder contains all the mongo executables.

C:\mongodb\mongodb-2.4\bin>dir
 Volume in drive C has no label.
 Volume Serial Number is F4E7-D692

 Directory of C:\mongodb\mongodb-2.4\bin

06/05/2013  10:15 AM              .
06/05/2013  10:15 AM              ..
06/05/2013  10:15 AM        11,231,744 bsondump.exe
06/05/2013  10:15 AM         6,355,456 mongo.exe
06/05/2013  10:15 AM        11,287,552 mongod.exe
06/05/2013  10:14 AM        91,515,904 mongod.pdb
06/05/2013  10:14 AM        11,266,560 mongodump.exe
06/05/2013  10:14 AM        11,234,816 mongoexport.exe
06/05/2013  10:14 AM        11,247,104 mongofiles.exe
06/05/2013  10:14 AM        11,252,736 mongoimport.exe
06/05/2013  10:14 AM        11,231,744 mongooplog.exe
06/05/2013  10:15 AM        11,243,008 mongoperf.exe
06/05/2013  10:14 AM        11,257,856 mongorestore.exe
06/05/2013  10:15 AM         8,816,640 mongos.exe
06/05/2013  10:14 AM        70,659,072 mongos.pdb
06/05/2013  10:14 AM        11,262,976 mongostat.exe
06/05/2013  10:14 AM        11,234,816 mongotop.exe
              15 File(s)    301,097,984 bytes
               2 Dir(s)  37,675,552,768 bytes free

Configuration File

Let’s create the mongodb configuration file ‘mongod.cfg’ in folder C:\mongodb\mongodb-2.4\mongod.cfg Create the requisite data folder and log file.

## Data folder
dbpath=C:\mongodb\mongodb-2.4\data
	 
##Log file
logpath=C:\mongodb\mongodb-2.4\log

Start MongoDB Server

Use mongod.exe to start the mongodb server. All the logs is being redirected to mongodb log file.

C:\mongodb\mongodb-2.4\bin>mongod --config C:\mongodb\mongodb-2.4\mongod.cfg
Wed Jun 05 10:46:54.654 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
Wed Jun 05 10:46:54.655 all output going to: C:\mongodb\mongodb-2.4\log.txt

Content of mongodb log file.

Wed Jun 05 10:46:54.857 [initandlisten] MongoDB starting : pid=2728 port=27017 dbpath=C:\mongodb\mongodb-2.4\data 32-bit host=SP-PC
Wed Jun 05 10:46:54.857 [initandlisten]
Wed Jun 05 10:46:54.857 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
Wed Jun 05 10:46:54.857 [initandlisten] **       32 bit builds are limited to less than 2GB of data (or less with --journal).
Wed Jun 05 10:46:54.857 [initandlisten] **       Note that journaling defaults to off for 32 bit and is currently off.
Wed Jun 05 10:46:54.857 [initandlisten] **       See http://dochub.mongodb.org/core/32bit
Wed Jun 05 10:46:54.858 [initandlisten]
Wed Jun 05 10:46:54.858 [initandlisten] db version v2.4.4
Wed Jun 05 10:46:54.858 [initandlisten] git version: 4ec1fb96702c9d4c57b1e06dd34eb73a16e407d2
Wed Jun 05 10:46:54.858 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=0, build=6002, platform=2, service_pack='Service Pack 2') BOOST_LIB_VERSION=1_49
Wed Jun 05 10:46:54.858 [initandlisten] allocator: system
Wed Jun 05 10:46:54.858 [initandlisten] options: { config: "C:\mongodb\mongodb-2.4\mongod.cfg", dbpath: "C:\mongodb\mongodb-2.4\data", logpath: "C:\mongodb\mongodb-2.4\log.txt" }
Wed Jun 05 10:46:54.948 [FileAllocator] allocating new datafile C:\mongodb\mongodb-2.4\data\local.ns, filling with zeroes...
Wed Jun 05 10:46:54.948 [FileAllocator] creating directory C:\mongodb\mongodb-2.4\data\_tmp
Wed Jun 05 10:46:55.068 [FileAllocator] done allocating datafile C:\mongodb\mongodb-2.4\data\local.ns, size: 16MB,  took 0.117 secs
Wed Jun 05 10:46:55.068 [FileAllocator] allocating new datafile C:\mongodb\mongodb-2.4\data\local.0, filling with zeroes...
Wed Jun 05 10:46:55.138 [FileAllocator] done allocating datafile C:\mongodb\mongodb-2.4\data\local.0, size: 16MB,  took 0.068 secs
Wed Jun 05 10:46:55.139 [initandlisten] command local.$cmd command: { create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0  reslen:37 192ms
Wed Jun 05 10:46:55.142 [websvr] admin web console waiting for connections on port 28017
Wed Jun 05 10:46:55.142 [initandlisten] waiting for connections on port 27017
 

Connect to mongo using client.

Use mongo.exe to connect the mongodb server.

C:\mongodb\mongodb-2.4\bin>mongo
MongoDB shell version: 2.4.4
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

Server has startup warnings:
Wed Jun 05 10:46:54.857 [initandlisten]
Wed Jun 05 10:46:54.857 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary
Wed Jun 05 10:46:54.857 [initandlisten] **       32 bit builds are limited to less than 2GB of data (or less with --journal).
Wed Jun 05 10:46:54.857 [initandlisten] **       Note that journaling defaults to off for 32 bit and is currently off.
Wed Jun 05 10:46:54.857 [initandlisten] **       See http://dochub.mongodb.org/core/32bit
Wed Jun 05 10:46:54.858 [initandlisten]
>
> show dbs
local   0.03125GB
> use local
switched to db local
> show collections
startup_log
> db.startup_log.find()
{ "_id" : "SP-PC-1370409414933", "hostname" : "SP-PC", "startTime" : I
SODate("2013-06-05T05:16:54Z"), "startTimeLocal" : "Wed Jun 05 10:46:54.933", "c
mdLine" : { "config" : "C:\\mongodb\\mongodb-2.4\\mongod.cfg", "dbpath" : "C:\\m
ongodb\\mongodb-2.4\\data", "logpath" : "C:\\mongodb\\mongodb-2.4\\log.txt" }, "
pid" : 2728, "buildinfo" : { "version" : "2.4.4", "gitVersion" : "4ec1fb96702c9d
4c57b1e06dd34eb73a16e407d2", "sysInfo" : "windows sys.getwindowsversion(major=6,
 minor=0, build=6002, platform=2, service_pack='Service Pack 2') BOOST_LIB_VERSI
ON=1_49", "loaderFlags" : "/nologo /LTCG /DEBUG /LARGEADDRESSAWARE /NODEFAULTLIB
:MSVCPRT", "compilerFlags" : "/TP /nologo /EHsc /W3 /wd4355 /wd4800 /wd4267 /wd4
244 /Z7 /errorReport:none /O2 /Oy- /MT /GL", "allocator" : "system", "versionArr
ay" : [  2,  4,  4,  0 ], "javascriptEngine" : "V8", "bits" : 32, "debug" : fals
e, "maxBsonObjectSize" : 16777216 } }

>
>
> db.startup_log.find().toArray()
	[
	        {
	                "_id" : "SP-PC-1370409414933",
	                "hostname" : "SP-PC",
	                "startTime" : ISODate("2013-06-05T05:16:54Z"),
	                "startTimeLocal" : "Wed Jun 05 10:46:54.933",
	                "cmdLine" : {
	                        "config" : "C:\\mongodb\\mongodb-2.4\\mongod.cfg",
	                        "dbpath" : "C:\\mongodb\\mongodb-2.4\\data",
	                        "logpath" : "C:\\mongodb\\mongodb-2.4\\log.txt"
	                },
	                "pid" : 2728,
	                "buildinfo" : {
	                        "version" : "2.4.4",
	                        "gitVersion" : "4ec1fb96702c9d4c57b1e06dd34eb73a16e407d2",
	                        "sysInfo" : "windows sys.getwindowsversion(major=6, minor=0, build=6002, platform=2, service_pack='Service Pack 2') BOOST_LIB_VERSION=1_
	49",
	                        "loaderFlags" : "/nologo /LTCG /DEBUG /LARGEADDRESSAWARE/NODEFAULTLIB:MSVCPRT",
	                        "compilerFlags" : "/TP /nologo /EHsc /W3 /wd4355 /wd4800/wd4267 /wd4244 /Z7 /errorReport:none /O2 /Oy- /MT /GL",
	                        "allocator" : "system",
	                        "versionArray" : [
	                                2,
	                                4,
	                                4,
	                                0
	                        ],
	                        "javascriptEngine" : "V8",
	                        "bits" : 32,
	                        "debug" : false,
	                        "maxBsonObjectSize" : 16777216
	                }
	        }
	]
>
>

Leave a Reply to assist you..

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s