Building simple and complex clusters with tungsten replicator
Upcoming SlideShare
Loading in...5
×
 

Building simple and complex clusters with tungsten replicator

on

  • 2,034 views

Creating simple and complex database replication cluster with Tungsten Replicator

Creating simple and complex database replication cluster with Tungsten Replicator

Statistics

Views

Total Views
2,034
Views on SlideShare
2,026
Embed Views
8

Actions

Likes
2
Downloads
54
Comments
0

2 Embeds 8

http://wiki.simplexi.com 7
http://chat.usealice.org 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-NonCommercial-NoDerivs LicenseCC Attribution-NonCommercial-NoDerivs LicenseCC Attribution-NonCommercial-NoDerivs License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Building simple and complex clusters with tungsten replicator Building simple and complex clusters with tungsten replicator Presentation Transcript

  • Building simple and complex replication clusters with Tungsten Giuseppe Maxia Replicator QA Director Continuent, Inc @datacharmer ©Continuent 2012. 1 This work is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported License.Tuesday, February 7, 12 1
  • From the users standpointTuesday, February 7, 12 2
  • 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 DBMSTuesday, February 7, 12 3
  • 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, February 7, 12 4
  • from this to this MySQL MySQL DBMS DBMS master master MySQL MySQL DBMS DBMS master master multiple masters?Tuesday, February 7, 12 5
  • 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, February 7, 12 6
  • 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 slaveTuesday, February 7, 12 7
  • Replicating to something else? mysql master MySQL DBMS MySQL DBMS mysql postgresql oracle mongodbTuesday, February 7, 12 8
  • All these examples tell us: Nice dream, but MySQL can’t do itTuesday, February 7, 12 9
  • Enter Tungsten ReplicatorTuesday, February 7, 12 10
  • http://code.google.com/p/tungsten-replicator Open Source 100% GPL v2Tuesday, February 7, 12 11
  • What can it do? • Easy failover • Multiple masters • Multiple sources to a single slave • Conflict prevention • Parallel replication • Replicate to Oracle and PostgreSQL databaseTuesday, February 7, 12 12
  • master-slave Heterogeneous Direct slave Regular MySQL MySQL Oracle Master Oracle MySQL fan-in slave all-masters star-schema ©Continuent 2012.Tuesday, February 7, 12 13
  • 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 proofTuesday, February 7, 12 14
  • Parallel replicationTuesday, February 7, 12 15
  • Parallel replication facts ✓Sharded by database ✓Good choice for slave lag problems ❖Bad choice for single database projectsTuesday, February 7, 12 16
  • Parallel Replication 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 lagTuesday, February 7, 12 17
  • measuring results START binary logs MySQL slave ONLINE Recording catch-up time Tungsten slave direct: alpha (slave) replicator alphaTuesday, February 7, 12 18
  • MySQL native replication slave catch up in 04:29:30Tuesday, February 7, 12 19
  • Tungsten parallel replication slave catch up in 00:55:40Tuesday, February 7, 12 20
  • Parallel replication made simpler FROM HERE ....Tuesday, February 7, 12 21
  • Parallel replication made simpler TO HERETuesday, February 7, 12 22
  • Parallel replication made simplerTuesday, February 7, 12 23
  • parallel replication direct slave factsTuesday, February 7, 12 24
  • parallel replication direct slave facts ✓No need to install Tungsten on the masterTuesday, February 7, 12 24
  • parallel replication direct slave facts ✓No need to install Tungsten on the master ✓Tungsten runs only on the slaveTuesday, February 7, 12 24
  • 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, February 7, 12 24
  • 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 slavesTuesday, February 7, 12 24
  • 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 taskTuesday, February 7, 12 24
  • Multiple mastersTuesday, February 7, 12 25
  • multiple masters • Tungsten Replicator recipe: use more servicesTuesday, February 7, 12 26
  • Bi-directional replicationTuesday, February 7, 12 27
  • Bi-directional replication with slavesTuesday, February 7, 12 28
  • Multiple sourcesTuesday, February 7, 12 29
  • multiple sources • Tungsten Replicator recipe is still valid: use more servicesTuesday, February 7, 12 30
  • Multiple source replicationTuesday, February 7, 12 31
  • Multiple masters replication: 3 nodesTuesday, February 7, 12 32
  • Multiple masters replication: 4 nodesTuesday, February 7, 12 33
  • star topologiesTuesday, February 7, 12 34
  • Conflict preventionTuesday, February 7, 12 35
  • Conflict prevention factsTuesday, February 7, 12 36
  • Conflict prevention facts • Sharded by databaseTuesday, February 7, 12 36
  • Conflict prevention facts • Sharded by database • Defined dynamicallyTuesday, February 7, 12 36
  • Conflict prevention facts • Sharded by database • Defined dynamically • Applied either at the master or at the slaveTuesday, February 7, 12 36
  • Conflict prevention facts • Sharded by database • Defined dynamically • Applied either at the master or at the slave • methods:Tuesday, February 7, 12 36
  • Conflict prevention facts • Sharded by database • Defined dynamically • Applied either at the master or at the slave • methods: • make replication failTuesday, February 7, 12 36
  • Conflict prevention facts • Sharded by database • Defined dynamically • Applied either at the master or at the slave • methods: • make replication fail • drop silentlyTuesday, February 7, 12 36
  • 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 warningTuesday, February 7, 12 36
  • Tungsten Conflict prevention points host1 host3 M S S host2 host4 master S M STuesday, February 7, 12 37
  • Tungsten Conflict prevention points host1 host3 M S S host2 host4 master S M STuesday, February 7, 12 37
  • Tungsten Conflict prevention points host1 host3 M S S host2 host4 master S M STuesday, February 7, 12 37
  • Prevention methods: Fail on master host1 host3 M S S host2 host4 master S M STuesday, February 7, 12 38
  • INSERT A x,y Prevention methods: Fail on master host1 host3 M S S host2 host4 master S M S INSERT A x,zTuesday, February 7, 12 38
  • INSERT A x,y Prevention methods: Fail on master host1 host3 M S S host2 host4 master S M S INSERT A x,zTuesday, February 7, 12 38
  • Prevention methods: Fail on slave host1 host3 M S S host2 host4 master S M STuesday, February 7, 12 39
  • INSERT A x,y Prevention methods: Fail on slave host1 host3 M S S host2 host4 master S M S INSERT A x,zTuesday, February 7, 12 39
  • INSERT A x,y Prevention methods: Fail on slave host1 host3 M S S host2 host4 master S M S INSERT A x,zTuesday, February 7, 12 39
  • Prevention methods: Fail on slave host1 (Multiple sources) M host2 host3 master M STuesday, February 7, 12 40
  • INSERT A x,y Prevention methods: Fail on slave host1 (Multiple sources) M host2 host3 master M S INSERT A x,zTuesday, February 7, 12 40
  • INSERT A x,y Prevention methods: Fail on slave host1 (Multiple sources) M host2 host3 master M S INSERT A x,zTuesday, February 7, 12 40
  • Prevention methods: DROP on master host1 host3 M S S host2 host4 master S M STuesday, February 7, 12 41
  • INSERT B x,y Prevention methods: DROP on master host1 host3 M S S host2 host4 master S M STuesday, February 7, 12 41
  • INSERT B x,y Prevention methods: DROP on master host1 host3 M S S host2 host4 master S M S INSERT B x,zTuesday, February 7, 12 41
  • Prevention methods: DROP on master host1 host3 M S S host2 host4 master S M S INSERT B x,zTuesday, February 7, 12 41
  • Prevention methods: DROP on slave host1 (Multiple sources) M host2 host3 master M STuesday, February 7, 12 42
  • INSERT A x,y Prevention methods: DROP on slave host1 (Multiple sources) M host2 host3 master M S INSERT A x,zTuesday, February 7, 12 42
  • Prevention methods: DROP on slave host1 (Multiple sources) M host2 INSERT B host3 x,y master INSERT B M x,z STuesday, February 7, 12 43
  • Prevention methods: DROP on slave host1 (Multiple sources) M host2 host3 master INSERT B M x,z STuesday, February 7, 12 43
  • Tungsten in practice InstallationTuesday, February 7, 12 44
  • Installation • Check the requirements • Get the binaries • Expand the tarball • Run ./tools/tungsten-installerTuesday, February 7, 12 45
  • 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 privilegesTuesday, February 7, 12 46
  • Installation types • master / slave • slave - directTuesday, February 7, 12 47
  • master/slave host2 host1 master slave THL binlog THL host3 slave THLTuesday, February 7, 12 48
  • slave direct host2 host1 slave master relay log THL binlog host3 slave relay log THLTuesday, February 7, 12 49
  • 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.4Tuesday, February 7, 12 50
  • 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.4Tuesday, February 7, 12 51
  • 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 --startTuesday, February 7, 12 52
  • 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 installingTuesday, February 7, 12 53
  • What does the installation do 1: Validate all servers host4 host1 host2 host3 ✔ ✔ ✔ ✔ ✗ ✗ ✗ ✗ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ Report all errorsTuesday, February 7, 12 54
  • What does the installation do 1 (again): Validate all servers host4 host1 host2 host3 ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔Tuesday, February 7, 12 55
  • What does the installation do 2: install Tungsten in all servers host4 $HOME/ host1 tinstall/ host2 config/ host3 releases/ relay/ logs/ tungsten/Tuesday, February 7, 12 56
  • 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 writeableTuesday, February 7, 12 57
  • 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 errorsTuesday, February 7, 12 58
  • 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-reportTuesday, February 7, 12 59
  • http://bit.ly/tr20_cookbookTuesday, February 7, 12 60
  • 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 2011Tuesday, February 7, 12 61
  • Conclusion and Q&ATuesday, February 7, 12 62
  • 560 S. Winchester Blvd., Suite 500 Check out our blogs! San Jose, CA 95128 http://scale-out-blog.blogspot.com Tel (866) 998-3642 http://datacharmer.blogspot.com Fax (408) 668-1009 http://flyingclusters.blogspot.com e-mail: sales@continuent.com Continuent Web Site: http://www.continuent.com Tungsten Replicator 2.0: http://code.google.com/p/tungsten-replicator ©Continuent 2012. 63Tuesday, February 7, 12 63