SlideShare une entreprise Scribd logo
1  sur  205
Télécharger pour lire hors ligne
MySQL Replication 101
                                    Giuseppe Maxia
                                    Continuent, Inc




   ©Continuent 2012.


Tuesday, April 10, 12                                 1
about me - Giuseppe Maxia
  •      a.k.a. The Data Charmer
  •      QA Director at Continuent, Inc
  •      Long time hacking with MySQL features
  •      Formerly, community manager,db consultant, designer,
         coder.
  •      A passion for QA and open source
  •      Blogger
  • http://datacharmer.blogspot.com


Tuesday, April 10, 12                                           2
DA              Why replication
                                                    • The web economy
      EN                                            • Scaling out
   AG
                                                    • From single server to replication
                        How to set replication
                                                    • Adding a slave
                                                    •   Binary log formats
                        Using Replication           •   What gets replicated and how
                                                    •   Replication awareness
                                                    •   Monitoring
                                                    •   Log management
                        Managing replication
                                                    •   Replacing a slave
                                                    •   Replacing a master
                                                    • master replacement
                        What Replication is for     • backup
                                                    • better reads

                        Gotchas, tips, and tricks

                                                    • What to read
                        More info
                                                    • More replication sessions
                                                                                          3

Tuesday, April 10, 12                                                                     3
DA              Why replication
                                                    • The web economy
      EN                                            • Scaling out
   AG
                                                    • From single server to replication
                        How to set replication
                                                    • Adding a slave
                                                    •   Binary log formats
                        Using Replication           •   What gets replicated and how
                                                    •   Replication awareness
                                                    •   Monitoring
                                                    •   Log management
                        Managing replication
                                                    •   Replacing a slave
                                                    •   Replacing a master
                                                    • master replacement
                        What Replication is for     • backup
                                                    • better reads

                        Gotchas, tips, and tricks

                                                    • What to read
                        More info
                                                    • More replication sessions
                                                                                          4

Tuesday, April 10, 12                                                                     4
www
                         $$$
                        The world today is
                        dominated by the
                         web economy
                                             5
Tuesday, April 10, 12                        5
www
                           $$$
                        Databases are
                         the backbone
                           of the web
                            economy
                                        6

Tuesday, April 10, 12                   6
What database for the web?




                                                     7

Tuesday, April 10, 12                                7
What database for the web?

                                                                                                                                             The most powerful database
     1   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
         reserved.




                                                                                                                                                                          7

Tuesday, April 10, 12                                                                                                                                                     7
What database for the web?

                                                                                                                                             The most powerful database
     1   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
         reserved.




                                                                                                                                             The most advanced open source
                                                                                                                                             database




                                                                                                                                                                             7

Tuesday, April 10, 12                                                                                                                                                        7
What database for the web?

                                                                                                                                             The most powerful database
     1   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
         reserved.




                                                                                                                                             The most advanced open source
                                                                                                                                             database

                                                                                                                                             The most deployed open source
                                                                                                                                             database



                                                                                                                                                                             7

Tuesday, April 10, 12                                                                                                                                                        7
What database for the web?

                                                                                                                                             The most powerful database
     1   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
         reserved.




                                                                                                                                             The most advanced open source
                                                                                                                                             database

                                                                                                                                             The most deployed open source
                                                                                                                                             database

                                                                                                                                             The most popular open source
                                                                                                                                             database
                                                                                                                                                                             7

Tuesday, April 10, 12                                                                                                                                                        7
www
                                 $$$
                          Actually, MySQL
                         databases are the
                        backbone of the web
                             economy
                                              8
Tuesday, April 10, 12                         8
What database for the web?

                                                                                                                                             No built-in replication
                                                                                                                                                                       ✗
                                                                                                                                                                       ✗
     1   Copyright © 2011, Oracle and/or its affiliates. All rights   Insert Information Protection Policy Classification from Slide 8
         reserved.




                                                                                                                                             No built-in replication


                                                                                                                                             No built-in replication
                                                                                                                                                                       ✗
                                                                                                                                             Built-in replication
                                                                                                                                                                       ✔
                                                                                                                                                                           9

Tuesday, April 10, 12                                                                                                                                                      9
www
                           $$$
               More precisely, MySQL
                REPLICATION is the
                backbone of the web
                     economy
                                  10

Tuesday, April 10, 12                  10
DA              Why replication
                                                    • The web economy
      EN                                            • Scaling out
   AG
                                                    • From single server to replication
                        How to set replication
                                                    • Adding a slave
                                                    •   Binary log formats
                        Using Replication           •   What gets replicated and how
                                                    •   Replication awareness
                                                    •   Monitoring
                                                    •   Log management
                        Managing replication
                                                    •   Replacing a slave
                                                    •   Replacing a master
                                                    • master replacement
                        What Replication is for     • backup
                                                    • better reads

                        Gotchas, tips, and tricks

                                                    • What to read
                        More info
                                                    • More replication sessions
                                                                                          11

Tuesday, April 10, 12                                                                     11
database server

                                                       a simple web
                                                        application
                                                          scheme

                         r/w requests



                                          web server




                                                 clients
                                                                      12
Tuesday, April 10, 12                                                 12
database server

                                                     scaling web
                                                      requests


                         r/w requests




                                                 web servers

                                          load balancer


                                               clients
                                                                   13
Tuesday, April 10, 12                                              13
database load
                                         on a simple
                                             web
                                         application
                                  r
                                  e
                          write   a
                                  d
                        85%       15%




                                                    14
Tuesday, April 10, 12                               14
write         read
                   20%          80%
                                        database load on a
                                         successful web
                                            application
                                                             15
Tuesday, April 10, 12                                        15
database server
                                                          scaling up
                                                         means buying
                                                           a bigger

             ✘           r/w requests
                                                          database
                                                            server




                                                 web servers

                                          load balancer


                                               clients
                                                                    16
Tuesday, April 10, 12                                                   16
write         read
                20%         80%



                                   the bigger database
                                   server will eventually
                                  have the same problem
                                                            17
Tuesday, April 10, 12                                       17
read/write
                          master                               a web
                                                             application
                                              read/only
                                                slaves
                                                            scheme with
                                                             replication
                                            load balancer
                        R/W


                                     R/O




                                             web servers

                                      load balancer


                                           clients
                                                                       18
Tuesday, April 10, 12                                                      18
r
                                     e
                           write     a          read
                                     d

                          85%      15%   100%
                        read/write
                          master

                                                       read/only
                                                         slaves



   database load
        with
     replication
                                                                   19
Tuesday, April 10, 12                                              19
r
                                     e
                           write     a          read
                                     d

                         85%       15%   100%
                        read/write
                          master

                                                       read/only
                                                         slaves


       scaling
   database load
        with
     replication
                                                                   20
Tuesday, April 10, 12                                              20
Replication assessment

                                        without replication     with replication

        database handling                     easy                  harder

               performance                    high            lower (binary logs)

   Point in Time recovery                     none                   easy

                        failover              none                 possible

               write scaling                  none                 minimal

                        backup           with downtime        without downtime

                read scaling                  none                   easy



                                                                                    21

Tuesday, April 10, 12                                                               21
DA              Why replication
                                                    • The web economy
      EN                                            • Scaling out
   AG
                                                    • From single server to replication
                        How to set replication
                                                    • Adding a slave
                                                    •   Binary log formats
                        Using Replication           •   What gets replicated and how
                                                    •   Replication awareness
                                                    •   Monitoring
                                                    •   Log management
                        Managing replication
                                                    •   Replacing a slave
                                                    •   Replacing a master
                                                    • master replacement
                        What Replication is for     • backup
                                                    • better reads

                        Gotchas, tips, and tricks

                                                    • What to read
                        More info
                                                    • More replication sessions
                                                                                          22

Tuesday, April 10, 12                                                                     22
client                                                         master
                                              transaction




                                                                          binary log




                                                    reads
                        slave
                                     IO thread




                                                              relay log                replication
                                                                                        concepts
                                 SQL thread                 reads
                                                                                                     23
Tuesday, April 10, 12                                                                                23
DA              Why replication
                                                    • The web economy
      EN                                            • Scaling out
   AG
                                                    • From single server to replication
                        How to set replication
                                                    • Adding a slave
                                                    •   Binary log formats
                        Using Replication           •   What gets replicated and how
                                                    •   Replication awareness
                                                    •   Monitoring
                                                    •   Log management
                        Managing replication
                                                    •   Replacing a slave
                                                    •   Replacing a master
                                                    • master replacement
                        What Replication is for     • backup
                                                    • better reads

                        Gotchas, tips, and tricks

                                                    • What to read
                        More info
                                                    • More replication sessions
                                                                                          24

Tuesday, April 10, 12                                                                     24
1                  SHUT DOWN THE DATABASE SERVER



                                  Master




                                                        25
Tuesday, April 10, 12                                   25
2                  MAKE A BACKUP COPY



                            Master




                                             26
Tuesday, April 10, 12                        26
3                          ENABLE THE MASTER



                                     Master



                               Configuration file
                        [mysqld]
                        log-bin=mysql-bin
                        server-id=1

                                                    27
Tuesday, April 10, 12                               27
4                  RESTART THE MASTER



                            Master




                                             28
Tuesday, April 10, 12                        28
5                       CREATE REPLICATION USER



                                    Master



                                  SQL command
                        GRANT REPLICATION SLAVE ON *.*
                        to 'slave_user@'10.10.100.%'
                        IDENTIFIED BY 'slave_pass';

                                                         29
Tuesday, April 10, 12                                    29
6                  INSTALL MySQL on the slave



                          Slave 1




Make sure that:
• You're using the same version of MySQL
• You have the same directory structure
• The server is not started yet

                                                     30
Tuesday, April 10, 12                                30
7                  COPY THE MASTER DATA to the slave



                                 Slave 1




                                                            31
Tuesday, April 10, 12                                       31
8                           ENABLE THE SLAVE



                                   Slave 1



                               Configuration file
                        [mysqld]
                        server-id=2
                        relay-log=mysql-relay
                        read-only
                        # optional:
                        log-bin=mysql-bin           32
Tuesday, April 10, 12                               32
9                  START THE SLAVE SERVER



                            Slave 1




                                                 33
Tuesday, April 10, 12                            33
10                          INITIALIZE THE SLAVE



                                  Slave 1



                                SQL command
                        SET MASTER TO
                        MASTER_HOST=master_IP,
                        MASTER_PORT=3306,
                        MASTER_USER=slave_user,
                        MASTER_PASSWORD='slave_pwd';
                                                       34
Tuesday, April 10, 12                                  34
11                       START THE SLAVE SERVICE



                                 Slave 1



                                SQL command
                        START SLAVE;




                                                      35
Tuesday, April 10, 12                                 35
12                          CHECK THE SLAVE



                                 Slave 1



                                SQL command
                        SHOW SLAVE STATUS G
                        ...
                         Slave_IO_Running: Yes
                        Slave_SQL_Running: Yes
                        ...
                                                 36
Tuesday, April 10, 12                            36
Troubleshooting

                 • SHOW SLAVE STATUS says
                   SLAVE_IO_RUNNING=No

                        • Make sure that the slave host can connect
                          to the master

                        • Make sure that master and slave have
                          different Server-id

                        • Check the error log of both master and
                          slave


                                                                      37

Tuesday, April 10, 12                                                 37
Testing the slave


                 • Create a table in the master.

                 • Make sure that the slave has replicated the
                   table.

                 • Insert data in the master

                 • read that data in the slave




                                                                 38

Tuesday, April 10, 12                                            38
What if the master was already logging?




                 • You have two options:

                        • Physical copy

                        • Logical copy




                                                           39

Tuesday, April 10, 12                                      39
Physical copy

                 • stop master

                 • make copy

                 • remove binary log files and index

                 • start master



                 • (alternative: use xtrabackup)


                                                      40

Tuesday, April 10, 12                                 40
Logical copy




                 • mysqldump --all-databases --master-data




                                                             41

Tuesday, April 10, 12                                        41
Common replication commands
                 • CHANGE MASTER TO

                 • SHOW MASTER STATUS

                 • SHOW SLAVE STATUS

                 • START SLAVE

                 • STOP SLAVE

                 • RESET MASTER (caution!)

                 • RESET SLAVE (caution!)

                                                      42

Tuesday, April 10, 12                                 42
CHANGE MASTER TO basic syntax
  STOP SLAVE;

  CHANGE MASTER TO
  MASTER_HOST='hostname', # or IP
  MASTER_PORT=3306,
  MASTER_USER='slaveuser',
  MASTER_PASSWORD='slavepassword',
  MASTER_LOG_FILE='filename', # default: first binlog
  MASTER_LOG_POS=123456; # default: from the beginning

  START SLAVE;




