~ 2 min read

My Journey with Large Scale Data Gathering

Create additional indexes on the DB

Setting up authenticated Mongo


# mongod.conf

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

# where to write logging data.
  destination: file
  logAppend: true
  path: mongod.log

# Where and how to store data.
  dbPath: ~/mongo/data

# how the process runs
  fork: false  # fork and run in background
  pidFilePath: /var/run/mongodb/mongod.pid  # location of pidfile

# network interfaces
  port: 27017
  # Enter,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
  bindIp:, outside_access.domain.com

  authorization: enabled

Mongo restart comand with auth

mongod --bind_ip_all  --auth --port 27017 --dbpath ~/mongo/data/

To add users + roles

    // main admin user
    use admin
    db.createUser({ user: "***", pwd: passwordPrompt(), roles: [{ role: "root", db: "admin" }, { role: "dbOwner", db: "work_db" }] })

    // specific DB user
    use work_db
    db.createUser({ user: "***", pwd: passwordPrompt(), roles: [{ role: "dbOwner", db: "work_db" }] })

Connection string

connectionURI = "mongodb://user:pass@localhost:27017/?serverSelectionTimeoutMS=5000&connectTimeoutMS=10000&authSource=WORK_DB&authMechanism=SCRAM-SHA-256"

Port Forwarding