Mysql replication mechanism from the main principle

Mysql replication master from the use

  • Embodiment disaster recovery, for failover
  • For separate read and write access service
  • Backup, to avoid data loss

 

From the master copy condition Mysql

  • Main library open binlog log (from the library needs to read from the inside)
  • From the master require different Mysql server-id
  • From the library server can communicate with the master library

 

Mysql master-slave replication principle

 

 

  1. Primary library receives a user operation done crud, into the database, updating the result set to binlog
  2. Master-slave synchronization from the Lord to find and send a request from the IO library, the main process to look at the main library from the library master change in parameters is legitimate, if the legal process to the main process of implementation of IO 3, otherwise refuse to deal with
  3. Main library according to the position of master points, binlog log points from this position until the last binlog log, which is ready to be sent to the library.
  4. The binlog log to find the one i sent from the library, and also sends new log point.
  5. Binlog log received from the library, writes realy-log (log relay) in the.
  6. Log position again point master info Save the main library pass over the last binlog log from the library IO process.
  7. Cycle initiation request from the IO library, and then to be made, the tube will not relay SQL read operation log. IO from the library according to the new log point, initiates a request to the master database, the master database performs operation 34, and then sent to a new binlog from the library, and then perform operations from the 5 libraries.
  8. In fact, the first time to put data in the relay-log, SQL has been known processes, the process of converting SQL relay-log data into SQL statements, written from the library, in order to achieve synchronization.
  9. Log-point reading from the library SQL thread count log, and not a one-time read, will read in the store to relay-log.info

Guess you like

Origin www.cnblogs.com/arebirth/p/mysqlmasterslaveprinciple.html