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