The main principle from the library

Master-slave replication role

1, the hot standby for data, as a backup database, the primary database server failure, can be switched to continue working from the database, to avoid data loss.
2, extended architecture. Increasing the volume of business, I / O access frequency is too high, stand-alone can not meet, then do store multiple libraries, reduce the frequency of disk I / O access and improve single machine I / O performance.
3, separate read and write the database can support more complicated. Especially important in the report. As part of the report sql statement is very slow, leading to lock the table, affecting front desk. If the future use of master, report uses slave, then the report will not cause sql lock the front desk, to ensure the reception speed.

Master-slave replication principle

1. There is a bin-log database binary files, records all sql statements.
2. Our goal is to copy the sql statement over bin-log files of the primary database.
3. allowed in the redo log data from the relay-log files and then executed once these sql statements can be.
4. The following is the main principle of this configuration from the configuration around
5. DETAILED three threads need to operate:
1.binlog output thread: whenever there is a connection to a master from the library, the master creates a thread library then sends the content binlog to the library. In the library, when the copy start, it will create two threads from the library for processing:
2. From the library I / O thread: When START SLAVE statement after the library started, create a library from I / O thread the thread is connected to a main library and the master library sends a request to update a record to the inside binlog from the library. Update read from the main library library I / O output binlog thread and thread sends updates to the local copy of the file, including relay log file.

3. From the SQL thread library: create a SQL thread from the library, from the library to read this thread I / O thread writes relay log of events and perform updates.

 

 

mysql master-slave replication problems:

  • After the main library downtime, data may be lost
  • From the library only a sql Thread, the main library to write pressure, copying is likely to delay

Solution:

  • Semi-synchronous replication - to solve the problem of data loss
  • Parallel copy - to solve the problem of delayed copy from the library

 

Reference links

【1】https://blog.csdn.net/darkangel1228/article/details/80004222

【2】https://blog.csdn.net/darkangel1228/article/details/80003967

Guess you like

Origin www.cnblogs.com/lalalatianlalu/p/11740966.html