Wednesday, 18 February 2015

Setting up MongoDB

Download mongoDB from https://www.mongodb.org/downloads. After installation, add mongoDB bin path to system path.

Step 1: Create a directory, where mongoDB stores data. For example I created directory “C:\data\db”.

Step 2: Run the command ‘mongod.exe --dbpath "c:\data\db"’. This command starts MongoDB server.

C:>mongod.exe --dbpath "c:\data\db"
2015-01-11T20:51:29.161+0530 [initandlisten] MongoDB starting : pid=5428 port=27017 dbpath=c:\data\db 64-bit host=RENT-MIS-LT3016
2015-01-11T20:51:29.161+0530 [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2015-01-11T20:51:29.161+0530 [initandlisten] db version v2.6.6
2015-01-11T20:51:29.161+0530 [initandlisten] git version: 608e8bc319627693b04cc7da29ecc300a5f45a1f
2015-01-11T20:51:29.161+0530 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_49
2015-01-11T20:51:29.161+0530 [initandlisten] allocator: system
2015-01-11T20:51:29.161+0530 [initandlisten] options: { storage: { dbPath: "c:\data\db" } }
2015-01-11T20:51:29.221+0530 [initandlisten] journal dir=c:\data\db\journal
2015-01-11T20:51:29.221+0530 [initandlisten] recover : no journal files present, no recovery needed
2015-01-11T20:51:29.281+0530 [initandlisten] allocating new ns file c:\data\db\local.ns, filling with zeroes...
2015-01-11T20:51:30.601+0530 [FileAllocator] allocating new datafile c:\data\db\local.0, filling with zeroes...
2015-01-11T20:51:30.601+0530 [FileAllocator] creating directory c:\data\db\_tmp
2015-01-11T20:51:30.831+0530 [FileAllocator] done allocating datafile c:\data\db\local.0, size: 64MB,  took 0.221 secs
2015-01-11T20:51:30.831+0530 [initandlisten] build index on: local.startup_log properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "local.startup_log" }
2015-01-11T20:51:30.831+0530 [initandlisten]     added index to empty collection
2015-01-11T20:51:30.831+0530 [initandlisten] command local.$cmd command: create { create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0 numYields:0  reslen:37 1556ms
2015-01-11T20:51:30.851+0530 [initandlisten] waiting for connections on port 27017

Step 3: Open other command prompt, and run ‘mongo.exe’
C:\>mongo.exe
MongoDB shell version: 2.6.6
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
>

To get list of commands use “db.help()”.




Prevoius                                                 Next                                                 Home

Benefits of MongoDB over RDBMS


1.   Very first benefit of MongoDB is it is schema less. Even documents in same collection don’t need to have same fields/structure.
2.   MongoDB is easy to scale. Below link explains it clearly.
3.   No complex joins like RDBMS is not required.
4.   Sharding support : As size of data grows drastically, single machine is not sufficient to handle it. Sharding solves the problem with horizontal scaling. You can add number of machines to support growth of drastically increasing data.



Prevoius                                                 Next                                                 Home

MongoDB


MongoDB is a open source NoSQL database, written in C++. MongoDB is a cross platform document oriented database.

What is a document?
Document is a set of key-value pairs.

Example
{
  "id": 1,
  "firstName": "Hari Krishna",
  "lastName": "Gurram"
}

Above document contains information about a person. There is no schema for documents.

What is a collection?
Collection is a group of documents. You can correlate collection as table and document as a row in the table. Documents in same collection don’t need to have same fields/structure.
Prevoius                                                 Next                                                 Home

Monday, 9 February 2015

sudo Vs root user


Root User
Root user is the most powerful user in the system and it can do everything. In real time, it is recommended that; don't give root access to others. If you give root access to somebody, then he can able to perform all operations, that root user can do.

sudo user
sudo user is a kind of root user, and can be permitted to execute specific commands or all commands executed by root user. Normally root user can made some users as sudo users, if the user is required to run some administrative commands.

Difference between sudo and root user
1. If you run any command as sudo user, then system keeps a log for that command, but it is not the case with root user.