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


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

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 複製協定(及其半同步變體)的圖表。不同執行個體之間的箭頭表示伺服器之間交換的訊息,或伺服器與用戶端應用程式之間交換的訊息。