Mysql Master-Slave Replication


Important information:
Binary Logs –> Replication events are written to the binary logs (on the master). Information stored here will be read by the slave later.
Relay Logs –> Simply a copy of the binary logs. Relay logs are stored on the slave.

IO Thread

Slave connects to master, copies the binary logs over and stores them locally in relay logs.

+------------------+              +------------------+
+--------+         |              +---------+        |
|MySQL   | -----   |              |MySQL    |        |
|Master  |     |   |              |Slave    |        |
+--------+    \/   |     IO       +---------+        |
|      Binary Logs | <--------->  |Relay Logs        |
+------------------+              +------------------+



SQL Thread


This thread reads events from the relay logs stored locally on the slave and applies them.

+------------------+
+---------+        |
|MySQL    | <---+  |
|Sla^e    |     |  | SQL Running
+---------+     |  |
|Relay Logs +---+  +
+-----------------+


More information can be found: https://www.percona.com/blog/2013/01/09/how-does-mysql-replication-really-work/