Environment Variables

Environment variables used in DMK

This page documents all the environment variables available in the DMK (Database Management Kit) environment configuration.

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/logs

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_LOG

Path to the log directory for the current MongoDB instance.

${MONGO_LOG_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@vm01:/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 for more information).

~/.dmk/dmk.conf.local
[mdb01_prod]
var::PS1_COLOR::=::warn::'red'::

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

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.

Last updated