Alta Disponibilidade
no MySQL 5.7
Airton Lastori
airton.lastori@oracle.com
Abril-2016
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
DBA Dev Gerencial
Quem?
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Não usa MySQL
Usa MySQL sem
HA
Usa MySQL com
HA
Quem?
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Agenda
1. Alta disponibilidade (HA) – conceitos básicos
2. Arquiteturas e topologias de HA para MySQL
3. Monitoramento e gerenciamento
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Alta disponibilidade
Conceitos básicos
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 6
O chefe
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 7
O Desenvolvedor
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 8
O DBA
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
“Precisamos garantir que a nossa
aplicação não pare nunca!
Nosso cliente não pode esperar.
Perderemos dinheiro e nossa marca
ficará prejudicada.”
Oracle Confidential – Internal/Restricted/Highly Restricted 9
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
“Vamos comprar um NoBreak para o
Servidor e está tudo certo!”
Oracle Confidential – Internal/Restricted/Highly Restricted 10
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
...
Oracle Confidential – Internal/Restricted/Highly Restricted 11
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
“Quanto % do tempo o sistema deve
ficar no ar?”
Oracle Confidential – Internal/Restricted/Highly Restricted 12
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
“100%, é claro!”
Oracle Confidential – Internal/Restricted/Highly Restricted 13
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
“Desculpe desapontá-lo, mas disponibilidade
infinita não existe.
Pense em serviços como abastecimento de
água ou energia elétrica...
Há necessidade de ter redundância e
contingência dos equipamentos e
processos+ferramentas para a operação”
Oracle Confidential – Internal/Restricted/Highly Restricted 14
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
“Chefe, na verdade precisamos de mais
1 servidor para aplicação. É só instalar
uma cópia da aplicação nele e estamos
bem. Teremos nosso Cluster!”
Oracle Confidential – Internal/Restricted/Highly Restricted 15
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
“Na camada de banco não é tão simples
assim...”
Oracle Confidential – Internal/Restricted/Highly Restricted 16
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 17
Xiii... Lá vem esse
cara complicar...
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Standalone Clusterizado
Oracle Confidential – Internal/Restricted/Highly Restricted 18
Problemas diferentes
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
mysql.com/why-mysql/white-papers/mysql_wp_ha_strategy_guide.php
Escolhendo a melhor solução para sua necessidade
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Etapas típicas de um projeto de HA
1. Definir qual o tempo máximo de indisponibilidade e perdas aceitáveis
2. Revisar todos intens da infra-estrutura atual que terão contingência
(mapear SPoF)
3. Definir a melhor arquitetura e topologia de HA para este contexto
4. Implantar a redundância dos componentes
5. Implantar monitoramento (instrumentação)
6. Implantar procedimentos operacionais para contingência
Oracle Confidential – Internal/Restricted/Highly Restricted 20
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Etapas típicas de um projeto de HA
1. Definir qual o tempo máximo aceitável de uma indisponibilidade
2. Revisar todos intens da infra-estrutura atual que terão contingência
(mapear SPoF)
3. Definir a melhor arquitetura e topologia de HA para este contexto
4. Implantar a redundância dos componentes
5. Implantar monitoramento (instrumentação)
6. Implantar procedimentos operacionais para contingência
Oracle Confidential – Internal/Restricted/Highly Restricted 21
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Arquiteturas e topologias
opções de HA para MySQL 5.7
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Não é tão simples assim…
Camadas de alta disponibilidade
Access to Data
Data Redundancy
App Servers
Routing
16/04/2016 Copyright 2015, Oracle and/or its affiliates. All rights reserved 24
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |16/04/2016 Copyright 2015, Oracle and/or its affiliates. All rights reserved 25
Camadas de alta disponibilidade
Access to Data
Data Redundancy
App Servers
Routing
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |16/04/2016 Copyright 2015, Oracle and/or its affiliates. All rights reserved 26
Camadas de alta disponibilidade
Access to Data
Data Redundancy
App Servers
Routing
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |16/04/2016 Copyright 2015, Oracle and/or its affiliates. All rights reserved 27
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
• Oracle Clusterware unifies servers
in a server farm to form a cluster
– At the core of Oracle RAC
• Oracle Cluster 12c includes MySQL
Server 5.6 agent
• Planned migration and failover of
MySQL database
– Hidden from the application
16/04/2016
MySQL on Oracle Clusterware
28Copyright 2015, Oracle and/or its affiliates. All rights reserved
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Aplicação
Replicação MySQL
Master Slave
Escritas & Leituras
Exemplos de uso:
backup
contingência
distribuição geográfica
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Replicação em 5 minutos
Monte seu lab e comece a brincar
• [blog post]
http://www.alastori.com.br/2015/02/tuto
rial-replicacao-mysql-em-5-minutos.html
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Exemplo depois de configurado server-id e log-bin na instância master e restaurado um backup no slave
master> CREATE USER repl_user@%;
master> GRANT REPLICATION SLAVE ON *.* TO repl_user@% IDENTIFIED BY
'repl_user_password';
master> SHOW MASTER STATUS G
*************************** 1. row ***************************
File: master-bin.000003
Position: 433
slave> CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=3310,
MASTER_USER='repl_user', MASTER_PASSWORD='repl_user_password',
MASTER_LOG_FILE='master-bin.000003', MASTER_LOG_POS=433;
slave> START SLAVE;
Oracle Confidential – Internal/Restricted/Highly Restricted 31
www.alastori.com.br/2015/02/tutorial-replicacao-mysql-em-5-minutos.html
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Aplicação
Replicação MySQL
Master Slave
Escritas & Leituras Leituras
Exemplos de uso:
dividir carga OLTP e OLAP
dado mais próximo do cliente
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Aplicação
Replicação: Escalabilidade de Leituras
Master Slave
Escritas & Leituras Leituras
Slave Slave
Leituras Leituras
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Grandes usuários MySQL usam a replicação
34
Web, Cloud, Distribuído e Embarcado…
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
MySQL 5.7: Replicação
• Maior throughput 8-10x
– Gargalo eliminado com 8 threads paralelas
• Replicação sem perda Semi-sync
– Melhor performance no master para Semi-
synchronous Replication
• Diagnóstico e monitoramento via
Performance Schema
• Mais operações online
– GTID deploy
– Filtros dinâmicos de replicação
Melhor Performance, Usabilidade e Disponibilidade
0%
50%
100%
150%
200%
250%
1 8 24 48
Slave Threads
Slave throughput vs. 96 Thread Master
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Slave
Database
• Session thread: processes queries from the
application – writes data to master database &
associated events to binary log
• Dump thread: reads events from binary log and
sends them to a slave
• I/O thread: receives replication events and
stores them in slave’s relay log
• SQL thread: reads replication events from
slave’s relay log and applies them to slave
database
MySQL Replication Workflow
Session
Binary
Log
Master
Database
Dump I/O
Relay
Log
SQL
16/04/2016 36Copyright 2015, Oracle and/or its affiliates. All rights reserved
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
• Asynchronous
– MySQL Default
– In parallel: Master acks
to app and sends
transaction to slave
• Fast
• Risk of lost changes if
master dies
• Semi-Synchronous
– MySQL 5.5+ - Enhanced
in MySQL 5.7
– Serially: Master waits
for change to be
received by slave then
In parallel ack to app
and apply changes on
slave
• Intermediate latency
• Lossless (MySQL 5.7)
• Synchronous
– Only available with
MySQL Cluster
– Serially: Master waits
for change to be
applied on all slaves
before ack to app
• Higher latency
• If Active/Active, best
suited to small
transactions
• Lossless
Asynchronous vs. Synchronous Replication
16/04/2016 Copyright 2015, Oracle and/or its affiliates. All rights reserved 37
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 38
Replicação Multi-Source: mais flexibilidade nas topologias
Binlog
Master 1
Binlog
Master 2
…
…
Binlog
Master N
IO 1
Relay 1
Coordinator
W1 W2 … WX
IO 2
Relay 2
Coordinator
W1 W2 … WX
…
…
Coordinator
W1 W2 … WX
IO N
Relay N
Coordinator
W1 W2 … WX
Slave
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 39
Group Replication: multi-master Ativo-Ativo
Router
App
Virtually Synchronous Replication
App App
labs.mysql.com
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |16/04/2016 Copyright 2015, Oracle and/or its affiliates. All rights reserved 40
Camadas de alta disponibilidade
Access to Data
Data Redundancy
App Servers
Routing
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 41
MySQL Cluster: Escalabilidade de Escritas
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |16/04/2016 Copyright 2015, Oracle and/or its affiliates. All rights reserved 42
Camadas de alta disponibilidade
Access to Data
Data Redundancy
App Servers
Routing
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
MySQL HA Routing Components
• MySQL Router
– Lightweight middleware
– Connection-based routing
– First-available or load balancing
• MySQL Connectors
– Built-in Failover/Load Balancing
• MySQL Utilities
– mysqlreplfailover – monitors replication, promotes new master and redirects slaves
– MySQL Fabric – provides topology metadata to connector or router (which slave
current master)
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Roadmap (HA + Sharding)
Global Data Shard 1 Shard 2
MySQL Fabric
(Orchestration)
SQL Queries
Server/Shard State &
Mapping
Global Group HA Group
Coordination
and Control
HA Group
Group Replication
cluster
44
Group Replication
cluster
Group Replication
cluster
MySQL
Router
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Resumo das opções
Replication
Shared Disk
Virtualization
Group Replication
Cluster Carrier
Grade Edition
Failover Speed Medium Low High High
Write Scaling None None Low High
Read Scaling High None High High
Ease of Migration From
Stand-alone InnoDB to HA
Medium High High Low
Possibility of Transaction
Loss During Failure
Config. Low Config. Low
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Monitoramento e Gerenciamento
ambientes de HA bem administrados
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 47
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 48
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 49
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 50
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 51
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Menor tempo em backups e restores, menos downtime
MySQL Enterprise Backup
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
MySQL Utilities
• Binary Log Operations
• Database Operations
• General Operations
• Server Operations
• Specialized Operations
• High Availability Operations
– How Can I Use Replication?
– How Do I Add New Servers to My
Topology and Change Master Role
– Setup Automatic Failover
– Restore the Previous Master After
Failover
– How Can I Find All of the Slaves Attached
to My Master Server?
– How To Check If Data Is Correctly
Replicated?
– How To Fix Errant Transactions on the
Replication Topology?
Oracle Confidential – Internal/Restricted/Highly Restricted 54
dev.mysql.com/doc/mysql-utilities/1.6/en/mysql-utils-ha.html
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
MySQL Utilities
• Binary Log Operations
• Database Operations
• General Operations
• Server Operations
• Specialized Operations
• High Availability Operations
– How Can I Use Replication?
– How Do I Add New Servers to My
Topology and Change Master Role
– Setup Automatic Failover
– Restore the Previous Master After
Failover
– How Can I Find All of the Slaves Attached
to My Master Server?
– How To Check If Data Is Correctly
Replicated?
– How To Fix Errant Transactions on the
Replication Topology?
Oracle Confidential – Internal/Restricted/Highly Restricted 55
dev.mysql.com/doc/mysql-utilities/1.6/en/mysql-utils-ha.html
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
MySQL Utilities – Exemplo
shell> mysqlrpladmin --master=root@server2:3312 
--slaves=root@server2:3313,root@server4:3314,root@server5:3315 
--rpl-user=rpl:rpl --new-master=root@server1:3311 --demote-master
switchover
# Checking privileges.
# Performing switchover from master at server2:3312 to slave at server1:3311.
# Checking candidate slave prerequisites.
# Checking slaves configuration to master.
# Waiting for slaves to catch up to old master.
# Stopping slaves.
# Performing STOP on all slaves.
...
Oracle Confidential – Internal/Restricted/Highly Restricted 56
dev.mysql.com/doc/mysql-utilities/1.6/en/mysql-utils-ha.html
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
MySQL Utilities – Exemplo
shell> mysqlreplicate --master=root@server2:3312 --
slave=root@server1:3311 -rpl-user=rpl:rpl
# master on localhost: ... connected.
# slave on localhost: ... connected.
# Checking for binary logging on master...
# Setting up replication...
# ...done.
Oracle Confidential – Internal/Restricted/Highly Restricted 57
dev.mysql.com/doc/mysql-utilities/1.6/en/mysql-utils-ha.html
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
MySQL Utilities – Exemplo
...
# Switchover complete.
# Replication Topology Health:
+----------+-------+---------+--------+------------+---------+
| host | port | role | state | gtid_mode | health |
+----------+-------+---------+--------+------------+---------+
| server1 | 3311 | MASTER | UP | ON | OK |
| server2 | 3312 | SLAVE | UP | ON | OK |
| server3 | 3313 | SLAVE | UP | ON | OK |
| server4 | 3314 | SLAVE | UP | ON | OK |
| server5 | 3315 | SLAVE | UP | ON | OK |
+----------+-------+---------+--------+------------+---------+
Oracle Confidential – Internal/Restricted/Highly Restricted 58
dev.mysql.com/doc/mysql-utilities/1.6/en/mysql-utils-ha.html
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
MySQL Enterprise Edition
Suporte + Backup + Monitor + Workbench + Plug-ins
Escalabilidade
Autenticação
Firewall
Auditoria
(novo) TDE
Criptografia
Oracle Enterprise Manager
for MySQL
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 60
Como alguns DBAs vêem o MySQL
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 61
...como ele realmente é...
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 62
...MySQL Enterprise Edition
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Sumário
1. HA não é simples nem de graça
2. O MySQL possui diversas opções para HA
3. Entenda os requisitos, compare as possíveis arquiteturas
e topologias, faça a melhor escolha!
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
@MySQLBR meetup.com/MySQL-BRfacebook.com/MySQLBR
pt.planet.mysql.com
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Obrigado!
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Perguntas?
Alta Disponibilidade no MySQL 5.7
Contato:
airton.lastori@oracle.com
twitter.com/mysqlbr
facebook.com/mysqlbr

