top of page
Writer's pictureRajesh S Nair

To start working on the mongo database, we would first want the installed mongo package to run as a service .These deamons will serve as a server/platform for our database instances to run.This deamon is represented by "mongod" and can be initiated by running mongod.exe or mongod.sh scripts in windows/unix .


Follow below steps to run a mongo deamon as a service in the server:

1. Start MongoDB

sudo service mongod start


2. Verify that MongoDB has started successfully

[initandlisten] waiting for connections on port 27017


3. Stop MongoDB.

sudo service mongod stop


4. Restart MongoDB

sudo service mongod restart


Each database instances will be running on unique ports .Default port for mongo database is 27017.

Run the below command to start a database instance on the server with the specific parameters of your requirement:

mongod --config mongo.conf


mongo.conf is a config file containing the different startup parameters provided as input to the mongod deamon.Below is an example of mongod.conf file containing all the general parameters used for a database startup:


# mongod.conf

# where to write logging data.

systemLog:

destination: file

logAppend: true

path: /u01/mongo/log/temp_mongod.log

# Where and how to store data.

storage:

dbPath: /u01/mongo/tempData

journal:

enabled: true

# engine:

# mmapv1:

# wiredTiger:

# how the process runs

processManagement:

fork: true # fork and run in background

pidFilePath: /u01/mongo/tempData/mongod.pid # location of pidfile

#timeZoneInfo: /usr/share/zoneinfo

# network interfaces

net:

port: 27017

#bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.

bindIp: 172.30.5.71 # Listen to local interface only, comment to listen on all interfaces.

replication:

replSetName: rs0

## Enterprise-Only Options

29 views0 comments
Writer's pictureRajesh S Nair

Installing mongo database is comparatively simpler and hassle free as compared to traditional databases.The main idea of mongo database is to assist on the go application development with providing minimum overhead in understanding and implementing underlying database architecture.


Mongo Installation in Unix/Linux/Ubuntu


1. Import the public key used by the package management system.

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5


Create a list file for MongoDB

echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list


2. Reload local package database

sudo apt-get update


3. Install the MongoDB packages

sudo apt-get install -y mongodb-org


Install a specific release of MongoDB

sudo apt-get install -y mongodb-org=3.6.4 mongodb-org-server=3.6.4 mongodb-org-shell=3.6.4 mongodb-org-mongos=3.6.4 mongodb-org-tools=3.6.4


4. Pin a specific version of MongoDB

echo "mongodb-org hold" | sudo dpkg --set-selections

echo "mongodb-org-server hold" | sudo dpkg --set-selections

echo "mongodb-org-shell hold" | sudo dpkg --set-selections

echo "mongodb-org-mongos hold" | sudo dpkg --set-selections

echo "mongodb-org-tools hold" | sudo dpkg --set-selections


Mongo Installation in Windows


To install MongoDB on Windows, download the Windows zip from the MongoDB

downloads page. Use the advice in the previous section to choose the correct version of

MongoDB. There are 32-bit and 64-bit releases for Windows, so select whichever version

you’re running. When you click the link, it will download the .zip. Use your favorite

extraction tool to unzip the archive.


Now you need to make a directory in which MongoDB can write database files. By

default, MongoDB tries to use the \data\db directory on the current drive as its data

directory (for example, if you’re running mongod on C:, it’ll use C:\data\db). You can

create this directory or any other empty directory anywhere on the filesystem. If you

chose to use a directory other than \data\db, you’ll need to specify the path when you

start MongoDB, which is covered in a moment.


Now that you have a data directory, open the command prompt (cmd.exe). Navigate to

the directory where you unzipped the MongoDB binaries and run the following:


If you chose a directory other than C:\data\db, you’ll have to specify it here, with the

--dbpath argument:

$ bin\mongod.exe --dbpath C:\Documents and Settings\Username\My Documents\db


Installing as a Service


MongoDB can also be installed as a service on Windows. To install, simply run with the

full path, escape any spaces, and use the --install option. For example:

$ C:\mongodb-windows-32bit-1.6.0\bin\mongod.exe

--dbpath "\"C:\Documents and Settings\Username\My Documents\db\"" --install


It can then be started and stopped from the Control Panel.


13 views0 comments
Writer's pictureRajesh S Nair

MongoDB was initially created in 2008 as part of a hosted application stack

• The companywas originally called 10gen.

• As part of their overarching plan to create the 10gen platform, the company built a database.


So , 10gen became a database company.

• In 2013, the company rebranded asMongoDB, Inc.

• The founders have other startups to their credit: DoubleClick, ShopWiki, Gilt.

• Themotivation for the database came fromobserving the following pattern with application development.

– The user base grows.

– The associated body of data grows.

– Eventually the application outgrows the database.

– Meeting performance requirements becomes difficult.


MongoDB is a document-oriented database, not a relational one. The primary reason

for moving away from the relational model is to make scaling out easier, but there are

some other advantages as well.

A document-oriented database replaces the concept of a “row” with a more flexible

model, the “document.” By allowing embedded documents and arrays, the documentoriented

approach makes it possible to represent complex hierarchical relationships

with a single record. This fits naturally into the way developers in modern object oriented

languages think about their data.


Below diagram will give insight on how a no-SQL database like mongo differs from traditional databases in terms of consistency, availability and partition tolerance.

Mongo will best suite the environment where consistency and partition tolerance holds key to the business model.



The below figure shows the various features a mongo database possess making it a cutting edge database to cater the current market requirement of application development.











18 views0 comments
bottom of page