Tuesday, April 10, 12                                    43
DA              Why replication
                                                    • The web economy
      EN                                            • Scaling out
   AG
                                                    • From single server to replication
                        How to set replication
                                                    • Adding a slave
                                                    •   Binary log formats
                        Using Replication           •   What gets replicated and how
                                                    •   Replication awareness
                                                    •   Monitoring
                                                    •   Log management
                        Managing replication
                                                    •   Replacing a slave
                                                    •   Replacing a master
                                                    • master replacement
                        What Replication is for     • backup
                                                    • better reads

                        Gotchas, tips, and tricks

                                                    • What to read
                        More info
                                                    • More replication sessions
                                                                                          44

Tuesday, April 10, 12                                                                     44
1                  NO NEED TO STOP THE MASTER!



                                 Master




                                                      45
Tuesday, April 10, 12                                 45
2                  STOP THE SLAVE



                          Slave 1




               SQL command
       STOP SLAVE IO_THREAD;
       # wait until the SQL_THREAD
       # has done everything
       STOP SLAVE SQL_THREAD;
       # STOP THE SERVER
                                         46
Tuesday, April 10, 12                    46
3                  MAKE A COPY OF THE DATA DIRECTORY



                                  Slave 1




                                                            47
Tuesday, April 10, 12                                       47
4                  RESTART THE SLAVE



                          Slave 1




                                            48
Tuesday, April 10, 12                       48
5                  INSTALL MySQL on the new slave



                            Slave 2



  Make sure that:
  • You're using the same version of MySQL
  • You have the same directory structure
  • The server is not started yet

                                                         49
Tuesday, April 10, 12                                    49
6                  COPY THE old slave DATA on the slave



                                 Slave 2




                                                               50
Tuesday, April 10, 12                                          50
7                        ENABLE THE NEW SLAVE



                                    Slave 2



                               Configuration file
                                                   uni que!
                        [mysqld]
                                          mus t be
                        server-id=3
                        relay-log=mysql-relay
                        read-only
                        # optional:
                        log-bin=mysql-bin                     51
Tuesday, April 10, 12                                         51
8                  START THE NEW SLAVE



                          Slave 2




                                              52
Tuesday, April 10, 12                         52
9                         CHECK THE SLAVE



                                 Slave 2



                                SQL command
                        SHOW SLAVE STATUS G
                        ...
                         Slave_IO_Running: Yes
                        Slave_SQL_Running: Yes
                        ...
                                                 53
Tuesday, April 10, 12                            53
Why it works


                 • No need to issue a CHANGE MASTER TO
                   command.

                 • Because we cloned the old slave

                 • The new slave gets its parameters from
                   the .info files in the data directory




                                                            54

Tuesday, April 10, 12                                       54
Starting and stopping replication




Tuesday, April 10, 12                                       55
Starting and stopping replication
  START SLAVE;




Tuesday, April 10, 12                                       55
Starting and stopping replication
  START SLAVE;
  START SLAVE SQL_THREAD;




Tuesday, April 10, 12                                       55
Starting and stopping replication
  START SLAVE;
  START SLAVE SQL_THREAD;
  START SLAVE IO_THREAD;




Tuesday, April 10, 12                                       55
Starting and stopping replication
  START SLAVE;
  START SLAVE SQL_THREAD;
  START SLAVE IO_THREAD;
  START SLAVE UNTIL MASTER_LOG_FILE='filename',
  MASTER_LOG_POS=xxxx;




Tuesday, April 10, 12                                       55
Starting and stopping replication
  START SLAVE;
  START SLAVE SQL_THREAD;
  START SLAVE IO_THREAD;
  START SLAVE UNTIL MASTER_LOG_FILE='filename',
  MASTER_LOG_POS=xxxx;
  STOP SLAVE;




Tuesday, April 10, 12                                       55
Starting and stopping replication
  START SLAVE;
  START SLAVE SQL_THREAD;
  START SLAVE IO_THREAD;
  START SLAVE UNTIL MASTER_LOG_FILE='filename',
  MASTER_LOG_POS=xxxx;
  STOP SLAVE;
  STOP SLAVE SQL_THREAD;




Tuesday, April 10, 12                                       55
Starting and stopping replication
  START SLAVE;
  START SLAVE SQL_THREAD;
  START SLAVE IO_THREAD;
  START SLAVE UNTIL MASTER_LOG_FILE='filename',
  MASTER_LOG_POS=xxxx;
  STOP SLAVE;
  STOP SLAVE SQL_THREAD;
  STOP SLAVE IO_THREAD;




Tuesday, April 10, 12                                       55
DA
      EN                 Hijacking the agenda
   AG




                 • MySQL Sandbox




                                                56

Tuesday, April 10, 12                           56
MySQL Sandbox
                        http://mysqlsandbox.net
             • Free software (Perl under GPL)
             • One (unix) host
             • Many database servers
             • Single or multiple sandboxes
             • Customized scripts to use the servers
             • Standard or circular replication
             • Installs IN SECONDS
Tuesday, April 10, 12                                  57
overview

         MySQL                                        MySQL
         server                                       server
             Data       DB1                    Data       DB1




             DB2        DB3
                              DATA DIRECTORY   DB2        DB3




                                   PORT


                                   SOCKET

Tuesday, April 10, 12                                           58
overview

         MySQL                                              MySQL
         server                                             server
             Data       DB1
                                     SAME            Data       DB1




             DB2        DB3
                                     DATA            DB2        DB3

                                  DIRECTORY?
  /var/lib/mysql                               /var/lib/mysql




                              DATA CORRUPTION
Tuesday, April 10, 12                                                 59
overview

         MySQL                                      MySQL
         server                                     server

                                    SAME
                                   PORT or
                                   SOCKET?
                        3306                      3306


 /tmp/mysql.sock                             /tmp/mysql.sock

                               DOES NOT START
Tuesday, April 10, 12                                        60
The hard way




Tuesday, April 10, 12                  61
The hard way

   Read the manual




Tuesday, April 10, 12                  61
The hard way

                         try to figure out
   Read the manual
                         what to change




Tuesday, April 10, 12                       61
The hard way

                         try to figure out
   Read the manual                          Install
                         what to change




Tuesday, April 10, 12                                 61
The easy way

                         MySQL Sandbox


     $ make_sandbox 
         /path/to/mysql-5.1.54_linux.tar.gz

     # it should work always




Tuesday, April 10, 12                         62
The easier way

                        Prepare once        Install many times

  # some                               $ make_sandbox 5.1.54
  # preliminary
  # work




Tuesday, April 10, 12                                            63
The easiest way

                        Prepare once       Install many times

  # some
  # preliminary                        $ sb 5.1.54
  # work




Tuesday, April 10, 12                                           64
MySQL Sandbox
                                                      VERSION
                                             MySQL
                                             server
            Data        DB1




            DB2         DB3
                              $SANDBOX_HOME/msb_VERSION/data


                                                       VERSION


                                    /tmp/mysql_VERSION.sock

Tuesday, April 10, 12                                            65
MySQL Sandbox
                                                     5.1.54
                                            MySQL
                                            server
            Data        DB1




            DB2         DB3
                              $SANDBOX_HOME/msb_5_1_54/data


                                                        5154


                                      /tmp/mysql_5154.sock

Tuesday, April 10, 12                                          66
MySQL Sandbox
                                                     5.5.9
                                            MySQL
                                            server
            Data        DB1




            DB2         DB3
                              $SANDBOX_HOME/msb_5_5_09/data


                                                       5509


                                      /tmp/mysql_5509.sock

Tuesday, April 10, 12                                         67
Single Sandbox
              MySQL         customized scripts
              server


     start
     stop
    restart
    status
     clear
   send_kill
      use

Tuesday, April 10, 12                            68
Multiple Sandbox
             MySQL           customized scripts
             server


      start_all
      stop_all
     restart_all m n1
     status_all s1 n2
      clear_all  s2 n3
     send_kill_a
         ll
       use_all
Tuesday, April 10, 12                             69
Where do you get it


        •from CPAN
              sudo su -
              cpan MySQL::Sandbox

        •from launchpad
              http://launchpad.net/mysql-sandbox




Tuesday, April 10, 12                              70
The easy replication way

                               MySQL Sandbox

 $ make_replication_sandbox 
     /path/to/mysql-5.1.54_linux.tar.gz


               Prepare once             Install many times

    # some                      $ make_replication_sandbox
    # preparation               5.1.54


Tuesday, April 10, 12                                        71
default architecture
                                          $HOME




                             /sandboxes            opt
                                                               expanded
                                                                tarballs
                        $SANDBOX_HOME
                                                  mysql


                                             $SANDBOX_BINARY
           installed
          sandboxes

Tuesday, April 10, 12                                                      72
default architecture
                                                  $HOME



                                     /sandboxes            opt



                        msb_5_0_91
                                                          mysql
                        msb_5_1_48
                                                                  5.0.91
                        rsandbox_5_1_48
                                                                  5.1.45
                               master
                                                                  5.1.48
                               node1
                                                                  5.5.4
                               node2
Tuesday, April 10, 12                                                      73
Tuesday, April 10, 12   74
creating a single sanbox
                  make_sandbox 
                     /path/to/mysql-X.X.XX-OS.tar.gz




Tuesday, April 10, 12                                  75
using a single sanbox
                  # after
                  # make_sandbox 
                  #   /path/to/mysql-X.X.XX-OS.tar.gz

                  $ cd $SANDBOX_HOME/msb_X_X_XX
                  $ ./use




Tuesday, April 10, 12                                   76
creating a single sanbox
                        with a specific options file

                  make_sandbox 
                     /path/to/mysql-X.X.XX-OS.tar.gz 
                     --my_file=/path/to/my.cnf




Tuesday, April 10, 12                                    77
easily create a sandbox after the first
                       one
                        The long way
 $ cd $HOME/opt/mysql   # $SANDBOX_BINARY
 $   gunzip -c 
   /path/to/mysql-5.1.34-osx10.5-x86.tar.gz 
    | tar -xf -
 $ mv mysql-5.1.34-osx10.5-x86 5.1.34
 $ make sandbox 5.1.34




Tuesday, April 10, 12                           78
easily create a sandbox after the first
                       one
                        The short way
 $ make_sandbox 
   path/to/mysql-5.1.34-osx10.5-x86.tar.gz 
   --export_binaries




Tuesday, April 10, 12                          79
starting a single sanbox
                  $ cd $SANDBOX_HOME/msb_X_X_XX
                  $ ./start




Tuesday, April 10, 12                              80
starting a single sanbox
                        with temporary options
                  $ cd $SANDBOX_HOME/msb_X_X_XX
                  $ ./start --option=value


                  $ ./restart --option=value


                  $ ./start --key-buffer=20000000




Tuesday, April 10, 12                               81
creating a sandbox with custom port
                 and directory
                  $ make_sandbox 5.1.34 
                     --sandbox_port=7800 
                     --sandbox_directory=mickeymouse




Tuesday, April 10, 12                                  82
creating a sandbox with automatic
                      port checking
                  $ make_sandbox 5.1.34 --check_port


                  # if 5.1.34 is free
                  #    port=5134
                  #    directory=msb_5_1_34
                  # else
                  #    port=5135 (or the first free)
                  #    directory=msb_5_1_34_a




Tuesday, April 10, 12                                  83
create a replication sandbox


 $ make_replication_sandbox 
   path/to/mysql-5.1.34-osx10.5-x86.tar.gz




Tuesday, April 10, 12                                  84
create a circular replication sandbox


 $ make_replication_sandbox 
   --circular=4 
   path/to/mysql-5.1.34-osx10.5-x86.tar.gz




Tuesday, April 10, 12                          85
changing port to an existing sandbox


 $ sbtool -o port 
     -s /path/to/source/sandbox 
     --new_port=XXXX




Tuesday, April 10, 12                        86
installing the innodb plugin


 $ sbtool -o plugin 
     --plugin=innodb 
     -s /path/to/source/sandbox




Tuesday, April 10, 12                                  87
creating a replication sandbox with
                     new base port

 $ make_replication_sandbox 
     --replication_directory=newwdir 
     --check_base_port 5.0.79

 #       Creates a replication directory under
 #       $SANDBOX_HOME/newdir
 #       The previous one is preserved.
 #       No conflicts happen

Tuesday, April 10, 12                            88
DA
      EN                How to set up replication
   AG




                                DEMO



                                                    89

