1.

Explain the Replication Architecture in MongoDB.

Answer»

The following diagram depicts the ARCHITECTURE diagram of a simple replica set cluster with only three server nodes – one PRIMARY node and two SECONDARY nodes:

  • In the preceding model, the PRIMARY database is the only active replica set member that receives write operations from database clients. The PRIMARY database saves data changes in the Oplog. Changes saved in the Oplog are sequential—that is, saved in the order that they are received and executed. 
  • The SECONDARY database is querying the PRIMARY database for new changes in the Oplog. If there are any changes, then Oplog entries are copied from PRIMARY to SECONDARY as soon as they are created on the PRIMARY node.
  • Then, the SECONDARY database applies changes from the Oplog to its own datafiles. Oplog entries are applied in the same order they were inserted in the log. As a result, datafiles on SECONDARY are kept in sync with changes on PRIMARY. 
  • Usually, SECONDARY databases copy data changes DIRECTLY from PRIMARY. Sometimes a SECONDARY database can replicate data from another SECONDARY. This type of replication is CALLED Chained Replication because it is a two-step replication process. Chained replication is useful in certain replication topologies, and it is enabled by default in MongoDB.


Discussion

No Comment Found