Qumulus
  • Welcome
  • Getting Started
    • Introduction to QUM
      • What can 1 QUM do?
      • QUM Performance
    • Dashboard
  • Your Account
    • Your Projects
      • Project Architecture
  • Resources
    • Compute
      • Instances
        • Creating an Instance
        • Instance Configuration
          • OS & Images
          • Instance Types
        • Using User Data
        • Connecting to an Instance
        • Instance Details
        • Instance Actions
        • Instance Monitoring
      • Instance Snapshot
        • Create & Restore
        • Snapshots Manage
  • Storage
    • Volumes
      • Create & Attach
      • Resize & Delete
    • Volume Snapshots
  • Networking
    • Public IPs
      • IP Allocation/Management
      • Associating/Disassociating IPs
    • Load Balancer
  • Security
    • Key Pairs
      • Creating Key Pairs
      • Managing Key Pairs
    • Security Groups
      • Managing Security Groups
    • SSL Certificates
  • How-To & Tutorials
    • Fixed cost Development Playground
    • Installing Redis Community
    • Installing Mongo Community
    • Installing PostgreSQL
    • VPN Server
      • VPN Server with OpenVPN
      • VPN Server with Netbird
  • RELEASES
    • Q1, 2025
  • Blogs
    • Release Beta v1.0
  • Release v2.0
Powered by GitBook
On this page
  1. How-To & Tutorials

Installing Mongo Community

Get High Performance Mongo Community up and running in under 3 minutes.

PreviousInstalling Redis CommunityNextInstalling PostgreSQL

Last updated 2 months ago

Getting up to speed with Mongo community for your development is super easy with Qumulus.

Create a new instance, select Ubuntu 24.04, Instance type as t1.small (or the size which suits you) and add script to the user data section, click launch!

Here is the 'user data' script you can use

#!/bin/bash

# This is a basic setup intended for development purposes.

# Update package list and install required packages.
apt update > /dev/null 2>&1
apt-get install -y gnupg curl ufw

# Setup MongoDB repository.
curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu $(grep '^UBUNTU_CODENAME=' /etc/os-release | cut -d'=' -f2)/mongodb-org/8.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-8.0.list

apt update > /dev/null 2>&1
apt-get install -y mongodb-org

# Configure MongoDB to listen on all interfaces and enable authorization.
sed -i "s/bindIp: 127.0.0.1/bindIp: 0.0.0.0/g" /etc/mongod.conf
sed -i "s/#security:/security:\n  authorization: enabled/g" /etc/mongod.conf

systemctl daemon-reload
systemctl start mongod
systemctl enable mongod

# Wait for MongoDB service to be ready (max 30 seconds).
for i in {1..30}; do
  if mongosh --eval "db.adminCommand('ping')" >/dev/null 2>&1; then
    echo "MongoDB is ready"
    break
  fi
  sleep 1
done

# Create admin user.
# Replace 'PleaseChangeYourPassword' with your actual secure password once the installation is completed.
MONGODB_USERNAME="admin"
MONGODB_PASSWORD="PleaseChangeYourPassword"
mongosh --eval "db.getSiblingDB('admin').createUser({user: '$MONGODB_USERNAME', pwd: '$MONGODB_PASSWORD', roles: [ { role: 'userAdminAnyDatabase', db: 'admin' }, 'readWriteAnyDatabase' ]})"

# Enable UFW if it's inactive.
if ufw status | grep -iq "inactive"; then
    echo "y" | ufw enable
fi

# Allow incoming TCP connections on MongoDB port (27017) and SSH (22).
ufw allow 27017/tcp
ufw allow 22/tcp
ufw reload
mongosh -u admin -p 'PleaseChangeYourPassword' --authenticationDatabase admin

Now switch to admin database and run password change command. Replace 'newSecurePassword' with a strong password.

use admin
db.changeUserPassword("admin", "newSecurePassword")

use the following format to connect to mongo. Replace PASSWORD and IP accordingly

mongodb://admin:PASSWORD@IP:27017/?authSource=admin

Once your instance is up and running, You can assign a public IP to it and SSH to it .Make sure you have inbound rules defined to allow SSH for the instance and open port for Mongo in the assigned to your VM.

First things first. Let's change the password for Mongo. and run following command with current password.

Finally, you may want to connect through or

Security Group
SSH to your VM
Mongodb Compass
Studio 3T
Associate Public IP
Allow inbound rule for SSH and Mongo
Change Mongod password