MongoDB 7.0 Enterprise Installation on Linux using Tarball
Table of Contents
1. Prerequisites
Install the required system libraries that MongoDB depends on.
# Verify OS version
[root@mongo01 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.7 (Ootpa)
[root@mongo01 ~]#
# Install required dependencies
[root@mongo01 ~]# dnf install -y cyrus-sasl cyrus-sasl-gssapi cyrus-sasl-plain krb5-libs \
> libcurl libpcap lm_sensors-libs net-snmp net-snmp-agent-libs \
> openldap openssl rpm-libs numactl-libs xz-libs tar
Last metadata expiration check: 0:20:27 ago on Wed 30 Sep 2026 05:56:37 AM EDT.
Package cyrus-sasl-2.1.27-6.el8_5.x86_64 is already installed.
Package cyrus-sasl-gssapi-2.1.27-6.el8_5.x86_64 is already installed.
Package cyrus-sasl-plain-2.1.27-6.el8_5.x86_64 is already installed.
Package krb5-libs-1.18.2-34.0.1.el8_10.x86_64 is already installed.
Package libcurl-7.61.1-34.el8_10.13.x86_64 is already installed.
Package libpcap-14:1.9.1-5.el8.x86_64 is already installed.
Package openldap-2.4.46-21.el8_10.x86_64 is already installed.
Package openssl-1:1.1.1k-17.el8_6.x86_64 is already installed.
Package rpm-libs-4.14.3-24.el8_6.x86_64 is already installed.
Package numactl-libs-2.0.12-13.el8.x86_64 is already installed.
Dependencies resolved.
=============================================================================================================
Package Arch Version Repository Size
=============================================================================================================
Installing:
lm_sensors-libs x86_64 3.4.0-23.20180522git70f7e08.el8 ol8_baseos_latest 59 k
net-snmp x86_64 1:5.8-33.0.1.el8_10 ol8_appstream 355 k
net-snmp-agent-libs x86_64 1:5.8-33.0.1.el8_10 ol8_appstream 749 k
Upgrading:
net-snmp-libs x86_64 1:5.8-33.0.1.el8_10 ol8_baseos_latest 827 k
numactl-libs x86_64 2.0.16-4.el8 ol8_baseos_latest 36 k
python3-rpm x86_64 4.14.3-32.0.1.el8_10 ol8_baseos_latest 155 k
rpm x86_64 4.14.3-32.0.1.el8_10 ol8_baseos_latest 544 k
rpm-build-libs x86_64 4.14.3-32.0.1.el8_10 ol8_baseos_latest 157 k
rpm-libs x86_64 4.14.3-32.0.1.el8_10 ol8_baseos_latest 348 k
rpm-plugin-selinux x86_64 4.14.3-32.0.1.el8_10 ol8_baseos_latest 78 k
rpm-plugin-systemd-inhibit x86_64 4.14.3-32.0.1.el8_10 ol8_baseos_latest 79 k
Installing dependencies:
mariadb-connector-c x86_64 3.1.11-2.el8_3 ol8_appstream 200 k
mariadb-connector-c-config noarch 3.1.11-2.el8_3 ol8_appstream 15 k
Transaction Summary
=============================================================================================================
Install 5 Packages
Upgrade 8 Packages
Total download size: 3.5 M
Downloading Packages:
(1/13): mariadb-connector-c-3.1.11-2.el8_3.x86_64.rpm 564 kB/s | 200 kB 00:00
(2/13): lm_sensors-libs-3.4.0-23.20180522git70f7e08.el8.x86_64.rpm 163 kB/s | 59 kB 00:00
(3/13): net-snmp-5.8-33.0.1.el8_10.x86_64.rpm 7.9 MB/s | 355 kB 00:00
(4/13): net-snmp-agent-libs-5.8-33.0.1.el8_10.x86_64.rpm 7.5 MB/s | 749 kB 00:00
(5/13): net-snmp-libs-5.8-33.0.1.el8_10.x86_64.rpm 10 MB/s | 827 kB 00:00
(6/13): numactl-libs-2.0.16-4.el8.x86_64.rpm 1.5 MB/s | 36 kB 00:00
(7/13): python3-rpm-4.14.3-32.0.1.el8_10.x86_64.rpm 5.0 MB/s | 155 kB 00:00
(8/13): rpm-4.14.3-32.0.1.el8_10.x86_64.rpm 12 MB/s | 544 kB 00:00
(9/13): rpm-build-libs-4.14.3-32.0.1.el8_10.x86_64.rpm 5.6 MB/s | 157 kB 00:00
(10/13): rpm-libs-4.14.3-32.0.1.el8_10.x86_64.rpm 13 MB/s | 348 kB 00:00
(11/13): rpm-plugin-selinux-4.14.3-32.0.1.el8_10.x86_64.rpm 2.9 MB/s | 78 kB 00:00
(12/13): rpm-plugin-systemd-inhibit-4.14.3-32.0.1.el8_10.x86_64.rpm 5.2 MB/s | 79 kB 00:00
(13/13): mariadb-connector-c-config-3.1.11-2.el8_3.noarch.rpm 11 kB/s | 15 kB 00:01
-------------------------------------------------------------------------------------------------------------
Total 2.6 MB/s | 3.5 MB 00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Upgrading : net-snmp-libs-1:5.8-33.0.1.el8_10.x86_64 1/21
Installing : lm_sensors-libs-3.4.0-23.20180522git70f7e08.el8.x86_64 2/21
Running scriptlet: lm_sensors-libs-3.4.0-23.20180522git70f7e08.el8.x86_64 2/21
Upgrading : rpm-libs-4.14.3-32.0.1.el8_10.x86_64 3/21
Running scriptlet: rpm-libs-4.14.3-32.0.1.el8_10.x86_64 3/21
Upgrading : rpm-4.14.3-32.0.1.el8_10.x86_64 4/21
Upgrading : rpm-build-libs-4.14.3-32.0.1.el8_10.x86_64 5/21
Running scriptlet: rpm-build-libs-4.14.3-32.0.1.el8_10.x86_64 5/21
Installing : mariadb-connector-c-config-3.1.11-2.el8_3.noarch 6/21
Installing : mariadb-connector-c-3.1.11-2.el8_3.x86_64 7/21
Installing : net-snmp-agent-libs-1:5.8-33.0.1.el8_10.x86_64 8/21
Installing : net-snmp-1:5.8-33.0.1.el8_10.x86_64 9/21
Running scriptlet: net-snmp-1:5.8-33.0.1.el8_10.x86_64 9/21
Upgrading : python3-rpm-4.14.3-32.0.1.el8_10.x86_64 10/21
Upgrading : rpm-plugin-selinux-4.14.3-32.0.1.el8_10.x86_64 11/21
Upgrading : rpm-plugin-systemd-inhibit-4.14.3-32.0.1.el8_10.x86_64 12/21
Upgrading : numactl-libs-2.0.16-4.el8.x86_64 13/21
Running scriptlet: numactl-libs-2.0.16-4.el8.x86_64 13/21
Cleanup : python3-rpm-4.14.3-24.el8_6.x86_64 14/21
Cleanup : rpm-build-libs-4.14.3-24.el8_6.x86_64 15/21
Running scriptlet: rpm-build-libs-4.14.3-24.el8_6.x86_64 15/21
Cleanup : rpm-plugin-systemd-inhibit-4.14.3-24.el8_6.x86_64 16/21
Cleanup : rpm-plugin-selinux-4.14.3-24.el8_6.x86_64 17/21
Cleanup : rpm-4.14.3-24.el8_6.x86_64 18/21
Cleanup : rpm-libs-4.14.3-24.el8_6.x86_64 19/21
Running scriptlet: rpm-libs-4.14.3-24.el8_6.x86_64 19/21
Cleanup : numactl-libs-2.0.12-13.el8.x86_64 20/21
Running scriptlet: numactl-libs-2.0.12-13.el8.x86_64 20/21
Cleanup : net-snmp-libs-1:5.8-25.el8.x86_64 21/21
Running scriptlet: net-snmp-libs-1:5.8-25.el8.x86_64 21/21
Verifying : lm_sensors-libs-3.4.0-23.20180522git70f7e08.el8.x86_64 1/21
Verifying : mariadb-connector-c-3.1.11-2.el8_3.x86_64 2/21
Verifying : mariadb-connector-c-config-3.1.11-2.el8_3.noarch 3/21
Verifying : net-snmp-1:5.8-33.0.1.el8_10.x86_64 4/21
Verifying : net-snmp-agent-libs-1:5.8-33.0.1.el8_10.x86_64 5/21
Verifying : net-snmp-libs-1:5.8-33.0.1.el8_10.x86_64 6/21
Verifying : net-snmp-libs-1:5.8-25.el8.x86_64 7/21
Verifying : numactl-libs-2.0.16-4.el8.x86_64 8/21
Verifying : numactl-libs-2.0.12-13.el8.x86_64 9/21
Verifying : python3-rpm-4.14.3-32.0.1.el8_10.x86_64 10/21
Verifying : python3-rpm-4.14.3-24.el8_6.x86_64 11/21
Verifying : rpm-4.14.3-32.0.1.el8_10.x86_64 12/21
Verifying : rpm-4.14.3-24.el8_6.x86_64 13/21
Verifying : rpm-build-libs-4.14.3-32.0.1.el8_10.x86_64 14/21
Verifying : rpm-build-libs-4.14.3-24.el8_6.x86_64 15/21
Verifying : rpm-libs-4.14.3-32.0.1.el8_10.x86_64 16/21
Verifying : rpm-libs-4.14.3-24.el8_6.x86_64 17/21
Verifying : rpm-plugin-selinux-4.14.3-32.0.1.el8_10.x86_64 18/21
Verifying : rpm-plugin-selinux-4.14.3-24.el8_6.x86_64 19/21
Verifying : rpm-plugin-systemd-inhibit-4.14.3-32.0.1.el8_10.x86_64 20/21
Verifying : rpm-plugin-systemd-inhibit-4.14.3-24.el8_6.x86_64 21/21
Upgraded:
net-snmp-libs-1:5.8-33.0.1.el8_10.x86_64 numactl-libs-2.0.16-4.el8.x86_64
python3-rpm-4.14.3-32.0.1.el8_10.x86_64 rpm-4.14.3-32.0.1.el8_10.x86_64
rpm-build-libs-4.14.3-32.0.1.el8_10.x86_64 rpm-libs-4.14.3-32.0.1.el8_10.x86_64
rpm-plugin-selinux-4.14.3-32.0.1.el8_10.x86_64 rpm-plugin-systemd-inhibit-4.14.3-32.0.1.el8_10.x86_64
Installed:
lm_sensors-libs-3.4.0-23.20180522git70f7e08.el8.x86_64 mariadb-connector-c-3.1.11-2.el8_3.x86_64
mariadb-connector-c-config-3.1.11-2.el8_3.noarch net-snmp-1:5.8-33.0.1.el8_10.x86_64
net-snmp-agent-libs-1:5.8-33.0.1.el8_10.x86_64
Complete!
[root@mongo01 ~]#
[root@mongo01 ~]# lscpu | grep -i numa
NUMA node(s): 1
NUMA node0 CPU(s): 0
[root@mongo01 ~]#
# Check available disk space
[root@mongo01 ~]# df -h /app /data /logs /backup
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 100G 746M 100G 1% /app
/dev/sdc1 100G 746M 100G 1% /data
/dev/sdd1 100G 746M 100G 1% /logs
/dev/sde1 100G 746M 100G 1% /backup
[root@mongo01 ~]#
π‘ Tip: The tarball method gives you full control over where every file goes. This is ideal for environments with separate mount points for data, logs, and application binaries.
2. Create the mongop OS User
Never run MongoDB as root. Create a dedicated service account.
# Create a dedicated group and user (home directory, password set)
[root@mongo01 ~]# groupadd mongogrp
[root@mongo01 ~]# useradd -g mongogrp -d /home/mongop -m mongop
[root@mongo01 ~]#
# Verify
[root@mongo01 ~]# id mongop
uid=1001(mongop) gid=1001(mongogrp) groups=1001(mongogrp)
[root@mongo01 ~]#
[root@mongo01 ~]# passwd mongop
Changing password for user mongop.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@mongo01 ~]#
3. Create the Directory Structure
Create all required directories in one shot.
# Create directories
[root@mongo01 ~]# mkdir -p /app/mongodb/7.0.43
[root@mongo01 ~]# mkdir -p /app/mongodb/config
[root@mongo01 ~]# mkdir -p /app/mongodb/keyfile
[root@mongo01 ~]# mkdir -p /data/mongodb
[root@mongo01 ~]# mkdir -p /logs/mongodb
[root@mongo01 ~]# mkdir -p /backup/mongodb
# Set ownership
[root@mongo01 ~]# chown -R mongop:mongogrp /app/mongodb
[root@mongo01 ~]# chown -R mongop:mongogrp /data/mongodb
[root@mongo01 ~]# chown -R mongop:mongogrp /logs/mongodb
[root@mongo01 ~]# chown -R mongop:mongogrp /backup/mongodb
# Set permissions
[root@mongo01 ~]# chmod 755 /app/mongodb
[root@mongo01 ~]# chmod 755 /app/mongodb/7.0.43
[root@mongo01 ~]# chmod 755 /app/mongodb/config
[root@mongo01 ~]# chmod 700 /app/mongodb/keyfile
[root@mongo01 ~]# chmod 700 /data/mongodb
[root@mongo01 ~]# chmod 755 /logs/mongodb
[root@mongo01 ~]# chmod 750 /backup/mongodb
# Verify the structure
[root@mongo01 ~]# tree -pug -L 2 /app/mongodb /data /logs /backup
/app/mongodb
βββ [drwxr-xr-x mongop mongogrp] 7.0.43
βββ [drwxr-xr-x mongop mongogrp] config
βββ [drwx------ mongop mongogrp] keyfile
/data
βββ [drwx------ mongop mongogrp] mongodb
/logs
βββ [drwxr-xr-x mongop mongogrp] mongodb
/backup
βββ [drwxr-x--- mongop mongogrp] mongodb
6 directories, 0 files
[root@mongo01 ~]#
4. Download the MongoDB Tarball
# Download and copy to DB server /tmp as user mongop
# Download from https://www.mongodb.com/try/download/enterprise
[root@mongo01 ~]# su - mongop
[mongop@mongo01 ~]$
# Verify the download
[mongop@mongo01 ~]$ ls -lrth /tmp/mongodb-linux-x86_64-enterprise-rhel8-7.0.43.tgz
-rw-r--r--. 1 mongop mongogrp 151M Oct 1 03:01 /tmp/mongodb-linux-x86_64-enterprise-rhel8-7.0.43.tgz
[mongop@mongo01 ~]$
# (Optional) Verify checksum if provided by MongoDB
[mongop@mongo01 ~]$ sha256sum /tmp/mongodb-linux-x86_64-enterprise-rhel8-7.0.43.tgz
bdc5bd96c6923319402270f025c57f69cf96023746fe056ec4d787975f8767e4 /tmp/mongodb-linux-x86_64-enterprise-rhel8-7.0.43.tgz
[mongop@mongo01 ~]$
5. Extract and Install to /app/mongodb/7.0.43
# Extract the tarball
[mongop@mongo01 ~]$ cd /tmp/
[mongop@mongo01 tmp]$ tar -xzvf mongodb-linux-x86_64-enterprise-rhel8-7.0.43.tgz
mongodb-linux-x86_64-enterprise-rhel80-7.0.43/LICENSE-Enterprise.txt
mongodb-linux-x86_64-enterprise-rhel80-7.0.43/MPL-2
mongodb-linux-x86_64-enterprise-rhel80-7.0.43/README
mongodb-linux-x86_64-enterprise-rhel80-7.0.43/THIRD-PARTY-NOTICES
mongodb-linux-x86_64-enterprise-rhel80-7.0.43/bin/install_compass
mongodb-linux-x86_64-enterprise-rhel80-7.0.43/bin/mongocryptd
mongodb-linux-x86_64-enterprise-rhel80-7.0.43/bin/mongod
mongodb-linux-x86_64-enterprise-rhel80-7.0.43/bin/mongodecrypt
mongodb-linux-x86_64-enterprise-rhel80-7.0.43/bin/mongokerberos
mongodb-linux-x86_64-enterprise-rhel80-7.0.43/bin/mongoldap
mongodb-linux-x86_64-enterprise-rhel80-7.0.43/bin/mongos
[mongop@mongo01 tmp]$
# Copy the contents into the target directory
[mongop@mongo01 tmp]$ cd mongodb-linux-x86_64-enterprise-rhel80-7.0.43/
[mongop@mongo01 mongodb-linux-x86_64-enterprise-rhel80-7.0.43]$ cp -rp * /app/mongodb/7.0.43/
[mongop@mongo01 mongodb-linux-x86_64-enterprise-rhel80-7.0.43]$
6. Verify the installation
# Verify the installation
[mongop@mongo01 tmp]$ ls -ltra /app/mongodb/7.0.43/
total 164
-rw-r--r--. 1 mongop mongogrp 16726 Sep 3 13:28 MPL-2
-rw-r--r--. 1 mongop mongogrp 122512 Sep 3 13:28 THIRD-PARTY-NOTICES
-rw-r--r--. 1 mongop mongogrp 2094 Sep 3 13:28 README
-rw-r--r--. 1 mongop mongogrp 17211 Sep 3 13:28 LICENSE-Enterprise.txt
drwxr-xr-x. 5 mongop mongogrp 49 Oct 1 02:24 ..
drwxr-xr-x. 2 mongop mongogrp 134 Oct 1 03:45 bin
drwxr-xr-x. 3 mongop mongogrp 101 Oct 1 03:54 .
[mongop@mongo01 tmp]$
# Verify the binaries
[mongop@mongo01 tmp]$ ls -la /app/mongodb/7.0.43/bin/
total 535500
drwxr-xr-x. 2 mongop mongogrp 134 Oct 1 03:45 .
drwxr-xr-x. 3 mongop mongogrp 101 Oct 1 03:54 ..
-rwxr-xr-x. 1 mongop mongogrp 15195 Sep 3 13:28 install_compass
-rwxr-xr-x. 1 mongop mongogrp 138349184 Sep 3 14:38 mongocryptd
-rwxr-xr-x. 1 mongop mongogrp 191980144 Sep 3 14:38 mongod
-rwxr-xr-x. 1 mongop mongogrp 26605968 Sep 3 14:35 mongodecrypt
-rwxr-xr-x. 1 mongop mongogrp 26423904 Sep 3 14:35 mongokerberos
-rwxr-xr-x. 1 mongop mongogrp 28072904 Sep 3 14:35 mongoldap
-rwxr-xr-x. 1 mongop mongogrp 136888448 Sep 3 14:38 mongos
[mongop@mongo01 tmp]$
# Verify the version
[mongop@mongo01 tmp]$ /app/mongodb/7.0.43/bin/mongod --version
db version v7.0.43
Build Info: {
"version": "7.0.43",
"gitVersion": "ef5a7d3480b59feae13d564376129fc4ceee6177",
"openSSLVersion": "OpenSSL 1.1.1k FIPS 25 Mar 2021",
"modules": [
"enterprise"
],
"allocator": "tcmalloc",
"environment": {
"distmod": "rhel80",
"distarch": "x86_64",
"target_arch": "x86_64"
}
}
[mongop@mongo01 tmp]$
β MongoDB 7.0.43 Enterprise binaries are installed.
7. Set Ownership and Permissions
# Ensure everything is owned by mongop
[root@mongo01 ~]# chown -R mongop:mongogrp /app/mongodb
[root@mongo01 ~]# chown -R mongop:mongogrp /data/mongodb
[root@mongo01 ~]# chown -R mongop:mongogrp /logs/mongodb
[root@mongo01 ~]# chown -R mongop:mongogrp /backup/mongodb
[root@mongo01 ~]#
# Secure the data directory
[root@mongo01 ~]# chmod 700 /data/mongodb
[root@mongo01 ~]#
# Verify
[root@mongo01 ~]# ls -ld /app/mongodb /data/mongodb /logs/mongodb /backup/mongodb
drwxr-xr-x. 5 mongop mongogrp 64 Oct 1 04:03 /app/mongodb
drwxr-x---. 2 mongop mongogrp 6 Oct 1 02:18 /backup/mongodb
drwx------. 2 mongop mongogrp 6 Oct 1 02:17 /data/mongodb
drwxr-xr-x. 2 mongop mongogrp 6 Oct 1 02:17 /logs/mongodb
[root@mongo01 ~]#
8. Configure mongod.conf
Create the MongoDB configuration file. The tarball method does not include a default config, so we create one from scratch.
[mongop@mongo01 ~]$ cat > /app/mongodb/config/mongod.conf << 'EOF'
# ============================================================
# MongoDB 7.0.43 Enterprise Configuration
# Server: mongo01
# ============================================================
# --- Storage ---
storage:
dbPath: /data/mongodb
wiredTiger:
engineConfig:
## cacheSizeGB: 4 # leave unset on small VMs; default = 50% of (RAM - 1 GB)
journalCompressor: snappy
collectionConfig:
blockCompressor: snappy
indexConfig:
prefixCompression: true
# --- System Log ---
systemLog:
destination: file
path: /logs/mongodb/mongod.log
logAppend: true
logRotate: reopen
# --- Network ---
net:
port: 27017
bindIp: 127.0.0.1,192.168.2.101 # change per node
maxIncomingConnections: 51200
# --- Process Management ---
processManagement:
fork: true
pidFilePath: /data/mongodb/mongod.pid
# --- Security (enable after initial setup) ---
#security:
# authorization: enabled
# keyFile: /app/mongodb/keyfile/mongodb-keyfile
# --- Operation Profiling ---
operationProfiling:
mode: slowOp
slowOpThresholdMs: 200
# --- Replication (uncomment for replica set) ---
#replication:
# replSetName: rs0
# oplogSizeMB: 10240
# --- Set Parameter ---
setParameter:
enableLocalhostAuthBypass: true
EOF
# Set Permissions
[mongop@mongo01 ~]$ ls -l /app/mongodb/config/mongod.conf
-rw-r--r--. 1 mongop mongogrp 1171 Oct 1 06:33 /app/mongodb/config/mongod.conf
[mongop@mongo01 ~]$ chmod 640 /app/mongodb/config/mongod.conf
[mongop@mongo01 ~]$
[mongop@mongo01 ~]$ ls -l /app/mongodb/config/mongod.conf
-rw-r-----. 1 mongop mongogrp 1171 Oct 1 06:33 /app/mongodb/config/mongod.conf
[mongop@mongo01 ~]$
π‘ Key settings explained:
cacheSizeGB: 4β Commented out in this config, so MongoDB uses its default (50% of (RAM β 1 GB)). Uncomment to set it explicitly; adjust for your server.bindIp: 127.0.0.1,192.168.2.101β Restrict to specific IPs (localhost plus the server’s own IP).maxIncomingConnections: 51200β Keep this below thenofileulimit (64000); MongoDB caps usable connections at about 80% of the file descriptor limit.logRotate: reopenβ Works withlogrotatefor log management.fork: trueβ Used in this guide, both for manual start and for systemd withType=forking(Section 15).fork: falseβ Only if you change the unit file toType=simpleand let systemd manage the process directly.
9. Configure Transparent Huge Pages (THP)
MongoDB performs poorly with THP enabled. Disable it permanently.
# Check current THP status
[root@mongo01 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
[root@mongo01 ~]#
# Disable THP immediately
[root@mongo01 ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
[root@mongo01 ~]#
[root@mongo01 ~]# echo never > /sys/kernel/mm/transparent_hugepage/defrag
[root@mongo01 ~]#
# Verify
[root@mongo01 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
[root@mongo01 ~]#
# Make it persistent across reboots
[root@mongo01 ~]# cat > /etc/systemd/system/disable-thp.service << 'EOF'
[Unit]
Description=Disable Transparent Huge Pages (THP)
DefaultDependencies=no
After=sysinit.target local-fs.target
Before=mongod.service
[Service]
Type=oneshot
ExecStart=/bin/sh -c 'echo never > /sys/kernel/mm/transparent_hugepage/enabled && echo never > /sys/kernel/mm/transparent_hugepage/defrag'
[Install]
WantedBy=basic.target
EOF
[root@mongo01 ~]# systemctl daemon-reload
[root@mongo01 ~]# systemctl enable disable-thp.service
Created symlink /etc/systemd/system/basic.target.wants/disable-thp.service β /etc/systemd/system/disable-thp.service.
[root@mongo01 ~]#
π΄ Critical: Running MongoDB with THP enabled causes significant performance degradation, especially under heavy write workloads. Always disable it.
10. Configure ulimits for the mongop User
MongoDB requires higher-than-default file descriptor and process limits.
[root@mongo01 ~]# cat > /etc/security/limits.d/99-mongodb.conf << 'EOF'
mongop soft nofile 64000
mongop hard nofile 64000
mongop soft nproc 64000
mongop hard nproc 64000
mongop soft memlock unlimited
mongop hard memlock unlimited
EOF
# Verify (login as mongop to test)
[root@mongo01 ~]# su -s /bin/bash mongop -c "ulimit -n"
64000
π‘ Note: limits.d applies to login sessions only (manual start as mongop). When MongoDB runs under systemd (Section 15), the limits come from LimitNOFILE and LimitNPROC in the unit file instead.
11. Install mongosh (shell is not in the 7.0 tarball)
[mongop@mongo01 tmp]$ curl -LO https://downloads.mongodb.com/compass/mongosh-2.12.0-linux-x64.tgz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 89.8M 100 89.8M 0 0 3794k 0 0:00:24 0:00:24 --:--:-- 6093k
[mongop@mongo01 tmp]$
[mongop@mongo01 tmp]$ tar -xzvf mongosh-2.12.0-linux-x64.tgz
mongosh-2.12.0-linux-x64/
mongosh-2.12.0-linux-x64/.sbom.json
mongosh-2.12.0-linux-x64/LICENSE-crypt-library
mongosh-2.12.0-linux-x64/LICENSE-mongosh
mongosh-2.12.0-linux-x64/README
mongosh-2.12.0-linux-x64/THIRD_PARTY_NOTICES
mongosh-2.12.0-linux-x64/bin/
mongosh-2.12.0-linux-x64/mongosh.1.gz
mongosh-2.12.0-linux-x64/bin/mongosh
mongosh-2.12.0-linux-x64/bin/mongosh_crypt_v1.so
[mongop@mongo01 tmp]$
[mongop@mongo01 tmp]$ cd mongosh-2.12.0-linux-x64/bin
[mongop@mongo01 bin]$ ls -l
total 288052
-rwxr-xr-x. 1 mongop mongogrp 199441944 Sep 17 05:18 mongosh
-rwxr-xr-x. 1 mongop mongogrp 95519056 Sep 17 05:18 mongosh_crypt_v1.so
[mongop@mongo01 bin]$
[mongop@mongo01 bin]$ cp mongosh /app/mongodb/7.0.43/bin/
[mongop@mongo01 bin]$ ls -l /app/mongodb/7.0.43/bin/
total 730268
-rwxr-xr-x. 1 mongop mongogrp 15195 Sep 3 13:28 install_compass
-rwxr-xr-x. 1 mongop mongogrp 138349184 Sep 3 14:38 mongocryptd
-rwxr-xr-x. 1 mongop mongogrp 191980144 Sep 3 14:38 mongod
-rwxr-xr-x. 1 mongop mongogrp 26605968 Sep 3 14:35 mongodecrypt
-rwxr-xr-x. 1 mongop mongogrp 26423904 Sep 3 14:35 mongokerberos
-rwxr-xr-x. 1 mongop mongogrp 28072904 Sep 3 14:35 mongoldap
-rwxr-xr-x. 1 mongop mongogrp 136888448 Sep 3 14:38 mongos
-rwxr-xr-x. 1 mongop mongogrp 199441944 Oct 1 07:40 mongosh
[mongop@mongo01 bin]$
[mongop@mongo01 ~]$ cat .bash_profile | grep export
export MONGO_HOME=/app/mongodb/7.0.43
export PATH=$MONGO_HOME/bin:$PATH
[mongop@mongo01 ~]$
[mongop@mongo01 ~]$ . .bash_profile
[mongop@mongo01 ~]$ which mongosh
/app/mongodb/7.0.43/bin/mongosh
[mongop@mongo01 ~]$
π‘ Tip: mongosh 2.12.0 is used here. Check the mongosh download page for the current 2.x release and adjust the file name accordingly.
12. Start MongoDB and Verify
# Start MongoDB
# Validate Config
[mongop@mongo01 ~]$ /app/mongodb/7.0.43/bin/mongod --config /app/mongodb/config/mongod.conf --outputConfig
config: /app/mongodb/config/mongod.conf
net:
bindIp: 127.0.0.1,192.168.2.101
maxIncomingConnections: 51200
port: 27017
operationProfiling:
mode: slowOp
slowOpThresholdMs: 200
outputConfig: true
processManagement:
fork: true
pidFilePath: /data/mongodb/mongod.pid
setParameter:
enableLocalhostAuthBypass: true
storage:
dbPath: /data/mongodb
wiredTiger:
collectionConfig:
blockCompressor: snappy
engineConfig:
journalCompressor: snappy
indexConfig:
prefixCompression: true
systemLog:
destination: file
logAppend: true
logRotate: reopen
path: /logs/mongodb/mongod.log
[mongop@mongo01 ~]$
# Start MongoDB Manually
[mongop@mongo01 ~]$ /app/mongodb/7.0.43/bin/mongod --config /app/mongodb/config/mongod.conf
{"t":{"$date":"2026-10-01T11:17:44.659Z"},"s":"I", "c":"CONTROL", "id":5760901, "ctx":"main","msg":"Applied --setParameter options","attr":{"serverParameters":{"enableLocalhostAuthBypass":{"default":true,"value":true}}}}
about to fork child process, waiting until server is ready for connections.
forked process: 7482
child process started successfully, parent exiting
[mongop@mongo01 ~]$
# Check the service status
[mongop@mongo01 ~]$ ps -ef | grep mongod
mongop 7482 1 2 07:17 ? 00:00:01 /app/mongodb/7.0.43/bin/mongod --config /app/mongodb/config/mongod.conf
mongop 7536 7203 0 07:18 pts/0 00:00:00 grep --color=auto mongod
[mongop@mongo01 ~]$
[mongop@mongo01 ~]$ pgrep -a mongod
7482 /app/mongodb/7.0.43/bin/mongod --config /app/mongodb/config/mongod.conf
[mongop@mongo01 ~]$
# Verify the port is listening
[mongop@mongo01 ~]$ ss -tlnp | grep 27017
LISTEN 0 128 192.168.2.101:27017 0.0.0.0:* users:(("mongod",pid=7482,fd=16))
LISTEN 0 128 127.0.0.1:27017 0.0.0.0:* users:(("mongod",pid=7482,fd=15))
[mongop@mongo01 ~]$
# Verify the log file
[mongop@mongo01 ~]$ tail -5 /logs/mongodb/mongod.log
{"t":{"$date":"2026-10-01T07:17:45.913-04:00"},"s":"I", "c":"REPL", "id":7360100, "ctx":"LogicalSessionCacheRefresh","msg":"Added oplog entry for createIndexes to transaction","attr":{"namespace":"config.$cmd","uuid":{"uuid":{"$uuid":"77a72875-feb0-4e35-85f7-b73e7acb4cfd"}},"object":{"createIndexes":"system.sessions","v":2,"key":{"lastUse":1},"name":"lsidTTLIndex","expireAfterSeconds":1800}}}
{"t":{"$date":"2026-10-01T07:17:45.923-04:00"},"s":"I", "c":"INDEX", "id":20345, "ctx":"LogicalSessionCacheRefresh","msg":"Index build: done building","attr":{"buildUUID":null,"collectionUUID":{"uuid":{"$uuid":"77a72875-feb0-4e35-85f7-b73e7acb4cfd"}},"namespace":"config.system.sessions","index":"_id_","ident":"index-5--4298299351002162572","collectionIdent":"collection-4--4298299351002162572","commitTimestamp":null}}
{"t":{"$date":"2026-10-01T07:17:45.923-04:00"},"s":"I", "c":"INDEX", "id":20345, "ctx":"LogicalSessionCacheRefresh","msg":"Index build: done building","attr":{"buildUUID":null,"collectionUUID":{"uuid":{"$uuid":"77a72875-feb0-4e35-85f7-b73e7acb4cfd"}},"namespace":"config.system.sessions","index":"lsidTTLIndex","ident":"index-6--4298299351002162572","collectionIdent":"collection-4--4298299351002162572","commitTimestamp":null}}
{"t":{"$date":"2026-10-01T07:18:45.827-04:00"},"s":"I", "c":"WTCHKPT", "id":22430, "ctx":"Checkpointer","msg":"WiredTiger message","attr":{"message":{"ts_sec":1790853525,"ts_usec":827875,"thread":"7482:0x7faade232700","session_name":"WT_SESSION.checkpoint","category":"WT_VERB_CHECKPOINT_PROGRESS","category_id":6,"verbose_level":"DEBUG_1","verbose_level_id":1,"msg":"saving checkpoint snapshot min: 34, snapshot max: 34 snapshot count: 0, oldest timestamp: (0, 0) , meta checkpoint timestamp: (0, 0) base write gen: 1"}}}
{"t":{"$date":"2026-10-01T07:19:45.857-04:00"},"s":"I", "c":"WTCHKPT", "id":22430, "ctx":"Checkpointer","msg":"WiredTiger message","attr":{"message":{"ts_sec":1790853585,"ts_usec":857560,"thread":"7482:0x7faade232700","session_name":"WT_SESSION.checkpoint","category":"WT_VERB_CHECKPOINT_PROGRESS","category_id":6,"verbose_level":"DEBUG_1","verbose_level_id":1,"msg":"saving checkpoint snapshot min: 35, snapshot max: 35 snapshot count: 0, oldest timestamp: (0, 0) , meta checkpoint timestamp: (0, 0) base write gen: 1"}}}
[mongop@mongo01 ~]$
# Verify the data directory
[mongop@mongo01 ~]$ ls -la /data/mongodb/
total 292
drwx------. 4 mongop mongogrp 4096 Oct 1 07:20 .
drwxr-xr-x. 3 root root 21 Oct 1 02:17 ..
-rw-------. 1 mongop mongogrp 20480 Oct 1 07:18 collection-0--4298299351002162572.wt
-rw-------. 1 mongop mongogrp 20480 Oct 1 07:18 collection-2--4298299351002162572.wt
-rw-------. 1 mongop mongogrp 4096 Oct 1 07:17 collection-4--4298299351002162572.wt
drwx------. 2 mongop mongogrp 71 Oct 1 07:21 diagnostic.data
-rw-------. 1 mongop mongogrp 20480 Oct 1 07:18 index-1--4298299351002162572.wt
-rw-------. 1 mongop mongogrp 20480 Oct 1 07:18 index-3--4298299351002162572.wt
-rw-------. 1 mongop mongogrp 4096 Oct 1 07:17 index-5--4298299351002162572.wt
-rw-------. 1 mongop mongogrp 4096 Oct 1 07:17 index-6--4298299351002162572.wt
drwx------. 2 mongop mongogrp 110 Oct 1 07:17 journal
-rw-------. 1 mongop mongogrp 20480 Oct 1 07:18 _mdb_catalog.wt
-rw-------. 1 mongop mongogrp 5 Oct 1 07:17 mongod.lock
-rw-r--r--. 1 mongop mongogrp 5 Oct 1 07:17 mongod.pid
-rw-------. 1 mongop mongogrp 20480 Oct 1 07:18 sizeStorer.wt
-rw-------. 1 mongop mongogrp 114 Oct 1 07:17 storage.bson
-rw-------. 1 mongop mongogrp 50 Oct 1 07:17 WiredTiger
-rw-------. 1 mongop mongogrp 4096 Oct 1 07:17 WiredTigerHS.wt
-rw-------. 1 mongop mongogrp 21 Oct 1 07:17 WiredTiger.lock
-rw-------. 1 mongop mongogrp 1464 Oct 1 07:20 WiredTiger.turtle
-rw-------. 1 mongop mongogrp 69632 Oct 1 07:20 WiredTiger.wt
[mongop@mongo01 ~]$
[mongop@mongo01 bin]$ /app/mongodb/7.0.43/bin/mongosh --version
2.12.0
[mongop@mongo01 bin]$
Connect to MongoDB and run a quick test:
[mongop@mongo01 ~]$ /app/mongodb/7.0.43/bin/mongosh
Current Mongosh Log ID: 6abe4ac0cdb713588eec9846
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.12.0
Using MongoDB: 7.0.43
Using Mongosh: 2.12.0
For mongosh info see: https://www.mongodb.com/docs/mongodb-shell/
------
The server generated these startup warnings when booting
2026-10-01T07:17:44.791-04:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
------
Enterprise test>
Enterprise test> db.runCommand({ ping: 1 })
{ ok: 1 }
Enterprise test>
Enterprise test> exit
[mongop@mongo01 ~]$
β MongoDB 7.0.43 Enterprise is running and accepting connections!
13. Configure the Firewall
# Open MongoDB port
[root@mongo01 ~]# firewall-cmd --permanent --add-port=27017/tcp
success
[root@mongo01 ~]# firewall-cmd --reload
success
[root@mongo01 ~]# firewall-cmd --list-ports
27017/tcp
[root@mongo01 ~]#
β οΈ Security: The command above opens port 27017 to every source. For production, restrict it to your application subnet instead:
[root@mongo01 ~]# firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.2.0/24" port port="27017" protocol="tcp" accept'
[root@mongo01 ~]# firewall-cmd --reload
14. Post-Installation β Enable Authentication
By default, MongoDB has no authentication. Enable it immediately for production.
# Step 1: Create the admin user
[mongop@mongo01 ~]$ /app/mongodb/7.0.43/bin/mongosh
Current Mongosh Log ID: 6abe7d51a184a905f5b11f44
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.12.0
Using MongoDB: 7.0.43
Using Mongosh: 2.12.0
For mongosh info see: https://www.mongodb.com/docs/mongodb-shell/
------
The server generated these startup warnings when booting
2026-10-01T07:17:44.791-04:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
------
Enterprise test>
Enterprise test> use admin
switched to db admin
Enterprise admin>
Enterprise admin> db.createUser({
| user: "admin",
| pwd: passwordPrompt(),
| roles: [
| { role: "root", db: "admin" }
| ]
| })
Enter password
********{ ok: 1 }
Enterprise admin>
Enterprise admin> exit
[mongop@mongo01 ~]$
π‘ Tip: Use passwordPrompt() and a strong password so the password never appears in the shell history or on screen.
# Step 2: Enable authentication in mongod.conf
[root@mongo01 ~]# openssl rand -base64 756 > /app/mongodb/keyfile/mongodb-keyfile
[root@mongo01 ~]# chown mongop:mongogrp /app/mongodb/keyfile/mongodb-keyfile
[root@mongo01 ~]# chmod 400 /app/mongodb/keyfile/mongodb-keyfile
[root@mongo01 ~]# ls -l /app/mongodb/keyfile/mongodb-keyfile
-r--------. 1 mongop mongogrp 1024 Oct 1 10:17 /app/mongodb/keyfile/mongodb-keyfile
[root@mongo01 ~]#
[root@mongo01 ~]# su - mongop
[mongop@mongo01 ~]$
[mongop@mongo01 ~]$ vi /app/mongodb/config/mongod.conf
From:
# --- Security (enable after initial setup) ---
#security:
# authorization: enabled
# keyFile: /app/mongodb/keyfile/mongodb-keyfile
To:
# Uncomment the security section:
[mongop@mongo01 ~]$ cat /app/mongodb/config/mongod.conf | egrep -i 'security|authorization|keyfile'
# --- Security (enable after initial setup) ---
security:
authorization: enabled
keyFile: /app/mongodb/keyfile/mongodb-keyfile
# Step 3: Restart MongoDB Manually
# Shutdown Manually
[mongop@mongo01 ~]$ /app/mongodb/7.0.43/bin/mongod --config /app/mongodb/config/mongod.conf --shutdown
# Startup Manually
[mongop@mongo01 ~]$ /app/mongodb/7.0.43/bin/mongod --config /app/mongodb/config/mongod.conf
--------------------------------------- ( OR )START --------------------------------------
[mongop@mongo01 ~]$ cat /app/mongodb/mongoctl.sh
#!/bin/bash
CONF=/app/mongodb/config/mongod.conf
BIN=/app/mongodb/7.0.43/bin/mongod
PIDFILE=/data/mongodb/mongod.pid
stop() {
if [ -f "$PIDFILE" ] && kill -0 "$(cat $PIDFILE)" 2>/dev/null; then
kill "$(cat $PIDFILE)"
while pgrep -x mongod > /dev/null; do sleep 1; done
echo "mongod stopped"
else
echo "mongod is not running"
fi
}
case "$1" in
start) $BIN --config $CONF ;;
stop) stop ;;
restart) stop; $BIN --config $CONF ;;
status) pgrep -a mongod || echo "mongod is not running" ;;
*) echo "Usage: $0 {start|stop|restart|status}" ;;
esac
[mongop@mongo01 ~]$
[mongop@mongo01 ~]$ ls -l /app/mongodb/mongoctl.sh
-rwxr-x---. 1 mongop mongogrp 588 Oct 1 11:01 /app/mongodb/mongoctl.sh
[mongop@mongo01 ~]$
/app/mongodb/mongoctl.sh start
/app/mongodb/mongoctl.sh stop
/app/mongodb/mongoctl.sh restart
/app/mongodb/mongoctl.sh status
[mongop@mongo01 ~]$ /app/mongodb/mongoctl.sh restart
mongod stopped
{"t":{"$date":"2026-10-01T15:40:45.556Z"},"s":"I", "c":"CONTROL", "id":5760901, "ctx":"main","msg":"Applied --setParameter options","attr":{"serverParameters":{"enableLocalhostAuthBypass":{"default":true,"value":true}}}}
about to fork child process, waiting until server is ready for connections.
forked process: 5033
child process started successfully, parent exiting
[mongop@mongo01 ~]$
--------------------------------------- END --------------------------------------
[mongop@mongo01 ~]$ /app/mongodb/7.0.43/bin/mongosh --host localhost --eval "db.hello().ok"
1
[mongop@mongo01 ~]$
β οΈ Note: Use either mongoctl.sh or systemctl to manage mongod, not both. Once the systemd service is set up in Section 15, use only systemctl.
# Step 4: Verify authentication is required
[mongop@mongo01 ~]$ /app/mongodb/7.0.43/bin/mongosh
Current Mongosh Log ID: 6abe7f1378c1f26219ec8e1a
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.12.0
Using MongoDB: 7.0.43
Using Mongosh: 2.12.0
For mongosh info see: https://www.mongodb.com/docs/mongodb-shell/
Enterprise test>
Enterprise test> show dbs
MongoServerError[Unauthorized]: Command listDatabases requires authentication
Enterprise test>
Enterprise test> use admin
switched to db admin
Enterprise admin>
Enterprise admin> db.auth("admin", passwordPrompt())
Enter password
******{ ok: 1 }
Enterprise admin>
Enterprise admin> db.runCommand({connectionStatus:1})
{
authInfo: {
authenticatedUsers: [ { user: 'admin', db: 'admin' } ],
authenticatedUserRoles: [ { role: 'root', db: 'admin' } ]
},
ok: 1
}
Enterprise admin> show dbs
admin 144.00 KiB
config 72.00 KiB
local 72.00 KiB
Enterprise admin>
Enterprise admin> exit
[mongop@mongo01 ~]$
β Authentication is now enabled. All connections require valid credentials.
15. Create systemd service unit file
#1. Stop the manually started instance first
[mongop@mongo01 ~]$ /app/mongodb/7.0.43/bin/mongod --config /app/mongodb/config/mongod.conf --shutdown
{"t":{"$date":"2026-10-04T11:01:12.262Z"},"s":"I", "c":"CONTROL", "id":5760901, "ctx":"main","msg":"Applied --setParameter options","attr":{"serverParameters":{"enableLocalhostAuthBypass":{"default":true,"value":true}}}}
Killing process with pid: 4712
[mongop@mongo01 ~]$
#2. Create the unit file (as root)
[root@mongo01 ~]#
cat > /etc/systemd/system/mongod.service <<'EOF'
[Unit]
Description=MongoDB Enterprise Database Server
Documentation=https://docs.mongodb.com/manual
After=network-online.target
Wants=network-online.target
[Service]
User=mongop
Group=mongogrp
Type=forking
PIDFile=/data/mongodb/mongod.pid
ExecStart=/app/mongodb/7.0.43/bin/mongod --config /app/mongodb/config/mongod.conf
ExecStop=/app/mongodb/7.0.43/bin/mongod --config /app/mongodb/config/mongod.conf --shutdown
LimitNOFILE=64000
LimitNPROC=64000
LimitFSIZE=infinity
LimitCPU=infinity
LimitAS=infinity
TimeoutStartSec=120
TimeoutStopSec=120
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
# 3. Enable and start
[root@mongo01 ~]# systemctl daemon-reload
[root@mongo01 ~]# systemctl enable mongod
[root@mongo01 ~]# systemctl start mongod
SELinux is preventing /usr/lib/systemd/systemd from execute access on the file /app/mongodb/7.0.43/bin/mongod.
[root@mongo01 ~]# systemctl stop mongod
[root@mongo01 ~]#
[root@mongo01 ~]# systemctl reset-failed mongod
[root@mongo01 ~]#
[root@mongo01 ~]# ls -Z /app/mongodb/7.0.43/bin/mongod
unconfined_u:object_r:unlabeled_t:s0 /app/mongodb/7.0.43/bin/mongod
[root@mongo01 ~]#
[root@mongo01 ~]# getenforce
Enforcing
[root@mongo01 ~]#
# Temporary Solution to disable SELINUX
[root@mongo01 ~]# setenforce 0
[root@mongo01 ~]# systemctl start mongod
[root@mongo01 ~]# systemctl status mongod
# Disable SELINUX permanently to Fix the issue as this is a lab setup.
[root@mongo01 ~]# cat /etc/sysconfig/selinux | grep -i SELINUX=d
SELINUX=disabled
[root@mongo01 ~]#
[root@mongo01 ~]# systemctl is-enabled mongod
enabled
[root@mongo01 ~]#
[root@mongo01 ~]# reboot
# After the server comes back up
[root@mongo01 ~]# systemctl status mongod
[root@mongo01 ~]# getenforce
Permissive
[root@mongo01 ~]#