Top Banner
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Для чего нужен и как работает MySQL Group Replication? Игорь Ильин MySQL Support
67

Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Jul 30, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved.

Для чего нужен и как работает MySQL Group Replication?

Игорь ИльинMySQL Support

Page 2: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Safe Harbor StatementThe following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

2

Page 3: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Типы репликации1

Page 4: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Репликация баз данных

ServerB

ServerA

AppINSERT ...

INSERT ... INSERT ...

Репликация“Процесс генерации нескольких копий данных в различных местах”Database Systems: A Practical Approach to Design, Implementation, and Management, Thomas M. Connolly, Carolyn E. Begg, Third Edition, 2002.

4

Page 5: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Репликация в MySQL

INSERT ...Server

B

binary log

INSERT ...

relay log

INSERT ...Server

A

binary log

App

ReceiverMeta-data

Update

ApplierMeta-data

Update

INSERT ...

Comm. Framework

5

Page 6: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Типы репликации в MySQL

A B Since 3.23

A B

semi-synchronous (plugin)

A CB

group replication (plugin)

transactions

transactionsSince 5.5

Since 5.7.17

asynchronous (native)

transactions, membership, coordination

acks

Теперь и в MySQL 8 as of 8.0.1

6

Page 7: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

MySQL Group Replication

• Что такое MySQL Group Replication?“Плагин для репликации в MySQL, предоставляющий возможность изменения данных на любом из серверов, со встроенной системой автоматического восстановления и с разрешением конфликтов.”

• Что MySQL Group Replication делает для пользователя?– Убирает необходимость ручного переключения в случае отказа одного из серверов.– Предоставляет отказоустойчивость.– Позволяет построить систему с возможностью изменять данные на любом сервере.– Автоматическая реконфигурация.

7

Page 8: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

MySQL Group Replication

P P P P P

Replication Group

Clients

8

Page 9: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Примеры использования2

Page 10: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Примеры использования

• Elastic Replication– Окружение с часто изменяющимся количеством серверов репликаций и с

необходимостью максимально упростить процесс этих изменений.

P P P P P

10

Page 11: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Примеры использования

• Highly Available Shards– Шардинг является популярным способом масштабирования нагрузки по

изменению данных. MySQL Group Replication может быть использован для создания таких отказоустойчивых групп.

P P P P P P P P P P P P P P P

11

Page 12: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Примеры использования

• Альтернатива стандартной схеме репликации Master-Slave• Single-primary режим предоставляет дополнительные возможности:

– Автоматическое определение ролей PRIMARY/SECONDARY – Автоматический выбор нового Primary сервера в случае отказа предыдщего– Автоматическая настройка соответствующих режимов RO/RW

S S S S P S

Primary

12

Page 13: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Single-primary

Режимы работы3

3.1

Page 14: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Single-primary

• Режим в котором один сервер принимает запросы на изменения данных (PRIMARY), а остальные доступны для чтения, всегда содержат актуальные данные и при необходимости могут быть использованы для отказоустойчивости (SECONDARIES).– Группа сама выбирает Primary сервер с помощью специального механизма

выборов.

• Single-primary является режимом по умолчанию.– Ближе к стандартной асинхронной репликации.– Не имеет некоторых ограничений multi-primary режима.

14

Page 15: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Single-primary

• Автоматический выбор нового Primary сервера.• Secondary сервера автоматически переводятся в режим read-only.

S S S S P S

Primary

15

Page 16: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Single-primary

• Автоматический выбор нового Primary сервера.

S S S P S

Primary

16

Page 17: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Single-primary

• UUID текущего Primary сервера можно определить следующим запросом.

mysql> SELECT * FROM performance_schema.global_status WHERE VARIABLE_NAME='group_replication_primary_member';VARIABLE_NAME VARIABLE_VALUEgroup_replication_primary_member dcd3b36b-79c5-11e6-97b8-00212844d44e

17

Page 18: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Multi-primary

Single-primary

Режимы работы3

3.1

3.2

Page 19: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Multi-primary update everywhere!

• Режим в котором запись возможна на любом сервере– Включается изменением значения переменной

--group_replication_single_primary_mode=OFF

19

P P P P P

Page 20: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Multi-primary update everywhere!

• Любые транзакции могут изменять любые данные.• Конфликты будут обнаружены и разрешены.

