In this tutorial you will learn about the MongoDB replication and understand what is MongoDB replication?
What is MongoDB Replication? Benefits of database replication in MongoDB
In this section we will understand about the replications of database in the MongoDB.
Replication refers to the process of synchronizing data across multiple machines and servers and this irrevocably benefits users in many ways. Firstly through replication the loss of data from a server is protected actively by other servers. Secondly hardware failure and all sorts of service interruptions can be avoided thanks to this. Replication allows you to assign different servers for different actions with additional copies of data. With the additional data copies you can assign tasks like recovery, reporting, backup, etc. Here below we mention the important benefits of replication and how in MongoDB replication works.
Effectiveness of replication
- Safety of data
- Ensuring high availability of data
- Faster and easier recovery of data from disaster
- No instances of server downtime in case of maintenance operations like backup, index rebuilding, compaction, etc.
Replication in MongoDB
In MongoDB the replication happens through replica set. Here below we explain in brief so one can understand how it works.
- Two or more nodes make up a replica set.
- Among the nodes one is primary and the others are secondary.
- Data replicates from primary to secondary nodes.
- In the time of maintenance or failure a new primary node is elected to ensure uninterrupted work process at the users end.
- As the recovery of the failed nodes get completed it again joins as the secondary node.
- Typically clients or users always interact with primary node and primary node then fetches data from other secondary nodes.
What is the difference between Sharding and replication?
Replication
The replication is process of creating additional copies of the data which is shared on different physical MongoDB server and which allows for automatic failover to another node. Such replication is very helpful in read operations.
Sharding
While sharding is used for the horizontal scaling of data and it is partitioned across the multiple servers with the help of shard key.
[ 0 ] Comments