Tuesday, April 10, 12                               89
DA              Why replication
                                                    • The web economy
      EN                                            • Scaling out
   AG
                                                    • From single server to replication
                        How to set replication
                                                    • Adding a slave
                                                    •   Binary log formats
                        Using Replication           •   What gets replicated and how
                                                    •   Replication awareness
                                                    •   Monitoring
                                                    •   Log management
                        Managing replication
                                                    •   Replacing a slave
                                                    •   Replacing a master
                                                    • master replacement
                        What Replication is for     • backup
                                                    • better reads

                        Gotchas, tips, and tricks

                                                    • What to read
                        More info
                                                    • More replication sessions
                                                                                          90

Tuesday, April 10, 12                                                                     90
Binary log formats

                 • Statement based replication

                        • default

                        • available since 3.23

                 • Row based replication

                        • introduced in 5.1

                        • ROW or MIXED


                                                         91

Tuesday, April 10, 12                                    91
Viewing the binary logs
  # statement based replication

  $ mysqlbinlog binary-log-name

  # or, as a SQL command
  SHOW BINLOG EVENTS IN 'binary-log-name';

  # row based replication

  $ mysqlbinlog --verbose 
    --base64-output=decode-rows binary-log-name




Tuesday, April 10, 12                             92
binary log examples
  # statement based replication

  mysqlbinlog binary-log-name



  # row based replication

  mysqlbinlog --verbose 
    --base64-output=decode-rows binary-log-name




Tuesday, April 10, 12                             93
DA              Why replication
                                                    • The web economy
      EN                                            • Scaling out
   AG
                                                    • From single server to replication
                        How to set replication
                                                    • Adding a slave
                                                    •   Binary log formats
                        Using Replication           •   What gets replicated and how
                                                    •   Replication awareness
                                                    •   Monitoring
                                                    •   Log management
                        Managing replication
                                                    •   Replacing a slave
                                                    •   Replacing a master
                                                    • master replacement
                        What Replication is for     • backup
                                                    • better reads

                        Gotchas, tips, and tricks

                                                    • What to read
                        More info
                                                    • More replication sessions
                                                                                          94

Tuesday, April 10, 12                                                                     94
what gets replicated
                        What        Statement-based            row-based
      insert/update/delete             statement            affected records
        schema/table/view
                                       statement               statement
          creation/drop
     stored routine/trigger
                                       statement               statement
         creation/drop
                                  statements executed
     stored procedure call                                  affected records
                                         inside SP
        stored function call           function call        affected records
                                 none: the slave runs the   affected records
          trigger execution
                                         trigger          moved. No trigger runs
                                   slaveside disabled      slaveside disabled
             event creation
                                          event                   event
           event execution             statement            affected records
                                                                                   95

Tuesday, April 10, 12                                                              95
what gets replicated
                        What        Statement-based            row-based
      insert/update/delete             statement            affected records
        schema/table/view
                                       statement               statement
          creation/drop
     stored routine/trigger
                                       statement               statement
         creation/drop
                                  statements executed
     stored procedure call                                  affected records
                                         inside SP
        stored function call           function call        affected records
                                 none: the slave runs the   affected records
          trigger execution
                                         trigger          moved. No trigger runs
                                   slaveside disabled      slaveside disabled
             event creation
                                          event                   event
           event execution             statement            affected records
                                                                                   95

Tuesday, April 10, 12                                                              95
what gets replicated
                        What        Statement-based            row-based
      insert/update/delete             statement            affected records
        schema/table/view
                                       statement               statement
          creation/drop
     stored routine/trigger
                                       statement               statement
         creation/drop
                                  statements executed
     stored procedure call                                  affected records
                                         inside SP
        stored function call           function call        affected records
                                 none: the slave runs the   affected records
          trigger execution
                                         trigger          moved. No trigger runs
                                   slaveside disabled      slaveside disabled
             event creation
                                          event                   event
           event execution             statement            affected records
                                                                                   95

Tuesday, April 10, 12                                                              95
what gets replicated
                        What        Statement-based            row-based
      insert/update/delete             statement            affected records
        schema/table/view
                                       statement               statement
          creation/drop
     stored routine/trigger
                                       statement               statement
         creation/drop
                                  statements executed
     stored procedure call                                  affected records
                                         inside SP
        stored function call           function call        affected records
                                 none: the slave runs the   affected records
          trigger execution
                                         trigger          moved. No trigger runs
                                   slaveside disabled      slaveside disabled
             event creation
                                          event                   event
           event execution             statement            affected records
                                                                                   95

Tuesday, April 10, 12                                                              95
what gets replicated
                        What        Statement-based            row-based
      insert/update/delete             statement            affected records
        schema/table/view
                                       statement               statement
          creation/drop
     stored routine/trigger
                                       statement               statement
         creation/drop
                                  statements executed
     stored procedure call                                  affected records
                                         inside SP
        stored function call           function call        affected records
                                 none: the slave runs the   affected records
          trigger execution
                                         trigger          moved. No trigger runs
                                   slaveside disabled      slaveside disabled
             event creation
                                          event                   event
           event execution             statement            affected records
                                                                                   95

Tuesday, April 10, 12                                                              95
what gets replicated
                        What        Statement-based            row-based
      insert/update/delete             statement            affected records
        schema/table/view
                                       statement               statement
          creation/drop
     stored routine/trigger
                                       statement               statement
         creation/drop
                                  statements executed
     stored procedure call                                  affected records
                                         inside SP
        stored function call           function call        affected records
                                 none: the slave runs the   affected records
          trigger execution
                                         trigger          moved. No trigger runs
                                   slaveside disabled      slaveside disabled
             event creation
                                          event                   event
           event execution             statement            affected records
                                                                                   95

Tuesday, April 10, 12                                                              95
what gets replicated
                        What        Statement-based            row-based
      insert/update/delete             statement            affected records
        schema/table/view
                                       statement               statement
          creation/drop
     stored routine/trigger
                                       statement               statement
         creation/drop
                                  statements executed
     stored procedure call                                  affected records
                                         inside SP
        stored function call           function call        affected records
                                 none: the slave runs the   affected records
          trigger execution
                                         trigger          moved. No trigger runs
                                   slaveside disabled      slaveside disabled
             event creation
                                          event                   event
           event execution             statement            affected records
                                                                                   95

Tuesday, April 10, 12                                                              95
what gets replicated
                        What        Statement-based            row-based
      insert/update/delete             statement            affected records
        schema/table/view
                                       statement               statement
          creation/drop
     stored routine/trigger
                                       statement               statement
         creation/drop
                                  statements executed
     stored procedure call                                  affected records
                                         inside SP
        stored function call           function call        affected records
                                 none: the slave runs the   affected records
          trigger execution
                                         trigger          moved. No trigger runs
                                   slaveside disabled      slaveside disabled
             event creation
                                          event                   event
           event execution             statement            affected records
                                                                                   95

Tuesday, April 10, 12                                                              95
what gets replicated
                        What        Statement-based            row-based
      insert/update/delete             statement            affected records
        schema/table/view
                                       statement               statement
          creation/drop
     stored routine/trigger
                                       statement               statement
         creation/drop
                                  statements executed
     stored procedure call                                  affected records
                                         inside SP
        stored function call           function call        affected records
                                 none: the slave runs the   affected records
          trigger execution
                                         trigger          moved. No trigger runs
                                   slaveside disabled      slaveside disabled
             event creation
                                          event                   event
           event execution             statement            affected records
                                                                                   95

Tuesday, April 10, 12                                                              95
DA
      EN                Binary logs in practice
   AG




                               DEMO



                                                  96

Tuesday, April 10, 12                             96
DA              Why replication
                                                    • The web economy
      EN                                            • Scaling out
   AG
                                                    • From single server to replication
                        How to set replication
                                                    • Adding a slave
                                                    • Binary log formats
                        Using Replication           • What gets replicated and how
                                                    • Replication awareness
                                                    • Monitoring
                                                    • Log management
                        Managing replication
                                                    • Replacing a slave
                                                    • Replacing a master
                                                    • master replacement
                        What Replication is for     • backup
                                                    • better reads

                        Gotchas, tips, and tricks

                                                    • What to read
                        More info
                                                    • More replication sessions
                                                                                          97

Tuesday, April 10, 12                                                                     97
From single server application




                        r/w requests




                                               98
Tuesday, April 10, 12                          98
To replication-aware application
                        read/write
                          master


                                            read/only
                                              slaves




                        R/W
                                           load balancer
                                     R/O




                                                           99
Tuesday, April 10, 12                                      99
Single server application
       $link = mysql_connect(
        $server_IP, 
        'mysql_user', 
        'mysql_password'
     );
     $result = mysql_query(
     'INSERT INTO table_name (x) VALUES (1)',
     $link
     );
     $result = mysql_query(
     'SELECT * FROM table_name WHERE x=1',
     $link
     );
                                                    100
Tuesday, April 10, 12                               100
Making an application aware of
                    replication
                                            <<database handling>>
                                                     db
              <<R/W database
                handling>>                  IP
                                            user
                   db                       password

   IP                                       connect
   user
   password

   connect                       <<read-only database           <<R/W database
                                      handling>>                  handling>>
   read                                  db                          db
   write
                               IP                          IP
                               user                        user
                               password                    password
                               read                        connect
                                                           read
                                                           write


                                                                                 101
Tuesday, April 10, 12                                                            101
Using replication:
                        the WRONG way
                                   No
                                            Write     Yes
                                         statement?

                        Connect to the                 Connect to
                        next available                 the master
                            slave



                          Read from                   Write to the
                            slave                       master

      R/W split
          by                                Stop
      statement                                                      102
Tuesday, April 10, 12                                                102
Why statement split is wrong



                 • Breaks transactions

                 • High risk of inconsistency

                 • Loses or corrupts data




                                                       103

Tuesday, April 10, 12                                  103
Using replication:
                         the RIGHT way
                                        No
                                                 Write      Yes
                                               function?

                          Connect to the                    Connect to
                          next available                    the master
                              slave


                            Read from                      Read and write
                              slave                         from master



                              more           Yes               more
                             queries?                         queries?
                                                                            Yes



    R/W split                   No                                No

   by function                                     Stop
                                                                                  104
Tuesday, April 10, 12                                                             104
Replication is single threaded


                 • Let’s assume you have two queries on the
                   master

                 • one query takes 3 minutes to complete

                 • the other takes 5 minutes

                 • Both start at 12:00 noon




                                                              105

Tuesday, April 10, 12                                         105
Single thread replication

  MASTER




 12:00 12:01 12:02 12:03 12:04 12:05 12:06 12:07 12:08 12:09 12:10 12:11




 SLAVE

                                                                           106
Tuesday, April 10, 12                                                      106
Single thread replication

  MASTER
            QUERY 1

                        QUERY 2



 12:00 12:01 12:02 12:03 12:04 12:05 12:06 12:07 12:08 12:09 12:10 12:11



       (does nothing)

 SLAVE

                                                                           106
Tuesday, April 10, 12                                                      106
Single thread replication

  MASTER
            QUERY 1

                        QUERY 2



 12:00 12:01 12:02 12:03 12:04 12:05 12:06 12:07 12:08 12:09 12:10 12:11



       (does nothing)             QUERY 1

 SLAVE

                                                                           106
Tuesday, April 10, 12                                                      106
Single thread replication

  MASTER
            QUERY 1

                        QUERY 2



 12:00 12:01 12:02 12:03 12:04 12:05 12:06 12:07 12:08 12:09 12:10 12:11



       (does nothing)             QUERY 1      QUERY 2

 SLAVE

                                                                           106
Tuesday, April 10, 12                                                      106
Single thread replication

  MASTER
            QUERY 1                QUERY 3               QUERY 5

                        QUERY 2              QUERY 4             QUERY 6



 12:00 12:01 12:02 12:03 12:04 12:05 12:06 12:07 12:08 12:09 12:10 12:11



       does nothing               QUERY 1              QUERY 2

 SLAVE

                                                                           107
Tuesday, April 10, 12                                                      107
DA              Why replication
                                                    • The web economy
      EN                                            • Scaling out
   AG
                                                    • From single server to replication
                        How to set replication
                                                    • Adding a slave
                                                    •   Binary log formats
                        Using Replication           •   What gets replicated and how
                                                    •   Replication awareness
                                                    •   Monitoring
                                                    •   Log management
                        Managing replication
                                                    •   Replacing a slave
                                                    •   Replacing a master
                                                    • master replacement
                        What Replication is for     • backup
                                                    • better reads

                        Gotchas, tips, and tricks

                                                    • What to read
                        More info
                                                    • More replication sessions
                                                                                          108

Tuesday, April 10, 12                                                                     108
Sample                                     get slave
                                                status
   monitoring
                                                                             slave

                                               Running?        No



                                                  Yes
                         master
                                              Get master
                                              binlog and
                                               position




                                             Same or later
                                                                    No
                                      Yes
                                            binlog/position?

                        check table
                         contents
                                                                     alert           109
