Mysql 內部結構 / Replication

Chapter 19 Replication

Table of Contents     html

19.1 Chapter Organizationmysql

19.2 Source Code Filessql

19.3 Principles     數據庫

19.4 Rules     服務器

Status of this section: up to date 2009-10-21app

This chapter describes MySQL replication principles, rules, and code, as it is supposed to work in version 5.1.this

The MySQL replication feature allows a server - the master - to send all changes to another server - the slave - and the slave tries to apply all changes to keep up-to-date with the master. Replication works as follows:spa

  • Whenever the master's database is modified, the change is written to a file, the so-called binary log, or binlog. This is done by the client thread that executed the query that modified the database..net

  • The master has a thread, called the dump thread, that continuously reads the master's binlog and sends it to the slave.線程

  • The slave has a thread, called the IO thread, that receives the binlog that the master's dump thread sent, and writes it to a file: the relay log.

  • The slave has another thread, called the SQL thread, that continuously reads the relay log and applies the changes to the slave server.


 

19.1 層次結構 

19.2 源代碼文件

19.3 原理     

19.4 規則     

本節狀態:最新2009-10-21

本章介紹了MySQL複製的原則,規則和代碼。它應該用在5.1版本上。

MySQL的複製功能容許服務器- master -發送的全部更改到另外一臺服務器-的slave -和slave試圖以應用全部更新操做,以便跟上最新的master。複製的工做原理以下:

  • 每當master的數據庫修改,更改寫入到文件中,即所謂的二進制日誌binlog。這些內容是由客戶端線程執行數據庫查詢(這裏的查詢是統稱,實際上只會保留DML,select並不保存)的。

  • master上有一個線程,稱爲dump thread,即連續讀取主的二進制日誌,並將其發送到slave。

  • slave有一個線程,稱爲IO線程(IO thread),接收了master的dump thread發送的二進制日誌,並將其寫入文件:在 中繼日誌(relay log)

  • slave上有另外一個線程,稱爲 SQL線程(SQL thread),即連續讀取中繼日誌並應用更改到slave的數據庫上。

相關文章
相關標籤/搜索