Master/slave replication first appeared in a beta release of MySQL back in 2000. In the three or so years since then, replication has become an essential feature for most of MySQL’s high-end users. And contrary to many assumptions, MySQL’s replication is quite easy to use, especially when compared to the replication systems that are part of high-end commercial databases. This month and next, let’s take a look at MySQL’s replication feature and the various ways you can put it to use.
Master/slave replication first appeared in a beta release of MySQL back in 2000. In the three or so years since then, replication has become an essential feature for most of MySQL’s high-end users. And contrary to many assumptions, MySQL’s replication is quite easy to use, especially when compared to the replication systems that are part of high-end commercial databases. This month and next, let’s take a look at MySQL’s replication feature and the various ways you can put it to use.
The Basics
MySQL’s replication systems allows multiple slave servers to stay in synch with changes to a single master server. Replicating your database has many advantages. For example, backup and recovery become easier. Rather than shutting down your master server to back it up, you can simply back up a slave. More importantly, replication makes it easier to scale large applications. By sending all write queries (INSERT, UPDATE, DELETE) to the master and using slaves for most of the read queries (SELECT), it’s possible to achieve nearly linear scalability for read-intensive applications.
There are two common techniques for implementing replication in a relational database server: copying logs or copying data. When copying logs, the master logs queries and sends them to the slave where they are replayed.
In contrast, data copying involves sending the changed data blocks from the master to the slaves. MySQL uses the log-based replication scheme.
Either method can be implemented either synchronously or asynchronously. Synchronous replication means that…
Please log in to view this content.
Not Yet a Member?
Register with LinuxMagazine.com and get free access to the entire archive, including: