MySQL master-Slave synchronization architecture is currently one of the most used database architecture, especially the load is relatively large site, so for master-slave synchronization management is very important, novice often in the case of master-slave synchronization errors do not know how to start, This article is a detailed description of MySQL master-slave management according to its own experience.
The role of MySQL master-slave synchronization
(1) Data distribution
(2) Load balancing (load Balancing)
(3) Backup
(4) High availability (Hi availability) and fault tolerance
The principle of MySQL master-slave synchronization
The main thing about MySQL's master-slave synchronization is to understand how MySQL's master-slave synchronization works, that is, the principle of master-slave synchronization, through the process that can clearly guide its work:
Describe the process roughly: from the server's IO thread, get the binary log from the primary server, save it locally as a trunk log, and then execute the contents of the relay log from the top through the SQL thread to keep it consistent from the library and the main library. The detailed process of master-slave synchronization is as follows:
- The primary server verifies the connection.
- The primary server opens a thread from the server.
- The offset shift from the primary server log is told to the primary server from the server.
- The primary server checks to see if the value is less than the current binary log bias shift.
- If it is less than, the notification is to fetch data from the server.
- From the server continues to fetch data from the primary server until it is finished, when the server thread goes to sleep, the primary server thread goes to sleep at the same time.
- When the primary server has an update, the primary server thread is activated, and the binary log is pushed to the slave server, and the server thread is notified to enter the working state.
- Executes the binary log from the server SQL thread and then goes to sleep.
Original link:http://blog.chinaunix.net/uid-20639775-id-3254611.html
Http://www.cnblogs.com/binyue/p/3850895.html
"Go" MySQL database master-Slave synchronization management