SlideShare uma empresa Scribd logo
1 de 116
Baixar para ler offline
MySQL replication outside the box




                                                                                                                    Giuseppe Maxia
                                                                                                                    QA Director
                                                                                                                    Continuent, Inc
                                                                                                                    @datacharmer
                   This work is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported License.
Tuesday, October 25, 11                                                                                                               1
about me -Giuseppe Maxia
    §    a.k.a. The Data Charmer
    §    QA Director, Continuent, Inc
    §    Long time hacking with database features
    §    Formerly, database consultant, designer, coder.
    §    A passion for QA
    §    An even greater passion for open source
    §    ... and community
    §    Passionate blogger
    §    http://datacharmer.blogspot.com




Tuesday, October 25, 11                                     2
Why Tungsten?




Tuesday, October 25, 11             3
transaction
                                                                              transaction
                                                             MySQL              transaction
                                                                            transaction
                                                                                  transaction
                                                             DBMS             transaction
                                                                                    transaction
                                                                                transaction
                                                                                      transaction
                                                                                  transaction
                                                                                    transaction
                                                                                      transaction



                                                      BINARY LOG




                              ns act act tio n
                          tra ansio ns sac ntio
                                ac ion ion n
                                               ac
                              nr tr tra aniton
                              tsa a n csio
                                       nts ct n
                                    rn a o
                                   taa scti
                                         r
                                  trnsa



                                       n
                                       n
                                                                     MySQL replication
                                   tio
                                  ct
                                tra

                          tra
                          REPLICATION
                                        transaction
                                        transaction
                                                                     is single threaded




                                    MySQL
                                    DBMS




Tuesday, October 25, 11                                                                             4
master                             master     master      master
                          MySQL                         MySQL     MySQL       MySQL
                          DBMS                          DBMS      DBMS        DBMS




        MySQL               MySQL   MySQL                           MySQL
        DBMS                DBMS    DBMS                            DBMS




     slave                  slave   slave                            slave


           single source                                   multi source (fan-in)

                                            multiple sources?
Tuesday, October 25, 11                                                               5
from this                        to this
                                                   MySQL             MySQL
                                                   DBMS              DBMS




                                                  master             master




                                                   MySQL             MySQL
                                                   DBMS              DBMS




                                                  master             master



                                      multiple masters?

Tuesday, October 25, 11                                                       6
INSERT                                         INSERT
        RECORD                                         RECORD
           A                                              A
                           MySQL              MySQL
                           DBMS               DBMS




                          master              master




                           MySQL              MySQL
                           DBMS               DBMS




        MODIFY            master              master   MODIFY
        RECORD                                         RECORD
           B                                              B
                              Avoiding conflicts?

Tuesday, October 25, 11                                          7
master
                                                    Seamless failover?
                    MySQL
                    DBMS

                                           master
                                            MySQL
                                            DBMS




                                                                         master
                                                                           MySQL
                                                                           DBMS




     MySQL                MySQL
     DBMS                 DBMS




  slave                   slave    MySQL
                                   DBMS
                                              MySQL
                                              DBMS




                                  slave       slave
                                                                 MySQL     MySQL
                                                                 DBMS      DBMS




                                                                slave      slave
Tuesday, October 25, 11                                                            8
Replicating to something else?


                             mysql master
                                   MySQL
                                   DBMS




                           MySQL
                           DBMS




                          mysql postgresql oracle   mongodb


Tuesday, October 25, 11                                       9
All these examples tell
              us:

                      Nice dream, but
                      MySQL can’t do it
Tuesday, October 25, 11                   10
Enter Tungsten Replicator




Tuesday, October 25, 11                               11
http://code.google.com/p/tungsten-replicator




Tuesday, October 25, 11                                12
http://code.google.com/p/tungsten-replicator




                                      Open Source




Tuesday, October 25, 11                                12
http://code.google.com/p/tungsten-replicator




                                      Open Source
                                      100% GPL v2



Tuesday, October 25, 11                                12
What can it do?
                • Easy failover
                • Multiple masters
                • Multiple sources to a single slave
                • Conflict prevention
                • Parallel replication
                • Replicate to Oracle and PostgreSQL database
Tuesday, October 25, 11                                         13
MySQL to foreign services


                            MySQL setup
                              to run as
                            MySQL master


               Master DB
                               Data is applied to
                                 PostgreSQL or
                               Oracle or to NoSQL
                                     entities



                             Bin
                            Logs
                 (Binlogs
                 enabled)                           Slave DB

      © Continuent 2010


Tuesday, October 25, 11                                        14
Tungsten Replicator in
                           a nutshell
                  host1
                                                       host2
                      master
                                                          slave

          binlog                                 THL
                              global
                          transaction ID   THL

                                                         trep_commit_seqno
                                                       origin  seqno eventid
                        trep_commit_seqno
                      origin  seqno eventid


Tuesday, October 25, 11                                                        15
Main components
                     • Transaction History Logs (THL)
                          •   roughly corresponding to MySQL relay logs

                          •   have a lot of metadata

                     • Service database
                          •   contains metadata for latest transactions

                          •   Metadata is committed together with data

                          •   Makes slaves crash proof


Tuesday, October 25, 11                                                   16
A failover scenario
              1: MySQL native replication




Tuesday, October 25, 11                     17
1. one Master, two slaves

        / Loading the “employees” test database




     © Continuent 2011


Tuesday, October 25, 11                           18
2. Master goes away

       / Stop replication


       / Slaves are updated at different levels

           # 2
           select count(*) from titles
           333,145

           # 3
           select count(*) from titles
           443,308

     © Continuent 2011


Tuesday, October 25, 11                           19
3. Look into Slave #2 binary logs

        / find the last transaction




     © Continuent 2011


Tuesday, October 25, 11                     20
4. Look into Slave #3 binary logs

        1. find the transaction that was last in slave #2
        2. Recognize that last transaction in the log of slave #3
           (This can actually take you a LOOOONG TIME)
        3. Get the position immediately after this transaction
        4. (e.g. 134000 in file mysql-bin.000018)




     © Continuent 2011


