Replication in MongoDb - Its advantage - What is replica set

You are here : Home / MongoDB Tutorial



Contents of page >
  • 1) What is replication in mongoDB?
  • 2) What are advantages of replication in MongoDB?
  • 3) How Replication Works in MongoDB >
    • 3.1) What is replica set?
    • 3.2) Replica set contains >
    • 3.3) Important key point about data bearing nodes in Replica Set>
    • 3.4) Diagram to show Replica Set >
  • 4) Summary -

1) What is replication in mongoDB?
Replication means synchronizing the data across multiple mongoDB servers.
2) What are advantages of replication in MongoDB?
  • Replication provides redundancy - for making data highly available all the time.
  • Data recovery becomes very easy in case of some major failure like software of hardware failure.
  • Data backup - If data loss happens on one server - data is available on other mongoDB database servers.
  • Data is available all time - So, no downtime in case of server maintenance or server changes.
  • For data security.

3) How Replication Works in MongoDB >
MongoDB uses replica set for replication of data.
3.1) What is replica set?
A replica set is a group of mongod instances that maintain the same data set.

3.2) Replica set contains >
  • Several data bearing nodes and
    • At a time, one data bearing nodes is primary  (receives all write operations) and
    • All other data bearing nodes are deemed secondary (replicate data from primary node).

3.3) Important key point about data bearing nodes in Replica Set>
    • At a time, only one data bearing nodes is primary.
    • In case of failure, some secondary node is elected to become primary node. And,
After recovery, it again becomes secondary node.


3.4) Diagram to show Replica Set >
So, we see in above diagram that >
    • one data bearing nodes is primary  (which receives all write operations) and
    • Several secondary data bearing nodes(replicate data from primary node).
And,
    • Clients reads from the primary node.

Read operation in Replica set in MongoDB >

Clients by default reads from the primary node.
But, clients can send read operation request to secondary node also.





4) Summary -

So in this mongoDB tutorial we learned about Replication in MongoDb.

Replication means synchronizing the data across multiple mongoDB servers.
Replication provides redundancy, Data recovery, Data backup and data security.

How Replication Works in MongoDB >
MongoDB uses replica set (group of mongod instances that maintain the same data set) for replication of data.


Having any doubt? or you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter. You may join our fbGroup or linkedInGroup as well.




RELATED LINKS>

Labels: MongoDB
eEdit
Must read for you :