Club Manager : Setting MongoDB

We have written our Data Layer but we are yet to configure our database. So we go ahead and set-up our MongoDB database next.

  • Go to https://www.mongodb.org/downloads and download the version applicable for your operating system build.
  • Once downloaded extract the content to a suitable location say D:_SVNWorkSourceMongoDB
  • Add two folders named data (to store database files) and log (to store log files) in the same directory (D:_SVNWorkSourceMongoDB)
  • We are going to use a configuration file to configure our database file and name it mongo.conf and going to place it at the same location as our MongoDB binaries (D:_SVNWorkSourceMongoDBbinmongo.conf) with following content
dbpath=..data
logpath=..logmongo-server.log
verbose=vvvvv
logappend=true

In above file we are stating that our database files are going to be stored in data folder and log-file with name mongo-server.log in log folder. Log file is to be appended and logs are having a verbosity of vvvvv.

Whenever required run this MongoDB instance using following command from command prompt and location D:_SVNWorkSourceMongoDBbin

mongod -f mongo.conf

When you do not require mongodb instance any more simply press Ctrl+C and it will stop normally.

Find below a detailed command prompt listing dirs and starting mongod instance

D:_SVNWorkSourceMongoDB>dir
 Volume in drive D is Durgesh

 Directory of D:_SVNWorkSourceMongoDB

02-05-2014  20:38    DIR          .
02-05-2014  20:38    DIR          ..
02-05-2014  20:37    DIR          bin
02-05-2014  20:43    DIR          data
04-08-2013  10:03            35,181 GNU-AGPL-3.0
02-05-2014  20:42    DIR          log
04-08-2013  10:03             1,359 README
04-08-2013  10:03            18,848 THIRD-PARTY-NOTICES
               3 File(s)         55,388 bytes
               5 Dir(s)  32,910,176,256 bytes free

D:_SVNWorkSourceMongoDB>cd bin

D:_SVNWorkSourceMongoDBbin>dir
 Volume in drive D is Durgesh

 Directory of D:_SVNWorkSourceMongoDBbin

02-05-2014  20:37    DIR          .
02-05-2014  20:37    DIR          ..
31-10-2013  21:47        11,273,728 bsondump.exe
02-05-2014  20:41                78 mongo.conf
31-10-2013  20:02         6,379,520 mongo.exe
31-10-2013  20:13        11,329,536 mongod.exe
31-10-2013  20:13        91,720,704 mongod.pdb
31-10-2013  20:30        11,308,544 mongodump.exe
31-10-2013  20:49        11,276,288 mongoexport.exe
31-10-2013  21:37        11,289,600 mongofiles.exe
31-10-2013  20:58        11,294,208 mongoimport.exe
31-10-2013  21:27        11,272,704 mongooplog.exe
31-10-2013  21:56        11,284,480 mongoperf.exe
31-10-2013  20:39        11,299,328 mongorestore.exe
31-10-2013  20:20         8,848,896 mongos.exe
31-10-2013  20:20        70,765,568 mongos.pdb
31-10-2013  21:08        11,304,960 mongostat.exe
31-10-2013  21:17        11,276,288 mongotop.exe
              16 File(s)    301,924,430 bytes
               2 Dir(s)  32,910,176,256 bytes free

D:_SVNWorkSourceMongoDBbin>type mongo.conf
dbpath=..data
logpath=..logmongo-server.log
verbose=vvvvv
logappend=true
D:_SVNWorkSourceMongoDBbin>mongod -f mongo.conf
Fri May 02 20:50:30.637
Fri May 02 20:50:30.639 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
Fri May 02 20:50:30.640
all output going to: D:_SVNWorkSourceMongoDBbin..logmongo-server.log

Leave a Reply