SlideShare a Scribd company logo
MySQL para Desenvolvedores


Airton Lastori
airton.lastori@oracle.com



30-jan-2013
1   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
@MySQLBR                                                            facebook.com/MySQLBR

                                                                                                                                               MySQLBR
                                       meetup.com/MySQL-BR




2   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
3   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Alguns clientes MySQL




4   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Alguns clientes MySQL




                                                                   fonte: alexa.com/topsites 30-jan-2013
5   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Alguns clientes MySQL




                                                                                          mysql.com/customers
6   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Alguns clientes MySQL




                                                                                          mysql.com/customers
7   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Tipos de aplicação
             70%
             60%
             50%
             40%
             30%
             20%
             10%
                                                                                                                                               Enterprise
              0%
                                                                                                                                               Community




8   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Desafio de desenvolvedor #1




                          Quais são os requisitos não
                         funcionais da minha aplicação?



9   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Na escolha da solução, considerar...



                         Escalabilidade, performance, disponibilidade,
                       estabilidade, segurança, simplicidade, flexibilidade,
                      custo total de propriedade, conhecimento da equipe...


                                        Ah! Não esqueça da fase de produção, dos DBAs...
                                            ferramentas, suporte, rotinas de manutenção.

10   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
MySQL para desenvolvedores

                                                                                                                                                Conhecendo melhor o
                                                     Portfolio                                                                                  universo MySQL para
                                                                                                                                                fazer boas escolhas…


                                    Ambiente de
                                  desenvolvimento


                               Escalabilidade e
                              Alta-disponibilidade

11   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
MySQL para desenvolvedores

                                                                                                                                                Conhecendo melhor o
                                                     Portfolio                                                                                  universo MySQL para
                                                                                                                                                fazer boas escolhas…


                                    Ambiente de
                                  desenvolvimento


                               Escalabilidade e
                              Alta-disponibilidade

12   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Compromisso Oracle com MySQL Community
       Portfólio disponível para download e uso sob GPL


                                                                                                                    MySQL Database Community Server
                                                                                                                    MySQL Cluster
                                                                                                                    MySQL Workbench
                                                                                                                    MySQL Connectors
                                                                                                                    MySQL Proxy
                                                                                                                    Documentação não GPL
                                                                                                                    Forums, Lists, Bugs, Blogs…

13   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Conectores: amplo suporte a várias linguagens

                                                     Oracle                                                                                              Comunidade

              •      Connector/ODBC                                                                                                             •   PHP
              •      Connector/Net (ADO.NET)                                                                                                    •   Perl
              •      Connector/Python                                                                                                           •   Ruby
              •      Connector/J (JDBC)                                                                                                         •   TCL
              •      Connector/C (C API)                                                                                                        •   Eiffel
              •      Connector/C++ (C++ API)                                                                                                    •   …


                                   dev.mysql.com/doc/refman/5.5/en/connectors-apis.html

14   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
MySQL Enterprise Edition
       Maior produtividade e mitigação de riscos


                                                                                                      Oracle Premier
                                                                                                     Lifetime Support
                                                        MySQL Enterprise                                                             Oracle Product
                                                           Security                                                            Certifications/Integrations

                               MySQL Enterprise                                                                                                   MySQL Enterprise
                                   Audit                                                                                                        Monitor/Query Analyzer

                  MySQL Enterprise                                                                                                                       MySQL Enterprise
                     Scalability                                                                                                                             Backup

               MySQL Enterprise
                                                                                                                                                           MySQL Workbench
               High Availability

15   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
MySQL para desenvolvedores

                                                                                                                                                Conhecendo melhor o
                                                     Portfolio                                                                                  universo MySQL para
                                                                                                                                                fazer boas escolhas…


                                    Ambiente de
                                  desenvolvimento


                               Escalabilidade e
                              Alta-disponibilidade

16   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Desafio de desenvolvedor #2




                      Instalação básica, ambiente de
                             desenvolvimento…

                                                                              ...em 15 minutos, ou menos!


17   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
18   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
No Linux ou Mac, prefira os binários




                                                                       mysql.com/downloads/mysql

19   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Cliente-Servidor



                                                                                                                       Client
                                                                                                            mysql / mysql.exe


                                                                                                                     Server
                                                                                                         mysqld / mysqld.exe




20   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Iniciar ou Parar o servidor MySQL no Windows




          …ou via MySQL Notifier




21   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Iniciar ou Parar o servidor MySQL no Linux

          Iniciar:
          /usr/local/mysql/bin> mysqld_safe --defaults-file=/etc/my.cnf &




          Parar:
          /usr/local/mysql/bin> mysqladmin shutdown




                                         dev.mysql.com/doc/refman/5.5/en/mysqld-safe.html

22   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Primeira conexão
          C:Program FilesMySQLMySQL Server 5.5bin>mysql -uroot -p
          Enter password: ****
          Welcome to the MySQL monitor.                                                    Commands end with ; or g.
          Your MySQL connection id is 8
          Server version: 5.5.28 MySQL Community Server (GPL)


          Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.


          Oracle is a registered trademark of Oracle Corporation and/or its
          affiliates. Other names may be trademarks of their respective
          owners.


          Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.


          mysql>



23   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Teste via MySQL Workbench 1/2




24   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Teste via MySQL Workbench 2/2




25   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Cliente-Servidor



                                                                                                     App + Connector
                                                            JDBC, ODBC, .Net, PHP, Python, Perl, Ruby, Native C API…


                                                                                                                         Server
                                                                                                            mysqld / mysqld.exe




26   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Desafio de desenvolvedor #3




                                                                            Hello World…


                                                                                                             ...em Java


27   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Adicione o driver MySQL ao CLASSPATH
           caminho completo do .jar




             Confira:
               C:>set CLASSPATH
               CLASSPATH=.;C:Program Files (x86)Javajre6libextQTJava.zip;C:Program
                 FilesMySQLmysql-connector-java-5.1.22mysql-connector-java-5.1.22-bin.jar