Tuesday, April 10, 12                                                                109
commands for checking replication
  master> SHOW MASTER STATUS
  master> SHOW PROCESSLIST


  slave> SHOW SLAVE STATUS
  slave> SHOW PROCESSLIST




Tuesday, April 10, 12                       110
replication user seen in the master
  master > show processlistG
  *************************** 1. row ***************
        Id: 2
     User: rsandbox
     Host: localhost:57011
        db: NULL
  Command: Binlog Dump
     Time: 81625
    State: Master has sent all binlog to slave; waiting
  for binlog to be updated
     Info: NULL
  [...]




Tuesday, April 10, 12                                     111
IO-thread in the slave
  slave > show processlistG
  *************************** 1. row ***************
        Id: 2
     User: system user
     Host:
        db: NULL
  Command: Connect
     Time: 124801
    State: Waiting for master to send event
     Info: NULL
  [...]




Tuesday, April 10, 12                                  112
SQL thread in the slave
  slave > show processlistG
  [...]
  *************************** 2. row ***************
        Id: 3
     User: system user
     Host:
        db: NULL
  Command: Connect
     Time: 124712
    State: Slave has read all relay log; waiting for the
  slave I/O thread to update it
     Info: NULL
  [...]



Tuesday, April 10, 12                                      113
monitoring replication
  master> SHOW MASTER STATUS


  slave> SHOW SLAVE STATUS



  FULL SCRIPTS:


  http://datacharmer.blogspot.com/2011/04/refactored-again-poor-mans-
  mysql.html


  http://forge.mysql.com/tools/tool.php?id=6




Tuesday, April 10, 12                                                   114
show master status
                            File: mysql-bin.000002
                        Position: 78045744
             Binlog_Do_DB:
  Binlog_Ignore_DB:




Tuesday, April 10, 12                                115
show slave status
                               Slave_IO_State: Waiting for master to send event
                                  Master_Host: 127.0.0.1
                                  Master_User: rsandbox
                                  Master_Port: 27371
                                Connect_Retry: 60
                              Master_Log_File: mysql-bin.000002
                          Read_Master_Log_Pos: 78045744
                               Relay_Log_File: mysql_sandbox27372-relay-bin.000055
                                Relay_Log_Pos: 78045889
                        Relay_Master_Log_File: mysql-bin.000002
                             Slave_IO_Running: Yes
                            Slave_SQL_Running: Yes




Tuesday, April 10, 12                                                                116
show slave status
     ...
                               Replicate_Do_DB:
                           Replicate_Ignore_DB:
                            Replicate_Do_Table:
                        Replicate_Ignore_Table:
                  Replicate_Wild_Do_Table:
        Replicate_Wild_Ignore_Table:
        ...




Tuesday, April 10, 12                                  117
show slave status
  ...
                                   Last_Errno: 0
                                   Last_Error:
                                 Skip_Counter: 0
                          Exec_Master_Log_Pos: 78045744
                              Relay_Log_Space: 78046100
  ...
                        Seconds_Behind_Master: 0
  ...
                                Last_IO_Errno: 0
                                Last_IO_Error:
                               Last_SQL_Errno: 0
                               Last_SQL_Error:




Tuesday, April 10, 12                                     118
DA
      EN                Breaking (and fixing) replication
   AG




                                   DEMO



                                                           119

Tuesday, April 10, 12                                      119
DA              Why replication
                                                    • The web economy
      EN                                            • Scaling out
   AG
                                                    • From single server to replication
                        How to set replication
                                                    • Adding a slave
                                                    •   Binary log formats
                        Using Replication           •   What gets replicated and how
                                                    •   Replication awareness
                                                    •   Monitoring
                                                    •   Log management
                        Managing replication
                                                    •   Replacing a slave
                                                    •   Replacing a master
                                                    • master replacement
                        What Replication is for     • backup
                                                    • better reads

                        Gotchas, tips, and tricks

                                                    • What to read
                        More info
                                                    • More replication sessions
                                                                                          120

Tuesday, April 10, 12                                                                     120
Logs rotation
  # server variables

  max-binlog-size
  expire-log-days

  # logs commands

  SHOW MASTER LOGS;
  PURGE MASTER LOGS TO 'filename';
  FLUSH [BINARY] LOGS;




Tuesday, April 10, 12                   121
DA              Why replication
                                                    • The web economy
      EN                                            • Scaling out
   AG
                                                    • From single server to replication
                        How to set replication
                                                    • Adding a slave
                                                    •   Binary log formats
                        Using Replication           •   What gets replicated and how
                                                    •   Replication awareness
                                                    •   Monitoring
                                                    •   Log management
                        Managing replication
                                                    •   Replacing a slave
                                                    •   Replacing a master
                                                    • master replacement
                        What Replication is for     • backup
                                                    • better reads

                        Gotchas, tips, and tricks

                                                    • What to read
                        More info
                                                    • More replication sessions
                                                                                          122

Tuesday, April 10, 12                                                                     122
Replacing                                    Slave
   a slave                                   crashe
                                                    s




                                       No
                                             are there     Yes
                                            more slaves?


                         STOP the
                          master                             STOP one
                                                               slave




                        add the first                       add another
                           slave                              slave


                                               Stop
                                                                         123
Tuesday, April 10, 12                                                    123
DA              Why replication
                                                    • The web economy
      EN                                            • Scaling out
   AG
                                                    • From single server to replication
                        How to set replication
                                                    • Adding a slave
                                                    •   Binary log formats
                        Using Replication           •   What gets replicated and how
                                                    •   Replication awareness
                                                    •   Monitoring
                                                    •   Log management
                        Managing replication
                                                    •   Replacing a slave
                                                    •   Replacing a master
                                                    • master replacement
                        What Replication is for     • backup
                                                    • better reads

                        Gotchas, tips, and tricks

                                                    • What to read
                        More info
                                                    • More replication sessions
                                                                                          124

Tuesday, April 10, 12                                                                     124
Replacing the                             Master
     master                                 crashe
                                                   s


                         Let all slaves
                         catch up with
                           execution               STOP
                                               replication in
                                                 all slaves



                          FIND the most                make it the
                         up to date slave               master



                           FIND which          run missing
                                                                      connect all
                        transactions are       transactions
                                                                     slaves to the
                          missing from           to other
                                                                     new master
                          other slaves            slaves


                                               Stop
                                                                                     125
Tuesday, April 10, 12                                                                125
Planned master switch


                        • Stop accepting writes
                        • Wait until all slaves have caught up
                        • Stop replication in all slaves
                        • Promote a slave to master
                        • Point all slaves to the new master

Tuesday, April 10, 12                                            126
Changing a failed master



                        • Pre-requisite:
                        • log_bin and log_slave_updates must be
                          enabled in all the slaves
                        • If not, there is more manual labor


Tuesday, April 10, 12                                             127
Changing a failed master (1)



                        • Wait until all slaves have caught up
                        • Identify the most advanced slave
                        • Make that slave the new master
                        • ... so far, so good


Tuesday, April 10, 12                                            128
Changing a failed master (2)
                        • For each remaining slave:
                        • Find the missing statements
                 •       Find the LAST statement replicated by the slave

                 •       Find the same statement in the new master
                         binlog (*)

                 •       get the position of the NEXT statement


                        (*) if log_slave_updates was not enabled, you
                        need to convert the relay log statements to SQL
                        and do the next step manually

Tuesday, April 10, 12                                                      129
Changing a failed master (3)


                        • For each remaining slave:
                        • Apply the missing statements
                         •   CHANGE MASTER TO
                             master_host=”new_master_hostname”,
                             master_port=new_master_port,
                             master_log_file=”mysql-bin.xxxxxx”,
                             master_log_pos=YYYY




Tuesday, April 10, 12                                              130
Reasons for complexity




                        • No global transaction ID



Tuesday, April 10, 12                                131
What is a global transaction ID


                        • A unique identifier of a transaction
                        • Unique for the whole cluster, not for each node
                        • Generated by the ultimate source (the master)
                        • Does not change when the transaction goes
                          through an intermediate master




Tuesday, April 10, 12                                                       132
Why should you care


                        • Failure recovery
                        • MySQL DOES NOT have it
                        • What can you do? Either wait for MySQL 5.6
                          or use Tungsten Replicator.




Tuesday, April 10, 12                                                  133
DA              Why replication
                                                    • The web economy
      EN                                            • Scaling out
   AG
                                                    • From single server to replication
                        How to set replication
                                                    • Adding a slave
                                                    •   Binary log formats
                        Using Replication           •   What gets replicated and how
                                                    •   Replication awareness
                                                    •   Monitoring
                                                    •   Log management
                        Managing replication
                                                    •   Replacing a slave
                                                    •   Replacing a master
                                                    • master replacement
                        What Replication is for     • backup
                                                    • better reads

                        Gotchas, tips, and tricks

                                                    • What to read
                        More info
                                                    • More replication sessions
                                                                                          134

Tuesday, April 10, 12                                                                     134
Slave = master replacement


                 • if:

                        • there are no filters;

                        • you are monitoring replication

                        • you make sure data is consistent




                                                             135

Tuesday, April 10, 12                                        135
Slave != backup
                 • There is no replacement for a good backup.

                 • Data loss due to a mistake in the master will
                   propagate to the slaves.

                 • Disasters are always smarter than
                   replication.

                 • Do your backups!

                 • Session on Wednesday at 12pm: "Be a Data
                   Management Hero with Good Backups!"

                                                                   136

Tuesday, April 10, 12                                              136
DA              Why replication
                                                    • The web economy
      EN                                            • Scaling out
   AG
                                                    • From single server to replication
                        How to set replication
                                                    • Adding a slave
                                                    •   Binary log formats
                        Using Replication           •   What gets replicated and how
                                                    •   Replication awareness
                                                    •   Monitoring
                                                    •   Log management
                        Managing replication
                                                    •   Replacing a slave
                                                    •   Replacing a master
                                                    • master replacement
                        What Replication is for     • backup
                                                    • better reads

                        Gotchas, tips, and tricks

                                                    • What to read
                        More info
                                                    • More replication sessions
                                                                                          137

Tuesday, April 10, 12                                                                     137
Replication
                                    =
                    let the slave do the dirty work



Tuesday, April 10, 12                                 138
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101
Replication 101

Contenu connexe

Tendances

The Dolphins Leap Again
The Dolphins Leap AgainThe Dolphins Leap Again
The Dolphins Leap AgainIvan Zoratti
 
MySQL High Availability and Disaster Recovery with Continuent, a VMware company
MySQL High Availability and Disaster Recovery with Continuent, a VMware companyMySQL High Availability and Disaster Recovery with Continuent, a VMware company
MySQL High Availability and Disaster Recovery with Continuent, a VMware companyContinuent
 
MySQL's new Secure by Default Install -- All Things Open October 20th 2015
MySQL's new Secure by Default Install -- All Things Open October 20th 2015MySQL's new Secure by Default Install -- All Things Open October 20th 2015
MySQL's new Secure by Default Install -- All Things Open October 20th 2015Dave Stokes
 
Ajuste (tuning) del rendimiento de SQL Server 2008
Ajuste (tuning) del rendimiento de SQL Server 2008Ajuste (tuning) del rendimiento de SQL Server 2008
Ajuste (tuning) del rendimiento de SQL Server 2008Eduardo Castro
 
What's New in MySQL 5.6
What's New in MySQL 5.6What's New in MySQL 5.6
What's New in MySQL 5.6Santo Leto
 
MySQL Cluster 8.0 tutorial text
MySQL Cluster 8.0 tutorial textMySQL Cluster 8.0 tutorial text
MySQL Cluster 8.0 tutorial textFrazer Clement
 
The History and Future of the MySQL ecosystem
The History and Future of the MySQL ecosystemThe History and Future of the MySQL ecosystem
The History and Future of the MySQL ecosystemRonald Bradford
 
Santo Leto - MySQL Connect 2012 - Getting Started with Mysql Cluster
Santo Leto - MySQL Connect 2012 - Getting Started with Mysql ClusterSanto Leto - MySQL Connect 2012 - Getting Started with Mysql Cluster
Santo Leto - MySQL Connect 2012 - Getting Started with Mysql ClusterSanto Leto
 
[INSIGHT OUT 2011] B12 better my sql security and administration(ronald)
[INSIGHT OUT 2011] B12 better my sql security and administration(ronald)[INSIGHT OUT 2011] B12 better my sql security and administration(ronald)
[INSIGHT OUT 2011] B12 better my sql security and administration(ronald)Insight Technology, Inc.
 
MySQL Backup and Recovery Essentials
MySQL Backup and Recovery EssentialsMySQL Backup and Recovery Essentials
MySQL Backup and Recovery EssentialsRonald Bradford
 