– Первый запрос выигрывает.

P P P P P

UPDATE t1 SET a=4 WHERE a=2UPDATE t1 SET a=3 WHERE a=1

20

Page 21: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Multi-primary update everywhere!

• Любые транзакции могут изменять любые данные.• Конфликты будут обнаружены и разрешены. - Первый запрос выигрывает.

P P P P P

UPDATE t1 SET a=4 WHERE a=2UPDATE t1 SET a=3 WHERE a=1 OKOK

21

Page 22: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Multi-primary update everywhere!

Любые транзакции могут изменять любые данные. Конфликты будут обнаружены и разрешены. - Первый запрос выигрывает..

P P P P P

UPDATE t1 SET a=2 WHERE a=1UPDATE t1 SET a=3 WHERE a=1

22

Page 23: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Multi-primary update everywhere!

• Любые транзакции могут изменять любые данные.• Конфликты будут обнаружены и разрешены.

– Первый запрос выигрывает.

P P P P P

UPDATE t1 SET a=2 WHERE a=1UPDATE t1 SET a=3 WHERE a=1 OK

23

Page 24: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Автоматическое восстановление серверов

Features4

4.1

Page 25: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Автоматическое восстановление серверов

• Сервер, который присоединяется к группе, автоматически синхронизирует данные.

P P P P P N

Новый сервер

25

Page 26: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Автоматическое восстановление серверов

Сервер, который присоединяется к группе, автоматически синхронизирует данные.

P P P P P N

ONLINE RECOVERING

26

Page 27: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Автоматическое восстановление серверов

Сервер, который присоединяется к группе, автоматически синхронизирует данные.

P P P P P N

ONLINE

27

Page 28: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Автоматическое восстановление серверов

• Если сервер покидает группу, то все остальные серверы в группе будут об этом проинформированы.

P P P P P P

Этот сервер отключается на обслуживание

Каждая конфигурация серверовопределяется view_id

view_id: 4

28

Page 29: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Автоматическое восстановление серверов

• Если сервер покидает группу, то остальные сервера будут об этом автоматически проинформированы.

P P P P P

29

Page 30: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Автоматическое восстановление серверов

• Когда сервер снова возвращается в группу он автоматически сихронизируется с остальной группой.

P P P P P P

RECOVERING -> ONLINE

view_id: 5

30

Page 31: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Интеграция с MySQL

Автоматическое восстановление серверов

Features4

4.1

4.2

Page 32: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Интеграция с MySQL

• MySQL Plugin– Стандартный MySQL плагин.

• MySQL InnoDB– Работа с данными такая же как и всегда для InnoDB.– Оптимизация InnoDB для лучшей поддержки Group Replication.

• MySQL Performance Schema– Мониторинг Group Replication осуществляется с помощью таблиц в Performance

Schema.

32

Page 33: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Интеграция с MySQL

– Group Replication не использует внешних компонентов.– Для использования Group Replication требуются те же навыки, что и для работы

с самим MySQL Server.

33

Page 34: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Полная поддержка GTID

Интеграция с MySQL

Автоматическое восстановление серверов

Features4

4.1

4.2

4.3

Page 35: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Полная поддержка GTID

• У всех транзакций в группе одинаковый UUID соответствующий ID группы.

P P P P P

INSERT y;Will have GTID: group_name:2

INSERT x;Will have GTID: group_name:1

35

Page 36: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Полная поддержка GTID

• Возможна ручная настройка идентификаторов пользователем.

P P P P P

INSERT y;Will have GTID: group_name:1

SET GTID_NEXT= “UUID:50”INSERT x;

36

Page 37: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Полная поддержка GTID

• Есть возможность репликации от внешнего сервера к группе, GTID будут сохранены.

P P P P P

Конфликты будут обнаружены

37

Page 38: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Полная поддержка GTID

• Есть возможность репликации из группы к внешнему серверу.

P P P P P

38

Page 39: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Настройка auto-increment

Полная поддержка GTID

Интеграция с MySQL

Автоматическое восстановление серверов

Features4

4.1

4.2

4.3

4.4

Page 40: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Настройка auto-increment

• Группа настроена не генерировать одинаковые auto-increment значения.

P P P P P

INSERT y;y: 4

INSERT z;z: 11

INSERT x;x: 1

40