Tuesday, October 25, 11                                             21
5. promote Slave #3 to master

       / in slave #2

           CHANGE MASTER TO
           master_host=‘slave_3_IP’,
           master_user=‘slavename’,
           master_password=‘slavepassword’,
           master_log_file=‘mysql-bin.000018’,
           master_log_pos=134000;




     © Continuent 2011


Tuesday, October 25, 11                          22
A failover scenario
                          1: Tungsten Replicator




Tuesday, October 25, 11                            23
1. one master, two slaves

        / loading the ‘employees’ test database




     © Continuent 2011


Tuesday, October 25, 11                           24
2. Master goes away

       / Stop replication


       / Slaves are updated at different levels

           # 2
           select count(*) from titles
           333,145

           # 3
           select count(*) from titles
           443,308

     © Continuent 2011


Tuesday, October 25, 11                           25
3. no need to find the last transaction

       / simply change roles

           trepctl -host slave3 setrole -role master
           trepctl -host slave2 setrole -role slave 
                    -uri thl://slave3

           trepctl -host slave3 online
            State: ONLINE

           trepctl -host slave2 online
            State: GOING-ONLINE:SYNCHRONIZING

     © Continuent 2011


Tuesday, October 25, 11                                 26
4. Check that the slave has synchronized

          # new master
          select seqno from tungsten.trep_commit_seqno;
          78

          # new slave
          select seqno from tungsten.trep_commit_seqno;
          64




     © Continuent 2011


Tuesday, October 25, 11                                   27
4. Tell the replicator to hurry up

          # new master
          trepctl -node slave3 flush
          Master log is synchronized with database at
          log sequence number: 78



          # new slave
          trepctl host slave2 wait -applied 78
          ONLINE
          select seqno from tungsten.trep_commit_seqno;
          78

     © Continuent 2011


Tuesday, October 25, 11                                   28
4. ... and we’re done
          # new master
          select count(*) from employees.titles
          count(*)
          443308

          # new slave:
          count(*)
          443308




     © Continuent 2011


Tuesday, October 25, 11                           29
Parallel replication




Tuesday, October 25, 11                          30
parallel replication
                                     From here ...




Tuesday, October 25, 11                              31
parallel replication
                                       To here.




Tuesday, October 25, 11                           32
Parallel replication facts


                     ✓Sharded by database
                     ✓Good choice for slave lag problems
                     ❖Bad choice for single database projects


Tuesday, October 25, 11                                         33
Benchmarking parallel
                           replication


Tuesday, October 25, 11                       34
db0
                                                  preparation (1)
                           db1                                 sysbench



                                db2                             sysbench


                                 db3                              sysbench


                                      db4                           sysbench



                                       db5                            sysbench


                                            db6                           sysbench


                                             db7                           sysbench



                                                  db8                        sysbench



                                                   db9                         sysbench


                                                                                 sysbench




Tuesday, October 25, 11                                                                     35
before the test (2)

           STOPPED



                                                 binary logs

   MySQL slave

                             OFFLINE

          Tungsten slave          direct:
                                   alpha
                                  (slave)

                              replicator alpha




Tuesday, October 25, 11                                        36
starting the test

           STOPPED



                                                  binary logs

   MySQL slave                                   Concurrent sysbench
                                                   on 30 databases
                                                  running for 1 hour
                            OFFLINE
                                                 TOTAL DATA: 130 GB
          Tungsten slave         direct:
                                  alpha
                                                 RAM per server: 20GB
                                 (slave)

                             replicator alpha

                                                Slaves will have 1 hour lag
Tuesday, October 25, 11                                                       37
measuring results

               START



                                                 binary logs

   MySQL slave

                             ONLINE                             Recording
                                                               catch-up time
          Tungsten slave          direct:
                                   alpha
                                  (slave)

                              replicator alpha




Tuesday, October 25, 11                                                        38
MySQL native
                           replication


              slave catch up in 04:29:30



Tuesday, October 25, 11                    39
Tungsten parallel
                             replication


              slave catch up in 00:55:40



Tuesday, October 25, 11                       40
Parallel replication made simpler




                          FROM HERE ....
Tuesday, October 25, 11                              41
Parallel replication made simpler




                          TO HERE
Tuesday, October 25, 11                              42
Parallel replication made simpler




Tuesday, October 25, 11                              43
parallel replication
                           direct slave facts




Tuesday, October 25, 11                          44
parallel replication
                           direct slave facts
     ✓No need to install Tungsten on the master




Tuesday, October 25, 11                           44
parallel replication
                           direct slave facts
     ✓No need to install Tungsten on the master
     ✓Tungsten runs only on the slave




Tuesday, October 25, 11                           44
parallel replication
                           direct slave facts
     ✓No need to install Tungsten on the master
     ✓Tungsten runs only on the slave
     ✓Replication can revert to native slave with two
             commands (trepctl offline; start
             slave)




Tuesday, October 25, 11                                 44
parallel replication
                           direct slave facts
     ✓No need to install Tungsten on the master
     ✓Tungsten runs only on the slave
     ✓Replication can revert to native slave with two
             commands (trepctl offline; start
             slave)

     ✓Native replication can continue on other slaves

Tuesday, October 25, 11                                 44
parallel replication
                           direct slave facts
     ✓No need to install Tungsten on the master
     ✓Tungsten runs only on the slave
     ✓Replication can revert to native slave with two
             commands (trepctl offline; start
             slave)

     ✓Native replication can continue on other slaves
     ❖Failover (either native or Tungsten) becomes a
             manual task
Tuesday, October 25, 11                                 44
Multiple masters




Tuesday, October 25, 11                      45
multiple masters


                     • Tungsten Replicator recipe: use more
                          services




Tuesday, October 25, 11                                       46
Bi-directional replication




Tuesday, October 25, 11                                47
Bi-directional replication with slaves




Tuesday, October 25, 11                         48
Multiple sources




Tuesday, October 25, 11                      49
multiple sources


                     • Tungsten Replicator recipe is still valid:
                          use more services




Tuesday, October 25, 11                                             50
Multiple source replication




Tuesday, October 25, 11                                 51
Multiple masters replication: 3 nodes




