Installing MongoDB

Installing MongoDB for integration with the DMK.

The following steps outline how to install MongoDB using the Optimal Flexible Architecture (OFA) approach.

Installation requirements

installation_requirements.sh
dnf -y install wget unzip

Create the directory structure

Create all the mandatory directories for the installation as root user.

directory_creation.sh
export MONGO_BASE=/u01/app/mongodb
export MONGO_DATA_ROOT=/u02/mongodb/data
export MONGO_JOURNAL_ROOT=/u03/mongodb/journal
export MONGO_LOG_ROOT=/u04/mongodb/logs
export MONGO_BACKUP_ROOT=/u90/mongodb/backup
mkdir -p $MONGO_BASE
mkdir -p $MONGO_DATA_ROOT
mkdir -p $MONGO_JOURNAL_ROOT
mkdir -p $MONGO_LOG_ROOT
mkdir -p $MONGO_BACKUP_ROOT
mkdir -p $MONGO_BASE/local
mkdir -p $MONGO_BASE/admin
mkdir -p $MONGO_BASE/etc
mkdir -p $MONGO_BASE/product
mkdir -p $MONGO_BASE/artifacts

Download MongoDB binaries

Depending on your requirements, visit the official MongoDB website to download the appropriate binaries. Select the desired edition (e.g., Community Edition), version, and platform. Be sure to choose the .tgz package and copy the corresponding download links. A .tgz installation is preferred to allow multiple versions of MongoDB on the same system.

For example, for MongoDB 8.0.11 Community Edition on RHEL 8.10, the download links are:

The MongoDB Shell and CLI Database Tools versions are independent of the MongoDB Server version.

On the server, download and extract the binaries as root:

mongo_bin_download.sh
MONGO_VERSION=8.0.11
cd $MONGO_BASE/artifacts
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel8-${MONGO_VERSION}.tgz
wget https://downloads.mongodb.com/compass/mongosh-2.5.6-linux-x64.tgz
wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-rhel88-x86_64-100.12.2.tgz
mkdir -p $MONGO_BASE/product/$MONGO_VERSION/bin
for file in $MONGO_BASE/artifacts/*.tgz; do
    tar -xvzf "$file" -C $MONGO_BASE/product/$MONGO_VERSION
done

find $MONGO_BASE/product/$MONGO_VERSION/ -executable -type f -exec ln -s {} $MONGO_BASE/product/$MONGO_VERSION/bin/ ';'
ls -l $MONGO_BASE/product/$MONGO_VERSION/bin/

MongoDB User Creation

Create a mongodb group and user, and grant the user ownership of the directories you just created.

user_creation.sh
groupadd mongodb -g 1500
useradd --uid 1500 -d /home/mongodb -g mongodb -m -s /bin/bash mongodb
chown -R mongodb: /u01
chown -R mongodb: /u02
chown -R mongodb: /u03
chown -R mongodb: /u04
chown -R mongodb: /u90

Last updated