When MongoDB database servers operate on a cluster of computers then data is distributed over many systems in a cluster and processing is parallelized. Data is partitioned into smaller chunks of more or less the same size and located on each system in a cluster. In the future we shall call such distribution as "sharding" (shared nothing distribution of data).
Partitioning and distribution of data over many nodes in a cluster increases a probability that a chunk of data is not accessible when one of the system in a cluster fails. To avoid such situation and to increase data availability the chunks of data are replicated on the other systems in a cluster. Replication means that each chunk of data is kept on more than one system in a cluster. When a system fails its replica is automatically used for processing. It is aclled as "automatic failover".
This presentation explains one it is possible to create replica servers (replication) in MongoDB. In brief, replication means automatic maintenance of data distributed over a number of MongoDB servers.
MongoDB implements replication as a mechanism called "replica sets". A replica sets is a group of nodes in a computer cluster configured such that they can automatically synchronize their data and failover when a node fails and disappears from a cluster.
Older versions of MongoDB support a method of replication called "master-slave" (now considered as deprecated) that still can be used in MongoDB starting from version 3.0.
In both approaches (replica sets and "master-slave"), a single primary node (a node that is a member of a cluster)receives all writes, and then all secondary nodes (the nodes that can potentially replace primary node when it fails) read and apply those writes to themselves asynchronously.
Replica sets use the same replication mechanism as master-slave with additionally ensuring automated failover.
In order to increase a reliability of the system each primary node may have many secondary nodes.