Data Durability in Replica Sets
In this lesson, we will look at what happens to the data, stored in a database when a secondary node is killed off.
Now that you are clear on how replication works and how it is implemented let’s look into some other details.
In one of the previous lessons, what happens when a primary node fails.
However, what happens if one of the secondary nodes is killed?
We learned previously that the goal of replication is to ensure that no data is lost if a server fails. Hence, the data is still available even if a secondary node is killed off.
Implementation
Now, let’s create a replica set, kill a secondary node, and then look at its impact on the data stored in the database.
Follow the steps below:
Creating a replica set
As in the previous lesson, the three mongod
instances are initiated first.
The three commands, for running the
mongod
instances, have already been run for you in the terminal below.
To see the details of the commands used to run these mongod
instances, go to the following lesson.
Starting the Mongo Shell
Next, connect to one of the running mongod
processes using the MongoDB shell client.
Call mongo
to connect to the mongod
process that is running on port 27017
.
Note: This will act as our primary node.
Type the command below on the terminal:
Get hands-on with 1400+ tech skills courses.