28   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
HelloMysql.java 1/2
              import java.sql.*;
              public class HelloMysql {
                 public static void main(String args[]){
                 System.out.println("Tentando conectar ao MySQL...");
                 try {
                        Class.forName("com.mysql.jdbc.Driver");
                        String url = "jdbc:mysql://localhost:3306/mysql";
                        String usuario = "root";
                        String senha = "root";
                        Connection con = DriverManager.getConnection(url, usuario, senha);
                        System.out.println("URL: " + url);
                        System.out.println("Connection: " + con);
                                                                                                                                                Continua…
29   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
HelloMysql.java 2/2
                        Statement stmt = con.createStatement();                                                                                 //objeto Statement
                        ResultSet rs;                                           //objeto ResultSet
                        rs = stmt.executeQuery("SELECT * FROM world.country");
                        System.out.println("Ola mundo!");
                        while(rs.next()){
                   String nomePais = rs.getString("Name");
                           System.out.print(nomePais + ", ");
                        }//end while
                        con.close();
                    } catch( Exception e ) {
                        e.printStackTrace();
                    }//end catch
                 }//end main
              }//end class HelloMysql
                                                                                                                                                              PRONTO!
30   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
java HelloMysql
            C:tutorial>javac HelloMysql.java


            C:tutorial>java HelloMysql
            Tentando conectar ao MySQL...
            URL: jdbc:mysql://localhost:3306/mysql
            Connection: com.mysql.jdbc.JDBC4Connection@ed07f45
            Ola mundo!
            Aruba, Afghanistan, Angola, Anguilla, Albania, Andorra, Netherlands Antilles, Un
            ited Arab Emirates, Argentina, Armenia, American Samoa, Antarctica, French South
            ern territories, Antigua and Barbuda, Australia, Austria, Azerbaijan, Burundi, B
            elgium, Benin, Burkina Faso, Bangladesh, Bulgaria, Bahrain, Bahamas, Bosnia and
            Herzegovina, Belarus, Belize, Bermuda, Bolivia, Brazil, Barbados, Brunei, Bhutan
            …
            ietnam, Vanuatu, Wallis and Futuna, Samoa, Yemen, Yugoslavia, South Africa, Zamb
            ia, Zimbabwe,



31   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Próximo passo: documentação

          Reference Manual
                    1. Tutorial
                    2. SQL Syntax
                    3. Connectors & APIs, Memcached
                    4. Functions, Views, Stored Programs
                    5. Optimization



                                                    dev.mysql.com/doc/refman/5.5/en/index.html

32   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
MySQL para desenvolvedores

                                                                                                                                                Conhecendo melhor o
                                                     Portfolio                                                                                  universo MySQL para
                                                                                                                                                fazer boas escolhas…


                                    Ambiente de
                                  desenvolvimento


                               Escalabilidade e
                              Alta-disponibilidade

33   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Desafio do desenvolvedor #4




                                     Projetar uma solução para
                                       disponibilidade 24x7…

                                                                            ...a famosa alta-disponibilidade


34   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Alta-Disponibilidade
                                                                                                                                                Clustering &

                            Custo & Complexidade
                                                                                                                                                Redundância
                                                                                                                                                  Geográfica

                                                                                                                         Clustering &
                                                                                                                         Virtualização


                                                                                            Replicação


                                                                                                     ISPs &                           On-Line        eCommerce
                                                                                                     Corporativo                      Services       Telecoms, Militar

                                                     9
                                                   35 dias
                                                                                 9
                                                                            4 days
                                                                            4 dias
                                                                                          .                      9
                                                                                                           8 horas
                                                                                                                                                9
                                                                                                                                           50 min
                                                                                                                                                           9
                                                                                                                                                         5 min           %
35   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Replicação MySQL
                                                                                               Aplicação



                                    Escritas & Leituras


                                                Master                                                                                     Slave




                                          • Modelo assíncrono (padrão)
                                          • Modelo semi-síncrono (a partir da versão 5.5)

36   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
MySQL failover
                                                                                               Aplicação



                                                                                                                               Escritas & Leituras


                                                Master                                                                                     Slave




                                          • Master down
                                          • Slave promovido para Master

37   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Alta-Disponibilidade
                                                                                                                           Clustering &
                                                                                                                          Redundância
                            Custo & Complexidade                                                                            Geográfica

                                                                             Clustering &
                                                                             Virtualização                                                          DRBD


                                                               Replicação
                                                                                                  Replicação

                                                                                                     ISPs &                           On-Line       eCommerce
                                                                                                     Corporativo                      Services      Telecoms, Militar

                                                     9
                                                   35 dias
                                                                                 9
                                                                            4 days
                                                                            4 dias
                                                                                          .                      9
                                                                                                           8 horas
                                                                                                                                                9
                                                                                                                                           50 min
                                                                                                                                                          9
                                                                                                                                                        5 min           %
38   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Soluções certificadas MySQL HA: resumo
                                                                                         MySQL 5.6                      Windows                 Solaris    Oracle VM              MySQL
                                                                                                                                                                        DRBD
                                                                                         Replication                     Cluster                Cluster    Template               Cluster

            Nível de disponibilidade                                                          99.9%                      99.95%                 99.99%     99.99%      99.99%     99.999%

            Auto-Failover                                                                        ✔                            ✔                   ✔          ✔           ✔          ✔
            Sem perda de dados durante                                                            ✔
            failover                                                                      Semi-Sync
                                                                                                                              ✔                   ✔          ✔           ✔          ✔

            Plataformas suportadas                                                                All                   Windows                 Solaris     Linux       Linux       All

                                                                                           Master +                      Active /               Active /   Active /    Active /   Multi-
            Modo de clusterização                                                           Slaves                       Passive                Passive    Passive     Passive    Master

            Dispensa Shared Storage                                                              ✔                            ✖                   ✖          ✖           ✔          ✔
            Ponto único de suporte                                                               ✔                            ✖                   ✔          ✔           ✔          ✔

                             mysql.com/why-mysql/white-papers/mysql_wp_ha_strategy_guide.php
39   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Desafio do desenvolvedor #5



                  Projetar uma solução que possa
                   crescer para comportar milhões
                            de usuários…


40   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Escalabilidade: horizontal vs vertical
            Scale Out                                                                                                               Scale Up
            • Adicionar mais servidores para                                                                                        • Trocar por hardware mais
              aumentar performance                                                                                                    poderoso, adicionar memória,
            • MySQL adota esta abordagem                                                                                              CPU
              em sistemas altamente                                                                                                 • Outras soluções normalmente
              escaláveis em hardware                                                                                                  usam hardware proprietário
              commodity (Intel / AMD)                                                                                                 (SMP)




