πŸ“˜ MONGODB

Reference documentation and troubleshooting guide.

🧩 MongoDB Wiki


πŸ“š Index

  1. πŸ“˜ Overview
  2. 🧱 Core Concepts
  3. 🧩 Architecture Components
  4. βš™οΈ Installation
  5. βš™οΈ Configuration
  6. 🧠 Basic Commands
  7. 🧩 Replica Set Setup
  8. πŸͺ£ Backup & Restore
  9. πŸͺΆ MongoDB in Graylog Context
  10. 🧰 Useful Admin Commands
  11. πŸ›‘οΈ Security Recommendations
  12. πŸ“Š Performance Tuning
  13. 🧾 Logs and Monitoring
  14. πŸ”— References

πŸ“˜ Overview

MongoDB is an open-source NoSQL database designed for speed, scalability, and flexibility. It uses BSON (Binary JSON) to store structured and unstructured data.

Use Cases: Logging, analytics, IoT, and cloud-native applications.

⬆ Back to Index


🧱 Core Concepts

⬆ Back to Index


🧩 Architecture Components

⬆ Back to Index


βš™οΈ Installation

Ubuntu (VM or Container)

curl -fsSL https://pgp.mongodb.com/server-7.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor

echo "deb [signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list

sudo apt update
sudo apt install -y mongodb-org
sudo systemctl enable mongod
sudo systemctl start mongod
sudo systemctl status mongod

⬆ Back to Index


βš™οΈ Configuration

File: /etc/mongod.conf

storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true
systemLog:
  destination: file
  path: /var/log/mongodb/mongod.log
net:
  port: 27017
  bindIp: 127.0.0.1
replication:
  replSetName: rs0

Restart MongoDB service:

sudo systemctl restart mongod

⬆ Back to Index


🧠 Basic Commands

⬆ Back to Index


🧩 Replica Set Setup

1️⃣ Initiate on Primary Node

mongo
rs.initiate({
  _id: "rs0",
  members: [
    { _id: 0, host: "mongo1:27017" },
    { _id: 1, host: "mongo2:27017" },
    { _id: 2, host: "mongo3:27017" }
  ]
})

2️⃣ Check Status

rs.status()
rs.isMaster()

⬆ Back to Index


πŸͺ£ Backup & Restore

⬆ Back to Index


πŸͺΆ MongoDB in Graylog Context

Tip: host MongoDB on a separate VM to isolate from OpenSearch for better performance and I/O.

⬆ Back to Index


🧰 Useful Admin Commands

⬆ Back to Index


πŸ›‘οΈ Security Recommendations

⬆ Back to Index


πŸ“Š Performance Tuning

⬆ Back to Index


🧾 Logs and Monitoring

⬆ Back to Index


πŸ”— References