Tuesday, October 25, 11                      52
Multiple masters replication: 4 nodes




Tuesday, October 25, 11                      53
Conflict prevention




Tuesday, October 25, 11                         54
Conflict prevention
                                facts




Tuesday, October 25, 11                        55
Conflict prevention
                                facts
                     • Sharded by database




Tuesday, October 25, 11                        55
Conflict prevention
                                facts
                     • Sharded by database
                     • Defined dynamically




Tuesday, October 25, 11                        55
Conflict prevention
                                facts
                     • Sharded by database
                     • Defined dynamically
                     • Applied either at the master or at the
                          slave




Tuesday, October 25, 11                                         55
Conflict prevention
                                facts
                     • Sharded by database
                     • Defined dynamically
                     • Applied either at the master or at the
                          slave
                     • methods:


Tuesday, October 25, 11                                         55
Conflict prevention
                                facts
                     • Sharded by database
                     • Defined dynamically
                     • Applied either at the master or at the
                          slave
                     • methods:
                          •   make replication fail




Tuesday, October 25, 11                                         55
Conflict prevention
                                facts
                     • Sharded by database
                     • Defined dynamically
                     • Applied either at the master or at the
                          slave
                     • methods:
                          •   make replication fail

                          •   drop silently


Tuesday, October 25, 11                                         55
Conflict prevention
                                facts
                     • Sharded by database
                     • Defined dynamically
                     • Applied either at the master or at the
                          slave
                     • methods:
                          •   make replication fail

                          •   drop silently

                          •   drop with warning
Tuesday, October 25, 11                                         55
Tungsten Conflict prevention points
                          host1
                                                               host3



                          M       S
                                                          S



                          host2                                host4
                              master

                          S       M                        S

Tuesday, October 25, 11                                                56
Tungsten Conflict prevention points
                          host1
                                                               host3



                          M       S
                                                          S



                          host2                                host4
                              master

                          S       M                        S

Tuesday, October 25, 11                                                56
Tungsten Conflict prevention points
                          host1
                                                               host3



                          M       S
                                                          S



                          host2                                host4
                              master

                          S       M                        S

Tuesday, October 25, 11                                                56
Prevention methods: Fail on master
                          host1
                                                               host3



                          M       S
                                                          S



                          host2                                host4
                              master

                          S       M                        S

Tuesday, October 25, 11                                                57
INSERT A
        x,y
                              Prevention methods: Fail on master
                          host1
                                                               host3



                          M       S
                                                          S



                          host2                                host4
                              master

                          S       M                        S
                                       INSERT A
                                          x,z
Tuesday, October 25, 11                                                57
INSERT A
        x,y
                              Prevention methods: Fail on master
                          host1
                                                               host3



                          M       S
                                                          S



                          host2                                host4
                              master

                          S       M                        S
                                       INSERT A
                                          x,z
Tuesday, October 25, 11                                                57
Prevention methods: Fail on slave
                          host1
                                                                host3



                          M       S
                                                           S



                          host2                                 host4
                              master

                          S       M                         S

Tuesday, October 25, 11                                                 58
INSERT A
        x,y
                               Prevention methods: Fail on slave
                          host1
                                                                host3



                          M       S
                                                           S



                          host2                                 host4
                              master

                          S       M                         S
                                        INSERT A
                                           x,z
Tuesday, October 25, 11                                                 58
INSERT A
        x,y
                               Prevention methods: Fail on slave
                          host1
                                                                host3



                          M       S
                                                           S



                          host2                                 host4
                              master

                          S       M                         S
                                        INSERT A
                                           x,z
Tuesday, October 25, 11                                                 58
Prevention methods: Fail on slave
                          host1
                                         (Multiple sources)



                          M




                          host2                               host3
                              master

                          M                               S

Tuesday, October 25, 11                                               59
INSERT A
        x,y
                             Prevention methods: Fail on slave
                          host1
                                         (Multiple sources)



                          M




                          host2                               host3
                              master

                          M                               S
                                       INSERT A
                                          x,z
Tuesday, October 25, 11                                               59
INSERT A
        x,y
                             Prevention methods: Fail on slave
                          host1
                                         (Multiple sources)



                          M




                          host2                               host3
                              master

                          M                               S
                                       INSERT A
                                          x,z
Tuesday, October 25, 11                                               59
Prevention methods: DROP on master
                          host1
                                                          host3



                          M       S
                                                     S



                          host2                           host4
                              master

                          S       M                   S

Tuesday, October 25, 11                                           60
INSERT A
        x,y
                          Prevention methods: DROP on master
                          host1
                                                          host3



                          M       S
                                                     S



                          host2                           host4
                              master

                          S       M                   S

Tuesday, October 25, 11                                           60
INSERT A
        x,y
                          Prevention methods: DROP on master
                          host1
                                                          host3



                          M       S
                                                     S



                          host2                           host4
                              master

                          S       M                   S
                                       INSERT A
                                          x,z
Tuesday, October 25, 11                                           60
Prevention methods: DROP on master
                          host1
                                                          host3



                          M       S
                                                     S



                          host2                           host4
                              master

                          S       M                   S
                                       INSERT A
                                          x,z
Tuesday, October 25, 11                                           60
Prevention methods: DROP on slave
                          host1
                                         (Multiple sources)



                          M




                          host2                            host3
                              master

                          M                            S

Tuesday, October 25, 11                                            61
INSERT A
        x,y
                           Prevention methods: DROP on slave
                          host1
                                         (Multiple sources)



                          M




                          host2                            host3
                              master

                          M                            S
                                       INSERT A
                                          x,z
Tuesday, October 25, 11                                            61
Prevention methods: DROP on slave
                          host1
                                         (Multiple sources)



                          M




                          host2          INSERT A          host3
                                            x,y
                              master
                                          INSERT A
                          M                  x,z       S

Tuesday, October 25, 11                                            62
Prevention methods: DROP on slave
                          host1
                                         (Multiple sources)



                          M




                          host2                            host3
                              master
                                          INSERT A
                          M                  x,z       S

Tuesday, October 25, 11                                            62
Tungsten in practice
                              Installation




