# Updating DMK

Starting with **release 2.3.0**, DMK for MongoDB uses Python 3.6 or later instead of Perl. Follow these steps to upgrade to the latest DMK release.

As `mongodb` user:

{% stepper %}
{% step %}

#### Prepare `~/.DMK` environment file with `$DMK_HOME` and Python binary location

Backup the current environment file, and create a new one:

```bash
mongodb@vm00:/home/mongodb/ [DUMMY] mv ~/.DMK ~/.DMK_old
mongodb@vm00:/home/mongodb/ [DUMMY] echo "export DMK_HOME=${DMK_HOME}" >> ~/.DMK
mongodb@vm00:/home/mongodb/ [DUMMY] echo "export PYTHON_BIN=$(which python3)" >> ~/.DMK
mongodb@vm00:/home/mongodb/ [DUMMY] echo "export MONGO_BASE=/u01/app/mongodb" >> ~/.DMK
```

{% endstep %}

{% step %}

#### Move the former DMK folder, and unzip the new DMK.

Rename the old folder to a hidden one so it won’t be registered as an active module.

```bash
mongodb@vm00:/home/mongodb/ [DUMMY] cd /u01/app/mongodb/local/
mongodb@vm00:/u01/app/mongodb/local/ [DUMMY] ls -l
drwxrwx---. 10 mongodb mongodb 118 Jul  1 04:34 dmk
mongodb@vm00:/u01/app/mongodb/local/ [DUMMY] mv dmk .dmk_old
mongodb@vm00:/u01/app/mongodb/local/ [DUMMY] unzip /u01/app/mongodb/artifacts/dmk_mongodb-2.3.1.zip
mongodb@vm00:/u01/app/mongodb/local/ [DUMMY] ls -ail
100690250 drwxrwx---.  8 mongodb mongodb  96 Jul  1 04:24 dmk
 33554663 drwxrwx---. 10 mongodb mongodb 118 Jul  1 04:34 .dmk_old
```

{% endstep %}

{% step %}

#### Update `.bash_profile`

The `.bash_profile` must be updated. Copy it from the new version to ensure proper configuration, and merge any existing customizations.

```bash
mongodb@vm00:/home/mongodb/ [DUMMY] mv ~/.bash_profile ~/.bash_profile_old
mongodb@vm00:/home/mongodb/ [DUMMY] cp -p /u01/app/mongodb/local/dmk/templates/profile/dmk.mongodb.profile ~/.bash_profile
```

{% code title=".bash\_profile" overflow="wrap" lineNumbers="true" %}

```bash
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# User specific environment and startup programs
umask 022

# BEGIN DMK BLOCK
if [ -z "$DMK_HOME" ]; then
    if [ -f "$HOME/.DMK" ]; then
        . "$HOME/.DMK"
    else
        echo "$HOME/.DMK file does not exist. It is needed to source DMK at login. Run '. <DMK_HOME>/bin/dmk.sh' or 'source <DMK_HOME>/bin/dmk.sh' to source DMK manually this time."
        return 1
    fi
fi

# Launched at login
. $DMK_HOME/bin/dmk.sh && $PYTHON_BIN $DMK_HOME/bin/dmk_status.py --table --all
# END DMK BLOCK
```

{% endcode %}
{% endstep %}

{% step %}

#### Log back into the `mongodb` user to load the new environment

To finalize the update process, log back into the `mongodb` user:

```bash
[root@vm00 ~]# su - mongodb
Last login: Tue Jul  1 05:29:45 EDT 2025 on pts/0
2025-07-01 05:31:24 | INFO     | Default configuration file '/u01/app/mongodb/local/dmk/etc/dmk.conf.default' does not exist. Creating it.
2025-07-01 05:31:24 | INFO     | Copying template file '/u01/app/mongodb/local/dmk/templates/etc/dmk.conf.unix' to '/u01/app/mongodb/local/dmk/etc/dmk.conf.default'
2025-07-01 05:31:24 | INFO     | Local configuration file does not exist. Creating it.
2025-07-01 05:31:24 | INFO     | Copying template file '/u01/app/mongodb/local/dmk/templates/etc/dmk.conf.local.template' to '/home/mongodb/.dmk/dmk.conf.local'

Instance             State           Version    Port   Bind IPs
----------------------------------------------------------------------
mdb01                STOPPED         8.0.16     25101  0.0.0.0
```

{% endstep %}

{% step %}

#### Customize DMK

If you had custom settings in your previous `dmk.conf` file, copy them into the new `~/.dmk/dmk.conf.local` file. Specifically, check the five environment variables listed below in the `GLOBAL` section, and their non-root counterpart in the `INSTANCE` section.

For any of these variable, you can override the default value by using `set_local_dmk_config.py`, for instance:

```bash
mongodb@vm00:/home/mongodb/ [mdb01] set_local_dmk_config.py INSTANCE MONGO_JOURNAL "\${MONGO_DATA_ROOT}/\${MONGO_INSTANCE}/journal"
```

| Variable              | Path                    | Purpose                                                                                                                                                                                              |
| --------------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `$MONGO_BASE`         | `/u01/app/mongodb`      | Binary files, instance configuration files.                                                                                                                                                          |
| `$MONGO_DATA_ROOT`    | `/u02/mongodb/data/`    | MongoDB data files.                                                                                                                                                                                  |
| `$MONGO_JOURNAL_ROOT` | `/u03/mongodb/journal/` | MongoDB journal files. If you don't want to separate MongoDB journal and data files, set `MONGO_JOURNAL_ROOT` to the same value as `MONGO_DATA_ROOT` with `set_local_dmk_config.py`                  |
| `$MONGO_LOG_ROOT`     | `/u04/mongodb/log/`     | MongoDB instances log files. Default changed in release 2.3.0 from `/u02/mongodblog` to `/u04/mongodb/log`, to separate data and log files. Use `set_local_dmk_config.py` to override this variable. |
| `$MONGO_BACKUP_ROOT`  | `/u90/mongodb/backup`   | MongoDB backups location.                                                                                                                                                                            |

Use `dmkc` and `dmkl` to quickly view the default and local configuration files, and modify locally the variables 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 %}
{% endstep %}
{% endstepper %}

{% hint style="success" %}
You have successfully updated DMK to the newest release.
{% endhint %}


---

# 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/installation-and-setup/updating_dmk.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.