Page 41: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Настройка auto-increment

• По умолчанию сдвиг определяется по server_id и увеличивается на 7.

P P P P P

INSERT y;y: 4

INSERT z;z: 11

INSERT x;x: 1

server_id: 1server_id: 4

41

Page 42: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Auto-increment configuration/handling

• Пользователь может изменить сдвиг с помощью опции GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT.

P P P P P

INSERT y;y: 4

INSERT z;z: 11

INSERT x;x: 1

server_id: 1server_id: 4

42

Page 43: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Поддержка различных версий

Настройка auto-increment

Полная поддержка GTID

Интеграция с MySQL

Автоматическое востановление серверов

Features4

4.1

4.2

4.3

4.4

4.5

Page 44: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Поддержка различных версий

• При присоединении нового сервера, его версия важна для совместимости с группой.

5.7.13 5.7.13 5.7.14 5.7.15 5.7.12

Серверы с различными версиями из одной ветки могут присоединяться к группе

44

Page 45: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Поддержка различных версий

При присоединении нового сервера, его версия важна для совместимости с группой.

8.0.0 8.0.0 8.0.0 8.0.0 5.7.15

Сервер с меньшей версией главной веткиНЕ может присоединться к группе

45

Page 46: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Поддержка различных версий

При присоединении нового сервера, его версия важна для совместимости с группой.

5.7.14 5.7.14 5.7.15 5.7.15 8.0.0

Сервер с БОЛЬШЕЙ версией главной веткиМОЖЕТ присоединяться к группе

46

Page 47: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Встроенный communication engine

Поддержка различных версий

Настройка auto-increment

Полная поддержка GTID

Интеграция с MySQL

Automatic distributed server recovery

Features4

4.1

4.2

4.3

4.4

4.5

4.6

Page 48: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Встроенный Communication Engine

• Плагин основан на семействе протоколов Paxos.– Compression, multi-platform, dynamic membership, distributed agreement,

quorum based message passing, SSL, IP whitelisting.• Не требуются никакие third-party приложения.• Не требуются сети с поддержкой multicast.

– MySQL Group Replication может работать в облаке, где multicast не всегда поддерживается.

48

Page 49: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Режим read-only

Встроенный communication engine

Поддержка различных версий

Настройка auto-increment

Полная поддержка GTID

Интеграция с MySQL

Automatic distributed server recovery

Features4

4.1

4.2

4.3

4.4

4.5

4.6

4.7

Page 50: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Режим Read-only

• Когда новый сервер присоединяется к группе, на время процесса синхронизации данных автоматически устанавливается режим read-only.

• В случае ошибки на одном из серверов, он автоматически меняет статус на ERROR и переходит в режим read-only, чтобы приложение по ошибке не могло изменить данные и нарушить целостность данных.

P P P P P

50

Page 51: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Поддержка безопасных подключений

Features4

4.8

Page 52: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Поддержка безопасных подключений

• Group Replication поддерживает безопасные подключения:– Соединения для востановления– Соединения между различными серверами в группе– Соединения между клиентами и группой

• IP Whitelisting– Список IP адресов, с которых разрешено присоединяться к группе.– По умолчанию стоит значение AUTOMATIC, которое позволяет присоединяться

из private подсети соответствующей текущему хосту.

52

Page 53: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Поддержка Parallel applier

Поддержка безопасных подключений

Features4

4.8

4.9

Page 54: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Поддержка Parallel applier

• Значительно увеличивает производительность репликации.• Настройка аналогична асинхронной репликации.

--slave_parallel_workers=NUMBER--slave_parallel_type=logical_clock--slave_preserve_commit_order=ON

54

Page 55: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Поддержка Parallel applier

• Определение Transaction Dependencies на основе Write Set– Изначально используется в Group Replication– Ускоряет процесс востановления сервера

master> SET @@GLOBAL.binlog_transaction_dependency_tracking=WRITESET;Query OK, 0 rows affected (0,00 sec)

master> SET @@GLOBAL.binlog_transaction_dependency_tracking=WRITESET_SESSION;Query OK, 0 rows affected (0,00 sec)