Tuesday, October 25, 11                          63
Installation

                     • Check the requirements
                     • Get the binaries
                     • Expand the tarball
                     • Run ./tools/tungsten-installer

Tuesday, October 25, 11                                 64
REQUIREMENTS

   • Java JRE or JDK (Sun/Oracle or Open-jdk)
   • Ruby 1.8 (only during installation)
   • ssh access to the same user in all nodes
   • MySQL user with all privileges

Tuesday, October 25, 11                         65
Installation types


                     • master / slave
                     • slave - direct


Tuesday, October 25, 11                        66
master/slave
                                                    host2
                      host1

                          master                        slave


                                                  THL
              binlog                THL

                                                    host3

                                                        slave


                                                  THL


Tuesday, October 25, 11                                         67
slave direct
                                                 host2
                      host1
                                                           slave
                          master
                                         relay log

                                                     THL
           binlog
                                                 host3

                                                           slave

                                         relay log

                                                     THL


Tuesday, October 25, 11                                            68
sample installation
                     • 4 servers
                          •   qa.r1.continuent.com r1

                          •   qa.r2.continuent.com r2

                          •   qa.r3.continuent.com r3

                          •   qa.r4.continuent.com r4

                     • MySQL 5.1
                     • tungsten-replicator-2.0.4
Tuesday, October 25, 11                                 69
Installation (1)
      # starting at node 4, but any would do

      for N in 1 2 3 4
      do
           ssh r$N mkdir tinstall
      done

      cd tinstall
      tar -xzf /path/to/tungsten-replicator-2.0.4.tar.gz
      cd tungsten-replicator-2.0.4




Tuesday, October 25, 11                                    70
Installation (2)
                export TUNGSTEN_BASE=$HOME/tinstall

         1 ./tools/tungsten-installer 
         2     --master-slave 
         3     --master-host=r1 
         4     --datasource-user=tungsten 
         5     --datasource-password=secret 
         6     --service-name=dragon 
         7     --home-directory=$TUNGSTEN_BASE 
         8     --cluster-hosts=r1,r2,r3,r4 
         9     --start




Tuesday, October 25, 11                               71
Installation (2)
  export TUNGSTEN_BASE=$HOME/tinstall

  ./tools/tungsten-installer 
     --master-slave  # installation mode
     --master-host=r1  # who’s the master
     --datasource-user=tungsten  # mysql username
     --datasource-password=secret  # mysql password
     --service-name=dragon    # name of the service
     --home-directory=$TUNGSTEN_BASE  # where we install
     --cluster-hosts=r1,r2,r3,r4  # hosts in cluster
     --start # start replicator after installing




Tuesday, October 25, 11                                 72
What does the
                            installation do
                 1: Validate all servers

               host4              host1           host2       host3

         ✔                    ✔               ✔           ✔
         ✗                    ✗               ✗           ✗
         ✔                    ✔               ✔           ✔
         ✔                    ✔               ✔           ✔

                          Report all errors
Tuesday, October 25, 11                                               73
What does the
                          installation do
                   1 (again): Validate all servers

               host4             host1        host2   host3

         ✔                   ✔            ✔           ✔
         ✔                   ✔            ✔           ✔
         ✔                   ✔            ✔           ✔
         ✔                   ✔            ✔           ✔



Tuesday, October 25, 11                                       74
What does the
                          installation do
               2: install Tungsten in all servers
                                              host4
                             $HOME/             host1
                               tinstall/         host2
                                config/             host3
                                releases/
                                relay/
                                logs/
                                tungsten/




Tuesday, October 25, 11                                     75
example
      ssh r2 chmod 444 $HOME/tinstall
      ./tools/tungsten-installer 
          --master-slave --master-host=r1 
          --datasource-user=tungsten 
          --datasource-password=secret 
          --service-name=dragon 
          --home-directory=$HOME/tinstall 
          --thl-directory=$HOME/tinstall/logs 
          --relay-directory=$HOME/tinstall/relay 
          --cluster-hosts=r1,r2,r3,r4 --start

      ERROR >> qa.r2.continuent.com >> /home/tungsten/
      tinstall is not writeable


Tuesday, October 25, 11                                  76
example
      ssh r2 chmod 755 $HOME/tinstall
      ./tools/tungsten-installer 
          --master-slave --master-host=r1 
          --datasource-user=tungsten 
          --datasource-password=secret 
          --service-name=dragon 
          --home-directory=$HOME/tinstall 
          --thl-directory=$HOME/tinstall/logs 
          --relay-directory=$HOME/tinstall/relay 
          --cluster-hosts=r1,r2,r3,r4 --start

      # no errors



Tuesday, October 25, 11                              77
Installation - direct
      ./tools/tungsten-installer 
          --direct 
          --master-host=r1 
          --slave-host=r4 
          --master-user=tungsten 
          --slave-user=tungsten 
          --master-password=secret 
          --slave-password=secret 
          --service-name=Castor 
          --channels=1 
          --home-directory=$TUNGSTEN_BASE 
          --start-and-report



Tuesday, October 25, 11                           78
Tungsten in practice
                                Admin




Tuesday, October 25, 11                          79
Main components


                     • THL (Tungsten generated Transaction
                          History Log)
                     • service database


Tuesday, October 25, 11                                      80
Tools

                     • replicator
                     • trepctl
                     • thl


Tuesday, October 25, 11                     81
replicator

                     • It’s the service provider
                     • You launch it once when you start
                     • You may restart it when you change
                          config




Tuesday, October 25, 11                                     82
trepctl

                     • Tungsten Replicator ConTroLler
                     • It’s the driving seat for your replication
                     • You can start, update, and stop services
                     • You can get specific info

Tuesday, October 25, 11                                             83
thl


                     • Transaction History List
                     • Gives you access to the Tungsten relay
                          logs




Tuesday, October 25, 11                                         84
http://bit.ly/tr20_cookbook




