MongoDB

MongoDB is arise in the mid-2000s under NoSQL community. Dwight Merriman and Eliot Horowitz, who had encountered development and scalability issues with traditional relational database approaches while building Web applications at DoubleClick, an Internet advertising company that is now owned by Google Inc. According to Merriman, the name of the database was derived from the word humongous to represent the idea of supporting large amounts of data. Merriman and Horowitz helped form 10Gen Inc. in 2007 to commercialize MongoDB and related software. The company was renamed MongoDB Inc. in 2013. The database was released to open source in 2009 and is available under the terms of the Free Software Foundation’s GNU AGPL Version 3.0 commercial license.

MongoDB allow to use collections and documents instead of using tables and rows as in relational databases. Documents comprise key-value pairs. Collections contain sets of documents and functions just like database schema in relational databases.

Below are few characteristics of the MongoDB:

  • Written in: C++
  • Main point: Retains some friendly properties of SQL. (Query, index)
  • License: AGPL (Drivers: Apache)
  • Protocol: Custom, binary (BSON)
  • Master/slave replication (auto failover with replica sets)
  • Sharding built-in
  • Queries are javascript expressions
  • Run arbitrary javascript functions server-side
  • Better update-in-place
  • Uses memory mapped files for data storage
  • Performance over features
  • Text search integrated
  • GridFS to store big data + metadata
  • Has geospatial indexing
  • Data center aware

Install MongoDB

MongoDB 3 is copied to 10.161.121.8 server (D:\SHARED\LRIS_RESOURCES). Get a copy of the file(mongodb-win32-x86_64-2008plus-ssl-3.0.7-signed) and install it in your pc.

Note: install in the D:\mongodb folder for continue this guide.

Configure MongoDB

create two folders “data” and “log” in the D:\mongodb folder. Again create mongo.config file and copy paste below text.

##store data here
dbpath=D:\mongodb\data
##all output go here
logpath=D:\mongodb\log\mongo.log
##log read and write operations
diaglog=3

 

Run Mongo DB

Now you will have the below folder structure in path D:\mongodb

Capture3

run command prompt with administrator privileges, use cd command to navigate D:\mongodb folder. Then type below command to run the mongo service.

mongod --config D:\mongodb\mongo.config

 

Install Mongo DB as a windows service

You can add mongo DB service as a windows service using below command. Before executing below command make sure to use cd command to navigate D:\mongodb\bin folder.

"D:\mongodb\bin\mongod.exe" --config "D:\mongodb\mongo.config" --install

 

Access Mongo DB console

open command prompt and direct to D:\mongodb\bin folder using “cd” command. Execute below command to start the console.

mongo.exe

output:

Capture

Creating a snapshot

open command prompt and direct to D:\mongodb\bin folder using “cd” command.

mongodump --db <db_name>

output:

Capture1.png

There are tons of option you can use with mongodump in here.

Restore a backup

open command prompt and direct to D:\mongodb\bin folder using “cd” command.

mongorestore --db <db_name> <dump_location>

output:
drop database
Capture
restore the dump file(bson)
Capture21

There are tons of option you can use with mongorestore in here.

Latest MongoDB manual 3.0 is here.

 

MongoDB client

For people who doesn’t like command prompt can use different client software to access the server. MongoChef is one of the well known software which is support for latest MongoDB versions.

You can get a copy of the software from the 10.161.121.8 server (D:\SHARED\LRIS_RESOURCES).

 

Note : For people who are interested feel free to access MongoDB open test instance in 10.161.121.11 server. The service is running on port 27017.