master> SET @@GLOBAL.binlog_transaction_dependency_tracking=COMMIT_ORDER; -- defaultQuery OK, 0 rows affected (0,00 sec

55

Page 56: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Поддержка Transaction SAVEPOINT

Поддержка Parallel applier

Поддержка безопасных подключений

Features4

4.8

4.9

4.10

Page 57: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Поддержка Transaction SAVEPOINT

Row 1 Row 2 Row 3 Row 40

2

4

6

8

10

12

Column 1Column 2Column 3

mysql> BEGIN;Query OK, 0 rows affected (0,00 sec)

mysql> INSERT INTO t1 VALUES(1);Query OK, 1 row affected (0,00 sec)

mysql> SAVEPOINT S1;Query OK, 0 rows affected (0,00 sec)

mysql> INSERT INTO t1 VALUES(2);Query OK, 1 row affected (0,00 sec)

mysql> ROLLBACK TO S1;Query OK, 0 rows affected (0,00 sec)

mysql> COMMIT;Query OK, 0 rows affected (0,00 sec)

57

Page 58: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Требования

Поддержка Transaction SAVEPOINT

Поддержка Parallel applier

Поддержка безопасных подключений

Features4

4.8

4.9

4.10

4.11

Page 59: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Требования (by design)

• Требуется InnoDB storage engine• Нужен primary key в каждой таблице • Требуются GTIDs• Требуется бинарный лог• Требуется row format binlog-а• Optimistic execution: транзакция

может быть отменена в момент COMMIT-а из-за конфликта с другой транзакцией на других серверах группы

• До 9 серверов в группе

• Serializable (для multi-primary)• Cascading Foreign Keys (для multi-primary)• Binary log events checksum

Не поддерживается

• Одновременные DDL (для multi-primary)• SELECT *** FOR UPDATE не использует

group locking (для multi-primary)

Warnings

59

Page 60: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Производительность5

Page 61: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Производительность

More on this subject on the series of replication performance blogs at: http://mysqlhighavailability.com/category/performance/

Servers9 Dual Xeon E5-2660-v3Enterprise SSD Storage10Gbps Ethernet Network

Client1 Dual Xeon E5-2699-v310Gbps Ethernet NetworkSysbench 0.5 RW workload

Peak Throughput (i.e., no flow control)Количество записе, которые приложение может сделать (в секунду).

Sustained Throughput (i.e., flow control)

Количество транзакций, которое приложение может записать в группу без отставания серверов (в секунду).

61

Количество серверов в группе

Page 62: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Производительность

• Усреднённая пропускная способность:– Производительность в Multi-primary режиме плавно снижается с ростом количества

серверов в группе.– Производительность в Single-primary режиме падает минимально с ростом количества

серверов в группе.• Пиковая пропускная способность:

– Производительность в Multi-primary режиме может увеличивать до 1.8 раз в сравнении с одиночным сервером.• Нагрузка по чтению данных распределена между серверами.

– В single-primary режиме отставание на secondary серверах отсутствует.

62

Page 63: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Заключение

7

Page 64: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Заключение

• Cloud Friendly– Подходит для систем с часто изменяющимся составом серверов.

• Интегрирован– С ядром MySQL Server.– С GTID, row based replication, таблицами performance schema.

• Автономный и упрощенный в использовании– Самовостановление: не требуется вмешательство админа для переключения.– Предоставляет отказоустойчивость, позволяет построить “update anywhere”

систему.• GA версии плагина доступны в MySQL 5.7.17+ и в 8.0.1+

64

Page 65: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

MySQL InnoDB Cluster: The End Goal

S1 S2 S3 S4 S…

M

M M

MySQL ConnectorApplication

MySQL Router

MySQL ConnectorApplication

MySQL Router

MySQL Shell

HA

Repl

icaS

et 1

S1 S2 S3 S4 S…

M

M M

MySQL ConnectorApplication

MySQL Router

HA

Repl

icaS

et 2

Repl

icaS

et 3

MySQL ConnectorApplication

MySQL Router

S1 S2 S3 S4 S…

M

M M

HA

65

Page 66: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Дополнительные ссылки

• Доступно для скачивания:– http://www.mysql.com/downloads/

• Документация:– http://dev.mysql.com/doc/refman/5.7/en/group-replication.html– http://dev.mysql.com/doc/refman/8.0/en/group-replication.html

• Блоги разработчиков:– http://mysqlhighavailability.com

66

Page 67: Для чего нужен и как работает MySQL Group Replication? · Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication •

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |