Spec-Zone.ru › MySQL 5.7

17.1.1.1 Репликация первичный-вторичный

Традиционная репликация MySQL предоставляет простой подход первичный-вторичный для репликации. Существует первичный (источник) и один или несколько вторичных (реплик). Первичный выполняет транзакции, подтверждает их, а затем они позже (поэтому асинхронно) отправляются вторичным, чтобы быть повторно выполненными (в репликации на основе операторов) или применёнными (в репликации на основе строк). Это система «shared-nothing», где все серверы по умолчанию имеют полную копию данных.

Рисунок 17.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.

Также существует полусинхронная репликация, которая добавляет один шаг синхронизации к протоколу. Это означает, что первичный ожидает, в момент подтверждения, что вторичный подтвердил, что он получил транзакцию. Только тогда первичный возобновляет операцию подтверждения.

Рисунок 17.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 acknowlegement, 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 (а также его полусинхронной версии). Стрелки между различными экземплярами представляют сообщения, обменивающиеся между серверами или сообщения, обменивающиеся между серверами и клиентским приложением.

© 2025 Oracle
Licensed under the GPLv2 License.
https://docs.oracle.com/cd/E17952_01/mysql-5.7-en/group-replication-primary-secondary-replication.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API