Initiate Each Shard Replica Set

Initiate the shard mongod instances (shard replica set) that will host subsets of the MATRIXX event-object data set in your MongoDB sharded deployment.

Before you begin

Before initiating the replica set, verify the following in the MongoDB configuration file:
  • Verify that the replication option is set to MtxEventReplSet.
  • Verify that the authorization option is set to enabled.
  • Verify that all mongod instances on each of the MongoDB host servers are started.
Important: Starting in MongoDB 4.0, you cannot specify the --nojournal option or storage.journal.enabled: false for replica set members that use the WiredTiger storage engine. Refer to the MongoDB product documentation for compatibility changes in MongoDB 4.0.

About this task

The instructions in this procedure initiate a single replica set with three mongod instances.

Procedure

  1. Connect to one of the mongod instances locally.
  2. Using the MongoDB mongo shell CLI, enter the rs.initiate() command to initiate the replica set.
    mongo 
    rs.initiate({ 
    "_id" : "MtxShard1ReplSet", 
    "members" : [ 
    {"_id" : 0, "host" : "ip1", "arbiterOnly": false},
    {"_id" : 1, "host" : "ip2", "arbiterOnly": false},
    {"_id" : 2, "host" : "ip3", "arbiterOnly": false}
    ] 
    }) 
    where:
    • ip1, ip2, and ip3 are the hostnames (or IP addresses) and port numbers of the host servers where mongod shard instances of the replica set are to run. The port number is required only if the port number is not the default (27017).
    • The arbiterOnly option is set to true if the mongod instance is to run as an arbiter only.
    • MtxShard1ReplSet is the name of the shard replica set in this example. Use the correct replica set name of each of your shards when initiating each one.
  3. Identify the replica set primary (mongod primary) by issuing the mongo shell CLI command rs.status() on any server.

    A few seconds after the replica set is initialized, one mongod instance is elected as the primary of the replica set. All changes to the replica set must be done when connected to the primary from this point in the setup instructions.

What to do next

After you initiate each shard replica set, initiate your config-server replica set.