-
Notifications
You must be signed in to change notification settings - Fork 80
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 2 sections:
- [Creating a Replica Set in MongoDB](#my-Creating a Replica Set in MongoDB)
- [Creating a Shard Cluster in MongoDB](#Creating a Shard Cluster (With Replica Set) in MongoDB)
MongoDB Documentation
- Deploying a new replica set
- Converting an existing stand-alone mongo to a replica set
- Considerations for a Geo distributed replica set
Cut to the Chase
- Have three machines installed with the same version of MongoDB.
- 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)
- On one of the nodes (the one you wish to be the primary) run_ rs.initiate()_
- On the primary node, run rs.add(IP:PORT) for each additional node in the replica set
- 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.
MongoDB Documentation
Cut to the Chase
- Have three machines installed with the same version of MongoDB.
- On each of these instances run mongod --configsvr --replSet SETNAME --dbpath /data/db (in our case, update the /etc/noobaa_supervisor.conf command for the mongodb service)
- Choose one node to be the primary and run rs.initiate() on it
- On the primary node, run rs.add(IP:PORT) for each additional node in the replica set
- On each node run mongos --configdb configReplSet/IP1:27019,IP2:27019,IP3:27019 where IP1 - IP3 are the IPs of the three nodes in the set. (in our case, update /etc/noobaa_supervisor.conf and add a mongos service containing the command above)