Tuesday, October 25, 11                85
Tungsten Replicator vs. Enterprise

  Feature                             Replicator   Enterprise
  Simple admin with trepctl               X            X
  MySQL Row/Statement 5.0/5.1/5.5         X            X
  Multi-master replication                X            X
  Parallel apply (2.0)                    X            X
  Distributed management with cctrl                    X
  Automated failover and recovery                      X
  Zero-downtime upgrade                                X
  SQL routing and load-balancing                       X
  Floating IP support                                  X

     © Continuent 2011


Tuesday, October 25, 11                                         86
Conclusion and Q&A




Tuesday, October 25, 11                        87
Contact Information


       Worldwide
       560 S. Winchester Blvd., Suite 500
       San Jose, CA 95128                              @datacharmer
       Tel (866) 998-3642
       Fax (408) 668-1009                              @continuent
       e-mail: sales@continuent.com




                                     Continuent Web Site:
                                 http://www.continuent.com
                                       Tungsten Project
                              http://tungsten-replicator.org
                          Getting started with Tungsten Replicator:
                              http://datacharmer.blogspot.com
     © Continuent 2011

Tuesday, October 25, 11                                               88
Tuesday, October 25, 11   89

Mais conteúdo relacionado

Destaque

Comparison of dbms
Comparison of dbmsComparison of dbms
Comparison of dbms
Tech_MX
 

Destaque (20)

Comparison of dbms
Comparison of dbmsComparison of dbms
Comparison of dbms
 
Relational database intro for marketers
Relational database intro for marketersRelational database intro for marketers
Relational database intro for marketers
 
MariaDB: 新兴的开源大数据引擎
MariaDB: 新兴的开源大数据引擎MariaDB: 新兴的开源大数据引擎
MariaDB: 新兴的开源大数据引擎
 
Databases in the hosted cloud
Databases in the hosted cloudDatabases in the hosted cloud
Databases in the hosted cloud
 
Continuent Tungsten - Scalable Saa S Data Management
Continuent Tungsten - Scalable Saa S Data ManagementContinuent Tungsten - Scalable Saa S Data Management
Continuent Tungsten - Scalable Saa S Data Management
 
Cool MariaDB Plugins
Cool MariaDB Plugins Cool MariaDB Plugins
Cool MariaDB Plugins
 
Solving MySQL replication problems with Tungsten
Solving MySQL replication problems with TungstenSolving MySQL replication problems with Tungsten
Solving MySQL replication problems with Tungsten
 
MySQL in the Hosted Cloud
MySQL in the Hosted CloudMySQL in the Hosted Cloud
MySQL in the Hosted Cloud
 
Better encryption & security with MariaDB 10.1 & MySQL 5.7
Better encryption & security with MariaDB 10.1 & MySQL 5.7Better encryption & security with MariaDB 10.1 & MySQL 5.7
Better encryption & security with MariaDB 10.1 & MySQL 5.7
 
My first moments with MongoDB
My first moments with MongoDBMy first moments with MongoDB
My first moments with MongoDB
 
Meet MariaDB 10.1 at the Bulgaria Web Summit
Meet MariaDB 10.1 at the Bulgaria Web SummitMeet MariaDB 10.1 at the Bulgaria Web Summit
Meet MariaDB 10.1 at the Bulgaria Web Summit
 
Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016
 
MariaDB - the "new" MySQL is 5 years old and everywhere (LinuxCon Europe 2015)
MariaDB - the "new" MySQL is 5 years old and everywhere (LinuxCon Europe 2015)MariaDB - the "new" MySQL is 5 years old and everywhere (LinuxCon Europe 2015)
MariaDB - the "new" MySQL is 5 years old and everywhere (LinuxCon Europe 2015)
 
Introduction to mysql part 1
Introduction to mysql part 1Introduction to mysql part 1
Introduction to mysql part 1
 
Juggle your data with Tungsten Replicator
Juggle your data with Tungsten ReplicatorJuggle your data with Tungsten Replicator
Juggle your data with Tungsten Replicator
 
MariaDB - a MySQL Replacement #SELF2014
MariaDB - a MySQL Replacement #SELF2014MariaDB - a MySQL Replacement #SELF2014
MariaDB - a MySQL Replacement #SELF2014
 
MySQL for Large Scale Social Games
MySQL for Large Scale Social GamesMySQL for Large Scale Social Games
MySQL for Large Scale Social Games
 
Advanced mysql replication for the masses
Advanced mysql replication for the massesAdvanced mysql replication for the masses
Advanced mysql replication for the masses
 
Setup & Operate Tungsten Replicator
Setup & Operate Tungsten ReplicatorSetup & Operate Tungsten Replicator
Setup & Operate Tungsten Replicator
 
Introducing MySQL MHA (JP/LT)
Introducing MySQL MHA (JP/LT)Introducing MySQL MHA (JP/LT)
Introducing MySQL MHA (JP/LT)
 

Mais de Giuseppe Maxia

Mais 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
 
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
 
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
 
Testing mysql creatively in a sandbox
Testing mysql creatively in a sandboxTesting mysql creatively in a sandbox
Testing mysql creatively in a sandbox
 
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
 
Replication 101
Replication 101Replication 101
Replication 101
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

Mysql replication outside the box

  • 1. MySQL replication outside the box Giuseppe Maxia QA Director Continuent, Inc @datacharmer This work is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported License. Tuesday, October 25, 11 1
  • 2. about me -Giuseppe Maxia § a.k.a. The Data Charmer § QA Director, Continuent, Inc § Long time hacking with database features § Formerly, database consultant, designer, coder. § A passion for QA § An even greater passion for open source § ... and community § Passionate blogger § http://datacharmer.blogspot.com Tuesday, October 25, 11 2
  • 4. transaction transaction MySQL transaction transaction transaction DBMS transaction transaction transaction transaction transaction transaction transaction BINARY LOG ns act act tio n tra ansio ns sac ntio ac ion ion n ac nr tr tra aniton tsa a n csio nts ct n rn a o taa scti r trnsa n n MySQL replication tio ct tra tra REPLICATION transaction transaction is single threaded MySQL DBMS Tuesday, October 25, 11 4
  • 5. master master master master MySQL MySQL MySQL MySQL DBMS DBMS DBMS DBMS MySQL MySQL MySQL MySQL DBMS DBMS DBMS DBMS slave slave slave slave single source multi source (fan-in) multiple sources? Tuesday, October 25, 11 5
  • 6. from this to this MySQL MySQL DBMS DBMS master master MySQL MySQL DBMS DBMS master master multiple masters? Tuesday, October 25, 11 6
  • 7. INSERT INSERT RECORD RECORD A A MySQL MySQL DBMS DBMS master master MySQL MySQL DBMS DBMS MODIFY master master MODIFY RECORD RECORD B B Avoiding conflicts? Tuesday, October 25, 11 7
  • 8. master Seamless failover? MySQL DBMS master MySQL DBMS master MySQL DBMS MySQL MySQL DBMS DBMS slave slave MySQL DBMS MySQL DBMS slave slave MySQL MySQL DBMS DBMS slave slave Tuesday, October 25, 11 8
  • 9. Replicating to something else? mysql master MySQL DBMS MySQL DBMS mysql postgresql oracle mongodb Tuesday, October 25, 11 9
  • 10. All these examples tell us: Nice dream, but MySQL can’t do it Tuesday, October 25, 11 10
  • 13. http://code.google.com/p/tungsten-replicator Open Source Tuesday, October 25, 11 12
  • 14. http://code.google.com/p/tungsten-replicator Open Source 100% GPL v2 Tuesday, October 25, 11 12
  • 15. What can it do? • Easy failover • Multiple masters • Multiple sources to a single slave • Conflict prevention • Parallel replication • Replicate to Oracle and PostgreSQL database Tuesday, October 25, 11 13
  • 16. MySQL to foreign services MySQL setup to run as MySQL master Master DB Data is applied to PostgreSQL or Oracle or to NoSQL entities Bin Logs (Binlogs enabled) Slave DB © Continuent 2010 Tuesday, October 25, 11 14
  • 17. Tungsten Replicator in a nutshell host1 host2 master slave binlog THL global transaction ID THL trep_commit_seqno origin seqno eventid trep_commit_seqno origin seqno eventid Tuesday, October 25, 11 15
  • 18. Main components • Transaction History Logs (THL) • roughly corresponding to MySQL relay logs • have a lot of metadata • Service database • contains metadata for latest transactions • Metadata is committed together with data • Makes slaves crash proof Tuesday, October 25, 11 16
  • 19. A failover scenario 1: MySQL native replication Tuesday, October 25, 11 17
  • 20. 1. one Master, two slaves / Loading the “employees” test database © Continuent 2011 Tuesday, October 25, 11 18
  • 21. 2. Master goes away / Stop replication / Slaves are updated at different levels # 2 select count(*) from titles 333,145 # 3 select count(*) from titles 443,308 © Continuent 2011 Tuesday, October 25, 11 19
  • 22. 3. Look into Slave #2 binary logs / find the last transaction © Continuent 2011 Tuesday, October 25, 11 20
  • 23. 4. Look into Slave #3 binary logs 1. find the transaction that was last in slave #2 2. Recognize that last transaction in the log of slave #3 (This can actually take you a LOOOONG TIME) 3. Get the position immediately after this transaction 4. (e.g. 134000 in file mysql-bin.000018) © Continuent 2011 Tuesday, October 25, 11 21
  • 24. 5. promote Slave #3 to master / in slave #2 CHANGE MASTER TO master_host=‘slave_3_IP’, master_user=‘slavename’, master_password=‘slavepassword’, master_log_file=‘mysql-bin.000018’, master_log_pos=134000; © Continuent 2011 Tuesday, October 25, 11 22
  • 25. A failover scenario 1: Tungsten Replicator Tuesday, October 25, 11 23
  • 26. 1. one master, two slaves / loading the ‘employees’ test database © Continuent 2011 Tuesday, October 25, 11 24
  • 27. 2. Master goes away / Stop replication / Slaves are updated at different levels # 2 select count(*) from titles 333,145 # 3 select count(*) from titles 443,308 © Continuent 2011 Tuesday, October 25, 11 25
  • 28. 3. no need to find the last transaction / simply change roles trepctl -host slave3 setrole -role master trepctl -host slave2 setrole -role slave -uri thl://slave3 trepctl -host slave3 online State: ONLINE trepctl -host slave2 online State: GOING-ONLINE:SYNCHRONIZING © Continuent 2011 Tuesday, October 25, 11 26
  • 29. 4. Check that the slave has synchronized # new master select seqno from tungsten.trep_commit_seqno; 78 # new slave select seqno from tungsten.trep_commit_seqno; 64 © Continuent 2011 Tuesday, October 25, 11 27
  • 30. 4. Tell the replicator to hurry up # new master trepctl -node slave3 flush Master log is synchronized with database at log sequence number: 78 # new slave trepctl host slave2 wait -applied 78 ONLINE select seqno from tungsten.trep_commit_seqno; 78 © Continuent 2011 Tuesday, October 25, 11 28
  • 31. 4. ... and we’re done # new master select count(*) from employees.titles count(*) 443308 # new slave: count(*) 443308 © Continuent 2011 Tuesday, October 25, 11 29
  • 33. parallel replication From here ... Tuesday, October 25, 11 31
  • 34. parallel replication To here. Tuesday, October 25, 11 32
  • 35. Parallel replication facts ✓Sharded by database ✓Good choice for slave lag problems ❖Bad choice for single database projects Tuesday, October 25, 11 33
  • 36. Benchmarking parallel replication Tuesday, October 25, 11 34
  • 37. db0 preparation (1) db1 sysbench db2 sysbench db3 sysbench db4 sysbench db5 sysbench db6 sysbench db7 sysbench db8 sysbench db9 sysbench sysbench Tuesday, October 25, 11 35
  • 38. before the test (2) STOPPED binary logs MySQL slave OFFLINE Tungsten slave direct: alpha (slave) replicator alpha Tuesday, October 25, 11 36
  • 39. starting the test STOPPED binary logs MySQL slave Concurrent sysbench on 30 databases running for 1 hour OFFLINE TOTAL DATA: 130 GB Tungsten slave direct: alpha RAM per server: 20GB (slave) replicator alpha Slaves will have 1 hour lag Tuesday, October 25, 11 37
  • 40. measuring results START binary logs MySQL slave ONLINE Recording catch-up time Tungsten slave direct: alpha (slave) replicator alpha Tuesday, October 25, 11 38
  • 41. MySQL native replication slave catch up in 04:29:30 Tuesday, October 25, 11 39
  • 42. Tungsten parallel replication slave catch up in 00:55:40 Tuesday, October 25, 11 40
  • 43. Parallel replication made simpler FROM HERE .... Tuesday, October 25, 11 41
  • 44. Parallel replication made simpler TO HERE Tuesday, October 25, 11 42
  • 45. Parallel replication made simpler Tuesday, October 25, 11 43
  • 46. parallel replication direct slave facts Tuesday, October 25, 11 44
  • 47. parallel replication direct slave facts ✓No need to install Tungsten on the master Tuesday, October 25, 11 44
  • 48. parallel replication direct slave facts ✓No need to install Tungsten on the master ✓Tungsten runs only on the slave Tuesday, October 25, 11 44
  • 49. parallel replication direct slave facts ✓No need to install Tungsten on the master ✓Tungsten runs only on the slave ✓Replication can revert to native slave with two commands (trepctl offline; start slave) Tuesday, October 25, 11 44
  • 50. parallel replication direct slave facts ✓No need to install Tungsten on the master ✓Tungsten runs only on the slave ✓Replication can revert to native slave with two commands (trepctl offline; start slave) ✓Native replication can continue on other slaves Tuesday, October 25, 11 44
  • 51. parallel replication direct slave facts ✓No need to install Tungsten on the master ✓Tungsten runs only on the slave ✓Replication can revert to native slave with two commands (trepctl offline; start slave) ✓Native replication can continue on other slaves ❖Failover (either native or Tungsten) becomes a manual task Tuesday, October 25, 11 44
  • 53. multiple masters • Tungsten Replicator recipe: use more services Tuesday, October 25, 11 46
  • 55. Bi-directional replication with slaves Tuesday, October 25, 11 48
  • 57. multiple sources • Tungsten Replicator recipe is still valid: use more services Tuesday, October 25, 11 50
  • 59. Multiple masters replication: 3 nodes Tuesday, October 25, 11 52
  • 60. Multiple masters replication: 4 nodes Tuesday, October 25, 11 53
  • 62. Conflict prevention facts Tuesday, October 25, 11 55
  • 63. Conflict prevention facts • Sharded by database Tuesday, October 25, 11 55
  • 64. Conflict prevention facts • Sharded by database • Defined dynamically Tuesday, October 25, 11 55
  • 65. Conflict prevention facts • Sharded by database • Defined dynamically • Applied either at the master or at the slave Tuesday, October 25, 11 55
  • 66. Conflict prevention facts • Sharded by database • Defined dynamically • Applied either at the master or at the slave • methods: Tuesday, October 25, 11 55
  • 67. Conflict prevention facts • Sharded by database • Defined dynamically • Applied either at the master or at the slave • methods: • make replication fail Tuesday, October 25, 11 55
  • 68. Conflict prevention facts • Sharded by database • Defined dynamically • Applied either at the master or at the slave • methods: • make replication fail • drop silently Tuesday, October 25, 11 55
  • 69. Conflict prevention facts • Sharded by database • Defined dynamically • Applied either at the master or at the slave • methods: • make replication fail • drop silently • drop with warning Tuesday, October 25, 11 55
  • 70. Tungsten Conflict prevention points host1 host3 M S S host2 host4 master S M S Tuesday, October 25, 11 56
  • 71. Tungsten Conflict prevention points host1 host3 M S S host2 host4 master S M S Tuesday, October 25, 11 56
  • 72. Tungsten Conflict prevention points host1 host3 M S S host2 host4 master S M S Tuesday, October 25, 11 56
  • 73. Prevention methods: Fail on master host1 host3 M S S host2 host4 master S M S Tuesday, October 25, 11 57
  • 74. INSERT A x,y Prevention methods: Fail on master host1 host3 M S S host2 host4 master S M S INSERT A x,z Tuesday, October 25, 11 57
  • 75. INSERT A x,y Prevention methods: Fail on master host1 host3 M S S host2 host4 master S M S INSERT A x,z Tuesday, October 25, 11 57
  • 76. Prevention methods: Fail on slave host1 host3 M S S host2 host4 master S M S Tuesday, October 25, 11 58
  • 77. INSERT A x,y Prevention methods: Fail on slave host1 host3 M S S host2 host4 master S M S INSERT A x,z Tuesday, October 25, 11 58
  • 78. INSERT A x,y Prevention methods: Fail on slave host1 host3 M S S host2 host4 master S M S INSERT A x,z Tuesday, October 25, 11 58
  • 79. Prevention methods: Fail on slave host1 (Multiple sources) M host2 host3 master M S Tuesday, October 25, 11 59
  • 80. INSERT A x,y Prevention methods: Fail on slave host1 (Multiple sources) M host2 host3 master M S INSERT A x,z Tuesday, October 25, 11 59
  • 81. INSERT A x,y Prevention methods: Fail on slave host1 (Multiple sources) M host2 host3 master M S INSERT A x,z Tuesday, October 25, 11 59
  • 82. Prevention methods: DROP on master host1 host3 M S S host2 host4 master S M S Tuesday, October 25, 11 60
  • 83. INSERT A x,y Prevention methods: DROP on master host1 host3 M S S host2 host4 master S M S Tuesday, October 25, 11 60
  • 84. INSERT A x,y Prevention methods: DROP on master host1 host3 M S S host2 host4 master S M S INSERT A x,z Tuesday, October 25, 11 60
  • 85. Prevention methods: DROP on master host1 host3 M S S host2 host4 master S M S INSERT A x,z Tuesday, October 25, 11 60
  • 86. Prevention methods: DROP on slave host1 (Multiple sources) M host2 host3 master M S Tuesday, October 25, 11 61
  • 87. INSERT A x,y Prevention methods: DROP on slave host1 (Multiple sources) M host2 host3 master M S INSERT A x,z Tuesday, October 25, 11 61
  • 88. Prevention methods: DROP on slave host1 (Multiple sources) M host2 INSERT A host3 x,y master INSERT A M x,z S Tuesday, October 25, 11 62
  • 89. Prevention methods: DROP on slave host1 (Multiple sources) M host2 host3 master INSERT A M x,z S Tuesday, October 25, 11 62
  • 90. Tungsten in practice Installation Tuesday, October 25, 11 63
  • 91. Installation • Check the requirements • Get the binaries • Expand the tarball • Run ./tools/tungsten-installer Tuesday, October 25, 11 64
  • 92. REQUIREMENTS • Java JRE or JDK (Sun/Oracle or Open-jdk) • Ruby 1.8 (only during installation) • ssh access to the same user in all nodes • MySQL user with all privileges Tuesday, October 25, 11 65
  • 93. Installation types • master / slave • slave - direct Tuesday, October 25, 11 66
  • 94. master/slave host2 host1 master slave THL binlog THL host3 slave THL Tuesday, October 25, 11 67
  • 95. slave direct host2 host1 slave master relay log THL binlog host3 slave relay log THL Tuesday, October 25, 11 68
  • 96. sample installation • 4 servers • qa.r1.continuent.com r1 • qa.r2.continuent.com r2 • qa.r3.continuent.com r3 • qa.r4.continuent.com r4 • MySQL 5.1 • tungsten-replicator-2.0.4 Tuesday, October 25, 11 69
  • 97. Installation (1) # starting at node 4, but any would do for N in 1 2 3 4 do ssh r$N mkdir tinstall done cd tinstall tar -xzf /path/to/tungsten-replicator-2.0.4.tar.gz cd tungsten-replicator-2.0.4 Tuesday, October 25, 11 70
  • 98. Installation (2) export TUNGSTEN_BASE=$HOME/tinstall 1 ./tools/tungsten-installer 2 --master-slave 3 --master-host=r1 4 --datasource-user=tungsten 5 --datasource-password=secret 6 --service-name=dragon 7 --home-directory=$TUNGSTEN_BASE 8 --cluster-hosts=r1,r2,r3,r4 9 --start Tuesday, October 25, 11 71
  • 99. Installation (2) export TUNGSTEN_BASE=$HOME/tinstall ./tools/tungsten-installer --master-slave # installation mode --master-host=r1 # who’s the master --datasource-user=tungsten # mysql username --datasource-password=secret # mysql password --service-name=dragon # name of the service --home-directory=$TUNGSTEN_BASE # where we install --cluster-hosts=r1,r2,r3,r4 # hosts in cluster --start # start replicator after installing Tuesday, October 25, 11 72
  • 100. What does the installation do 1: Validate all servers host4 host1 host2 host3 ✔ ✔ ✔ ✔ ✗ ✗ ✗ ✗ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ Report all errors Tuesday, October 25, 11 73
  • 101. What does the installation do 1 (again): Validate all servers host4 host1 host2 host3 ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ Tuesday, October 25, 11 74
  • 102. What does the installation do 2: install Tungsten in all servers host4 $HOME/ host1 tinstall/ host2 config/ host3 releases/ relay/ logs/ tungsten/ Tuesday, October 25, 11 75
  • 103. example ssh r2 chmod 444 $HOME/tinstall ./tools/tungsten-installer --master-slave --master-host=r1 --datasource-user=tungsten --datasource-password=secret --service-name=dragon --home-directory=$HOME/tinstall --thl-directory=$HOME/tinstall/logs --relay-directory=$HOME/tinstall/relay --cluster-hosts=r1,r2,r3,r4 --start ERROR >> qa.r2.continuent.com >> /home/tungsten/ tinstall is not writeable Tuesday, October 25, 11 76
  • 104. example ssh r2 chmod 755 $HOME/tinstall ./tools/tungsten-installer --master-slave --master-host=r1 --datasource-user=tungsten --datasource-password=secret --service-name=dragon --home-directory=$HOME/tinstall --thl-directory=$HOME/tinstall/logs --relay-directory=$HOME/tinstall/relay --cluster-hosts=r1,r2,r3,r4 --start # no errors Tuesday, October 25, 11 77
  • 105. Installation - direct ./tools/tungsten-installer --direct --master-host=r1 --slave-host=r4 --master-user=tungsten --slave-user=tungsten --master-password=secret --slave-password=secret --service-name=Castor --channels=1 --home-directory=$TUNGSTEN_BASE --start-and-report Tuesday, October 25, 11 78
  • 106. Tungsten in practice Admin Tuesday, October 25, 11 79
  • 107. Main components • THL (Tungsten generated Transaction History Log) • service database Tuesday, October 25, 11 80
  • 108. Tools • replicator • trepctl • thl Tuesday, October 25, 11 81
  • 109. replicator • It’s the service provider • You launch it once when you start • You may restart it when you change config Tuesday, October 25, 11 82
  • 110. trepctl • Tungsten Replicator ConTroLler • It’s the driving seat for your replication • You can start, update, and stop services • You can get specific info Tuesday, October 25, 11 83
  • 111. thl • Transaction History List • Gives you access to the Tungsten relay logs Tuesday, October 25, 11 84
  • 113. Tungsten Replicator vs. Enterprise Feature Replicator Enterprise Simple admin with trepctl X X MySQL Row/Statement 5.0/5.1/5.5 X X Multi-master replication X X Parallel apply (2.0) X X Distributed management with cctrl X Automated failover and recovery X Zero-downtime upgrade X SQL routing and load-balancing X Floating IP support X © Continuent 2011 Tuesday, October 25, 11 86
  • 114. Conclusion and Q&A Tuesday, October 25, 11 87
  • 115. Contact Information Worldwide 560 S. Winchester Blvd., Suite 500 San Jose, CA 95128 @datacharmer Tel (866) 998-3642 Fax (408) 668-1009 @continuent e-mail: sales@continuent.com Continuent Web Site: http://www.continuent.com Tungsten Project http://tungsten-replicator.org Getting started with Tungsten Replicator: http://datacharmer.blogspot.com © Continuent 2011 Tuesday, October 25, 11 88