41   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Evolução da escalabilidade do MySQL



                  2008                                                               2009                                                        2010         2013


               até 4 CPU                                                         até 16 CPU                                                     até 32 CPU   até 48 CPU
               MySQL 5.0                                                         MySQL 5.1                                                      MySQL 5.5    MySQL 5.6

               MySQL AB                                                                  Sun                                                      Oracle




42   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Benchmarks MySQL 5.5 vs 5.6

             Sysbench
             32-core
             Mesmo Hardware
             Tuning ótimo




43   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Benchmarks MySQL 5.5 vs 5.6

             Sysbench
             32-core
             Mesmo Hardware
             Tuning ótimo



                                                                                                                           Sysbench
                                                                                                                             32-core
                                                                                                                        Same Hardware
                                                                                                                        Optimal Tuning




44   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Escalabilidade horizontal
                                                                                                    Particionamento
       Replicação MySQL                                                                                                                             Data Sharding
                                                                                                       Funcional
     • método mais simples e                                                             • dividir a carga em múltiplos                         • método de maior sucesso
       mais comum                                                                          nós, com responsabilidades                             para escalar aplicações
                                                                                           distintas                                              MySQL de grande porte
     • indicado para aplicações                                                                                                                   hoje
       de LEITURA intensiva                                                              • os nós podem ter
                                                                                           redundância via replicação                           • dados compartilhados em
     • problemas com cache                                                                 para alta-disponibilidade                              tabelas/caches globais,
       duplicado em aplicações                                                           • normalmente não é                                      SOA
       com datasets grandes                                                                transparente para a aplicação                        • difícil de adaptar
                                                                                           e também recorre ao scale up                           aplicações legadas
                                                                                           para cada database funcional,
                                                                                           o que impõe limites




45   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Replicação MySQL: escalando LEITURAS
                                                                                               Aplicação



                                    Escritas & Leituras                                                                                  Leituras



                                                Master                                                                                     Slave




                                          • Divisão de leituras e escritas (R/W Split)
                                          • É possível adicionar mais slaves, dividir a carga

46   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Data Sharding: escalando ESCRITAS
                                      Table T1                                                                                                  Data Node 1



                                                                                                          P1                                    Data Node 2

                                                                                                          P2
                                                                                                          P3                                    Data Node 3

                                                                                                          P4
                                                                                                                                                Data Node 4




47   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Data Sharding: escalando ESCRITAS
                                      Table T1                                                                                                  Data Node 1
                                                                                                                                                F1


                                                                                                          P1                                    Data Node 2

                                                                                                          P2
                                                                                                          P3                                    Data Node 3

                                                                                                          P4
                                                                                                                                                Data Node 4




48   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Data Sharding: escalando ESCRITAS
                                      Table T1                                                                                                  Data Node 1
                                                                                                                                                F1


                                                                                                          P1                                    Data Node 2
                                                                                                                                                F3
                                                                                                          P2
                                                                                                          P3                                    Data Node 3

                                                                                                          P4
                                                                                                                                                Data Node 4




49   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Data Sharding: escalando ESCRITAS
                                      Table T1                                                                                                  Data Node 1
                                                                                                                                                F1


                                                                                                          P1                                    Data Node 2
                                                                                                                                                F3
                                                                                                          P2
                                                                                                          P3                                    Data Node 3
                                                                                                                                                F2
                                                                                                          P4
                                                                                                                                                Data Node 4




50   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Data Sharding: escalando ESCRITAS
                                      Table T1                                                                                                  Data Node 1
                                                                                                                                                F1


                                                                                                          P1                                    Data Node 2
                                                                                                                                                F3
                                                                                                          P2
                                                                                                          P3                                    Data Node 3
                                                                                                                                                F2
                                                                                                          P4
                                                                                                                                                Data Node 4
                                                                                                                                                F4




51   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Desafios do desenvolvedor #4 + #5




                        É possível combinar alta-
                     disponibilidade e escalabilidade?

                                                         ...assim como Facebook, Twitter, Youtube


52   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Data Sharding + Replicação
                                      Table T1                                                                                                  Data Node 1
                                                                                                                                                F1


                                                                                                          P1                                    Data Node 2
                                                                                                                                                          F1
                                                                                                          P2
                                                                                                          P3                                    Data Node 3

                                                                                                          P4
                                                                                                                                                Data Node 4




53   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Data Sharding + Replicação
                                      Table T1                                                                                                  Data Node 1
                                                                                                                                                F1        F3


                                                                                                          P1                                    Data Node 2
                                                                                                                                                F3        F1
                                                                                                          P2
                                                                                                          P3                                    Data Node 3

                                                                                                          P4
                                                                                                                                                Data Node 4




54   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Alta-Disponibilidade: Replicação Síncrona
                                      Table T1                                                                                                  Data Node 1
                                                                                                                                                F1        F3


                                                                                                          P1                                    Data Node 2
                                                                                                                                                F3        F1
                                                                                                          P2
                                                                                                          P3                                    Data Node 3
                                                                                                                                                F2
                                                                                                          P4
                                                                                                                                                Data Node 4
                                                                                                                                                          F2




55   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Data Sharding + Replicação
                                      Table T1                                                                                                  Data Node 1
                                                                                                                                                F1        F3


                                                                                                          P1                                    Data Node 2
                                                                                                                                                F3        F1
                                                                                                          P2
                                                                                                          P3                                    Data Node 3
                                                                                                                                                F2        F4
                                                                                                          P4
                                                                                                                                                Data Node 4
                                                                                                                                                F4        F2




56   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Data Sharding + Replicação
                                      Table T1                                                                                                  Data Node 1
                                                                                                                                                F1        F3




                                                                                                                                                               Group 1
                                                                                                          P1                                    Data Node 2
                                                                                                                                                F3        F1
                                                                                                          P2
                                                                                                          P3                                    Data Node 3
                                                                                                                                                F2        F4
                                                                                                          P4




                                                                                                                                                               Group 2
                                                                                                                                                Data Node 4
                                                                                                                                                F4        F2




57   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Data Sharding + Replicação
                                      Table T1                                                                                                  Data Node 1
                                                                                                                                                F1        F3




                                                                                                                                                               Group 1
                                                                                                          P1                                    Data Node 2
                                                                                                                                                F3        F1
                                                                                                          P2
                                                                                                          P3                                    Data Node 3
                                                                                                                                                F2        F4
                                                                                                          P4




                                                                                                                                                               Group 2
                                                                                                                                                Data Node 4
                                                                                                                                                F4        F2




