← Back to writing

12 March 2019

Starting Database in Mongo

To start the mongo database server on the linux machine with specific parameters for the database to start with we can use a config file , generally named as

mongo-setupmongomongo-startup

To start the mongo database server on the linux machine with specific parameters for the database to start with we can use a config file , generally named as mongod.conf

The file would contain the below entry, edit the required parameters as per requirement:

# 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.

#security:

#operationProfiling:

replication:

replSetName: rs0

#sharding:

## Enterprise-Only Options

#auditLog:

#snmp:

This file can be used to start the mongo database deamon by using the below command:

mongod –config mongo.conf

 We can additionally use –fork to run the service in background

mongod –config mongo.conf –fork
The database files created when we execute the above command and start the mongo database are:

Journal – redo logs for crash recovery

Mongod.lock – to keep the database running

Pcat.ns – namespace file – system catalogue

Pcat.0,pcat.1 – data files , 2gb limit,automatically created and preallocated