文件首頁
MySQL 9.0 參考手冊
相關文件 下載本手冊
PDF (美式信紙) - 40.0Mb
PDF (A4) - 40.1Mb
Man Pages (TGZ) - 258.2Kb
Man Pages (Zip) - 365.3Kb
Info (Gzip) - 4.0Mb
Info (Zip) - 4.0Mb


MySQL 9.0 參考手冊  /  ...  /  來源到副本的複製

20.1.1.1 來源到副本的複製

傳統的 MySQL 複製 提供簡單的來源到副本的複製方法。來源是主要節點,而且有一個或多個副本,它們是次要節點。來源會套用交易、提交它們,然後稍後(因此是非同步)將它們傳送至副本,以重新執行(在以陳述式為基礎的複製中)或套用(在以列為基礎的複製中)。它是共享式系統,其中預設情況下所有伺服器都有資料的完整副本。

圖 20.1 MySQL 非同步複製

A transaction received by the source is executed, written to the binary log, then committed, and a response is sent to the client application. The record from the binary log is sent to the relay logs on Replica 1 and Replica 2 before the commit takes place on the source. On each of the replicas, the transaction is applied, written to the replica's binary log, and committed. The commit on the source and the commits on the replicas are all independent and asynchronous.

也有半同步複製,它會在協定中新增一個同步步驟。這表示主要節點會在套用時等待次要節點確認它已收到交易。只有這樣,主要節點才會繼續提交作業。

圖 20.2 MySQL 半同步複製

A transaction received by the source is executed and written to the binary log. The record from the binary log is sent to the relay logs on Replica 1 and Replica 2. The source then waits for an acknowledgement from the replicas. When both of the replicas have returned the acknowledgement, the source commits the transaction, and a response is sent to the client application. After each replica has returned its acknowledgement, it applies the transaction, writes it to the binary log, and commits it. The commit on the source depends on the acknowledgement from the replicas, but the commits on the replicas are independent from each other and from the commit on the source.

在這兩張圖片中,有經典非同步 MySQL 複製協定(及其半同步變體)的圖表。不同執行個體之間的箭頭代表伺服器之間交換的訊息或伺服器與用戶端應用程式之間交換的訊息。