58   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Casos de muito sucesso

            Facebook
            Youtube
            Twitter
            Flickr
            Evernote
            Pinterest
           …



                                                                                             highscalability.com
59   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
MySQL Cluster: auto-sharding
                                           Clients



                                                                                           Application Layer




Management                                                                                                                                         Management


                                                                                                   Data Layer                                             Table T1
                                                       F1                        F3                       F2                        F4                               P1
                                                       F3                        F1                       F4                        F2                               P2
                                                                                                                                                                     P3
                                                                               MySQL Cluster Data Nodes                                                              P4

   60   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
APIs de Acesso aos Dados




                                                                                                                                                  Os mesmos dados
                                                                                                                                                          acessados
                                                                                                                                                    simultaneamente
                                                                                                                                                através de interfaces
                                                                                                                                                       SQL e NoSQL



61   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Alguns Clientes MySQL Cluster




62   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Caso de sucesso
                                                                                                                                       •2 milhões usuários, com 30.000 novos
                                                                                                                                       usuários por dia
                                                                                                                                       •10.000 usuários concorrentes
                                                                                                                                       •10.000 Transações Por Segundo
                                                                                                                                       •99.999% uptime

                                                                                                                                       “The MySQL support service has
                                                                                                                                       been essential in helping us for
                                                                                                                                       troubleshooting and giving
                                                                                                                                       recommendations for the production
                                                                                                                                       cluster.”
                                                                                                                                                 Carlos Morales (DBA), Playfulplay.com

                       blogs.oracle.com/MySQL/entry/mysql_cluster_powers_el_chavo
63   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
MySQL Cluster
                      Carrier Grade                                                           • Arquitetura shared-nothing in-memory parallel
                       Database                                                               • Modelo relacional ACID, SQL

                                                                                              • 99.999% de disponibilidade
           Alta Disponibilidade                                                               • Self-healing, failover abaixo de 1 segundo

                                                                                              • Performance em tempo real para altas cargas
               Alta Performance                                                               • Latência baixa e preditiva

                                                                                              • Elasticidade, crescimento incremental
                     Escalabilidade                                                           • Escalabilidade linear, distribuition aware

                                                                                              • Open Source, hardware commodity
                       Open Source                                                            • APIs NoSQL (C++, Java, Memcached, Node.js)

64   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
MySQL Cluster Auto-Install (beta)




       Simples de instalar e provisionar clusters multi-node
       Complementa MySQL Cluster Manager no gerenciamento de cliclo de vida

65   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
MySQL Cluster Manager
        Para testes em uma única máquina
        1.            Download MCM/Cluster edelivery.oracle.com:
        2.            Unzip e execute o comando:
             C:MySQLmcmbin> mcmd –bootstrap
             MySQL Cluster Manager 1.1.2 started
             Connect to MySQL Cluster Manager by running “C:MySQLmcmbinmcm" -a NOVA:1862
             Configuring default cluster 'mycluster'...
             Starting default cluster 'mycluster'...
             Cluster 'mycluster' started successfully
               ndb_mgmd NOVA:1186
               ndbd NOVA
               ndbd NOVA
               mysqld NOVA:3306
               mysqld NOVA:3307
               ndbapi *
             Connect to the database by running “C:MySQLmcmclusterbinmysql" -h NOVA -P 3306 -u root


66   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Mais sobre como começar com MySQL Cluster


                                                                                                                Whitepaper:
                                                                                                                MySQL Cluster Evaluation Guide
                                                                                                                February 2012
                                                                                                                mysql.com/why-mysql/white-papers/mysql-
                                                                                                                cluster-evaluation-guide/




67   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Exemplos Memcached API


              On-demand Webinar:
              NoSQL Memcached API for MySQL Cluster
              22 August 2012
              mysql.com/news-and-events/on-demand-webinars/display-od-723.html




68   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Exemplos JavaScript / Node.js API


              Blog:
              Tutorial Getting Started with the NoSQL JavaScript / Node.js API for
              MySQL Cluster
              10 June 2012
              blogs.oracle.com/MySQL/entry/tutorial_getting_started_with_the




69   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Novo Desafio do desenvolvedor




                                                                                            Big Data



70   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
MySQL in the Big Data Lifecycle
                                                                                                                                                ACQUIRE
                                          DECIDE
                BI Solutions

                                                                                                                                                  NoSQL APIs



                                                                                                                                                   Binlog API
                                  ANALYZE                                                                                                       ORGANIZE


71   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
MySQL e Big Data


                                                                                                                Whitepaper:
                                                                                                                MySQL and Hadoop – Big Data Integration
                                                                                                                December 2012
                                                                                                                mysql.com/why-mysql/white-papers/mysql-
                                                                                                                and-hadoop-guide-to-big-data-integration/




72   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Sumário

                   O MySQL é o banco de dados open source mais popular do
                    mundo, usado em grandes sites, aplicações mobile e
                    embarcadas.
                   Há várias opções de arquiteturas e APIs, oferecendo enorme
                    flexibilidade, escalabilidade e alta-disponibilidade.
                   Instale e comece a usar em menos de 15min. Use e abuse da
                    documentação!



73   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
@MySQLBR                                                            facebook.com/MySQLBR

                                                                                                                                                Obrigado!
                                        meetup.com/MySQL-BR




74   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
MySQL para Desenvolvedores


Perguntas?


75   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Arquitetura MySQL Server

                  Clients and Apps
                                                                                                                                  Clients & Connectors
                   mysqld                                                                          Native C API, JDBC, ODBC, .Net, PHP, Ruby, Python, VB, Perl




                                                                                         Connection Pool, SQL Interface, Parser, Optimizer, Caches
                  Enterprise Management
                   Services and Utilities

                           Backup & Recovery                                                                                            Storage Engines
                                Monitor                                                              InnoDB, MyISAM, Memory, Archive, Cluster (NDB API), etc…
                              Workbench
                                Utilities
                                                                                                                           Filesystems, Files and Logs
                                                                                                                   Data, Index, Redo, Undo, Binary, Error, Slow




