In this chapter, we studied how to create a replica set from scratch to provide a readily available MongoDB server. First of all, we discussed the basic considerations of a replica set. Next, we configured the workspace to run the replica set. Additionally, we learned basic replica set commands in order to add or remove members from the replica set.
In our example, we had a three-member replica set, one primary
and two secondary
nodes. After configuration and setup, to test the replica set, we deactivated different nodes in the replica set. Also, we found that upon disabling the primary
node, the replica set will choose another primary
node from the active secondary members using an election process.
Also, we learned to run an arbiter
node and add it to an existing replica set network. We found that arbiter
nodes won't save and hold data at all.
In the next chapter, we will learn sharding in MongoDB, and distributing a dataset into different servers and machines.