Databases 3 min read

Understanding MySQL Master‑Slave Replication: Principles and Benefits

This article explains MySQL master‑slave replication, covering its purpose for high availability, key features like real‑time disaster backup and read‑write separation, and the three essential steps—binlog recording on the master, I/O thread transfer to the relay log, and SQL thread replay on the slave.

Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Understanding MySQL Master‑Slave Replication: Principles and Benefits

MySQL Master‑Slave Replication

MySQL master‑slave replication is a common high‑availability and data‑architecture solution that synchronizes changes from the master database to one or more slave databases, providing data redundancy, load balancing, and disaster recovery.

Key Features

Real‑time disaster backup for easy failover.

Read‑write separation to reduce master load and improve read performance.

Data backup without impacting business operations.

How It Works

The replication relies on the binary log (binlog). The master records all data changes in the binlog, and the slave reads and replays these events to stay synchronized.

Three Main Steps

1. Master records binlog

When the master executes write operations such as INSERT, UPDATE, or DELETE, it writes the changes to the binlog in addition to the data files. The binlog records the operations, not the data itself, and is flushed to disk after transaction commit.

2. Slave I/O thread pulls the binlog and writes to relay log

After replication starts, the slave’s I/O thread connects to the master, which starts a Binlog Dump thread to send the binlog contents. The slave writes the received events into a local relay log.

3. Slave SQL thread replays the relay log

The slave’s SQL thread reads the relay log and executes the SQL statements in order, bringing the slave data into the same state as the master.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DatabasemysqlreplicationMaster‑Slave
Mike Chen's Internet Architecture
Written by

Mike Chen's Internet Architecture

Over ten years of BAT architecture experience, shared generously!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.