76   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12
Storage Engines
                                                                                        MyISAM                                                   InnoDB              NDB Cluster
      Transações                                                                                   ✖                                                  ✔                      ✔

      Nível de Lock                                                                           Tabela                                                 Linha                  Linha
                                                                                      Assíncrona ou                                             Assíncrona ou
      Replicação                                                                                                                                                   Síncrona, Multi-master
                                                                                      Semi-síncrona                                             Semi-síncrona
      Foreign Keys                                                                                 ✖                                                  ✔                a partir da v7.3

      Full-text indexes                                                                            ✔                                            a partir da v5.6             ✖

      Compressão de dados                                                           somente Leitura                                                   ✔                      ✖

      Caches                                                                        somente Índices                                             Dados e Índices       Dados e Índices

      Suporte Geospacial                                                    Tipos de Dados e Índices                                   somente Tipos de Dados      somente Tipos de Dados

      Limite de armazenamento                                                                 256TB                                                  64TB                  384EB

                                                  dev.mysql.com/doc/refman/5.5/en/storage-engines.html

77   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.   Insert Information Protection Policy Classification from Slide 12

More Related Content

Similar to MySQL para Desenvolvedores (20)

PDF
MySQL Spatial
MySQL Brasil
 
PDF
Posscon my sql56
Dave Stokes
 
PDF
What is new in MySQL? (Lars Thalmann)
Ontico
 
PDF
From Nice to Have to Mission Critical: MySQL Enterprise Edition
郁萍 王
 
PPTX
Simple Way for MySQL to NoSQL
Okcan Yasin Saygılı
 
PDF
MySQL para Desenvolvedores de Games
MySQL Brasil
 
PDF
MySQL Community and Commercial Edition
Mario Beck
 
PDF
MySQL HA Solutions
Mat Keep
 
PDF
MySQL For Oracle Developers
Ronald Bradford
 
PDF
MySQL Enterprise Monitor
Ted Wennmark
 
PDF
MySQL Tech Tour Nov, 2013
Mysql Latinoamérica
 
PDF
MySQL 8: Ready for Prime Time
Arnab Ray
 
PDF
Santo Leto - MySQL Connect 2012 - Getting Started with Mysql Cluster
Santo Leto
 
PDF
Upgrade from MySQL 5.7 to MySQL 8.0
Olivier DASINI
 
PDF
20191001 bkk-secret-of inno-db_clusterv1
Ivan Ma
 
PDF
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...
GeneXus
 
PDF
20200613 my sql-ha-deployment
Ivan Ma
 
PDF
My sql crashcourse_2012
sqlhjalp
 
PDF
Oracle enterprise architects day
Ayodele Peter Boglo
 
PDF
Developing Applications with MySQL and Java
Mark Matthews
 
MySQL Spatial
MySQL Brasil
 
Posscon my sql56
Dave Stokes
 
What is new in MySQL? (Lars Thalmann)
Ontico
 
From Nice to Have to Mission Critical: MySQL Enterprise Edition
郁萍 王
 
Simple Way for MySQL to NoSQL
Okcan Yasin Saygılı
 
MySQL para Desenvolvedores de Games
MySQL Brasil
 
MySQL Community and Commercial Edition
Mario Beck
 
MySQL HA Solutions
Mat Keep
 
MySQL For Oracle Developers
Ronald Bradford
 
MySQL Enterprise Monitor
Ted Wennmark
 
MySQL Tech Tour Nov, 2013
Mysql Latinoamérica
 
MySQL 8: Ready for Prime Time
Arnab Ray
 
Santo Leto - MySQL Connect 2012 - Getting Started with Mysql Cluster
Santo Leto
 
Upgrade from MySQL 5.7 to MySQL 8.0
Olivier DASINI
 
20191001 bkk-secret-of inno-db_clusterv1
Ivan Ma
 
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...
GeneXus
 
20200613 my sql-ha-deployment
Ivan Ma
 
My sql crashcourse_2012
sqlhjalp
 
Oracle enterprise architects day
Ayodele Peter Boglo
 
Developing Applications with MySQL and Java
Mark Matthews
 

More from MySQL Brasil (20)

PDF
MySQL como Document Store PHP Conference 2017
MySQL Brasil
 
PDF
MySQL no Paypal Tesla e Uber
MySQL Brasil
 
PDF
MySQL 8.0.1 DMR
MySQL Brasil
 
PDF
Alta disponibilidade com MySQL Enterprise
MySQL Brasil
 
PDF
MySQL Roadmap NoSQL HA Fev17
MySQL Brasil
 
PDF
Segurança no MySQL
MySQL Brasil
 
PDF
5 razões estratégicas para usar MySQL
MySQL Brasil
 
PDF
Alta disponibilidade no MySQL 5.7 GUOB 2016
MySQL Brasil
 
PDF
MySQL 5.7 como Document Store
MySQL Brasil
 
PDF
Enabling digital transformation with MySQL
MySQL Brasil
 
PDF
Alta Disponibilidade no MySQL 5.7 para aplicações em PHP
MySQL Brasil
 
PDF
Alta Disponibilidade no MySQL 5.7
MySQL Brasil
 
PDF
NoSQL no MySQL 5.7
MySQL Brasil
 
PDF
OpenStack & MySQL
MySQL Brasil
 
PDF
10 Razões para Usar MySQL em Startups
MySQL Brasil
 
PDF
Novidades do MySQL para desenvolvedores ago15
MySQL Brasil
 
PDF
Estratégias de Segurança e Gerenciamento para MySQL
MySQL Brasil
 
PDF
Novidades do Universo MySQL julho-15
MySQL Brasil
 
PDF
Serviços Escaláveis e de Alta Performance com MySQL e Java
MySQL Brasil
 
PDF
MySQL The State of the Dolphin - jun15
MySQL Brasil
 
MySQL como Document Store PHP Conference 2017
MySQL Brasil
 
MySQL no Paypal Tesla e Uber
MySQL Brasil
 
MySQL 8.0.1 DMR
MySQL Brasil
 
Alta disponibilidade com MySQL Enterprise
MySQL Brasil
 
MySQL Roadmap NoSQL HA Fev17
MySQL Brasil
 
Segurança no MySQL
MySQL Brasil
 
5 razões estratégicas para usar MySQL
MySQL Brasil
 
Alta disponibilidade no MySQL 5.7 GUOB 2016
MySQL Brasil
 
MySQL 5.7 como Document Store
MySQL Brasil
 
Enabling digital transformation with MySQL
MySQL Brasil
 
Alta Disponibilidade no MySQL 5.7 para aplicações em PHP
MySQL Brasil
 
Alta Disponibilidade no MySQL 5.7
MySQL Brasil
 
NoSQL no MySQL 5.7
MySQL Brasil
 
