Replication In MongoDB

Share via:

Replication In MongoDB

♦ Replication is the process of creating and maintaining the multiple copies of data across the different servers and also ensuring the copy of the data remains consistent and updated.
♦ Replica set is one of the ways of implementing the replication in MongoDB.
♦ Replica set is a specific implementation configuration of replication in MongoDB.

 

Replica Set:
♦ It is a group of MongoDB instances that work together to maintain the same data It consists of multiple servers.
♦ The minimum recommended configuration for a replica set is three members which includes one primary and two secondary nodes.
♦ A replica set can have maximum up to 50 members but only seven voting members which are used to help in electing the primary node.
♦ A replica set can have up to 50 Members but only 7 voting members.

 

Advantages of using Replication:
1. Data Redundancy
2. High Availability
3. Scalability
4. Load Balancing
5. Fault Tolerance
6. Disaster Recovery

 

Members of replica set:
1. Primary node
2. Secondary node
3. Arbiter node
4. Oplogs

 

1. Primary node :
♦ It is the primary source of data modifications, which handles all the write operations and applies all the write operations to the dataset.
♦ It keeps tracking of the replica set’s Oplog.
♦ It handles both the read and write operations from the client’s application.
♦ Secondary nodes will replicate the Oplog which is generated from the write operations from the primary node.
♦ It ensures the health and data consistency within the replica set.

 

2. Secondary node:
♦ These nodes will replicate the primary node Oplog and also it acts as backup, ensuring that these nodes are always up to date with the data in the primary node.
♦ Replica set can have more than two secondary nodes.
♦ Secondary nodes are used to read the data.
♦ If the primary node fails, one of the secondary nodes will be elected as the new primary node.
♦ Secondary nodes should be monitored regularly to ensure their health and performance.

 

3. Arbiter node:
♦ The arbiter node will not store any replica sets in it.
♦ Main use of the arbiter node is to participate in the election when the primary fails to work which helps in the situation of tie in the election process.
♦ It helps in maintaining the replica set’s fault tolerance.
♦ This does not affect the storage capacity of the replica set.

 

4. Oplog:
♦ It is expanded as an operation log.
♦ It is a capped collection which is present in the primary node.
♦ Oplog is used for secondary nodes to replicate the data from the primary node in an asynchronous process.
♦ The default size of Oplog is 50MB, you can increase the size of the Oplog based on your application requirements up to 50gb.

 

Author    : Teja
LinkedIn : https://www.linkedin.com/in/teja-sai-nadh-reddy-tatireddy-048882201
Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates
KTExperts is always active on social media platforms.
Facebook  : https://www.facebook.com/ktexperts/
LinkedIn    : https://www.linkedin.com/company/ktexperts/
Twitter       : https://twitter.com/ktexpertsadmin
YouTube   :  https://www.youtube.com/c/ktexperts
Instagram  : https://www.instagram.com/knowledgesharingplatform
Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

Add Comment