Skip to content

mongoDB Replicas and Shards

Nimrod Becker edited this page Feb 8, 2016 · 19 revisions

General ReplicaSet and Sharding deployment. Assumes MongoDB version 3.2 and up.

This page will be broken into 3 sections:

  1. [Creating a Replica Set in MongoDB](#my-Creating a Replica Set in MongoDB)
  2. [Creating a Shard Cluster in MongoDB](#Creating a Shard Cluster in MongoDB)
  3. [Creating a Shard Cluster with Replica Set for Each Shard in Mongodb](#Creating a Shard Cluster with Replica Set for Each Shard in Mongodb)

Creating a Replica Set in MongoDB

MongoDB Documentation

Cut to the Chase

  1. Have three machines installed with the same version of MongoDB.
  2. On each of the machine start the mongod service with the --replSet "NAME_OF_REPLICA" (in our case, update the /etc/noobaa_supervisor.conf command for the mongodb service)
  3. On one of the nodes (the one you wish to be the primary) run_ rs.initiate()_
  4. On the primary node, run rs.add(IP:PORT) for each additional node in the replica set
  5. You can verify the replica set configuration and status by using rs.status() and rs.conf()

These steps can also be performed via the mongo config file.

Creating a Shard Cluster in MongoDB

Creating a Shard Cluster with Replica Set for Each Shard in Mongodb

Clone this wiki locally