Installing DMK
DMK first installation and setup.
This page describes how to install and configure DMK for the first time on a MongoDB server.
Unzipping DMK
Log in as the mongodb
user using su - mongodb
, and unzip DMK into the /u01/app/mongodb/local
directory.
su - mongodb
unzip dmk_mongodb-2.3.0.zip -d /u01/app/mongodb/local
Running dmk.sh
for the first time
dmk.sh
for the first timeThen, source the /u01/app/mongodb/local/dmk/bin/dmk.sh
script to initialize the environment. It will create the basic configuration files.
Warning Be sure to run . dmk.sh
(with a leading dot) rather than dmk.sh
to ensure that environment variables are properly set in the current shell session.
[mongodb@vm00 ~]$ . /u01/app/mongodb/local/dmk/bin/dmk.sh
2025-07-01 08:57:41 | INFO | DMK_HOME environment variable is not defined.
2025-07-01 08:57:41 | INFO | First time installation of DMK.
2025-07-01 08:57:41 | INFO | Using DMK_HOME=/u01/app/mongodb/local/dmk as default.
2025-07-01 08:57:41 | INFO | Creating DMK source file at '/home/mongodb/.DMK'
2025-07-01 08:57:41 | INFO | Default configuration file '/u01/app/mongodb/local/dmk/etc/dmk.conf.default' does not exist. Creating it.
2025-07-01 08:57:41 | INFO | Copying template file '/u01/app/mongodb/local/dmk/templates/etc/dmk.conf.unix' to '/u01/app/mongodb/local/dmk/etc/dmk.conf.default'
After running this command, the DMK environment is loaded. In particular, an alias defined in dmk.sh
allows you to reload the DMK environment at any time.
alias dmk='. ${DMK_HOME}/bin/dmk.sh'
For future use of the DMK, you can just load the environment with dmk
.
Files created at this point are :
$MONGO_BASE/etc/mongodb.lst
: List of all MongoDB instances (empty at first).$DMK_HOME/etc/dmk.conf.default
: Default configuration file for DMK. Do not modify this file, as it will be overwritten during DMK updates.~/.dmk/dmk.conf.local
: Local configuration file for DMK. Changes made here overwrite default configuration.~/.DMK
: File whereDMK_HOME
and the Python bin directory are defined.
export DMK_HOME=/u01/app/mongodb/local/dmk
export PYTHON_BIN=/usr/bin/python3
If you have a custom Python installation, please change the PYTHON_BIN
variable.
Editing .bash_profile
.bash_profile
Now, edit your .bash_profile
file to add the function which will be used to source DMK environment at login, and to switch between instances. The template can be found under /u01/app/mongodb/local/dmk/templates/profile/dmk.mongodb.profile
.
cp -p ${DMK_HOME}/templates/profile/dmk.mongodb.profile /home/mongodb/.bash_profile
This .bash_profile
will load DMK at login.
# .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"
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
You can source .bash_profile
to verify that the DMK environment is correctly loaded:
[mongodb@vm00 ~]$ . .bash_profile
2025-06-27 11:09:48 | INFO | No MongoDB instances found.
You have successfully completed the DMK installation process.
Last updated