liveBook · Manning

Local Atlas cluster

As explained in MongoDB 8.0 in Action, Third Edition

A local Atlas cluster is a locally running MongoDB deployment that emulates the environment and capabilities of a cloud-based MongoDB Atlas cluster.

A local Atlas cluster is a locally running MongoDB deployment that emulates a cloud-based Atlas cluster for application development. Atlas CLI provisions it with Docker images or directly on the host, while local networking lets applications connect through MongoDB’s usual interfaces. section 13.1

A local Atlas cluster provides:

  • A single-node mongod replica set, configuration files, and a default local endpoint on port 27017. section 13.1
  • A separate mongot process for full-text search, vector search, and search-index management. section 13.1
  • Atlas CLI lifecycle commands for setup, connect, list, start, pause, logs, search, and delete operations. section 13.1
  • A development-focused environment rather than a production deployment; the local mongot binary is in private preview. section 13.4.2

Create and verify a local cluster

1. Install and start Docker. 2. Run `atlas deployments setup --type local`. 3. Accept the default deployment settings, which create a MongoDB 8.0 deployment on port 27017. 4. Choose `mongosh` when prompted for a connection method. 5. Run `show dbs` to inspect available databases and `docker ps` to verify that the healthy local container maps `127.0.0.1:27017` to port 27017. section 13.2.2

Listing 13.1 Atlas CLI local deployment option
atlas deployments --help
Manage cloud and local deployments.

Usage:
  atlas deployments [command]

Aliases:
  deployments, deployment

Cloud and local deployments commands:
  setup       Create a local deployment.
  delete      Delete a deployment.
  list        Return all deployments.
  connect     Connect to a deployment that is running
  ➥locally or in Atlas. If the deployment is paused,
  ➥make sure to run atlas deployments start first.
  logs        Get deployment logs.
  start       Start a deployment.
  pause       Pause a deployment.
  search      Manage search for cloud and local deployments.

Flags:
  -h, --help   help for deployments

Global Flags:
  -P, --profile string   Name of the profile to use from
  ➥your configuration file. To learn about profiles f
  ➥or the Atlas CLI, see https://dochub.mongodb.org/core/
  ➥atlas-cli-save-connection-settings.

Use "atlas deployments [command] --help" for more
➥information about a command.

Use the Atlas CLI command listing as a quick operational reference for creating, connecting to, inspecting, pausing, starting, searching, and deleting local deployments. section 13.1

cat README.md
`mongot` runs as a separate process alongside `mongod`.
➥When configured, `mongot` handles requests related to search
➥and index management for `mongod`.

The mongot binary for local development is in Private Preview.
It is available for testing in order to gather feedback.
Do not use the mongot binary for production deployments.

## Setup

1. Create a keyfile for the connection between mongod and mongot.
    * `mkdir data && echo keyfile > data/keyfile && chmod 600 data/keyfile`
    * If you already have replication enabled you don't
➥ need to create another keyfile, and you
      can keep your existing `replSetName` and `keyFile`
➥configurations in the following step.

2. Configure mongod
    * If you're using a configuration file, add these lines:
      ```yaml
      replication:
        replSetName: rs0
      security:
        keyFile: data/keyfile
      setParameter:
        mongotHost: localhost:27027
        searchIndexManagementHostAndPort: localhost:27027
      ```

    * If you're using command line flags, add these:
        ```shell
        --replSet rs0
        --keyFile data/keyfile
        --setParameter "mongotHost=localhost:27027"
        --setParameter "searchIndexManagementHostAndPort=localhost:27027"
        ```
3. Restart mongod. If a new replica set was created,
➥connect and run `rs.initiate()`
4. Start mongot: `./mongot --mongodHostAndPort=localhost:27017
➥–-keyfile=data/keyfile`
    * Other optional arguments include:
        * `--data-dir`: where mongot should persist data.
➥The default value is to data/mongot.
        * `--log-path`: location where mongot should write logs.
➥The default is to print to stdout.
5. Test the local Atlas Search server.
    ```js
    db.coll.createSearchIndex({"mappings": {"dynamic": true}})
    db.coll.aggregate([{"$listSearchIndexes": {}}])
    db.coll.dropSearchIndex("default")

Inspect the container README when configuring mongod and mongot: it documents keyfile-based communication, replication settings, restarts, and basic search-index tests. section 13.4.2

How MongoDB 8.0 in Action, Third Edition covers it

How deep it goes
Explains CLI setup, Docker verification, process layout, configuration, and search tests, but stops short of production deployment guidance.
Examples
Uses Atlas CLI setup, mongosh database inspection, Docker container checks, and container-level mongot search-index tests.
What it assumes
Assumes Docker and Atlas CLI availability, while introducing local deployment setup, mongosh connection, and mongot configuration.
What you can do after
Operate/configure a local deployment, connect with mongosh, inspect its container, and test search-index management.
How it connects
Connects MongoDB Atlas, Atlas CLI, Docker, mongod, mongot, replica sets, change streams, Lucene, and Atlas Search.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of MongoDB 8.0 in Action, Third Edition. The section links point to the parts of the book it draws on.