🥒
Dill's Knowledge Base
  • Hello World
  • 💻SQL
    • ❌Error Handling
    • 🧀Parameter Sniffing
      • Indexes
      • Query Hints
      • RECOMPILE
      • Branching
      • Memory Grants
      • Summary
      • Bonus
    • SQL Server Buffer Pool
  • 🖱️MongoDB
    • Instructor Led Training
      • DF100
      • DF200
      • DF300
      • DF400
    • MongoDB DBA University
      • DBA Admin Tools
      • DBA Basics
      • Metrics & Monitoring
  • 💻Web Design
    • Oxygen Tips
    • Bricks Builder
      • Tips
      • Discovery Call
      • Utility vs Custom Classes
      • Math Functions
      • Static vs Relative Units
  • Azure
    • AZ-900
      • Benefit of Cloud Computing
      • CapEx, OpEx and Consumption-based
      • Differences Between Cloud Service Categories
      • Identify The Right Service Type
      • Differences Between Types of Cloud Computing
      • Reliability and Predictability
      • Regions and Region Pairs
      • Availability Zones
      • Resource Groups
      • Subscriptions
      • Management Groups
      • Azure Resource Manager
      • Azure ARC
      • Resources Required for VM
      • Benefits and Usage of Core Compute Resources
      • Benefits and Usage of Core Network Resources
      • Public/Private Endpoints
      • Benefits and Usage of Storage Accounts
      • Benefits and Usage of Database Resources
      • Data Movement and Migration Options
      • Benefits and Usage of IoT Services
      • Benefits and Usage of Big Data and Analytics Services
      • Benefits and Usage of AI Services
      • Benefits and Usage of Serverless Technologies
      • Benefits and Usage of DevOps Technologies
      • Functionality of Azure Management Solutions
      • Functionality and Usage of Azure Advisor
      • Functionality and Usage of ARM Templates
      • Functionality and Usage of Azure Monitor
      • Functionality and Usage of Azure Service Health
      • Functionality of Microsoft Defender for Cloud
      • Functionality and Usage of Key Vault
      • Functionality and Usage of Microsoft Sentinel
      • Azure Dedicated Host
      • Defense in Depth
      • Describe the Concept of Zero Trust
      • Functionality and Usage of NSGs
      • Functionality and Usage of Azure Firewall
      • Functionality and Usage of Azure DDoS Protection
      • Explain Authentication and Authorization
      • Functionality and Usage of Azure AD
      • Microsoft Entra Overview
      • Functionality of Conditional Access, MFA and SSO
      • Functionality and Usage of RBAC
      • Functionality and Usage of Resource Locks
      • Functionality and Usage of Tags
      • Functionality and Usage of Azure Policy
      • Governance Hierarchy Constructs
      • Azure Blueprints
      • Describe Microsoft Privacy Statement, OST and DPA
      • Purpose of Trust Center and Azure Compliance Documentation
      • Purpose of Azure Sovereign Regions
      • Factors That Affect Costs
      • Factors to Reduce Cost
      • Functionality and Usage of Azure Cost Management
      • Purpose of Service Level Agreements
    • DP-900
      • Study Cram
    • DP-300
      • Deploy IaaS Soluton with Azure SQL
  • 📦Kubernetes
    • Udemy: Kubernetes for Beginners
Powered by GitBook
On this page
  • Connecting to MongoDB Server
  • Logging Basics
  1. MongoDB
  2. MongoDB DBA University

DBA Basics

PreviousDBA Admin ToolsNextMetrics & Monitoring

Last updated 1 year ago

Connecting to MongoDB Server

Running mongosh with no params will default to 127.0.0.1:27017

Localhost Exception

  • Allows all connections from the localhost interface to have full access to that instance so that the first user can be created

    • This applies only when there are no users or roles created in the MongoDB instance

  • It can only create the first user and then it is disabled

use {db_name}

  • Swtiches database context

db.createUser()

  • Root role gives full control over instance and ability to create other users

    • Typically you want to user least viable privileges

show users

  • Show all existing users

  • May fail with "command requires authentication"

    • db.auth("dbaTestAdmin", passwordPrompt() )

      • Prompts user for password

db.adminCommand(<command>)

  • The above examples are the exact same, but the 2nd command is preferred as it does not require you to switch database context

  • The main purpose of this admin database is to store system collections and user authentication and authorization data, which includes the administrator and user's usernames, passwords, and roles. Access is limited to only to administrators, who have the ability to create, update, and delete users and assign roles.

MongoDB Shell (mongosh)

  • Fully functional REPL environment for interacting with MongoDB deployment

Logging Basics

db.serverCmdLineOpts().parsed.systemLog.path

  • Command utility to help you find the location of the logs on disk

show logs

  • displays tag names

show log global

  • Displays all logs tagged as global

  • By default, "show log" will default to global

MongoDB Logs are structured in JSON format

  • Logs have severity levels indicated by the "I" key

    • ex. {"s":"I"} is an information log

      • verbosity must be set to 0 for informational logs and is the default level

  • "c" is the category tag

  • "id" is a unique identifier

  • "ctx" is the name of the thread that caused the message

  • Logs will only contain keys that they have info for

Log Rotation

  • prevents log files from consuming too much disk space

  • MongoDB does not automatically rotate the logs, but a system admin can do so

    • db.adminCommand ({logRotate: "server"})

🖱️