# Environment Variables

This page documents all the environment variables available in the DMK (Database Management Kit) environment configuration. These variables are set by default in `$DMK_HOME/etc/dmk.conf.default`, but you can override them in a local configuration file in `~/.dmk/dmk.conf.local` with the `set_local_dmk_config.py` script:

{% code title="$DMK\_HOME/bin/set\_local\_dmk\_config.py" overflow="wrap" %}

```bash
mongodb@vm00:/u01/app/mongodb/admin/ [mdb01] set_local_dmk_config.py INSTANCE MONGO_JOURNAL "\${MONGO_DATA_ROOT}/\${MONGO_INSTANCE}/journal"
Backup created: /home/mongodb/.dmk/dmk.conf.bak_20251024_084959
Updated MONGO_JOURNAL in [INSTANCE]
Old value: var::MONGO_JOURNAL::=::nowarn::"${MONGO_JOURNAL_ROOT}/${MONGO_INSTANCE}"::
New value: var::MONGO_JOURNAL::=::nowarn::"${MONGO_DATA_ROOT}/${MONGO_INSTANCE}/journal"::
Use 'dmkc' and 'dmkl' aliases to quickly view default and local configuration files.
```

{% endcode %}

#### Global Variables (`[GLOBAL]`)

| Variable                     | Description                                                              | Default                                                                                                        |
| ---------------------------- | ------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------- |
| `MONGO_BASE`                 | Base directory for all MongoDB deployments (e.g. binaries, config, etc). | `/u01/app/mongodb`                                                                                             |
| `MONGO_DATA_ROOT`            | Directory where MongoDB stores its data files.                           | `/u02/mongodb/data`                                                                                            |
| `MONGO_JOURNAL_ROOT`         | Directory for MongoDB journal files.                                     | `/u03/mongodb/journal`                                                                                         |
| `MONGO_LOG_ROOT`             | Global directory where instance-specific logs are stored.                | `/u04/mongodb/log`                                                                                             |
| `MONGO_BACKUP_ROOT`          | Directory used for backups of MongoDB data.                              | `/u90/mongodb/backup`                                                                                          |
| `INSTANCE_NAMING_CONVENTION` | Regular expression used to validate MongoDB instance names.              | `^mdb([a-zA-Z]{0,4})(\d+)$`                                                                                    |
| `PS1`                        | Custom shell prompt including the current MongoDB instance.              | `'${LOGNAME}@${HOSTNAME}:${PWD}/ [${MONGO_INSTANCE}] '`                                                        |
| `HOSTNAME`                   | Hostname of the server, derived via system call.                         | `bash "$(/bin/hostname 2>/dev/null \| cut -f 1 -d '.' \|\| /usr/bin/hostname 2>/dev/null \| cut -f 1 -d '.')"` |
| `PATH` (addition)            | Appends MongoDB binaries to the environment path.                        | `${MONGO_HOME}/bin`                                                                                            |

#### Instance-Specific Variables (`[INSTANCE]`)

| Variable         | Description                                                                          | Default                                   |
| ---------------- | ------------------------------------------------------------------------------------ | ----------------------------------------- |
| `MONGO_INSTANCE` | Name of the current MongoDB instance.                                                |                                           |
| `MONGO_ADMIN`    | Path to the admin directory for the current MongoDB instance.                        | `${MONGO_BASE}/admin/${MONGO_INSTANCE}`   |
| `MONGO_DATA`     | Path to the data directory.                                                          | `${MONGO_DATA_ROOT}/${MONGO_INSTANCE}`    |
| `MONGO_JOURNAL`  | Path to the journal directory .                                                      | `${MONGO_JOURNAL_ROOT}/${MONGO_INSTANCE}` |
| `MONGO_LOG`      | Path to the log directory.                                                           | `${MONGO_LOG_ROOT}/${MONGO_INSTANCE}`     |
| `MONGO_BACKUP`   | Path to the backup directory.                                                        | `${MONGO_BACKUP_ROOT}/${MONGO_INSTANCE}`  |
| `MONGO_URI`      | Connection string for the MongoDB instance. May include credentials and TLS options. |                                           |

#### Colored prompts

The `PS1` prompt is changed by DMK, and has a default value of `'${LOGNAME}@${HOSTNAME}:${PWD}/ [${MONGO_INSTANCE}] '` (as an example, it looks like this `mongodb@vm00:/home/mongodb/ [mdb01]` ). If you want to customize the prompt to add colors, you can either force the color inside the `PS1` variable or use the `PS1_COLOR` environment variable, that will be read by DMK.

* Here is an example of `PS1` modification that makes the prompt red: `var::PS1::=::warn::'\e[0;31m${LOGNAME}@${HOSTNAME}:${PWD}/ [${MONGO_INSTANCE}]\e[0m '::`
* DMK follows the following colors with the syntax `var::PS1_COLOR::=::warn::'color'::`, replacing `color` by: | Color | Code | | `black` | `\[\e[0;30m\]` | | `red` | `\[\e[0;31m\]` | | `green` | `\[\e[0;32m\]` | | `yellow` | `\[\e[0;33m\]` | | `blue` | `\[\e[0;34m\]` | | `magenta` | `\[\e[0;35m\]` | | `cyan` | `\[\e[0;36m\]` | | `lightgray` | `\[\e[0;37m\]` | | `bold_color` (for instance `bold_red`) | The first `0` is replace by a `1`, for instance `\[\e[1;31m\]` for `bold_red` |

To make those changes, open DMK local configuration file with `dmkl`, and add the `PS1` and/or `PS1_COLOR` configuration in the corresponding section (see [Using DMK](https://dbi-services.gitbook.io/dmk-mongodb/installation-and-setup/using_dmk) for more information).

{% code title="\~/.dmk/dmk.conf.local" overflow="wrap" %}

```conf
[mdb01_prod]
var::PS1_COLOR::=::warn::'red'::

[mdb01_test]
var::PS1_COLOR::=::warn::'green'::
```

{% endcode %}

### Notes

* Variables marked as `::warn` in the config may generate warnings if undefined or misconfigured.
* Instance-specific variables rely on the `MONGO_INSTANCE` variable being correctly set before use.
* TLS options, if defined, may appear in `MONGO_URI` as part of secure connection strings.
