Configuring and Starting MongoDB Server
As mentioned in the installation "mongod" file will works as a MongoDB server. So we need to run the mongod binary file or we need to start the service of mongod.
 Running MongoDB as a Non-Service
                Mode.
 Running MongoDB as a Non-Service
                Mode.
              mongod is the primary daemon process for the MongoDB system. It handles data requests, manages data access, and performs background management operations.
Basic syntax of mongod is as follows
mongod options
Options List
| Option | Description | 
|---|---|
| --version | Returns the mongod release number | 
| --config <filename>, -f <filename> | A configuration file for runtime configuration options (only ASCII encoding file) | 
| --verbose, -v | Internal reporting will be returned on standard output | 
| --port <port> | The TCP port on which the MongoDB instance listens for client connections.Default: 27017 | 
| --bind_ip <ip address> | The IP address that mongod binds to in order to listen for connections from applications | 
| --maxConns <number> | The maximum number of simultaneous connections that mongod will accept. | 
| --logpath <path> | Sends all logging information to a log file instead of to standard output. MongoDB will create a file if not exist but not folder structure. | 
| --dbpath <path> | The directory where the mongod instance stores its data.Default: /data/db on Linux and OS X, \data\db on Windows | 
                Let’s view some examples for the usage of the above options 
              
 Starting MongoDB without options
 Starting MongoDB without options
              - Execute 'mongod' file existed in bin folder of mongodb
- The above binary will run if the db folder is existed in the
                  path
                  - for windows c:/mongodb
- for linux /var/lib/mongodb ( or /etc/mongod.conf details)
 (We need to create above directory if not present, else mongod server will not run)
 
 Starting MongoDB in the port 24936
                instead of 27017
 Starting MongoDB in the port 24936
                instead of 27017
              mongod--port 24936
 Starting MongoDB using the db location
                at “d:/mymongo/db” and logs location at "d:/mymongo/logs"
 Starting MongoDB using the db location
                at “d:/mymongo/db” and logs location at "d:/mymongo/logs"
              - Before starting mongod for this the above folder structure we need to create directory structure like in d: need create mymongo,db,logs directories.
- mongod --logpath “d:/mymongo/logs” --dbpath “d:/mymongo/db”.
 Running MongoDB as a Service.
 Running MongoDB as a Service.
              In Windows OS
- In Windows Creating and Starting service.
                  - Create a .cfg file and mention the systemLog.path and storage.path.
- Assuming creating mymongod .cfg file in path d:\mymongo\mymongod.cfg.
- Sample mymongod.cfg file data 
 systemLog:
 destination: file
 path: c:\mymongo\log\mongod.log
 storage:
 dbpath: d:\mymongo\data\db
 
 
- Creating/Installing service
                  - "C:\mongodb\bin\mongod.exe" --config "d:\mymongo\mymongod.cfg" --install
 
- Starting server if Service installed
                  - net start MongoDB
 
- Stopping MongoDB server
                  - Net stop MongoDB
 
In Linux Machines
- Starting MongoDB
                  - sudo service mongod start
 
- Starting MongoDB
                  - sudo service mongod stop
 
- Restarting MongoDB
                  - sudo service mongod restart