Tendances (13)

The Dolphins Leap Again
The Dolphins Leap AgainThe Dolphins Leap Again
The Dolphins Leap Again
 
MySQL High Availability and Disaster Recovery with Continuent, a VMware company
MySQL High Availability and Disaster Recovery with Continuent, a VMware companyMySQL High Availability and Disaster Recovery with Continuent, a VMware company
MySQL High Availability and Disaster Recovery with Continuent, a VMware company
 
MySQL's new Secure by Default Install -- All Things Open October 20th 2015
MySQL's new Secure by Default Install -- All Things Open October 20th 2015MySQL's new Secure by Default Install -- All Things Open October 20th 2015
MySQL's new Secure by Default Install -- All Things Open October 20th 2015
 
MySQL高可用
MySQL高可用MySQL高可用
MySQL高可用
 
Ajuste (tuning) del rendimiento de SQL Server 2008
Ajuste (tuning) del rendimiento de SQL Server 2008Ajuste (tuning) del rendimiento de SQL Server 2008
Ajuste (tuning) del rendimiento de SQL Server 2008
 
Introduction Mysql
Introduction Mysql Introduction Mysql
Introduction Mysql
 
Mysql tutorial 5257
Mysql tutorial 5257Mysql tutorial 5257
Mysql tutorial 5257
 
What's New in MySQL 5.6
What's New in MySQL 5.6What's New in MySQL 5.6
What's New in MySQL 5.6
 
MySQL Cluster 8.0 tutorial text
MySQL Cluster 8.0 tutorial textMySQL Cluster 8.0 tutorial text
MySQL Cluster 8.0 tutorial text
 
The History and Future of the MySQL ecosystem
The History and Future of the MySQL ecosystemThe History and Future of the MySQL ecosystem
The History and Future of the MySQL ecosystem
 
Santo Leto - MySQL Connect 2012 - Getting Started with Mysql Cluster
Santo Leto - MySQL Connect 2012 - Getting Started with Mysql ClusterSanto Leto - MySQL Connect 2012 - Getting Started with Mysql Cluster
Santo Leto - MySQL Connect 2012 - Getting Started with Mysql Cluster
 
[INSIGHT OUT 2011] B12 better my sql security and administration(ronald)
[INSIGHT OUT 2011] B12 better my sql security and administration(ronald)[INSIGHT OUT 2011] B12 better my sql security and administration(ronald)
[INSIGHT OUT 2011] B12 better my sql security and administration(ronald)
 
MySQL Backup and Recovery Essentials
MySQL Backup and Recovery EssentialsMySQL Backup and Recovery Essentials
MySQL Backup and Recovery Essentials
 

Similaire à Replication 101

MySQL 5.6 Updates
MySQL 5.6 UpdatesMySQL 5.6 Updates
MySQL 5.6 UpdatesDave Stokes
 
What Drove Wordnik Non-Relational?
What Drove Wordnik Non-Relational?What Drove Wordnik Non-Relational?
What Drove Wordnik Non-Relational?DATAVERSITY
 
A33 tips and best practice for db as by francisco alvarez
A33 tips and best practice for db as by francisco alvarezA33 tips and best practice for db as by francisco alvarez
A33 tips and best practice for db as by francisco alvarezInsight Technology, Inc.
 
Severalnines Self-Training: MySQL® Cluster - Part II
Severalnines Self-Training: MySQL® Cluster - Part IISeveralnines Self-Training: MySQL® Cluster - Part II
Severalnines Self-Training: MySQL® Cluster - Part IISeveralnines
 
Severalnines Self-Training: MySQL® Cluster - Part VIII
Severalnines Self-Training: MySQL® Cluster - Part VIIISeveralnines Self-Training: MySQL® Cluster - Part VIII
Severalnines Self-Training: MySQL® Cluster - Part VIIISeveralnines
 
My sql 5.6_replwebinar_may12
My sql 5.6_replwebinar_may12My sql 5.6_replwebinar_may12
My sql 5.6_replwebinar_may12Mat Keep
 
My sql 5.5_product_update
My sql 5.5_product_updateMy sql 5.5_product_update
My sql 5.5_product_updatehenriquesidney
 
Big data at CallFire
Big data at CallFireBig data at CallFire
Big data at CallFireVijesh Mehta
 
Inside Wordnik's Architecture
Inside Wordnik's ArchitectureInside Wordnik's Architecture
Inside Wordnik's ArchitectureTony Tam
 
Using multi tiered storage systems for storing both structured & unstructured...
Using multi tiered storage systems for storing both structured & unstructured...Using multi tiered storage systems for storing both structured & unstructured...
Using multi tiered storage systems for storing both structured & unstructured...ORACLE USER GROUP ESTONIA
 
My Site is slow - Drupal Camp London 2013
My Site is slow - Drupal Camp London 2013My Site is slow - Drupal Camp London 2013
My Site is slow - Drupal Camp London 2013hernanibf
 
Whats Cool in Java E 6
Whats Cool in Java E 6Whats Cool in Java E 6
Whats Cool in Java E 6Arun Gupta
 
Stathy DevOps in MSP / MKE on IAC
Stathy DevOps in MSP / MKE on IACStathy DevOps in MSP / MKE on IAC
Stathy DevOps in MSP / MKE on IACStathy Touloumis
 
Cómo construimos Oracle TimesTen
Cómo construimos Oracle TimesTenCómo construimos Oracle TimesTen
Cómo construimos Oracle TimesTenSoftware Guru
 
My site is slow
My site is slowMy site is slow
My site is slowhernanibf
 
Web frameworks don't matter
Web frameworks don't matterWeb frameworks don't matter
Web frameworks don't matterTomas Doran
 
Severalnines Self-Training: MySQL® Cluster - Part VII
Severalnines Self-Training: MySQL® Cluster - Part VIISeveralnines Self-Training: MySQL® Cluster - Part VII
Severalnines Self-Training: MySQL® Cluster - Part VIISeveralnines
 
SeaJUG May 2012 mybatis
SeaJUG May 2012 mybatisSeaJUG May 2012 mybatis
SeaJUG May 2012 mybatisWill Iverson
 
Bridging the Developer and the Datacenter
Bridging the Developer and the DatacenterBridging the Developer and the Datacenter
Bridging the Developer and the Datacenterlurs83
 

Similaire à Replication 101 (20)

MySQL 5.6 Updates
MySQL 5.6 UpdatesMySQL 5.6 Updates
MySQL 5.6 Updates
 
What Drove Wordnik Non-Relational?
What Drove Wordnik Non-Relational?What Drove Wordnik Non-Relational?
What Drove Wordnik Non-Relational?
 
A33 tips and best practice for db as by francisco alvarez
A33 tips and best practice for db as by francisco alvarezA33 tips and best practice for db as by francisco alvarez
A33 tips and best practice for db as by francisco alvarez
 
Severalnines Self-Training: MySQL® Cluster - Part II
Severalnines Self-Training: MySQL® Cluster - Part IISeveralnines Self-Training: MySQL® Cluster - Part II
Severalnines Self-Training: MySQL® Cluster - Part II
 
Severalnines Self-Training: MySQL® Cluster - Part VIII
Severalnines Self-Training: MySQL® Cluster - Part VIIISeveralnines Self-Training: MySQL® Cluster - Part VIII
Severalnines Self-Training: MySQL® Cluster - Part VIII
 
My sql 5.6_replwebinar_may12
My sql 5.6_replwebinar_may12My sql 5.6_replwebinar_may12
My sql 5.6_replwebinar_may12
 
My sql 5.5_product_update
My sql 5.5_product_updateMy sql 5.5_product_update
My sql 5.5_product_update
 
Big data at CallFire
Big data at CallFireBig data at CallFire
Big data at CallFire
 
Inside Wordnik's Architecture
Inside Wordnik's ArchitectureInside Wordnik's Architecture
Inside Wordnik's Architecture
 
Using multi tiered storage systems for storing both structured & unstructured...
Using multi tiered storage systems for storing both structured & unstructured...Using multi tiered storage systems for storing both structured & unstructured...
Using multi tiered storage systems for storing both structured & unstructured...
 
My Site is slow - Drupal Camp London 2013
My Site is slow - Drupal Camp London 2013My Site is slow - Drupal Camp London 2013
My Site is slow - Drupal Camp London 2013
 
Whats Cool in Java E 6
Whats Cool in Java E 6Whats Cool in Java E 6
Whats Cool in Java E 6
 
Stathy DevOps in MSP / MKE on IAC
Stathy DevOps in MSP / MKE on IACStathy DevOps in MSP / MKE on IAC
Stathy DevOps in MSP / MKE on IAC
 
Cómo construimos Oracle TimesTen
Cómo construimos Oracle TimesTenCómo construimos Oracle TimesTen
Cómo construimos Oracle TimesTen
 
My site is slow
My site is slowMy site is slow
My site is slow
 
Web frameworks don't matter
Web frameworks don't matterWeb frameworks don't matter
Web frameworks don't matter
 
Philly DB MapR Overview
Philly DB MapR OverviewPhilly DB MapR Overview
Philly DB MapR Overview
 
Severalnines Self-Training: MySQL® Cluster - Part VII
Severalnines Self-Training: MySQL® Cluster - Part VIISeveralnines Self-Training: MySQL® Cluster - Part VII
Severalnines Self-Training: MySQL® Cluster - Part VII
 
SeaJUG May 2012 mybatis
SeaJUG May 2012 mybatisSeaJUG May 2012 mybatis
SeaJUG May 2012 mybatis
 
Bridging the Developer and the Datacenter
Bridging the Developer and the DatacenterBridging the Developer and the Datacenter
Bridging the Developer and the Datacenter
 

Plus de Giuseppe Maxia

MySQL NDB 8.0 clusters in your laptop with dbdeployer
MySQL NDB 8.0 clusters in your laptop with dbdeployerMySQL NDB 8.0 clusters in your laptop with dbdeployer
MySQL NDB 8.0 clusters in your laptop with dbdeployerGiuseppe Maxia
 
Dbdeployer, the universal installer
Dbdeployer, the universal installerDbdeployer, the universal installer
Dbdeployer, the universal installerGiuseppe Maxia
 
Test complex database systems in your laptop with dbdeployer
Test complex database systems in your laptop with dbdeployerTest complex database systems in your laptop with dbdeployer
Test complex database systems in your laptop with dbdeployerGiuseppe Maxia
 
A quick tour of Mysql 8 roles
A quick tour of Mysql 8 rolesA quick tour of Mysql 8 roles
A quick tour of Mysql 8 rolesGiuseppe Maxia
 
Synchronise your data between MySQL and MongoDB
Synchronise your data between MySQL and MongoDBSynchronise your data between MySQL and MongoDB
Synchronise your data between MySQL and MongoDBGiuseppe Maxia
 
Juggle your data with Tungsten Replicator
Juggle your data with Tungsten ReplicatorJuggle your data with Tungsten Replicator
Juggle your data with Tungsten ReplicatorGiuseppe Maxia
 
Tungsten Replicator tutorial
Tungsten Replicator tutorialTungsten Replicator tutorial
Tungsten Replicator tutorialGiuseppe Maxia
 
Preventing multi master conflicts with tungsten
Preventing multi master conflicts with tungstenPreventing multi master conflicts with tungsten
Preventing multi master conflicts with tungstenGiuseppe Maxia
 
MySQL high availability power and usability
MySQL high availability power and usabilityMySQL high availability power and usability
MySQL high availability power and usabilityGiuseppe Maxia
 
Solving MySQL replication problems with Tungsten
Solving MySQL replication problems with TungstenSolving MySQL replication problems with Tungsten
Solving MySQL replication problems with TungstenGiuseppe Maxia
 
State of the art of MySQL replication and clustering
State of the art of MySQL replication and clusteringState of the art of MySQL replication and clustering
State of the art of MySQL replication and clusteringGiuseppe Maxia
 
Mysql 5.5 and 5.6 replication
Mysql 5.5 and 5.6 replicationMysql 5.5 and 5.6 replication
Mysql 5.5 and 5.6 replicationGiuseppe Maxia
 
Lightning talks percona live mysql_2012
Lightning talks percona live mysql_2012Lightning talks percona live mysql_2012
Lightning talks percona live mysql_2012Giuseppe Maxia
 

Plus de Giuseppe Maxia (20)

MySQL NDB 8.0 clusters in your laptop with dbdeployer
MySQL NDB 8.0 clusters in your laptop with dbdeployerMySQL NDB 8.0 clusters in your laptop with dbdeployer
MySQL NDB 8.0 clusters in your laptop with dbdeployer
 
Test like a_boss
Test like a_bossTest like a_boss
Test like a_boss
 