Alta Disponibilidade no MySQL 5.7

  • 1.
    Alta Disponibilidade no MySQL5.7 Airton Lastori airton.lastori@oracle.com Abril-2016
  • 2.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | DBA Dev Gerencial Quem?
  • 3.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Não usa MySQL Usa MySQL sem HA Usa MySQL com HA Quem?
  • 4.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Agenda 1. Alta disponibilidade (HA) – conceitos básicos 2. Arquiteturas e topologias de HA para MySQL 3. Monitoramento e gerenciamento
  • 5.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Alta disponibilidade Conceitos básicos
  • 6.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 6 O chefe
  • 7.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 7 O Desenvolvedor
  • 8.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 8 O DBA
  • 9.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | “Precisamos garantir que a nossa aplicação não pare nunca! Nosso cliente não pode esperar. Perderemos dinheiro e nossa marca ficará prejudicada.” Oracle Confidential – Internal/Restricted/Highly Restricted 9
  • 10.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | “Vamos comprar um NoBreak para o Servidor e está tudo certo!” Oracle Confidential – Internal/Restricted/Highly Restricted 10
  • 11.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | ... Oracle Confidential – Internal/Restricted/Highly Restricted 11
  • 12.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | “Quanto % do tempo o sistema deve ficar no ar?” Oracle Confidential – Internal/Restricted/Highly Restricted 12
  • 13.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | “100%, é claro!” Oracle Confidential – Internal/Restricted/Highly Restricted 13
  • 14.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | “Desculpe desapontá-lo, mas disponibilidade infinita não existe. Pense em serviços como abastecimento de água ou energia elétrica... Há necessidade de ter redundância e contingência dos equipamentos e processos+ferramentas para a operação” Oracle Confidential – Internal/Restricted/Highly Restricted 14
  • 15.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | “Chefe, na verdade precisamos de mais 1 servidor para aplicação. É só instalar uma cópia da aplicação nele e estamos bem. Teremos nosso Cluster!” Oracle Confidential – Internal/Restricted/Highly Restricted 15
  • 16.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | “Na camada de banco não é tão simples assim...” Oracle Confidential – Internal/Restricted/Highly Restricted 16
  • 17.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 17 Xiii... Lá vem esse cara complicar...
  • 18.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Standalone Clusterizado Oracle Confidential – Internal/Restricted/Highly Restricted 18 Problemas diferentes
  • 19.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | mysql.com/why-mysql/white-papers/mysql_wp_ha_strategy_guide.php Escolhendo a melhor solução para sua necessidade
  • 20.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Etapas típicas de um projeto de HA 1. Definir qual o tempo máximo de indisponibilidade e perdas aceitáveis 2. Revisar todos intens da infra-estrutura atual que terão contingência (mapear SPoF) 3. Definir a melhor arquitetura e topologia de HA para este contexto 4. Implantar a redundância dos componentes 5. Implantar monitoramento (instrumentação) 6. Implantar procedimentos operacionais para contingência Oracle Confidential – Internal/Restricted/Highly Restricted 20
  • 21.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Etapas típicas de um projeto de HA 1. Definir qual o tempo máximo aceitável de uma indisponibilidade 2. Revisar todos intens da infra-estrutura atual que terão contingência (mapear SPoF) 3. Definir a melhor arquitetura e topologia de HA para este contexto 4. Implantar a redundância dos componentes 5. Implantar monitoramento (instrumentação) 6. Implantar procedimentos operacionais para contingência Oracle Confidential – Internal/Restricted/Highly Restricted 21
  • 22.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Arquiteturas e topologias opções de HA para MySQL 5.7
  • 23.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Não é tão simples assim… Camadas de alta disponibilidade Access to Data Data Redundancy App Servers Routing 16/04/2016 Copyright 2015, Oracle and/or its affiliates. All rights reserved 24
  • 24.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. |16/04/2016 Copyright 2015, Oracle and/or its affiliates. All rights reserved 25 Camadas de alta disponibilidade Access to Data Data Redundancy App Servers Routing
  • 25.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. |16/04/2016 Copyright 2015, Oracle and/or its affiliates. All rights reserved 26 Camadas de alta disponibilidade Access to Data Data Redundancy App Servers Routing
  • 26.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. |16/04/2016 Copyright 2015, Oracle and/or its affiliates. All rights reserved 27
  • 27.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | • Oracle Clusterware unifies servers in a server farm to form a cluster – At the core of Oracle RAC • Oracle Cluster 12c includes MySQL Server 5.6 agent • Planned migration and failover of MySQL database – Hidden from the application 16/04/2016 MySQL on Oracle Clusterware 28Copyright 2015, Oracle and/or its affiliates. All rights reserved
  • 28.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Aplicação Replicação MySQL Master Slave Escritas & Leituras Exemplos de uso: backup contingência distribuição geográfica
  • 29.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Replicação em 5 minutos Monte seu lab e comece a brincar • [blog post] http://www.alastori.com.br/2015/02/tuto rial-replicacao-mysql-em-5-minutos.html
  • 30.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Exemplo depois de configurado server-id e log-bin na instância master e restaurado um backup no slave master> CREATE USER repl_user@%; master> GRANT REPLICATION SLAVE ON *.* TO repl_user@% IDENTIFIED BY 'repl_user_password'; master> SHOW MASTER STATUS G *************************** 1. row *************************** File: master-bin.000003 Position: 433 slave> CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=3310, MASTER_USER='repl_user', MASTER_PASSWORD='repl_user_password', MASTER_LOG_FILE='master-bin.000003', MASTER_LOG_POS=433; slave> START SLAVE; Oracle Confidential – Internal/Restricted/Highly Restricted 31 www.alastori.com.br/2015/02/tutorial-replicacao-mysql-em-5-minutos.html
  • 31.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Aplicação Replicação MySQL Master Slave Escritas & Leituras Leituras Exemplos de uso: dividir carga OLTP e OLAP dado mais próximo do cliente
  • 32.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Aplicação Replicação: Escalabilidade de Leituras Master Slave Escritas & Leituras Leituras Slave Slave Leituras Leituras
  • 33.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Grandes usuários MySQL usam a replicação 34 Web, Cloud, Distribuído e Embarcado…
  • 34.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | MySQL 5.7: Replicação • Maior throughput 8-10x – Gargalo eliminado com 8 threads paralelas • Replicação sem perda Semi-sync – Melhor performance no master para Semi- synchronous Replication • Diagnóstico e monitoramento via Performance Schema • Mais operações online – GTID deploy – Filtros dinâmicos de replicação Melhor Performance, Usabilidade e Disponibilidade 0% 50% 100% 150% 200% 250% 1 8 24 48 Slave Threads Slave throughput vs. 96 Thread Master
  • 35.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Slave Database • Session thread: processes queries from the application – writes data to master database & associated events to binary log • Dump thread: reads events from binary log and sends them to a slave • I/O thread: receives replication events and stores them in slave’s relay log • SQL thread: reads replication events from slave’s relay log and applies them to slave database MySQL Replication Workflow Session Binary Log Master Database Dump I/O Relay Log SQL 16/04/2016 36Copyright 2015, Oracle and/or its affiliates. All rights reserved
  • 36.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | • Asynchronous – MySQL Default – In parallel: Master acks to app and sends transaction to slave • Fast • Risk of lost changes if master dies • Semi-Synchronous – MySQL 5.5+ - Enhanced in MySQL 5.7 – Serially: Master waits for change to be received by slave then In parallel ack to app and apply changes on slave • Intermediate latency • Lossless (MySQL 5.7) • Synchronous – Only available with MySQL Cluster – Serially: Master waits for change to be applied on all slaves before ack to app • Higher latency • If Active/Active, best suited to small transactions • Lossless Asynchronous vs. Synchronous Replication 16/04/2016 Copyright 2015, Oracle and/or its affiliates. All rights reserved 37
  • 37.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 38 Replicação Multi-Source: mais flexibilidade nas topologias Binlog Master 1 Binlog Master 2 … … Binlog Master N IO 1 Relay 1 Coordinator W1 W2 … WX IO 2 Relay 2 Coordinator W1 W2 … WX … … Coordinator W1 W2 … WX IO N Relay N Coordinator W1 W2 … WX Slave
  • 38.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 39 Group Replication: multi-master Ativo-Ativo Router App Virtually Synchronous Replication App App labs.mysql.com
  • 39.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. |16/04/2016 Copyright 2015, Oracle and/or its affiliates. All rights reserved 40 Camadas de alta disponibilidade Access to Data Data Redundancy App Servers Routing
  • 40.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 41 MySQL Cluster: Escalabilidade de Escritas
  • 41.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. |16/04/2016 Copyright 2015, Oracle and/or its affiliates. All rights reserved 42 Camadas de alta disponibilidade Access to Data Data Redundancy App Servers Routing
  • 42.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | MySQL HA Routing Components • MySQL Router – Lightweight middleware – Connection-based routing – First-available or load balancing • MySQL Connectors – Built-in Failover/Load Balancing • MySQL Utilities – mysqlreplfailover – monitors replication, promotes new master and redirects slaves – MySQL Fabric – provides topology metadata to connector or router (which slave current master)
  • 43.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Roadmap (HA + Sharding) Global Data Shard 1 Shard 2 MySQL Fabric (Orchestration) SQL Queries Server/Shard State & Mapping Global Group HA Group Coordination and Control HA Group Group Replication cluster 44 Group Replication cluster Group Replication cluster MySQL Router
  • 44.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Resumo das opções Replication Shared Disk Virtualization Group Replication Cluster Carrier Grade Edition Failover Speed Medium Low High High Write Scaling None None Low High Read Scaling High None High High Ease of Migration From Stand-alone InnoDB to HA Medium High High Low Possibility of Transaction Loss During Failure Config. Low Config. Low
  • 45.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Monitoramento e Gerenciamento ambientes de HA bem administrados
  • 46.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 47
  • 47.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 48
  • 48.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 49
  • 49.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 50
  • 50.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 51
  • 51.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. |
  • 52.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Menor tempo em backups e restores, menos downtime MySQL Enterprise Backup
  • 53.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | MySQL Utilities • Binary Log Operations • Database Operations • General Operations • Server Operations • Specialized Operations • High Availability Operations – How Can I Use Replication? – How Do I Add New Servers to My Topology and Change Master Role – Setup Automatic Failover – Restore the Previous Master After Failover – How Can I Find All of the Slaves Attached to My Master Server? – How To Check If Data Is Correctly Replicated? – How To Fix Errant Transactions on the Replication Topology? Oracle Confidential – Internal/Restricted/Highly Restricted 54 dev.mysql.com/doc/mysql-utilities/1.6/en/mysql-utils-ha.html
  • 54.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | MySQL Utilities • Binary Log Operations • Database Operations • General Operations • Server Operations • Specialized Operations • High Availability Operations – How Can I Use Replication? – How Do I Add New Servers to My Topology and Change Master Role – Setup Automatic Failover – Restore the Previous Master After Failover – How Can I Find All of the Slaves Attached to My Master Server? – How To Check If Data Is Correctly Replicated? – How To Fix Errant Transactions on the Replication Topology? Oracle Confidential – Internal/Restricted/Highly Restricted 55 dev.mysql.com/doc/mysql-utilities/1.6/en/mysql-utils-ha.html
  • 55.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | MySQL Utilities – Exemplo shell> mysqlrpladmin --master=root@server2:3312 --slaves=root@server2:3313,root@server4:3314,root@server5:3315 --rpl-user=rpl:rpl --new-master=root@server1:3311 --demote-master switchover # Checking privileges. # Performing switchover from master at server2:3312 to slave at server1:3311. # Checking candidate slave prerequisites. # Checking slaves configuration to master. # Waiting for slaves to catch up to old master. # Stopping slaves. # Performing STOP on all slaves. ... Oracle Confidential – Internal/Restricted/Highly Restricted 56 dev.mysql.com/doc/mysql-utilities/1.6/en/mysql-utils-ha.html
  • 56.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | MySQL Utilities – Exemplo shell> mysqlreplicate --master=root@server2:3312 -- slave=root@server1:3311 -rpl-user=rpl:rpl # master on localhost: ... connected. # slave on localhost: ... connected. # Checking for binary logging on master... # Setting up replication... # ...done. Oracle Confidential – Internal/Restricted/Highly Restricted 57 dev.mysql.com/doc/mysql-utilities/1.6/en/mysql-utils-ha.html
  • 57.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | MySQL Utilities – Exemplo ... # Switchover complete. # Replication Topology Health: +----------+-------+---------+--------+------------+---------+ | host | port | role | state | gtid_mode | health | +----------+-------+---------+--------+------------+---------+ | server1 | 3311 | MASTER | UP | ON | OK | | server2 | 3312 | SLAVE | UP | ON | OK | | server3 | 3313 | SLAVE | UP | ON | OK | | server4 | 3314 | SLAVE | UP | ON | OK | | server5 | 3315 | SLAVE | UP | ON | OK | +----------+-------+---------+--------+------------+---------+ Oracle Confidential – Internal/Restricted/Highly Restricted 58 dev.mysql.com/doc/mysql-utilities/1.6/en/mysql-utils-ha.html
  • 58.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | MySQL Enterprise Edition Suporte + Backup + Monitor + Workbench + Plug-ins Escalabilidade Autenticação Firewall Auditoria (novo) TDE Criptografia Oracle Enterprise Manager for MySQL
  • 59.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 60 Como alguns DBAs vêem o MySQL
  • 60.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 61 ...como ele realmente é...
  • 61.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 62 ...MySQL Enterprise Edition
  • 62.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Sumário 1. HA não é simples nem de graça 2. O MySQL possui diversas opções para HA 3. Entenda os requisitos, compare as possíveis arquiteturas e topologias, faça a melhor escolha!
  • 63.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | @MySQLBR meetup.com/MySQL-BRfacebook.com/MySQLBR pt.planet.mysql.com
  • 64.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Obrigado! Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
  • 65.
    Copyright © 2015Oracle and/or its affiliates. All rights reserved. | Perguntas? Alta Disponibilidade no MySQL 5.7 Contato: airton.lastori@oracle.com twitter.com/mysqlbr facebook.com/mysqlbr