Databases Reference
In-Depth Information
CHAPTER 10
Replication
MySQL's built-in replication is the foundation for building large, high-performance
applications on top of MySQL, using the so-called “scale-out” architecture. Replication
lets you configure one or more servers as replicas 1 of another server, keeping their data
synchronized with the master copy. This is not just useful for high-performance
applications—it is also the cornerstone of many strategies for high availability, scala-
bility, disaster recovery, backups, analysis, data warehousing, and many other tasks.
In fact, scalability and high availability are related topics, and we'll be weaving these
themes through this chapter and the next two.
In this chapter, we examine all aspects of replication. We begin with an overview of
how it works, then look at basic server setup, designing more advanced replication
configurations, and managing and optimizing your replicated servers. Although we
generally focus a lot on performance in this topic, we are equally concerned with cor-
rectness and reliability when it comes to replication, so'll we show you how replication
can fail and how to make it work well.
Replication Overview
The basic problem replication solves is keeping one server's data synchronized with
another's. Many replicas can connect to a single master and stay in sync with it, and a
replica can, in turn, act as a master. You can arrange masters and replicas in many
different ways.
MySQL supports two kinds of replication: statement-based replication and row-based
replication . Statement-based (or “logical”) replication has been available since MySQL
3.23. Row-based replication was added in MySQL 5.1. Both kinds work by recording
changes in the master's binary log 2 and replaying the log on the replica, and both are
1. You might see replicas referred to as “slaves.” We avoid this term wherever possible.
2. If you're new to the binary log, you can find more information in Chapter 8 , the rest of this chapter, and
Chapter 15 .
 
Search WWH ::




Custom Search