Power & Source of Big Ideas

MongoDB Docker Container Crashing on Ubuntu 24.04 (Noble Num

Moderators: chensy, FATechsupport

Hello everyone,

I'm encountering a persistent issue trying to run MongoDB in a Docker container on my FriendlyELEC CM3588 board, which is running the official Ubuntu 24.04 (Noble Numbat) image with kernel 6.1.y.

The Problem:
When I try to bring up the MongoDB container using docker compose up, it repeatedly crashes shortly after starting. The logs consistently show out-of-memory errors related to tcmalloc and MmapAligned() failing to allocate large memory blocks. Here are the key error messages:

mongodb | MmapAligned() failed - unable to allocate with tag (hint=..., size=1073741824, alignment=1073741824) - is something limiting address placement?
mongodb | CHECK in Alloc: FATAL ERROR: Out of memory trying to allocate internal tcmalloc data (bytes=131072, object-size=640); is something preventing mmap from succeeding (sandbox, VSS limitations)?
mongodb exited with code 134

What I've Tried So Far (Unsuccessful):

1. Disabling Transparent Huge Pages (THP): I've added --no-transparent-huge-pages to the mongod command in my docker-compose.yml.
2. Increasing vm.max_map_count: I've set vm.max_map_count to 262144 (the recommended value for MongoDB) persistently via /etc/sysctl.d/99-mongodb.conf.
3. Clean Docker Volume: Each attempt involves removing the Docker volume (pi_mongodb_data) to ensure a fresh start.
4. Different MongoDB Versions: I've tried both mongo:latest and mongo:6.0 images.

Context:
Interestingly, when I was previously running Armbian on this same CM3588, MongoDB in Docker worked without these memory allocation issues, although the overall system performance was slower. This suggests that the problem might be specific to the memory management or kernel configuration of the FriendlyELEC Ubuntu 24.04 image.

I'm looking for insights or suggestions from anyone who might have encountered similar issues with MongoDB or other memory-intensive applications on this specific Ubuntu image or RK3588-based devices. Could there be other kernel parameters or specific optimizations needed for this board/OS combination?


Regards,
Alex
MongoDB Direct Installation Pitfalls on FriendlyELEC CM3588 (Ubuntu 24.04 ARM64)

This note summarizes the key challenges and solutions encountered while directly installing MongoDB Community Edition on a FriendlyELEC CM3588 running Ubuntu 24.04 (Noble Numbat) ARM64, especially after Docker-based attempts failed due to memory allocation issues.

**1. Docker Memory Allocation Issues (Initial Problem):**
* **Symptom:** MongoDB Docker containers (both `latest` and `6.0`) repeatedly crashed with `MmapAligned() failed` and `FATAL ERROR: Out of memory trying to allocate internal tcmalloc data` errors.
* **Root Cause (Suspected):** The vendor's Ubuntu 24.04 kernel (6.1.y) on the RK3588 likely has different memory management configurations compared to Armbian, causing `tcmalloc` (MongoDB's memory allocator) to struggle with large, contiguous memory mappings.
* **Unsuccessful Docker Fixes:**
* Adding `--no-transparent-huge-pages` to `mongod` command.
* Increasing `vm.max_map_count` to `262144` persistently via `sysctl`.

**2. MongoDB APT Repository 404 Error (Direct Install Pitfall #1):**
* **Symptom:** When trying to `sudo apt update` after adding the MongoDB 7.0 repository for `noble` (Ubuntu 24.04), a `404 Not Found` error occurred.
* **Root Cause:** MongoDB 7.0 packages for Ubuntu 24.04 (`noble`) were not yet available in the official `repo.mongodb.org/apt/ubuntu noble/mongodb-org/7.0` repository at the time of installation.
* **Solution:** Used the MongoDB 7.0 repository for **Ubuntu 22.04 (Jammy Jellyfish)**, which is generally compatible with 24.04:
```bash
sudo rm /etc/apt/sources.list.d/mongodb-org-7.0.list
echo "deb [ arch=arm64 signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
sudo apt update
```
Note: for detailed info about the issue refer to: https://www.mongodb.com/community/forum ... 3/263451/9

**3. MongoDB Configuration File Error (Direct Install Pitfall #2):**
* **Symptom:** After installing MongoDB and attempting to change the `dbPath` to `/mnt/merged_ssd/mongodb-data` in `/etc/mongod.conf`, the `mongod` service failed to start with the error: `Unrecognized option: storage.journal.enabled`.
* **Root Cause:** The `storage.journal.enabled: true` option is deprecated and removed in MongoDB 7.0. The default `mongod.conf` provided by the package might still contain this legacy option.
* **Solution:** Edited `/etc/mongod.conf` using `gnome-text-editor admin:///etc/mongod.conf` and **removed the entire `journal` section** (or at least the `enabled: true` line under `journal`). The `storage` section was updated to simply:
```yaml
storage:
dbPath: /mnt/merged_ssd/mongodb-data
```

**Summary of Successful Direct Installation Steps:**
1. `sudo apt update && sudo apt upgrade -y`
2. `sudo apt install -y curl gnupg`
3. `curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | sudo gpg --dearmor -o /usr/share/keyrings/mongodb-archive-keyring.gpg`
4. `sudo rm /etc/apt/sources.list.d/mongodb-org-7.0.list` (if previous attempts were made)
5. `echo "deb [ arch=arm64 signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list`
6. `sudo apt update`
7. `sudo apt install -y mongodb-org`
8. `sudo systemctl stop mongod`
9. `sudo mkdir -p /mnt/merged_ssd/mongodb-data`
10. `sudo chown -R mongodb:mongodb /mnt/merged_ssd/mongodb-data`
11. `gnome-text-editor admin:///etc/mongod.conf` (and remove `storage.journal.enabled: true` or the entire `journal` section)
12. `sudo systemctl start mongod`
13. `sudo systemctl enable mongod`

This direct installation approach successfully bypassed the Docker-related memory allocation issues and allowed MongoDB to run on the FriendlyELEC CM3588.



My current mongod.conf file:

# mongod.conf

# for documentation of all options, see:
# http://docs.mongodb.org/manual/referenc ... n-options/

# Where and how to store data.
storage:
dbPath: /mnt/merged_ssd/mongodb-data # Change this line

# engine:
# wiredTiger:

# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log

# network interfaces
net:
port: 27017
bindIp: 127.0.0.1


# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo

#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:
There is ultimate solution - recombie kernel. then you will be able to run MongoDB version 8.0.
viewtopic.php?f=84&t=4554
This is a detailed instruction how to recompile - it worked for me!

Who is online

In total there are 6 users online :: 0 registered, 0 hidden and 6 guests (based on users active over the past 5 minutes)
Most users ever online was 5185 on Wed Jan 22, 2020 1:44 pm

Users browsing this forum: No registered users and 6 guests