Dbdeployer, the universal installer
Dbdeployer, the universal installerDbdeployer, the universal installer
Dbdeployer, the universal installer
 
Test complex database systems in your laptop with dbdeployer
Test complex database systems in your laptop with dbdeployerTest complex database systems in your laptop with dbdeployer
Test complex database systems in your laptop with dbdeployer
 
Dbdeployer
DbdeployerDbdeployer
Dbdeployer
 
Dbdeployer
DbdeployerDbdeployer
Dbdeployer
 
A quick tour of Mysql 8 roles
A quick tour of Mysql 8 rolesA quick tour of Mysql 8 roles
A quick tour of Mysql 8 roles
 
MySQL document_store
MySQL document_storeMySQL document_store
MySQL document_store
 
Replication skeptic
Replication skepticReplication skeptic
Replication skeptic
 
Synchronise your data between MySQL and MongoDB
Synchronise your data between MySQL and MongoDBSynchronise your data between MySQL and MongoDB
Synchronise your data between MySQL and MongoDB
 
Juggle your data with Tungsten Replicator
Juggle your data with Tungsten ReplicatorJuggle your data with Tungsten Replicator
Juggle your data with Tungsten Replicator
 
MySQL in your laptop
MySQL in your laptopMySQL in your laptop
MySQL in your laptop
 
Script it
Script itScript it
Script it
 
Tungsten Replicator tutorial
Tungsten Replicator tutorialTungsten Replicator tutorial
Tungsten Replicator tutorial
 
Preventing multi master conflicts with tungsten
Preventing multi master conflicts with tungstenPreventing multi master conflicts with tungsten
Preventing multi master conflicts with tungsten
 
MySQL high availability power and usability
MySQL high availability power and usabilityMySQL high availability power and usability
MySQL high availability power and usability
 
Solving MySQL replication problems with Tungsten
Solving MySQL replication problems with TungstenSolving MySQL replication problems with Tungsten
Solving MySQL replication problems with Tungsten
 
State of the art of MySQL replication and clustering
State of the art of MySQL replication and clusteringState of the art of MySQL replication and clustering
State of the art of MySQL replication and clustering
 
Mysql 5.5 and 5.6 replication
Mysql 5.5 and 5.6 replicationMysql 5.5 and 5.6 replication
Mysql 5.5 and 5.6 replication
 
Lightning talks percona live mysql_2012
Lightning talks percona live mysql_2012Lightning talks percona live mysql_2012
Lightning talks percona live mysql_2012
 

Dernier

Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 

Dernier (20)

Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 

