Mysql master-slave replication principle and steps

The principle of master-slave replication is as follows.

slave (from the server)

master (master server)

mysql master-slave is an asynchronous replication process

The master turns on the bin-log function. The log file is used to record the database read and write additions and deletions. During the
master-slave synchronization process, the master server master has a worker thread I/O dump thread, and the slave server slave has two worker threads I/O thread and SQL thread .

Slave connects to the master through the IO thread, and requests a bin-log, content after position.
The MASTER server receives the log request information sent by the slave IO thread, and the io thread returns the bin-log content and position to the slave IO thread.
The slave server receives the bin-log log content, writes the bin-log log content to the relay-log relay log, and creates a master.info file that records the master ip username and password master bin-log name, bin- log position.
The slave side starts the SQL thread, monitors whether the relay-log log content is updated in real time, parses the SQL statement in the file, and executes it in the slave database.

 

Guess you like

Origin blog.csdn.net/luzhensmart/article/details/112525190