Chapter 11. Replication

 

This chapter covers

  • Understanding basic replication concepts
  • Connecting a driver to a replica set
  • Administering replica sets and handling failover
  • Increasing the durability of writes with write concerns
  • Optimizing your reads with the read preference
  • Managing complex replica sets using tagging

Replication is central to most database management systems because of one inevitable fact: failures happen. If you want your live production data to be available even after a failure, you need to be sure that your production databases are available on more than one machine. Replication provides data protection, high availability, and disaster recovery.

We’ll begin this chapter by introducing replication and discussing its main use cases. Then we’ll cover MongoDB’s replication through a detailed study of replica sets. Finally, we’ll describe how to connect to replicated MongoDB clusters using the drivers, how to use write concerns, and how to load-balance reads across replicas.

11.1. Replication overview

11.2. Replica sets

11.3. Drivers and replication

11.4. Summary