OpenStack & MySQL
MySQL Brasil
 
10 Razões para Usar MySQL em Startups
MySQL Brasil
 
Novidades do MySQL para desenvolvedores ago15
MySQL Brasil
 
Estratégias de Segurança e Gerenciamento para MySQL
MySQL Brasil
 
Novidades do Universo MySQL julho-15
MySQL Brasil
 
Serviços Escaláveis e de Alta Performance com MySQL e Java
MySQL Brasil
 
MySQL The State of the Dolphin - jun15
MySQL Brasil
 
Ad

Recently uploaded (20)

PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Biography of Daniel Podor.pdf
Daniel Podor
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Ad

MySQL para Desenvolvedores

  • 1. MySQL para Desenvolvedores Airton Lastori [email protected] 30-jan-2013 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 2. @MySQLBR facebook.com/MySQLBR MySQLBR meetup.com/MySQL-BR 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 3. 3 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 4. Alguns clientes MySQL 4 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 5. Alguns clientes MySQL fonte: alexa.com/topsites 30-jan-2013 5 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 6. Alguns clientes MySQL mysql.com/customers 6 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 7. Alguns clientes MySQL mysql.com/customers 7 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 8. Tipos de aplicação 70% 60% 50% 40% 30% 20% 10% Enterprise 0% Community 8 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 9. Desafio de desenvolvedor #1 Quais são os requisitos não funcionais da minha aplicação? 9 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 10. Na escolha da solução, considerar... Escalabilidade, performance, disponibilidade, estabilidade, segurança, simplicidade, flexibilidade, custo total de propriedade, conhecimento da equipe... Ah! Não esqueça da fase de produção, dos DBAs... ferramentas, suporte, rotinas de manutenção. 10 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 11. MySQL para desenvolvedores Conhecendo melhor o Portfolio universo MySQL para fazer boas escolhas… Ambiente de desenvolvimento Escalabilidade e Alta-disponibilidade 11 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 12. MySQL para desenvolvedores Conhecendo melhor o Portfolio universo MySQL para fazer boas escolhas… Ambiente de desenvolvimento Escalabilidade e Alta-disponibilidade 12 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 13. Compromisso Oracle com MySQL Community Portfólio disponível para download e uso sob GPL  MySQL Database Community Server  MySQL Cluster  MySQL Workbench  MySQL Connectors  MySQL Proxy  Documentação não GPL  Forums, Lists, Bugs, Blogs… 13 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 14. Conectores: amplo suporte a várias linguagens Oracle Comunidade • Connector/ODBC • PHP • Connector/Net (ADO.NET) • Perl • Connector/Python • Ruby • Connector/J (JDBC) • TCL • Connector/C (C API) • Eiffel • Connector/C++ (C++ API) • … dev.mysql.com/doc/refman/5.5/en/connectors-apis.html 14 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 15. MySQL Enterprise Edition Maior produtividade e mitigação de riscos Oracle Premier Lifetime Support MySQL Enterprise Oracle Product Security Certifications/Integrations MySQL Enterprise MySQL Enterprise Audit Monitor/Query Analyzer MySQL Enterprise MySQL Enterprise Scalability Backup MySQL Enterprise MySQL Workbench High Availability 15 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 16. MySQL para desenvolvedores Conhecendo melhor o Portfolio universo MySQL para fazer boas escolhas… Ambiente de desenvolvimento Escalabilidade e Alta-disponibilidade 16 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 17. Desafio de desenvolvedor #2 Instalação básica, ambiente de desenvolvimento… ...em 15 minutos, ou menos! 17 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 18. 18 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 19. No Linux ou Mac, prefira os binários mysql.com/downloads/mysql 19 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 20. Cliente-Servidor Client mysql / mysql.exe Server mysqld / mysqld.exe 20 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 21. Iniciar ou Parar o servidor MySQL no Windows …ou via MySQL Notifier 21 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 22. Iniciar ou Parar o servidor MySQL no Linux Iniciar: /usr/local/mysql/bin> mysqld_safe --defaults-file=/etc/my.cnf & Parar: /usr/local/mysql/bin> mysqladmin shutdown dev.mysql.com/doc/refman/5.5/en/mysqld-safe.html 22 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 23. Primeira conexão C:Program FilesMySQLMySQL Server 5.5bin>mysql -uroot -p Enter password: **** Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 8 Server version: 5.5.28 MySQL Community Server (GPL) Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql> 23 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 24. Teste via MySQL Workbench 1/2 24 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 25. Teste via MySQL Workbench 2/2 25 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 26. Cliente-Servidor App + Connector JDBC, ODBC, .Net, PHP, Python, Perl, Ruby, Native C API… Server mysqld / mysqld.exe 26 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 27. Desafio de desenvolvedor #3 Hello World… ...em Java 27 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 28. Adicione o driver MySQL ao CLASSPATH caminho completo do .jar Confira: C:>set CLASSPATH CLASSPATH=.;C:Program Files (x86)Javajre6libextQTJava.zip;C:Program FilesMySQLmysql-connector-java-5.1.22mysql-connector-java-5.1.22-bin.jar 28 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 29. HelloMysql.java 1/2 import java.sql.*; public class HelloMysql { public static void main(String args[]){ System.out.println("Tentando conectar ao MySQL..."); try { Class.forName("com.mysql.jdbc.Driver"); String url = "jdbc:mysql://localhost:3306/mysql"; String usuario = "root"; String senha = "root"; Connection con = DriverManager.getConnection(url, usuario, senha); System.out.println("URL: " + url); System.out.println("Connection: " + con); Continua… 29 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 30. HelloMysql.java 2/2 Statement stmt = con.createStatement(); //objeto Statement ResultSet rs; //objeto ResultSet rs = stmt.executeQuery("SELECT * FROM world.country"); System.out.println("Ola mundo!"); while(rs.next()){ String nomePais = rs.getString("Name"); System.out.print(nomePais + ", "); }//end while con.close(); } catch( Exception e ) { e.printStackTrace(); }//end catch }//end main }//end class HelloMysql PRONTO! 30 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 31. java HelloMysql C:tutorial>javac HelloMysql.java C:tutorial>java HelloMysql Tentando conectar ao MySQL... URL: jdbc:mysql://localhost:3306/mysql Connection: com.mysql.jdbc.JDBC4Connection@ed07f45 Ola mundo! Aruba, Afghanistan, Angola, Anguilla, Albania, Andorra, Netherlands Antilles, Un ited Arab Emirates, Argentina, Armenia, American Samoa, Antarctica, French South ern territories, Antigua and Barbuda, Australia, Austria, Azerbaijan, Burundi, B elgium, Benin, Burkina Faso, Bangladesh, Bulgaria, Bahrain, Bahamas, Bosnia and Herzegovina, Belarus, Belize, Bermuda, Bolivia, Brazil, Barbados, Brunei, Bhutan … ietnam, Vanuatu, Wallis and Futuna, Samoa, Yemen, Yugoslavia, South Africa, Zamb ia, Zimbabwe, 31 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 32. Próximo passo: documentação Reference Manual 1. Tutorial 2. SQL Syntax 3. Connectors & APIs, Memcached 4. Functions, Views, Stored Programs 5. Optimization dev.mysql.com/doc/refman/5.5/en/index.html 32 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 33. MySQL para desenvolvedores Conhecendo melhor o Portfolio universo MySQL para fazer boas escolhas… Ambiente de desenvolvimento Escalabilidade e Alta-disponibilidade 33 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 34. Desafio do desenvolvedor #4 Projetar uma solução para disponibilidade 24x7… ...a famosa alta-disponibilidade 34 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 35. Alta-Disponibilidade Clustering & Custo & Complexidade Redundância Geográfica Clustering & Virtualização Replicação ISPs & On-Line eCommerce Corporativo Services Telecoms, Militar 9 35 dias 9 4 days 4 dias . 9 8 horas 9 50 min 9 5 min % 35 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 36. Replicação MySQL Aplicação Escritas & Leituras Master Slave • Modelo assíncrono (padrão) • Modelo semi-síncrono (a partir da versão 5.5) 36 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 37. MySQL failover Aplicação Escritas & Leituras Master Slave • Master down • Slave promovido para Master 37 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 38. Alta-Disponibilidade Clustering & Redundância Custo & Complexidade Geográfica Clustering & Virtualização DRBD Replicação Replicação ISPs & On-Line eCommerce Corporativo Services Telecoms, Militar 9 35 dias 9 4 days 4 dias . 9 8 horas 9 50 min 9 5 min % 38 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 39. Soluções certificadas MySQL HA: resumo MySQL 5.6 Windows Solaris Oracle VM MySQL DRBD Replication Cluster Cluster Template Cluster Nível de disponibilidade 99.9% 99.95% 99.99% 99.99% 99.99% 99.999% Auto-Failover ✔ ✔ ✔ ✔ ✔ ✔ Sem perda de dados durante ✔ failover Semi-Sync ✔ ✔ ✔ ✔ ✔ Plataformas suportadas All Windows Solaris Linux Linux All Master + Active / Active / Active / Active / Multi- Modo de clusterização Slaves Passive Passive Passive Passive Master Dispensa Shared Storage ✔ ✖ ✖ ✖ ✔ ✔ Ponto único de suporte ✔ ✖ ✔ ✔ ✔ ✔ mysql.com/why-mysql/white-papers/mysql_wp_ha_strategy_guide.php 39 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 40. Desafio do desenvolvedor #5 Projetar uma solução que possa crescer para comportar milhões de usuários… 40 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 41. Escalabilidade: horizontal vs vertical Scale Out Scale Up • Adicionar mais servidores para • Trocar por hardware mais aumentar performance poderoso, adicionar memória, • MySQL adota esta abordagem CPU em sistemas altamente • Outras soluções normalmente escaláveis em hardware usam hardware proprietário commodity (Intel / AMD) (SMP) 41 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 42. Evolução da escalabilidade do MySQL 2008 2009 2010 2013 até 4 CPU até 16 CPU até 32 CPU até 48 CPU MySQL 5.0 MySQL 5.1 MySQL 5.5 MySQL 5.6 MySQL AB Sun Oracle 42 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 43. Benchmarks MySQL 5.5 vs 5.6 Sysbench 32-core Mesmo Hardware Tuning ótimo 43 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 44. Benchmarks MySQL 5.5 vs 5.6 Sysbench 32-core Mesmo Hardware Tuning ótimo Sysbench 32-core Same Hardware Optimal Tuning 44 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 45. Escalabilidade horizontal Particionamento Replicação MySQL Data Sharding Funcional • método mais simples e • dividir a carga em múltiplos • método de maior sucesso mais comum nós, com responsabilidades para escalar aplicações distintas MySQL de grande porte • indicado para aplicações hoje de LEITURA intensiva • os nós podem ter redundância via replicação • dados compartilhados em • problemas com cache para alta-disponibilidade tabelas/caches globais, duplicado em aplicações • normalmente não é SOA com datasets grandes transparente para a aplicação • difícil de adaptar e também recorre ao scale up aplicações legadas para cada database funcional, o que impõe limites 45 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 46. Replicação MySQL: escalando LEITURAS Aplicação Escritas & Leituras Leituras Master Slave • Divisão de leituras e escritas (R/W Split) • É possível adicionar mais slaves, dividir a carga 46 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 47. Data Sharding: escalando ESCRITAS Table T1 Data Node 1 P1 Data Node 2 P2 P3 Data Node 3 P4 Data Node 4 47 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 48. Data Sharding: escalando ESCRITAS Table T1 Data Node 1 F1 P1 Data Node 2 P2 P3 Data Node 3 P4 Data Node 4 48 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 49. Data Sharding: escalando ESCRITAS Table T1 Data Node 1 F1 P1 Data Node 2 F3 P2 P3 Data Node 3 P4 Data Node 4 49 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 50. Data Sharding: escalando ESCRITAS Table T1 Data Node 1 F1 P1 Data Node 2 F3 P2 P3 Data Node 3 F2 P4 Data Node 4 50 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 51. Data Sharding: escalando ESCRITAS Table T1 Data Node 1 F1 P1 Data Node 2 F3 P2 P3 Data Node 3 F2 P4 Data Node 4 F4 51 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 52. Desafios do desenvolvedor #4 + #5 É possível combinar alta- disponibilidade e escalabilidade? ...assim como Facebook, Twitter, Youtube 52 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 53. Data Sharding + Replicação Table T1 Data Node 1 F1 P1 Data Node 2 F1 P2 P3 Data Node 3 P4 Data Node 4 53 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 54. Data Sharding + Replicação Table T1 Data Node 1 F1 F3 P1 Data Node 2 F3 F1 P2 P3 Data Node 3 P4 Data Node 4 54 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 55. Alta-Disponibilidade: Replicação Síncrona Table T1 Data Node 1 F1 F3 P1 Data Node 2 F3 F1 P2 P3 Data Node 3 F2 P4 Data Node 4 F2 55 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 56. Data Sharding + Replicação Table T1 Data Node 1 F1 F3 P1 Data Node 2 F3 F1 P2 P3 Data Node 3 F2 F4 P4 Data Node 4 F4 F2 56 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 57. Data Sharding + Replicação Table T1 Data Node 1 F1 F3 Group 1 P1 Data Node 2 F3 F1 P2 P3 Data Node 3 F2 F4 P4 Group 2 Data Node 4 F4 F2 57 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 58. Data Sharding + Replicação Table T1 Data Node 1 F1 F3 Group 1 P1 Data Node 2 F3 F1 P2 P3 Data Node 3 F2 F4 P4 Group 2 Data Node 4 F4 F2 58 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 59. Casos de muito sucesso  Facebook  Youtube  Twitter  Flickr  Evernote  Pinterest … highscalability.com 59 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 60. MySQL Cluster: auto-sharding Clients Application Layer Management Management Data Layer Table T1 F1 F3 F2 F4 P1 F3 F1 F4 F2 P2 P3 MySQL Cluster Data Nodes P4 60 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 61. APIs de Acesso aos Dados Os mesmos dados acessados simultaneamente através de interfaces SQL e NoSQL 61 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 62. Alguns Clientes MySQL Cluster 62 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 63. Caso de sucesso •2 milhões usuários, com 30.000 novos usuários por dia •10.000 usuários concorrentes •10.000 Transações Por Segundo •99.999% uptime “The MySQL support service has been essential in helping us for troubleshooting and giving recommendations for the production cluster.” Carlos Morales (DBA), Playfulplay.com blogs.oracle.com/MySQL/entry/mysql_cluster_powers_el_chavo 63 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 64. MySQL Cluster Carrier Grade • Arquitetura shared-nothing in-memory parallel Database • Modelo relacional ACID, SQL • 99.999% de disponibilidade Alta Disponibilidade • Self-healing, failover abaixo de 1 segundo • Performance em tempo real para altas cargas Alta Performance • Latência baixa e preditiva • Elasticidade, crescimento incremental Escalabilidade • Escalabilidade linear, distribuition aware • Open Source, hardware commodity Open Source • APIs NoSQL (C++, Java, Memcached, Node.js) 64 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 65. MySQL Cluster Auto-Install (beta)  Simples de instalar e provisionar clusters multi-node  Complementa MySQL Cluster Manager no gerenciamento de cliclo de vida 65 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 66. MySQL Cluster Manager Para testes em uma única máquina 1. Download MCM/Cluster edelivery.oracle.com: 2. Unzip e execute o comando: C:MySQLmcmbin> mcmd –bootstrap MySQL Cluster Manager 1.1.2 started Connect to MySQL Cluster Manager by running “C:MySQLmcmbinmcm" -a NOVA:1862 Configuring default cluster 'mycluster'... Starting default cluster 'mycluster'... Cluster 'mycluster' started successfully ndb_mgmd NOVA:1186 ndbd NOVA ndbd NOVA mysqld NOVA:3306 mysqld NOVA:3307 ndbapi * Connect to the database by running “C:MySQLmcmclusterbinmysql" -h NOVA -P 3306 -u root 66 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 67. Mais sobre como começar com MySQL Cluster Whitepaper: MySQL Cluster Evaluation Guide February 2012 mysql.com/why-mysql/white-papers/mysql- cluster-evaluation-guide/ 67 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 68. Exemplos Memcached API On-demand Webinar: NoSQL Memcached API for MySQL Cluster 22 August 2012 mysql.com/news-and-events/on-demand-webinars/display-od-723.html 68 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 69. Exemplos JavaScript / Node.js API Blog: Tutorial Getting Started with the NoSQL JavaScript / Node.js API for MySQL Cluster 10 June 2012 blogs.oracle.com/MySQL/entry/tutorial_getting_started_with_the 69 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 70. Novo Desafio do desenvolvedor Big Data 70 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 71. MySQL in the Big Data Lifecycle ACQUIRE DECIDE BI Solutions NoSQL APIs Binlog API ANALYZE ORGANIZE 71 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 72. MySQL e Big Data Whitepaper: MySQL and Hadoop – Big Data Integration December 2012 mysql.com/why-mysql/white-papers/mysql- and-hadoop-guide-to-big-data-integration/ 72 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 73. Sumário  O MySQL é o banco de dados open source mais popular do mundo, usado em grandes sites, aplicações mobile e embarcadas.  Há várias opções de arquiteturas e APIs, oferecendo enorme flexibilidade, escalabilidade e alta-disponibilidade.  Instale e comece a usar em menos de 15min. Use e abuse da documentação! 73 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 74. @MySQLBR facebook.com/MySQLBR Obrigado! meetup.com/MySQL-BR 74 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 75. MySQL para Desenvolvedores Perguntas? 75 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 76. Arquitetura MySQL Server Clients and Apps Clients & Connectors mysqld Native C API, JDBC, ODBC, .Net, PHP, Ruby, Python, VB, Perl Connection Pool, SQL Interface, Parser, Optimizer, Caches Enterprise Management Services and Utilities Backup & Recovery Storage Engines Monitor InnoDB, MyISAM, Memory, Archive, Cluster (NDB API), etc… Workbench Utilities Filesystems, Files and Logs Data, Index, Redo, Undo, Binary, Error, Slow 76 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  • 77. Storage Engines MyISAM InnoDB NDB Cluster Transações ✖ ✔ ✔ Nível de Lock Tabela Linha Linha Assíncrona ou Assíncrona ou Replicação Síncrona, Multi-master Semi-síncrona Semi-síncrona Foreign Keys ✖ ✔ a partir da v7.3 Full-text indexes ✔ a partir da v5.6 ✖ Compressão de dados somente Leitura ✔ ✖ Caches somente Índices Dados e Índices Dados e Índices Suporte Geospacial Tipos de Dados e Índices somente Tipos de Dados somente Tipos de Dados Limite de armazenamento 256TB 64TB 384EB dev.mysql.com/doc/refman/5.5/en/storage-engines.html 77 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12