MongoDB

Configuration

Docker

Image

Compose

version: "3.7"
services:
  mongo: # access with `mongosh 'mongodb://user:password@127.0.0.1/database?authSource=admin'`
    # image reference: https://hub.docker.com/_/mongo
    image: library/mongo:6.0.8
    environment:
      MONGO_INITDB_DATABASE: database
      MONGO_INITDB_ROOT_USERNAME: user
      MONGO_INITDB_ROOT_PASSWORD: password
    ports: ["27017:27017"]
    network_mode: host
    volumes: # [] # uncomment this and comment below to remove persistence
      - ./.data/mongodb/data/data/db:/data/db

Debugging/error handling

Exit code 14

Keywords

"FileNotOpen", "Failed to open archive file"

Explanation

This exit code is formally defined as:


Returned by MongoDB applications which encounter an unrecoverable error, an uncaught exception or uncaught signal. The system exits without performing a clean shutdown.

Exploration

This error typically implies a system-level issue that prevents MongoDB from starting successfully.

Known Fixes 1 - MongoDB by Bitnami running in Kubernetes

This fix addresses an issue where the disk space allocated for MongoDB was filled to 100%

  • Update the statefulset resource so that the container's command is sleep 1000000.

  • Allow the MongoDB pod instances to restart

  • Get a shell into each of them and use df -h to view the available diskspace

  • Observe that /bitnami/mongodb is at 100% or near that

  • Using MongoDB logs, figure out where it is trying to write to, in this fix, the issue was with the diagnostic data and the following command was run to free up disk space:

rm -rf /bitnami/mongodb/data/db/diagnostic.data/*

Reference/useful links

Last updated