# Starting & Stopping MongoDB instances

This page describes three ways to manage MongoDB instances using DMK.

***

#### Managing MongoDB instances with `dmk_db_ctl.py`

You can manage MongoDB instances using the control script provided by DMK:

```bash
$DMK_HOME/bin/dmk_db_ctl.py -i <instance_name> -a [start|stop|restart]
```

Replace `<instance_name>` with the actual name of your instance (e.g., `mdb01`).

***

#### Managing MongoDB instances with aliases (`mgstart`, `mgstop`, `mgrestart`)

If you have sourced your DMK environment, you can use the following aliases:

```bash
# Start the current instance
mgstart

# Stop the current instance
mgstop

# Restart the current instance
mgrestart
```

These aliases are just shortcuts to the `dmk_db_ctl.py` script.

***

#### Managing MongoDB instances with `systemd`

If your instance is configured with a `systemd` service, you can manage it using:

```bash
sudo systemctl [start|stop|restart|status] mongod_<instance_name>.service
```

Make sure the service name matches the instance name (e.g., `mongod_mdb01.service`).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dbi-services.gitbook.io/dmk-mongodb/managing-databases/starting_stopping_instance.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