Replication 101

  • 1. MySQL Replication 101 Giuseppe Maxia Continuent, Inc ©Continuent 2012. Tuesday, April 10, 12 1
  • 2. about me - Giuseppe Maxia • a.k.a. The Data Charmer • QA Director at Continuent, Inc • Long time hacking with MySQL features • Formerly, community manager,db consultant, designer, coder. • A passion for QA and open source • Blogger • http://datacharmer.blogspot.com Tuesday, April 10, 12 2
  • 3. DA Why replication • The web economy EN • Scaling out AG • From single server to replication How to set replication • Adding a slave • Binary log formats Using Replication • What gets replicated and how • Replication awareness • Monitoring • Log management Managing replication • Replacing a slave • Replacing a master • master replacement What Replication is for • backup • better reads Gotchas, tips, and tricks • What to read More info • More replication sessions 3 Tuesday, April 10, 12 3
  • 4. DA Why replication • The web economy EN • Scaling out AG • From single server to replication How to set replication • Adding a slave • Binary log formats Using Replication • What gets replicated and how • Replication awareness • Monitoring • Log management Managing replication • Replacing a slave • Replacing a master • master replacement What Replication is for • backup • better reads Gotchas, tips, and tricks • What to read More info • More replication sessions 4 Tuesday, April 10, 12 4
  • 5. www $$$ The world today is dominated by the web economy 5 Tuesday, April 10, 12 5
  • 6. www $$$ Databases are the backbone of the web economy 6 Tuesday, April 10, 12 6
  • 7. What database for the web? 7 Tuesday, April 10, 12 7
  • 8. What database for the web? The most powerful database 1 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved. 7 Tuesday, April 10, 12 7
  • 9. What database for the web? The most powerful database 1 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved. The most advanced open source database 7 Tuesday, April 10, 12 7
  • 10. What database for the web? The most powerful database 1 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved. The most advanced open source database The most deployed open source database 7 Tuesday, April 10, 12 7
  • 11. What database for the web? The most powerful database 1 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved. The most advanced open source database The most deployed open source database The most popular open source database 7 Tuesday, April 10, 12 7
  • 12. www $$$ Actually, MySQL databases are the backbone of the web economy 8 Tuesday, April 10, 12 8
  • 13. What database for the web? No built-in replication ✗ ✗ 1 Copyright © 2011, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 reserved. No built-in replication No built-in replication ✗ Built-in replication ✔ 9 Tuesday, April 10, 12 9
  • 14. www $$$ More precisely, MySQL REPLICATION is the backbone of the web economy 10 Tuesday, April 10, 12 10
  • 15. DA Why replication • The web economy EN • Scaling out AG • From single server to replication How to set replication • Adding a slave • Binary log formats Using Replication • What gets replicated and how • Replication awareness • Monitoring • Log management Managing replication • Replacing a slave • Replacing a master • master replacement What Replication is for • backup • better reads Gotchas, tips, and tricks • What to read More info • More replication sessions 11 Tuesday, April 10, 12 11
  • 16. database server a simple web application scheme r/w requests web server clients 12 Tuesday, April 10, 12 12
  • 17. database server scaling web requests r/w requests web servers load balancer clients 13 Tuesday, April 10, 12 13
  • 18. database load on a simple web application r e write a d 85% 15% 14 Tuesday, April 10, 12 14
  • 19. write read 20% 80% database load on a successful web application 15 Tuesday, April 10, 12 15
  • 20. database server scaling up means buying a bigger ✘ r/w requests database server web servers load balancer clients 16 Tuesday, April 10, 12 16
  • 21. write read 20% 80% the bigger database server will eventually have the same problem 17 Tuesday, April 10, 12 17
  • 22. read/write master a web application read/only slaves scheme with replication load balancer R/W R/O web servers load balancer clients 18 Tuesday, April 10, 12 18
  • 23. r e write a read d 85% 15% 100% read/write master read/only slaves database load with replication 19 Tuesday, April 10, 12 19
  • 24. r e write a read d 85% 15% 100% read/write master read/only slaves scaling database load with replication 20 Tuesday, April 10, 12 20
  • 25. Replication assessment without replication with replication database handling easy harder performance high lower (binary logs) Point in Time recovery none easy failover none possible write scaling none minimal backup with downtime without downtime read scaling none easy 21 Tuesday, April 10, 12 21
  • 26. DA Why replication • The web economy EN • Scaling out AG • From single server to replication How to set replication • Adding a slave • Binary log formats Using Replication • What gets replicated and how • Replication awareness • Monitoring • Log management Managing replication • Replacing a slave • Replacing a master • master replacement What Replication is for • backup • better reads Gotchas, tips, and tricks • What to read More info • More replication sessions 22 Tuesday, April 10, 12 22
  • 27. client master transaction binary log reads slave IO thread relay log replication concepts SQL thread reads 23 Tuesday, April 10, 12 23
  • 28. DA Why replication • The web economy EN • Scaling out AG • From single server to replication How to set replication • Adding a slave • Binary log formats Using Replication • What gets replicated and how • Replication awareness • Monitoring • Log management Managing replication • Replacing a slave • Replacing a master • master replacement What Replication is for • backup • better reads Gotchas, tips, and tricks • What to read More info • More replication sessions 24 Tuesday, April 10, 12 24
  • 29. 1 SHUT DOWN THE DATABASE SERVER Master 25 Tuesday, April 10, 12 25
  • 30. 2 MAKE A BACKUP COPY Master 26 Tuesday, April 10, 12 26
  • 31. 3 ENABLE THE MASTER Master Configuration file [mysqld] log-bin=mysql-bin server-id=1 27 Tuesday, April 10, 12 27
  • 32. 4 RESTART THE MASTER Master 28 Tuesday, April 10, 12 28
  • 33. 5 CREATE REPLICATION USER Master SQL command GRANT REPLICATION SLAVE ON *.* to 'slave_user@'10.10.100.%' IDENTIFIED BY 'slave_pass'; 29 Tuesday, April 10, 12 29
  • 34. 6 INSTALL MySQL on the slave Slave 1 Make sure that: • You're using the same version of MySQL • You have the same directory structure • The server is not started yet 30 Tuesday, April 10, 12 30
  • 35. 7 COPY THE MASTER DATA to the slave Slave 1 31 Tuesday, April 10, 12 31
  • 36. 8 ENABLE THE SLAVE Slave 1 Configuration file [mysqld] server-id=2 relay-log=mysql-relay read-only # optional: log-bin=mysql-bin 32 Tuesday, April 10, 12 32
  • 37. 9 START THE SLAVE SERVER Slave 1 33 Tuesday, April 10, 12 33
  • 38. 10 INITIALIZE THE SLAVE Slave 1 SQL command SET MASTER TO MASTER_HOST=master_IP, MASTER_PORT=3306, MASTER_USER=slave_user, MASTER_PASSWORD='slave_pwd'; 34 Tuesday, April 10, 12 34
  • 39. 11 START THE SLAVE SERVICE Slave 1 SQL command START SLAVE; 35 Tuesday, April 10, 12 35
  • 40. 12 CHECK THE SLAVE Slave 1 SQL command SHOW SLAVE STATUS G ... Slave_IO_Running: Yes Slave_SQL_Running: Yes ... 36 Tuesday, April 10, 12 36
  • 41. Troubleshooting • SHOW SLAVE STATUS says SLAVE_IO_RUNNING=No • Make sure that the slave host can connect to the master • Make sure that master and slave have different Server-id • Check the error log of both master and slave 37 Tuesday, April 10, 12 37
  • 42. Testing the slave • Create a table in the master. • Make sure that the slave has replicated the table. • Insert data in the master • read that data in the slave 38 Tuesday, April 10, 12 38
  • 43. What if the master was already logging? • You have two options: • Physical copy • Logical copy 39 Tuesday, April 10, 12 39
  • 44. Physical copy • stop master • make copy • remove binary log files and index • start master • (alternative: use xtrabackup) 40 Tuesday, April 10, 12 40
  • 45. Logical copy • mysqldump --all-databases --master-data 41 Tuesday, April 10, 12 41
  • 46. Common replication commands • CHANGE MASTER TO • SHOW MASTER STATUS • SHOW SLAVE STATUS • START SLAVE • STOP SLAVE • RESET MASTER (caution!) • RESET SLAVE (caution!) 42 Tuesday, April 10, 12 42
  • 47. CHANGE MASTER TO basic syntax STOP SLAVE; CHANGE MASTER TO MASTER_HOST='hostname', # or IP MASTER_PORT=3306, MASTER_USER='slaveuser', MASTER_PASSWORD='slavepassword', MASTER_LOG_FILE='filename', # default: first binlog MASTER_LOG_POS=123456; # default: from the beginning START SLAVE; Tuesday, April 10, 12 43
  • 48. DA Why replication • The web economy EN • Scaling out AG • From single server to replication How to set replication • Adding a slave • Binary log formats Using Replication • What gets replicated and how • Replication awareness • Monitoring • Log management Managing replication • Replacing a slave • Replacing a master • master replacement What Replication is for • backup • better reads Gotchas, tips, and tricks • What to read More info • More replication sessions 44 Tuesday, April 10, 12 44
  • 49. 1 NO NEED TO STOP THE MASTER! Master 45 Tuesday, April 10, 12 45
  • 50. 2 STOP THE SLAVE Slave 1 SQL command STOP SLAVE IO_THREAD; # wait until the SQL_THREAD # has done everything STOP SLAVE SQL_THREAD; # STOP THE SERVER 46 Tuesday, April 10, 12 46
  • 51. 3 MAKE A COPY OF THE DATA DIRECTORY Slave 1 47 Tuesday, April 10, 12 47
  • 52. 4 RESTART THE SLAVE Slave 1 48 Tuesday, April 10, 12 48
  • 53. 5 INSTALL MySQL on the new slave Slave 2 Make sure that: • You're using the same version of MySQL • You have the same directory structure • The server is not started yet 49 Tuesday, April 10, 12 49
  • 54. 6 COPY THE old slave DATA on the slave Slave 2 50 Tuesday, April 10, 12 50
  • 55. 7 ENABLE THE NEW SLAVE Slave 2 Configuration file uni que! [mysqld] mus t be server-id=3 relay-log=mysql-relay read-only # optional: log-bin=mysql-bin 51 Tuesday, April 10, 12 51
  • 56. 8 START THE NEW SLAVE Slave 2 52 Tuesday, April 10, 12 52
  • 57. 9 CHECK THE SLAVE Slave 2 SQL command SHOW SLAVE STATUS G ... Slave_IO_Running: Yes Slave_SQL_Running: Yes ... 53 Tuesday, April 10, 12 53
  • 58. Why it works • No need to issue a CHANGE MASTER TO command. • Because we cloned the old slave • The new slave gets its parameters from the .info files in the data directory 54 Tuesday, April 10, 12 54
  • 59. Starting and stopping replication Tuesday, April 10, 12 55
  • 60. Starting and stopping replication START SLAVE; Tuesday, April 10, 12 55
  • 61. Starting and stopping replication START SLAVE; START SLAVE SQL_THREAD; Tuesday, April 10, 12 55
  • 62. Starting and stopping replication START SLAVE; START SLAVE SQL_THREAD; START SLAVE IO_THREAD; Tuesday, April 10, 12 55
  • 63. Starting and stopping replication START SLAVE; START SLAVE SQL_THREAD; START SLAVE IO_THREAD; START SLAVE UNTIL MASTER_LOG_FILE='filename', MASTER_LOG_POS=xxxx; Tuesday, April 10, 12 55
  • 64. Starting and stopping replication START SLAVE; START SLAVE SQL_THREAD; START SLAVE IO_THREAD; START SLAVE UNTIL MASTER_LOG_FILE='filename', MASTER_LOG_POS=xxxx; STOP SLAVE; Tuesday, April 10, 12 55
  • 65. Starting and stopping replication START SLAVE; START SLAVE SQL_THREAD; START SLAVE IO_THREAD; START SLAVE UNTIL MASTER_LOG_FILE='filename', MASTER_LOG_POS=xxxx; STOP SLAVE; STOP SLAVE SQL_THREAD; Tuesday, April 10, 12 55
  • 66. Starting and stopping replication START SLAVE; START SLAVE SQL_THREAD; START SLAVE IO_THREAD; START SLAVE UNTIL MASTER_LOG_FILE='filename', MASTER_LOG_POS=xxxx; STOP SLAVE; STOP SLAVE SQL_THREAD; STOP SLAVE IO_THREAD; Tuesday, April 10, 12 55
  • 67. DA EN Hijacking the agenda AG • MySQL Sandbox 56 Tuesday, April 10, 12 56
  • 68. MySQL Sandbox http://mysqlsandbox.net • Free software (Perl under GPL) • One (unix) host • Many database servers • Single or multiple sandboxes • Customized scripts to use the servers • Standard or circular replication • Installs IN SECONDS Tuesday, April 10, 12 57
  • 69. overview MySQL MySQL server server Data DB1 Data DB1 DB2 DB3 DATA DIRECTORY DB2 DB3 PORT SOCKET Tuesday, April 10, 12 58
  • 70. overview MySQL MySQL server server Data DB1 SAME Data DB1 DB2 DB3 DATA DB2 DB3 DIRECTORY? /var/lib/mysql /var/lib/mysql DATA CORRUPTION Tuesday, April 10, 12 59
  • 71. overview MySQL MySQL server server SAME PORT or SOCKET? 3306 3306 /tmp/mysql.sock /tmp/mysql.sock DOES NOT START Tuesday, April 10, 12 60
  • 72. The hard way Tuesday, April 10, 12 61
  • 73. The hard way Read the manual Tuesday, April 10, 12 61
  • 74. The hard way try to figure out Read the manual what to change Tuesday, April 10, 12 61
  • 75. The hard way try to figure out Read the manual Install what to change Tuesday, April 10, 12 61
  • 76. The easy way MySQL Sandbox $ make_sandbox /path/to/mysql-5.1.54_linux.tar.gz # it should work always Tuesday, April 10, 12 62
  • 77. The easier way Prepare once Install many times # some $ make_sandbox 5.1.54 # preliminary # work Tuesday, April 10, 12 63
  • 78. The easiest way Prepare once Install many times # some # preliminary $ sb 5.1.54 # work Tuesday, April 10, 12 64
  • 79. MySQL Sandbox VERSION MySQL server Data DB1 DB2 DB3 $SANDBOX_HOME/msb_VERSION/data VERSION /tmp/mysql_VERSION.sock Tuesday, April 10, 12 65
  • 80. MySQL Sandbox 5.1.54 MySQL server Data DB1 DB2 DB3 $SANDBOX_HOME/msb_5_1_54/data 5154 /tmp/mysql_5154.sock Tuesday, April 10, 12 66
  • 81. MySQL Sandbox 5.5.9 MySQL server Data DB1 DB2 DB3 $SANDBOX_HOME/msb_5_5_09/data 5509 /tmp/mysql_5509.sock Tuesday, April 10, 12 67
  • 82. Single Sandbox MySQL customized scripts server start stop restart status clear send_kill use Tuesday, April 10, 12 68
  • 83. Multiple Sandbox MySQL customized scripts server start_all stop_all restart_all m n1 status_all s1 n2 clear_all s2 n3 send_kill_a ll use_all Tuesday, April 10, 12 69
  • 84. Where do you get it •from CPAN sudo su - cpan MySQL::Sandbox •from launchpad http://launchpad.net/mysql-sandbox Tuesday, April 10, 12 70
  • 85. The easy replication way MySQL Sandbox $ make_replication_sandbox /path/to/mysql-5.1.54_linux.tar.gz Prepare once Install many times # some $ make_replication_sandbox # preparation 5.1.54 Tuesday, April 10, 12 71
  • 86. default architecture $HOME /sandboxes opt expanded tarballs $SANDBOX_HOME mysql $SANDBOX_BINARY installed sandboxes Tuesday, April 10, 12 72
  • 87. default architecture $HOME /sandboxes opt msb_5_0_91 mysql msb_5_1_48 5.0.91 rsandbox_5_1_48 5.1.45 master 5.1.48 node1 5.5.4 node2 Tuesday, April 10, 12 73
  • 89. creating a single sanbox make_sandbox /path/to/mysql-X.X.XX-OS.tar.gz Tuesday, April 10, 12 75
  • 90. using a single sanbox # after # make_sandbox # /path/to/mysql-X.X.XX-OS.tar.gz $ cd $SANDBOX_HOME/msb_X_X_XX $ ./use Tuesday, April 10, 12 76
  • 91. creating a single sanbox with a specific options file make_sandbox /path/to/mysql-X.X.XX-OS.tar.gz --my_file=/path/to/my.cnf Tuesday, April 10, 12 77
  • 92. easily create a sandbox after the first one The long way $ cd $HOME/opt/mysql # $SANDBOX_BINARY $ gunzip -c /path/to/mysql-5.1.34-osx10.5-x86.tar.gz | tar -xf - $ mv mysql-5.1.34-osx10.5-x86 5.1.34 $ make sandbox 5.1.34 Tuesday, April 10, 12 78
  • 93. easily create a sandbox after the first one The short way $ make_sandbox path/to/mysql-5.1.34-osx10.5-x86.tar.gz --export_binaries Tuesday, April 10, 12 79
  • 94. starting a single sanbox $ cd $SANDBOX_HOME/msb_X_X_XX $ ./start Tuesday, April 10, 12 80
  • 95. starting a single sanbox with temporary options $ cd $SANDBOX_HOME/msb_X_X_XX $ ./start --option=value $ ./restart --option=value $ ./start --key-buffer=20000000 Tuesday, April 10, 12 81
  • 96. creating a sandbox with custom port and directory $ make_sandbox 5.1.34 --sandbox_port=7800 --sandbox_directory=mickeymouse Tuesday, April 10, 12 82
  • 97. creating a sandbox with automatic port checking $ make_sandbox 5.1.34 --check_port # if 5.1.34 is free # port=5134 # directory=msb_5_1_34 # else # port=5135 (or the first free) # directory=msb_5_1_34_a Tuesday, April 10, 12 83
  • 98. create a replication sandbox $ make_replication_sandbox path/to/mysql-5.1.34-osx10.5-x86.tar.gz Tuesday, April 10, 12 84
  • 99. create a circular replication sandbox $ make_replication_sandbox --circular=4 path/to/mysql-5.1.34-osx10.5-x86.tar.gz Tuesday, April 10, 12 85
  • 100. changing port to an existing sandbox $ sbtool -o port -s /path/to/source/sandbox --new_port=XXXX Tuesday, April 10, 12 86
  • 101. installing the innodb plugin $ sbtool -o plugin --plugin=innodb -s /path/to/source/sandbox Tuesday, April 10, 12 87
  • 102. creating a replication sandbox with new base port $ make_replication_sandbox --replication_directory=newwdir --check_base_port 5.0.79 # Creates a replication directory under # $SANDBOX_HOME/newdir # The previous one is preserved. # No conflicts happen Tuesday, April 10, 12 88
  • 103. DA EN How to set up replication AG DEMO 89 Tuesday, April 10, 12 89
  • 104. DA Why replication • The web economy EN • Scaling out AG • From single server to replication How to set replication • Adding a slave • Binary log formats Using Replication • What gets replicated and how • Replication awareness • Monitoring • Log management Managing replication • Replacing a slave • Replacing a master • master replacement What Replication is for • backup • better reads Gotchas, tips, and tricks • What to read More info • More replication sessions 90 Tuesday, April 10, 12 90
  • 105. Binary log formats • Statement based replication • default • available since 3.23 • Row based replication • introduced in 5.1 • ROW or MIXED 91 Tuesday, April 10, 12 91
  • 106. Viewing the binary logs # statement based replication $ mysqlbinlog binary-log-name # or, as a SQL command SHOW BINLOG EVENTS IN 'binary-log-name'; # row based replication $ mysqlbinlog --verbose --base64-output=decode-rows binary-log-name Tuesday, April 10, 12 92
  • 107. binary log examples # statement based replication mysqlbinlog binary-log-name # row based replication mysqlbinlog --verbose --base64-output=decode-rows binary-log-name Tuesday, April 10, 12 93
  • 108. DA Why replication • The web economy EN • Scaling out AG • From single server to replication How to set replication • Adding a slave • Binary log formats Using Replication • What gets replicated and how • Replication awareness • Monitoring • Log management Managing replication • Replacing a slave • Replacing a master • master replacement What Replication is for • backup • better reads Gotchas, tips, and tricks • What to read More info • More replication sessions 94 Tuesday, April 10, 12 94
  • 109. what gets replicated What Statement-based row-based insert/update/delete statement affected records schema/table/view statement statement creation/drop stored routine/trigger statement statement creation/drop statements executed stored procedure call affected records inside SP stored function call function call affected records none: the slave runs the affected records trigger execution trigger moved. No trigger runs slaveside disabled slaveside disabled event creation event event event execution statement affected records 95 Tuesday, April 10, 12 95
  • 110. what gets replicated What Statement-based row-based insert/update/delete statement affected records schema/table/view statement statement creation/drop stored routine/trigger statement statement creation/drop statements executed stored procedure call affected records inside SP stored function call function call affected records none: the slave runs the affected records trigger execution trigger moved. No trigger runs slaveside disabled slaveside disabled event creation event event event execution statement affected records 95 Tuesday, April 10, 12 95
  • 111. what gets replicated What Statement-based row-based insert/update/delete statement affected records schema/table/view statement statement creation/drop stored routine/trigger statement statement creation/drop statements executed stored procedure call affected records inside SP stored function call function call affected records none: the slave runs the affected records trigger execution trigger moved. No trigger runs slaveside disabled slaveside disabled event creation event event event execution statement affected records 95 Tuesday, April 10, 12 95
  • 112. what gets replicated What Statement-based row-based insert/update/delete statement affected records schema/table/view statement statement creation/drop stored routine/trigger statement statement creation/drop statements executed stored procedure call affected records inside SP stored function call function call affected records none: the slave runs the affected records trigger execution trigger moved. No trigger runs slaveside disabled slaveside disabled event creation event event event execution statement affected records 95 Tuesday, April 10, 12 95
  • 113. what gets replicated What Statement-based row-based insert/update/delete statement affected records schema/table/view statement statement creation/drop stored routine/trigger statement statement creation/drop statements executed stored procedure call affected records inside SP stored function call function call affected records none: the slave runs the affected records trigger execution trigger moved. No trigger runs slaveside disabled slaveside disabled event creation event event event execution statement affected records 95 Tuesday, April 10, 12 95
  • 114. what gets replicated What Statement-based row-based insert/update/delete statement affected records schema/table/view statement statement creation/drop stored routine/trigger statement statement creation/drop statements executed stored procedure call affected records inside SP stored function call function call affected records none: the slave runs the affected records trigger execution trigger moved. No trigger runs slaveside disabled slaveside disabled event creation event event event execution statement affected records 95 Tuesday, April 10, 12 95
  • 115. what gets replicated What Statement-based row-based insert/update/delete statement affected records schema/table/view statement statement creation/drop stored routine/trigger statement statement creation/drop statements executed stored procedure call affected records inside SP stored function call function call affected records none: the slave runs the affected records trigger execution trigger moved. No trigger runs slaveside disabled slaveside disabled event creation event event event execution statement affected records 95 Tuesday, April 10, 12 95
  • 116. what gets replicated What Statement-based row-based insert/update/delete statement affected records schema/table/view statement statement creation/drop stored routine/trigger statement statement creation/drop statements executed stored procedure call affected records inside SP stored function call function call affected records none: the slave runs the affected records trigger execution trigger moved. No trigger runs slaveside disabled slaveside disabled event creation event event event execution statement affected records 95 Tuesday, April 10, 12 95
  • 117. what gets replicated What Statement-based row-based insert/update/delete statement affected records schema/table/view statement statement creation/drop stored routine/trigger statement statement creation/drop statements executed stored procedure call affected records inside SP stored function call function call affected records none: the slave runs the affected records trigger execution trigger moved. No trigger runs slaveside disabled slaveside disabled event creation event event event execution statement affected records 95 Tuesday, April 10, 12 95
  • 118. DA EN Binary logs in practice AG DEMO 96 Tuesday, April 10, 12 96
  • 119. DA Why replication • The web economy EN • Scaling out AG • From single server to replication How to set replication • Adding a slave • Binary log formats Using Replication • What gets replicated and how • Replication awareness • Monitoring • Log management Managing replication • Replacing a slave • Replacing a master • master replacement What Replication is for • backup • better reads Gotchas, tips, and tricks • What to read More info • More replication sessions 97 Tuesday, April 10, 12 97
  • 120. From single server application r/w requests 98 Tuesday, April 10, 12 98
  • 121. To replication-aware application read/write master read/only slaves R/W load balancer R/O 99 Tuesday, April 10, 12 99
  • 122. Single server application $link = mysql_connect( $server_IP,  'mysql_user',  'mysql_password' ); $result = mysql_query( 'INSERT INTO table_name (x) VALUES (1)', $link ); $result = mysql_query( 'SELECT * FROM table_name WHERE x=1', $link ); 100 Tuesday, April 10, 12 100
  • 123. Making an application aware of replication <<database handling>> db <<R/W database handling>> IP user db password IP connect user password connect <<read-only database <<R/W database handling>> handling>> read db db write IP IP user user password password read connect read write 101 Tuesday, April 10, 12 101
  • 124. Using replication: the WRONG way No Write Yes statement? Connect to the Connect to next available the master slave Read from Write to the slave master R/W split by Stop statement 102 Tuesday, April 10, 12 102
  • 125. Why statement split is wrong • Breaks transactions • High risk of inconsistency • Loses or corrupts data 103 Tuesday, April 10, 12 103
  • 126. Using replication: the RIGHT way No Write Yes function? Connect to the Connect to next available the master slave Read from Read and write slave from master more Yes more queries? queries? Yes R/W split No No by function Stop 104 Tuesday, April 10, 12 104
  • 127. Replication is single threaded • Let’s assume you have two queries on the master • one query takes 3 minutes to complete • the other takes 5 minutes • Both start at 12:00 noon 105 Tuesday, April 10, 12 105
  • 128. Single thread replication MASTER 12:00 12:01 12:02 12:03 12:04 12:05 12:06 12:07 12:08 12:09 12:10 12:11 SLAVE 106 Tuesday, April 10, 12 106
  • 129. Single thread replication MASTER QUERY 1 QUERY 2 12:00 12:01 12:02 12:03 12:04 12:05 12:06 12:07 12:08 12:09 12:10 12:11 (does nothing) SLAVE 106 Tuesday, April 10, 12 106
  • 130. Single thread replication MASTER QUERY 1 QUERY 2 12:00 12:01 12:02 12:03 12:04 12:05 12:06 12:07 12:08 12:09 12:10 12:11 (does nothing) QUERY 1 SLAVE 106 Tuesday, April 10, 12 106
  • 131. Single thread replication MASTER QUERY 1 QUERY 2 12:00 12:01 12:02 12:03 12:04 12:05 12:06 12:07 12:08 12:09 12:10 12:11 (does nothing) QUERY 1 QUERY 2 SLAVE 106 Tuesday, April 10, 12 106
  • 132. Single thread replication MASTER QUERY 1 QUERY 3 QUERY 5 QUERY 2 QUERY 4 QUERY 6 12:00 12:01 12:02 12:03 12:04 12:05 12:06 12:07 12:08 12:09 12:10 12:11 does nothing QUERY 1 QUERY 2 SLAVE 107 Tuesday, April 10, 12 107
  • 133. DA Why replication • The web economy EN • Scaling out AG • From single server to replication How to set replication • Adding a slave • Binary log formats Using Replication • What gets replicated and how • Replication awareness • Monitoring • Log management Managing replication • Replacing a slave • Replacing a master • master replacement What Replication is for • backup • better reads Gotchas, tips, and tricks • What to read More info • More replication sessions 108 Tuesday, April 10, 12 108
  • 134. Sample get slave status monitoring slave Running? No Yes master Get master binlog and position Same or later No Yes binlog/position? check table contents alert 109 Tuesday, April 10, 12 109
  • 135. commands for checking replication master> SHOW MASTER STATUS master> SHOW PROCESSLIST slave> SHOW SLAVE STATUS slave> SHOW PROCESSLIST Tuesday, April 10, 12 110
  • 136. replication user seen in the master master > show processlistG *************************** 1. row *************** Id: 2 User: rsandbox Host: localhost:57011 db: NULL Command: Binlog Dump Time: 81625 State: Master has sent all binlog to slave; waiting for binlog to be updated Info: NULL [...] Tuesday, April 10, 12 111
  • 137. IO-thread in the slave slave > show processlistG *************************** 1. row *************** Id: 2 User: system user Host: db: NULL Command: Connect Time: 124801 State: Waiting for master to send event Info: NULL [...] Tuesday, April 10, 12 112
  • 138. SQL thread in the slave slave > show processlistG [...] *************************** 2. row *************** Id: 3 User: system user Host: db: NULL Command: Connect Time: 124712 State: Slave has read all relay log; waiting for the slave I/O thread to update it Info: NULL [...] Tuesday, April 10, 12 113
  • 139. monitoring replication master> SHOW MASTER STATUS slave> SHOW SLAVE STATUS FULL SCRIPTS: http://datacharmer.blogspot.com/2011/04/refactored-again-poor-mans- mysql.html http://forge.mysql.com/tools/tool.php?id=6 Tuesday, April 10, 12 114
  • 140. show master status File: mysql-bin.000002 Position: 78045744 Binlog_Do_DB: Binlog_Ignore_DB: Tuesday, April 10, 12 115
  • 141. show slave status Slave_IO_State: Waiting for master to send event Master_Host: 127.0.0.1 Master_User: rsandbox Master_Port: 27371 Connect_Retry: 60 Master_Log_File: mysql-bin.000002 Read_Master_Log_Pos: 78045744 Relay_Log_File: mysql_sandbox27372-relay-bin.000055 Relay_Log_Pos: 78045889 Relay_Master_Log_File: mysql-bin.000002 Slave_IO_Running: Yes Slave_SQL_Running: Yes Tuesday, April 10, 12 116
  • 142. show slave status ... Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: ... Tuesday, April 10, 12 117
  • 143. show slave status ... Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 78045744 Relay_Log_Space: 78046100 ... Seconds_Behind_Master: 0 ... Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Tuesday, April 10, 12 118
  • 144. DA EN Breaking (and fixing) replication AG DEMO 119 Tuesday, April 10, 12 119
  • 145. DA Why replication • The web economy EN • Scaling out AG • From single server to replication How to set replication • Adding a slave • Binary log formats Using Replication • What gets replicated and how • Replication awareness • Monitoring • Log management Managing replication • Replacing a slave • Replacing a master • master replacement What Replication is for • backup • better reads Gotchas, tips, and tricks • What to read More info • More replication sessions 120 Tuesday, April 10, 12 120
  • 146. Logs rotation # server variables max-binlog-size expire-log-days # logs commands SHOW MASTER LOGS; PURGE MASTER LOGS TO 'filename'; FLUSH [BINARY] LOGS; Tuesday, April 10, 12 121
  • 147. DA Why replication • The web economy EN • Scaling out AG • From single server to replication How to set replication • Adding a slave • Binary log formats Using Replication • What gets replicated and how • Replication awareness • Monitoring • Log management Managing replication • Replacing a slave • Replacing a master • master replacement What Replication is for • backup • better reads Gotchas, tips, and tricks • What to read More info • More replication sessions 122 Tuesday, April 10, 12 122
  • 148. Replacing Slave a slave crashe s No are there Yes more slaves? STOP the master STOP one slave add the first add another slave slave Stop 123 Tuesday, April 10, 12 123
  • 149. DA Why replication • The web economy EN • Scaling out AG • From single server to replication How to set replication • Adding a slave • Binary log formats Using Replication • What gets replicated and how • Replication awareness • Monitoring • Log management Managing replication • Replacing a slave • Replacing a master • master replacement What Replication is for • backup • better reads Gotchas, tips, and tricks • What to read More info • More replication sessions 124 Tuesday, April 10, 12 124
  • 150. Replacing the Master master crashe s Let all slaves catch up with execution STOP replication in all slaves FIND the most make it the up to date slave master FIND which run missing connect all transactions are transactions slaves to the missing from to other new master other slaves slaves Stop 125 Tuesday, April 10, 12 125
  • 151. Planned master switch • Stop accepting writes • Wait until all slaves have caught up • Stop replication in all slaves • Promote a slave to master • Point all slaves to the new master Tuesday, April 10, 12 126
  • 152. Changing a failed master • Pre-requisite: • log_bin and log_slave_updates must be enabled in all the slaves • If not, there is more manual labor Tuesday, April 10, 12 127
  • 153. Changing a failed master (1) • Wait until all slaves have caught up • Identify the most advanced slave • Make that slave the new master • ... so far, so good Tuesday, April 10, 12 128
  • 154. Changing a failed master (2) • For each remaining slave: • Find the missing statements • Find the LAST statement replicated by the slave • Find the same statement in the new master binlog (*) • get the position of the NEXT statement (*) if log_slave_updates was not enabled, you need to convert the relay log statements to SQL and do the next step manually Tuesday, April 10, 12 129
  • 155. Changing a failed master (3) • For each remaining slave: • Apply the missing statements • CHANGE MASTER TO master_host=”new_master_hostname”, master_port=new_master_port, master_log_file=”mysql-bin.xxxxxx”, master_log_pos=YYYY Tuesday, April 10, 12 130
  • 156. Reasons for complexity • No global transaction ID Tuesday, April 10, 12 131
  • 157. What is a global transaction ID • A unique identifier of a transaction • Unique for the whole cluster, not for each node • Generated by the ultimate source (the master) • Does not change when the transaction goes through an intermediate master Tuesday, April 10, 12 132
  • 158. Why should you care • Failure recovery • MySQL DOES NOT have it • What can you do? Either wait for MySQL 5.6 or use Tungsten Replicator. Tuesday, April 10, 12 133
  • 159. DA Why replication • The web economy EN • Scaling out AG • From single server to replication How to set replication • Adding a slave • Binary log formats Using Replication • What gets replicated and how • Replication awareness • Monitoring • Log management Managing replication • Replacing a slave • Replacing a master • master replacement What Replication is for • backup • better reads Gotchas, tips, and tricks • What to read More info • More replication sessions 134 Tuesday, April 10, 12 134
  • 160. Slave = master replacement • if: • there are no filters; • you are monitoring replication • you make sure data is consistent 135 Tuesday, April 10, 12 135
  • 161. Slave != backup • There is no replacement for a good backup. • Data loss due to a mistake in the master will propagate to the slaves. • Disasters are always smarter than replication. • Do your backups! • Session on Wednesday at 12pm: "Be a Data Management Hero with Good Backups!" 136 Tuesday, April 10, 12 136
  • 162. DA Why replication • The web economy EN • Scaling out AG • From single server to replication How to set replication • Adding a slave • Binary log formats Using Replication • What gets replicated and how • Replication awareness • Monitoring • Log management Managing replication • Replacing a slave • Replacing a master • master replacement What Replication is for • backup • better reads Gotchas, tips, and tricks • What to read More info • More replication sessions 137 Tuesday, April 10, 12 137
  • 163. Replication = let the slave do the dirty work Tuesday, April 10, 12 138