First, MySQL master-slave replication
Common master-Slave architecture:
- One master one from : a master, a Slave
- one master multi-slave : One master, multiple Slave
Specifically, refer to:
Implementation Details
What are the underlying implementation details of MySQL in the master-slave synchronization? After this, we analyze the reason of the master-slave delay and optimize the scheme, prepare the theory.
In summary, MySQL's master-slave replication: 异步单线程 .
Master1 IO线程 , responsible for transmitting to slave binary log ( binlog )
SlaveOn 2 Threads: IO 线程 and 执行SQL的线程 , where:
IO线程: Append the obtained log information to the relay log;
执行SQL的线程: Relay log content is detected to be updated, then execute SQL on slave;
Special Note : MySQL 5.6.3 started to support " 多线程 the 主从复制 ", 一个数据库 一个线程 多个数据库 can 多个线程 .
Complete Master & Slave between the master and slave replication processes:
MySQL Add from library