Atikh's DBA blog
  • Home
  • Oracle
  • MySQL
  • MongoDB
  • PostgreSQL
  • Snowflake
  • About Me
  • Contact Us

Starting and Stopping MongoDB

 Atikh Shaikh     MongoDB     No comments   

Starting the MongoDB


MongoDB is started with a mongod executable file, it has many configurable options which can be viewed with mongod--help on the command line
We will discuss a few important of them below 

--dbpath
Each mongod process needs its own data directory. if you are running multiple instances of mongod on the same machine then you need a separate directory for each instance

When mongod starts up, it creates mongod.lock in the data directory, which prevents any other mongod process from using the same directory.

--port
By default, mongod uses a 27017 port for the server to listen. In case another instance is required to be run on same machine then different port needs to be assigned.

--fork
Fork the server process, running MongoDB as daemon

--logpath
This will create a logfile in the directory specified instead of writing everything on the command line, it will overwrite the existing logfile if --logappend option is not specified in addition to --logpath. Before overwriting it take a backup of the existing logfile with the timestamp


--config
Use configuration file for additional options not specified on the command line such as mongo --config ~/.mongodb.conf to read the configuration file

So if we want to run mongo on port 27027 with data directory D:\mongodb\data\db\logs and logfile directory D:\mongodb\data\db\logs we will use the below command

mongod --dbpath=D:\mongodb\data\db --port 27027 --logpath D:\mongodb\data\db\logs\mongodblog.log

Below are commands executed and their output on the command line

Once we start mongod with options as mentioned above, it creates lock file and log file

techondba-mongd-start-port-logfile, mongodb startup

mongod.lock file in dbpath location

techondba-mongod.lock-data directory


Logfile

techondba-mongod-mongodblogs


Stopping the MongoDB


There are a couple of ways of stopping MongoDB

  • First and basic way to press Ctrl-C, It will send SIGINT or SIGTERM signal. 
  • Another way is to use the kill command 

if PID of the mongod process is xyz then kill -2 xyz will do the same Ctrl-C. (never use kill -9 as you will need to repair the database on the next startup as there are chances of corruption on datafiles)

Another way to cleanly shut down a running server is to use the shutdown command. This should be run admin database shown below

techondba-mongod-stop-shutdownServer()


Comment below if you need any additional information
  • Share This:  
  •  Facebook
  •  Twitter
  •  Instagram
  •  Pin
  •  linkedin
  •  reddit
Email ThisBlogThis!Share to XShare to Facebook

Related Posts:

  • Data Types in MongoDB MongoDB supports a wide range of data types as values in documents, we will discuss those below Basic Data Types Documents in MongoDB can be tho… Read More
  • MongoDB Storage Engines With version 3.0, MongoDB introduced the Pluggable Storage Engine API. WiredTiger is one of the pluggable storage engines bundled with MongoDB Pl… Read More
  • MongoDB 4.0 New FeaturesMongoDB 4.0 has been released on Aug 6, 2018, with tremendous new features specially ACID transactions. I have listed the MongoDB 4.0 new featur… Read More
  • Starting and Stopping MongoDB Starting the MongoDB MongoDB is started with a mongod executable file, it has many configurable options which can be viewed with mongod--help on … Read More
  • MongoDB Database Backup and Restore MongoDB stores all its data in the data directory mentioned by --dbpath during startup. Taking backup of MongoDB is as simple … Read More
Newer Post Older Post Home

0 comments:

Post a Comment

Author

Atikh Shaikh
View my complete profile

Categories

  • MongoDB (18)
  • Oracle 12c (30)
  • Oracle12cR2 New Feature (3)
  • PostgreSQL (20)
  • RMAN (10)
  • Snowflake (8)
  • mysql (23)
  • oracle (74)

Blog Archive

  • ▼  2018 (38)
    • ►  November (25)
    • ▼  December (13)
      • Starting and Stopping MongoDB
      • Oracle Database Architecture Physical and Logical
      • MongoDB Database Backup and Restore
      • Startup and Shutdown Oracle Database
      • Oracle 12c New features – Multitenant Database
      • MongoDB Storage Engines
      • Create Pluggable Database (PDB) in Oracle 12c
      • Warning: PDB altered with errors- opening PDB in O...
      • Oracle 12c: Starting and Stopping PDB
      • Know your Hostname in MySQL
      • Everything you need to know about Oracle Data Pump
      • List Databases, Tables, schemas and other basic c...
      • User Managed Backups in Oracle
  • ►  2019 (33)
    • ►  January (15)
    • ►  February (6)
    • ►  March (2)
    • ►  April (5)
    • ►  May (5)
  • ►  2020 (5)
    • ►  April (1)
    • ►  May (2)
    • ►  July (2)
  • ►  2021 (8)
    • ►  June (3)
    • ►  July (3)
    • ►  August (1)
    • ►  December (1)
  • ►  2022 (33)
    • ►  May (3)
    • ►  June (10)
    • ►  July (3)
    • ►  August (4)
    • ►  September (8)
    • ►  October (3)
    • ►  November (2)
  • ►  2023 (14)
    • ►  February (1)
    • ►  April (5)
    • ►  May (2)
    • ►  June (1)
    • ►  September (1)
    • ►  October (1)
    • ►  December (3)
  • ►  2024 (5)
    • ►  January (2)
    • ►  March (3)
  • ►  2025 (6)
    • ►  March (1)
    • ►  April (3)
    • ►  May (2)

Popular Posts

  • ORA-29283: invalid file operation: unexpected "LFI" error (1509)[29437]
    I was trying to export the schema in my windows PC, it got stuck with below error    C:\Users\shaik\Videos\technodba exp>expdp userid...
  • Oracle 23ai : The all new Hybrid Read-Only for pluggable databases (PDBs)
      The latest Oracle database version, Oracle 23ai, introduced a new open mode called Hybrid Read-Only for pluggable databases (PDBs). Local ...
  • Oracle Dataguard Broker Configuration (DGMGRL)
    Data Guard Broker is a command-line interface that makes managing primary and standby databases easy. DBA can use a single command to switch...
  • PostgreSQL : How to get data directory location for PostgreSQL instance
    Sometimes, you start working on a PostgreSQL instance but forget about the data directory, here we will discuss different methods to know th...
  • ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES
    In previous articles, we have learned about user creation and grants  in MySQL in detail, but there are a few privileges called global priv...

Labels

oracle Oracle 12c mysql PostgreSQL MongoDB oracle 19c Oracle23c oracle19c Orale PDB-CDB oracle12c python AWS Oracle ASM Virtualbox pluggable database storage engine

Pages

  • Disclaimer
  • Privacy Policy

Follow TechnoDBA

Copyright © 2025 Atikh's DBA blog | Powered by Blogger