Navigation

Cluster Configuration File

Overview

The mongocli command requires cluster configuration settings for creating or updating a MongoDB Cloud Manager or MongoDB Ops Manager cluster. The configuration properties can be provided through a .yaml or .json file. The following sections describe the Configuration Properties that are required for creating or updating a cluster and provide a Sample Configuration File that you can copy and modify.

Configuration Properties

The following sections contain the:

  • Cluster-wide configuration properties
  • Replica set member configuration properties
  • Sharded cluster configuration properties

Cluster-Wide Settings

The configuration file for creating or updating a MongoDB Cloud Manager or MongoDB Ops Manager cluster must contain the following cluster-wide settings:

Field Type Description
name string Name of the cluster.
version string Version of the mongod process to deploy.
featureCompatibilityVersion string Feature Compatibility Version of the deployment.
processes array of objects Required for replica sets. An array of objects containing settings for each mongod process. Each mongod has replica set member settings.
shards array of objects Required for sharded clusters. An array of objects containing settings for each shard.
config object Required for sharded clusters. Object that contains your config server replica set.
mongos array of objects Required for sharded clusters. An array of objects containing settings for each mongos instance.

Replica Set Member Settings

The configuration file for creating or updating a MongoDB Cloud Manager or MongoDB Ops Manager cluster can contain the following settings for each replica set member:

Field Type Description Required?
buildIndexes boolean

Flag that indicates whether to direct the mongod to build indexes. Value can be true or false.

This setting corresponds to the buildIndexes mongod replica set configuration option.

no
dbPath string Directory where the mongod instance stores its data. This cannot be modified after deployment. yes
delay int Number of seconds behind the primary member that this member should lag. This setting corresponds to the slaveDelay mongod replica set configuration option. no
hostname string Name of the host to add to the replica set. This is the host on which Ops Manager deploys the mongod process. yes
logPath string Location and name of the log file for the mongod process on the host. yes
port integer Port for the replica set member. The mongod process must have exclusive access to the specified port. yes
priority integer

Priority of the replica set member during elections. Value can be:

  • 0
  • 1

Non-voting members must have a priority of 0. Replica set members with a priority of 0 cannot become the primary and cannot trigger elections.

yes
votes integer

Number that indicates whether the replica set member votes in the election. Value can be:

  • 0 if the replica set member cannot vote
  • 1 if the replica set member can vote

To learn more about votes, see votes.

yes

Shard Settings

The configuration file for creating or updating a MongoDB Cloud Manager or MongoDB Ops Manager cluster can contain the following settings for each shard:

Field Type Description Required?
name string Name of the of the shard. yes
processes array of objects An array of objects containing settings for each mongod process. Each mongod has replica set member settings. yes

Sample Configuration File

name: "myCluster"
version: 4.2.2
featureCompatibilityVersion: 4.2
processes:
    - hostname: host0
      dbPath: /data/cluster_2/rs1
      logPath: /data/cluster_2/rs1/mongodb.log
      priority: 1
      votes: 1
      port: 29010
    - hostname: host1
      dbPath: /data/cluster_2/rs2
      logPath: /data/cluster_2/rs2/mongodb.log
      priority: 1
      votes: 1
      port: 29020
    - hostname: host2
      dbPath: /data/cluster_2/rs3
      logPath: /data/cluster_2/rs3/mongodb.log
      priority: 1
      votes: 1
      port: 29030
{
    "name": "myCluster",
    "version": "4.2.2",
    "featureCompatibilityVersion": "4.2",
    "processes": [
     {
        "hostname": "host0",
        "dbPath": "/data/cluster_3/rs1",
        "logPath": "/data/cluster_3/rs1/mongodb.log",
        "priority": 1,
        "votes": 1,
        "port": 30010
     },
     {
        "hostname": "host1",
        "dbPath": "/data/cluster_3/rs2",
        "logPath": "/data/cluster_3/rs2/mongodb.log",
        "priority": 1,
        "votes": 1,
        "port": 30020
     },
     {
        "hostname": "host2",
        "dbPath": "/data/cluster_3/rs3",
        "logPath": "/data/cluster_3/rs3/mongodb.log",
        "priority": 1,
        "votes": 1,
        "port": 30030
     }
   ]
}
{
  "name": "myShardedCluster",
  "version": "4.2.2",
  "featureCompatibilityVersion": "4.2",
  "shards": [
    {
      "name": "myShard_0",
      "processes": [
        {
          "dbPath": "/data/myCluster/myShard_0/27000",
          "hostname": "host0.example",
          "logPath": "/data/myCluster/myShard_0/27000/mongodb.log",
          "port": 27000,
          "votes": 1
        },
        {
          "dbPath": "/data/myCluster/myShard_0/27001",
          "hostname": "host1.example",
          "logPath": "/data/myCluster/myShard_0/27001/mongodb.log",
          "port": 27001,
          "votes": 1
        },
        {
          "dbPath": "/data/myCluster/myShard_0/27002",
          "hostname": "host2.example",
          "logPath": "/data/myCluster/myShard_0/27002/mongodb.log",
          "port": 27002,
          "version": "4.2.8-ent",
          "votes": 1
        }
      ]
    },
    {
      "name": "myShard_1",
      "processes": [
        {
          "dbPath": "/data/myCluster/myShard_1/28000",
          "hostname": "host3.example",
          "logPath": "/data/myCluster/myShard_1/28000/mongodb.log",
          "port": 28000,
          "votes": 1
        },
        {
          "dbPath": "/data/myCluster/myShard_1/28001",
          "hostname": "host4.example",
          "logPath": "/data/myCluster/myShard_1/28001/mongodb.log",
          "port": 28001,
          "votes": 1
        },
        {
          "dbPath": "/data/myCluster/myShard_1/28002",
          "hostname": "host5.example",
          "logPath": "/data/myCluster/myShard_1/28002/mongodb.log",
          "port": 28002,
          "votes": 1
        }
      ]
    }
  ],
  "config": {
    "name": "configRS",
    "processes": [
      {
        "dbPath": "/data/myCluster/configRS/29000",
        "hostname": "host6.example",
        "logPath": "/data/myCluster/configRS/29000/mongodb.log",
        "port": 29000,
        "votes": 1
      },
      {
        "dbPath": "/data/myCluster/configRS/29001",
        "hostname": "host7.example",
        "logPath": "/data/myCluster/configRS/29001/mongodb.log",
        "port": 29001,
        "votes": 1
      },
      {
        "dbPath": "/data/myCluster/configRS/29002",
        "hostname": "host8.example",
        "logPath": "/data/myCluster/configRS/29002/mongodb.log",
        "port": 29002,
        "votes": 1
      }
    ]
  },
  "mongos": [
    {
      "hostname": "host9.example",
      "logPath": "/data/myCluster/mongoses/27015/mongodb.log",
      "port": 27015
    }
  ]
}