Your SlideShare is downloading. ×
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Drupal Camp Göteborg 2013: Skalbarhet och tillgänglighet med MySQL-replikering

211

Published on

Skala dina applikationsdata och leverera service utan avbrott med hjälp av MySQL-replikering! I Drupal sparas vanligen all dynamisk data i en MySQL-databas. MySQL är världens mest populära open …

Skala dina applikationsdata och leverera service utan avbrott med hjälp av MySQL-replikering! I Drupal sparas vanligen all dynamisk data i en MySQL-databas. MySQL är världens mest populära open source-databas och den används i 9 av världens 10 mest använda webbsajter. Med replikering kan databasen dupliceras till flera servrar. Facebook, PayPal, Twitter, Wikipedia, YouTube och Zappos förlitar sig på MySQL-replikering för att hantera tiotals miljoner användare tillförlitligt och för att hantera sin exponentiella tillväxt genom att skala ut på standardhårdvara.

Välkommen till detta föredrag för en praktisk demonstration av MySQL-replikering, där vi går igenom hur du:

- konfigurerar och kalibrerar MySQL-replikering;
- skalar dina tjänster med MySQL-replikering;
- skapar självläkande kluster med MySQL-replikering.

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
211
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Skalbarhet ochtillgänglighet medMySQL-replikeringSven Sandberg (sven.sandberg@oracle.com)Principal Software Engineer, MySQL Replication Core Team(För tillfället föräldraledig)
  • 2. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`2Safe Harbour StatementThe following is intended to outline our general product direction. It isintended for information purposes only, and may not be incorporated into anycontract.It is not a commitment to deliver any material, code, or functionality, andshould not be relied upon in making purchasing decisions. The development,release, and timing of any features or functionality described for Oracle’sproducts remains at the sole discretion of Oracle.
  • 3. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`3OverviewMySQL Replication Design Setting Up
  • 4. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`4OverviewMySQL Replication Design Setting Up
  • 5. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`5Industry Leaders Rely On MySQLReplication  Design  Setting UpCloudOEM & ISVsWeb & Enterprise
  • 6. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`6Replication: Copy Changes Master → Slave MySQL Master Server– Changes data– Sends changes to slave MySQL Slave Server– Receives changes from master– Applies received changes to databaseM SReplication  Design  Setting Up
  • 7. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`7Replication: Copy Changes Master → SlaveM M/S SSSSMSMMServer can be master, slave or bothMaster can have multiple slavesSlave can only have one masterReplication  Design  Setting Up
  • 8. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`8Replication: Copy Changes Master → SlaveM/SSMMCircular replication is also possibleYou can simulate multiplemasters by time-sharingM/SM/SM/SM/SM/SSMMSwitchevery 5 secReplication  Design  Setting Up
  • 9. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`9Why Replication? – Performance Read scale-outM Swrite clients read clientsReplication  Design  Setting Up
  • 10. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`10Why Replication? – Performance Read scale-outM Swrite clients read clientsMorereads?Moreslaves!Replication  Design  Setting Up
  • 11. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`11Why Replication? – Performance Read scale-outM SSSSMwrite clients read clientsread clientswrite clientsMorereads?Moreslaves!Replication  Design  Setting Up
  • 12. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`12Why Replication? – Redundancy If master crashes, promote slave to masterCBAReplication  Design  Setting Up
  • 13. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`13Why Replication? – Redundancy If master crashes, promote slave to masterCBAReplication  Design  Setting UpCrash
  • 14. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`14Why Replication? – Redundancy If master crashes, promote slave to masterCBAB is thenew masterReplication  Design  Setting Up
  • 15. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`15Why Replication? – Long-distance DataDistributionCBBAACImage fromwww.ginkgomaps.comReplication  Design  Setting Up
  • 16. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`16Replication  Design  Setting UpCool!So, give me a 7 minintro to replication.
  • 17. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`17OverviewMySQL Replication Design Setting Up
  • 18. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`18All Changes Written to Binary Logbinary logClientReplication  Design  Setting Up
  • 19. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`19All Changes Written to Binary Logbinary logClientcreate table t (a int);Replication  Design  Setting Up
  • 20. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`20All Changes Written to Binary Logcreate...binary logClientTable tcreate table t (a int);Replication  Design  Setting Up
  • 21. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`21All Changes Written to Binary Logcreate...binary logClientTable tcreate table t (a int);insert into t values (1);Replication  Design  Setting Up
  • 22. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`22All Changes Written to Binary Logcreate...insert...binary logClientTable t1create table t (a int);insert into t values (1);Replication  Design  Setting Up
  • 23. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`23Slave Initiates ReplicationBbinary logAbinary logClientReplication  Design  Setting Up1. Slave sendsrequest to start replicationto master2. Master sendsstream of replication datato slave
  • 24. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`24create...Binary Log Sent to Slave, Re-executedReplication  Design  Setting UpBbinary logAbinary logClient
  • 25. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`25create...Binary Log Sent to Slave, Re-executedTable tReplication  Design  Setting UpBbinary logcreate...Abinary logClient
  • 26. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`26create...Binary Log Sent to Slave, Re-executedTable t Table tReplication  Design  Setting Upcreate...Bbinary logcreate...Abinary logClient
  • 27. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`27create...insert...Binary Log Sent to Slave, Re-executedTable t Table tReplication  Design  Setting Upcreate...Bbinary logcreate...Abinary logClient
  • 28. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`28create...insert...Binary Log Sent to Slave, Re-executedTable t1Table tReplication  Design  Setting Upcreate...Bbinary logcreate...insert...Abinary logClient
  • 29. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`29create...insert...Binary Log Sent to Slave, Re-executedTable t1Table t1Replication  Design  Setting Upcreate...insert...Bbinary logcreate...insert...Abinary logClient
  • 30. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`30Actually, Changes Land in Slaves Relay LogBbinary logrelay logAbinary logClientDumpthreadIOthreadSQLthreadReplication  Design  Setting UpNetwork
  • 31. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`31create...Actually, Changes Land in Slaves Relay LogBbinary logrelay logAbinary logClientDumpthreadIOthreadSQLthreadReplication  Design  Setting UpNetwork
  • 32. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`32create...Actually, Changes Land in Slaves Relay LogBbinary logrelay logcreate...Abinary logClientDumpthreadIOthreadSQLthreadTable tReplication  Design  Setting UpNetwork
  • 33. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`33create...Actually, Changes Land in Slaves Relay LogBbinary logcreate...relay logcreate...Abinary logClientDumpthreadIOthreadSQLthreadTable tReplication  Design  Setting UpNetwork
  • 34. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`34create...Actually, Changes Land in Slaves Relay Logcreate...Bbinary logcreate...relay logcreate...Abinary logClientDumpthreadIOthreadSQLthreadTable t Table tReplication  Design  Setting UpNetwork
  • 35. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`35create...insert...Actually, Changes Land in Slaves Relay Logcreate...Bbinary logcreate...relay logcreate...Abinary logClientDumpthreadIOthreadSQLthreadTable t Table tReplication  Design  Setting UpNetwork
  • 36. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`36create...insert...Actually, Changes Land in Slaves Relay Logcreate...Bbinary logcreate...relay logcreate...insert...Abinary logClientDumpthreadIOthreadSQLthreadTable t1Table tReplication  Design  Setting UpNetwork
  • 37. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`37create...insert...Actually, Changes Land in Slaves Relay Logcreate...Bbinary logcreate...insert...relay logcreate...insert...Abinary logClientDumpthreadIOthreadSQLthreadTable t1Table tReplication  Design  Setting UpNetwork
  • 38. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`38create...insert...Actually, Changes Land in Slaves Relay Logcreate...insert...Bbinary logcreate...insert...relay logcreate...insert...Abinary logClientDumpthreadIOthreadSQLthreadTable t1Table t1Replication  Design  Setting UpNetwork
  • 39. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`39create...Replication is Asynchronouscreate...Bbinary logcreate...relay logcreate...Abinary logClientDumpthreadIOthreadSQLthreadTable t Table tAtomic → db and logconsistent after crashAtomic → db and logconsistent after crashAsynchronous Asynchronous Asynchronous(Atomictoo)(Atomictoo)Replication  Design  Setting UpNetwork
  • 40. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`40Replication  Design  Setting UpReplicationseems fantastic!I want to try!
  • 41. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`41OverviewMySQL Replication Design Setting Up
  • 42. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`42Setting Up Replication Masters my.cnf:server­id=1log­bin=master­bin Slaves my.cnf:server­id=2log­bin=slave­binrelay­log=slave­relay­binlog­slave­updatesReplication  Design  Setting Up
  • 43. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`43Setting Up Replication On master: create replication user> CREATE USER `rpl_user`@`slave_host`;> GRANT REPLICATION SLAVE ON *.*     TO `rpl_user`@`slave_host` IDENTIFIED BY secret;> FLUSH PRIVILEGES; On slave: initiate replication> CHANGE MASTER TO  MASTER_HOST = master_host, MASTER_PORT = <port>,  MASTER_USER = rpl_user, MASTER_PASSWORD = secret;> START SLAVE;Replication  Design  Setting Up
  • 44. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`44Replicate! On master: execute some SQL> USE test_db;> CREATE TABLE t1 (a INT);> INSERT INTO t1 VALUES (1); On slave: check that it replicated:> SELECT * FROM test_db.t1;a1Replication  Design  Setting Up
  • 45. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`45Check Replication Status On master:> SHOW BINARY LOGS;> SHOW BINLOG EVENTS;Log_name File_sizemaster-bin.000001 426Log_name Pos Event_type sid end_pos Infomaster-bin.000001 4 Format_desc 1 120 Server ver: 5.6.6-m9-log, Binlog ver: 4master-bin.000001 120 Query 1 217 use `test`; CREATE TABLE t1 (a INT)master-bin.000001 217 Query 1 296 BEGINmaster-bin.000001 296 Query 1 395 use `test`; INSERT INTO t1 VALUES (1)master-bin.000001 395 Xid 1 426 COMMIT /* xid=21 */One binary logso farFive events:One CREATE andone INSERTReplication  Design  Setting Up
  • 46. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`46Check Replication Status On slave:> SHOW SLAVE STATUSG…Slave_IO_Running YesSlave_SQL_Running Yes…Last_IO_Errno 0Last_IO_ErrorLast_SQL_Errno 0Last_SQL_Error…Both slave threadsare runningIf any thread stopswith an error,look for errormessage hereReplication  Design  Setting Up
  • 47. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`47Replication  Design  Setting UpNext? Vote!1. Fail-over + Crash tolerance2. Fail-over + Q&A3. Q&A
  • 48. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`48OverviewMySQL ReplicationCrash-Tolerance Failover Reduce Risk for Data Loss– Semi-sync– Transactional meta-data Performance– Transactional meta-data– Multi-threaded slave
  • 49. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`49Crash-Tolerance Can happen to anyone:– Hardware failure– Human mistake– Bug– Natural disaster Features in MySQL 5.6:– Reduce admin overhead– Prevent unplanned downtime– Prevent planned downtimeCrash-Tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 50. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`50Crash-Tolerance Fail-over: “back on track” faster & more automatically– Global Transaction Identifiers Reduce risk for data loss: less administration → less downtime– Semi-synchronous replication → slave has all changes from master– Update replication metadata transactionally → safe on disk Performance: help slave keep up with master– Replication metadata in table – leverage disk sync from storage engine– Multi-threaded slave5.55.6Crash-Tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 51. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`51Crash-Tolerance  Fail-over  Reduce Risk for Data Loss  PerformanceOK.Tell me aboutfail-over!
  • 52. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`52OverviewMySQL ReplicationCrash-Tolerance Failover Reduce Risk for Data Loss– Semi-sync– Transactional meta-data Performance– Transactional meta-data– Multi-threaded slave
  • 53. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`53Fail-over Handle server crash with minimal disruption Example 1: treeCBACrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 54. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`54Fail-over Handle server crash with minimal disruption Example 1: treeCBACrash-tolerance  Fail-over  Reduce Risk for Data Loss  PerformanceCrash
  • 55. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`55Fail-overCBA Handle server crash with minimal disruption Example 1: treeCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 56. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`56Fail-overCBAMake B the new master Handle server crash with minimal disruption Example 1: treeCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 57. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`57Fail-overCA B Handle server crash with minimal disruption Example 1: tree Example 2: lineCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 58. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`58Fail-overCA B Handle server crash with minimal disruption Example 1: tree Example 2: lineCrash-tolerance  Fail-over  Reduce Risk for Data Loss  PerformanceCrash
  • 59. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`59Fail-overCA B Handle server crash with minimal disruption Example 1: tree Example 2: lineCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 60. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`60Fail-overCA BMake A direct master of C Handle server crash with minimal disruption Example 1: tree Example 2: lineCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 61. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`61Fail-overCABD Handle server crash with minimal disruption Example 1: tree Example 2: line Example 3: circleCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 62. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`62Fail-overCABD Handle server crash with minimal disruption Example 1: tree Example 2: line Example 3: circleCrash-tolerance  Fail-over  Reduce Risk for Data Loss  PerformanceCrash
  • 63. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`63Fail-overCABD Handle server crash with minimal disruption Example 1: tree Example 2: line Example 3: circleCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 64. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`64Fail-overCAMake a shortcutin the circleBD Handle server crash with minimal disruption Example 1: tree Example 2: line Example 3: circleCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 65. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`65Fail-overCABD Handle server crash with minimal disruption Example 1: tree Example 2: line Example 3: circle Example 4: scheduled maintenanceCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 66. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`66Fail-overCABDTakeout D! Handle server crash with minimal disruption Example 1: tree Example 2: line Example 3: circle Example 4: scheduled maintenanceCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 67. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`67Fail-overCABDMaintainD offline,withoutdisruptingservice Handle server crash with minimal disruption Example 1: tree Example 2: line Example 3: circle Example 4: scheduled maintenanceCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 68. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`68Fail-overCABD Handle server crash with minimal disruption Example 1: tree Example 2: line Example 3: circle Example 4: scheduled maintenanceCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 69. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`69Fail-over Handle server crash with minimal disruption Example 1: tree Example 2: line Example 3: circle Example 4: scheduled maintenance Example 5: arbitrary topologyCrash-tolerance  Fail-over  Reduce Risk for Data Loss  PerformanceABCDEF
  • 70. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`70Fail-over: Design Server assigns Global Transaction Identifier (GTID) to everytransaction:– server_uuid:numbera61678ba­4889­4279­9e58­45ba840af334:1– server_uuid identifies the server; globally unique– number is incremented by 1 for each transaction on this server Writes GTID to binary log Slave preserves GTID when re-executing transactionCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 71. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`71Fail-over: Design: New Events In Binary Log> SHOW BINLOG EVENTS;Log_name Pos Event_type sid end_pos Infomaster-bin.000001 4 Format_desc 1 120 Server ver: 5.6.12-m9-log, Binlog ver: 4master-bin.000001 120 Prev_gtids 1 151master-bin.000001 151 Gtid 1 199 SET @@GTID_NEXT= <uuid>:1master-bin.000001 199 Query 1 296 use `test`; CREATE TABLE t1 (a INT)master-bin.000001 296 Gtid 1 344 SET @@GTID_NEXT= <uuid>:2master-bin.000001 344 Query 1 423 BEGINmaster-bin.000001 423 Query 1 522 use `test`; INSERT INTO t1 VALUES (1)master-bin.000001 522 Xid 1 602 COMMIT /* xid=21 */3 new events:1 Previous_gtids +2 GtidCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performancefileheadertrans-actiontrans-action
  • 72. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`72Fail-over: Design: Protocol Master-slave protocol:– Slave sends to master:range of identifiers of executed transactions to master– Master sends all other transactions to slave(slave)id1,trx1,id2,trx2(master)id1,trx1,id2,trx2,id3,trx3binlogA 2. id3, trx3, …1. id1…id2binlogBCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 73. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`73Fail-over: Design: Protocol Example 1: treeA(crashed)(master)Aid1,trx1,id2,trx2,id3,trx3binlog(slave)Cid1,trx1binlog(slave)id1,trx1,id2,trx2BbinlogCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 74. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`74Fail-over: Design: Protocol Example 1: treeA(crashed)(master)Aid1,trx1,id2,trx2,id3,trx3binlog(slave)Cid1,trx1binlog(slave)id1,trx1,id2,trx2BbinlogCrash-tolerance  Fail-over  Reduce Risk for Data Loss  PerformanceCrash
  • 75. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`75Fail-over: Design: Protocol Example 1: tree(slave)Cid1,trx1binlog(slave)id1,trx1,id2,trx2BbinlogA(crashed)(crashed)Aid1,trx1,id2,trx2,id3,trx3binlog id1id2, trx2,...Crash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 76. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`76Fail-over: Design: Protocol Example 1: tree Example 2: circleBbinlogAbinlogCbinlogclient clientCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 77. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`77Fail-over: Design: Protocol Example 1: tree Example 2: circleid1,trx1BbinlogAbinlogCbinlogclient client trx1Crash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 78. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`78Fail-over: Design: Protocol Example 1: tree Example 2: circleid1,trx1,id2,trx2Bbinlogid2,trx2AbinlogCbinlogclient clienttrx2 trx1Crash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 79. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`79Fail-over: Design: Protocol Example 1: tree Example 2: circleid1,trx1,id2,trx2,id3,trx3Bbinlogid2,trx2AbinlogCbinlogclient clienttrx2 trx1, trx3Crash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 80. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`80Fail-over: Design: Protocol Example 1: tree Example 2: circleid1,trx1,id2,trx2,id3,trx3Bbinlogid2,trx2AbinlogCbinlogclient clienttrx2 trx1, trx3Crash-tolerance  Fail-over  Reduce Risk for Data Loss  PerformanceCrash
  • 81. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`81Fail-over: Design: Protocol Example 1: tree Example 2: circleid1,trx1,id2,trx2,id3,trx3Bbinlogid2,trx2AbinlogCbinlogclient clienttrx2 trx1, trx3id2id1,trx1,id3,trx3,...Crash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 82. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`82Crash-tolerance  Fail-over  Reduce Risk for Data Loss  PerformanceWow!Show me how toconfigure forfail-over!
  • 83. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`83Fail-over: Set Up Prerequisites:– Configure replication as usual– Use transactional storage engine for all tables (InnoDB)– Dont use CREATE TABLE … SELECTCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 84. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`84Fail-over: Set Up Prepare the server for fail-over1. Sync and stop all servers2. Add to every my.cnf:gtid­mode=onenforce­gtid­consistency=onlog­binlog­slave­updates3. Start all servers4. Create replication user on every server that may become master5. Execute:> CHANGE MASTER TO MASTER_AUTO_POSITION = 1Crash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 85. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`85Fail-over: Perform Perform fail-overOn each slave:> CHANGE MASTER TO MASTER_HOST = <host>,                   MASTER_PORT = <port number>,                   MASTER_USER = <user name>                   MASTER_PASSWORD = secret;Crash-tolerance  Fail-over  Reduce Risk for Data Loss  PerformanceCredentials onnew master
  • 86. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`86Fail-over: Perform Perform fail-overCBACHANGE MASTER TOMASTER_HOST = B,MASTER_PORT = <Bs port>,MASTER_USER = <user name>MASTER_PASSWORD = secret;Crash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 87. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`87Fail-over: Perform Perform fail-overCHANGE MASTER TOMASTER_HOST = C,MASTER_PORT = <Cs port>,MASTER_USER = <user name>MASTER_PASSWORD = secret;CABDCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 88. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`88Crash-tolerance  Fail-over  Reduce Risk for Data Loss  PerformanceI love GTIDs!Can fail-over beautomated?
  • 89. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`89Fail-over: Utilities Mysqlrpladmin– Promote one slave to master– mysqlrpladmin switchover  ­­master=user[:pass]@host[:port][:sock]  ­­discover­slaves­login=user[:pass]  ­­new­master=user[:pass]@host[:port][:sock]– Many other admin tasksCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 90. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`90Fail-over: Utilities Mysqlfailover– Monitor master– If master goes away, do automatic fail-over– mysqlfailover  ­­master=user[:password]@host[:port[:socket]]  ­­discover­slaves­login=user:passwordCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 91. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`91Fail-over: Utilities Video tutorial– dev.mysql.com/tech­resources/articles/mysql­replication­utilities.html  Blog– drcharlesbell.blogspot.co.uk/2012/04/mysql­utilities­and­global­transaction.html  Doc– dev.mysql.com/doc/workbench/en/mysqlfailover.html– dev.mysql.com/doc/workbench/en/mysqlrpladmin.htm  Download– www.mysql.com/downloads/workbench/Crash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 92. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`92Crash-tolerance  Fail-over  Reduce Risk for Data Loss  PerformanceNow I cando fail-over!But how do I avoidlosing data aftera crash?
  • 93. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`93OverviewMySQL ReplicationCrash-Tolerance Failover Reduce Risk for Data Loss– Semi-sync– Transactional meta-data Performance– Transactional meta-data– Multi-threaded slave
  • 94. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`94Overview - less manual work- reduce downtimeMySQL ReplicationCrash-Tolerance Failover Reduce Risk for Data Loss– Semi-sync– Transactional meta-data Performance– Transactional meta-data– Multi-threaded slave
  • 95. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`95Overview - less manual work- reduce downtimeMySQL ReplicationCrash-Tolerance Failover Reduce Risk for Data Loss– Semi-sync– Transactional meta-data Performance– Transactional meta-data– Multi-threaded slavea.k.a. “slave has allchanges from master”
  • 96. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`96Asynchronous vs Semi-sync Replication By default, replication is asynchronous– Master does not wait for slave– Fast– ACK to app before slave receives change → changes lost if master dies New in MySQL 5.5: semi-synchronous replication plugin– Master acks to apponly after changes are in slaves relay log– Master has to wait– Less risk for lost updatesCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 97. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`97create...Replication is Asynchronouscreate...Bbinary logcreate...relay logcreate...Abinary logClientDumpthreadIOthreadSQLthreadTable t Table tCrash-tolerance  Fail-over  Reduce Risk for Data Loss  PerformanceNetwork
  • 98. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`98create...Replication is Asynchronouscreate...Bbinary logcreate...relay logcreate...Abinary logClientDumpthreadIOthreadSQLthreadTable t Table tAtomic → db and logconsistent after crashAtomic → db and logconsistent after crashAsynchronous Asynchronous Asynchronous(Atomictoo)(Atomictoo)Crash-tolerance  Fail-over  Reduce Risk for Data Loss  PerformanceNetwork
  • 99. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`99create...Semi-synchronous Replicationcreate...Bbinary logcreate...relay logcreate...Abinary logClientDumpthreadIOthreadSQLthreadTable t Table tAsynchronousNetworkSemi-synchronous replication:statement is in slaves relay logbefore client ackCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 100. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`100Semi-synchronous Replication: Set Up Consists of two plugins: master plugin, slave plugin Installation: read the manual :-)– http://dev.mysql.com/doc/refman/5.6/en/replication­semisync­installation.html After installation:– On master:SET GLOBAL rpl_semi_sync_master_enabled = {0|1};– On slave:SET GLOBAL rpl_semi_sync_slave_enabled = {0|1};Crash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 101. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`101Crash-tolerance  Fail-over  Reduce Risk for Data Loss  PerformanceSo semi-syncensures slave has allchanges before my appgets notified.Anything else that helpsconsistency aftera crash?
  • 102. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`102OverviewMeta-datasafe on diskMySQL ReplicationCrash-Tolerance Failover Reduce Risk for Data Loss– Semi-sync– Transactional meta-data Performance– Transactional meta-data– Multi-threaded slave
  • 103. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`103Replication Metadata in Tables Slave threads maintain their current positions– IO thread: where to read from master– SQL thread: where to read from relay log Positions stored on disk– Before: in file– 5.6: in tableCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performanceinsert...Bbinary loginsert...relay logIOthreadSQLthread
  • 104. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`104Replication Metadata in Tables File: updated aftertransaction commitCrash-tolerance  Fail-over  Reduce Risk for Data Loss  PerformanceTrans-actionUpdatepositionTrans-actionUpdatepositionCrashpossible Table: updated atomically attransaction commit Consistent after server crash
  • 105. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`105Replication Metadata in Tables: Set Up Only meaningful if using transactional storage engine Add to slaves my.cnf:master­info­repository=TABLEslave­info­repository=TABLEdefault­storage­engine=InnoDBCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 106. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`106Crash-tolerance  Fail-over  Reduce Risk for Data Loss  PerformanceNice!Also, wont slave be morein sync if we improveslave performance?
  • 107. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`107OverviewMySQL ReplicationCrash-Tolerance Failover Reduce Risk for Data Loss– Semi-sync– Transactional meta-data Performance– Transactional meta-data– Multi-threaded slaveSlave less behind→ less lost updates,short fail-over time
  • 108. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`108OverviewMySQL ReplicationCrash-Tolerance Failover Reduce Risk for Data Loss– Semi-sync– Transactional meta-data Performance– Transactional meta-data– Multi-threaded slaveSlave less behind→ less lost updates,short fail-over timeFewer disk syncs
  • 109. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`109Performance: Replication Metadata In TablesCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance File: separate disk syncfor the fileTrans-actionUpdatepositionTrans-actionUpdatepositionSync Table: leverage sync fromstorage engine (even better: group commit) Again, use transactional engineSync Sync
  • 110. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`110Crash-tolerance  Fail-over  Reduce Risk for Data Loss  PerformanceAhh, sotransactional meta-datais double-good!How else can I improveslave performance?
  • 111. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`111OverviewMySQL ReplicationCrash-Tolerance Failover Reduce Risk for Data Loss– Semi-sync– Transactional meta-data Performance– Transactional meta-data– Multi-threaded slave
  • 112. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`112Performance: Parallel Slave ThreadsBbinary logrelay logAbinary logClientClientParallel writerthreads on masterWrites are serializedin binary logSingle applieron slave →Can becomebottleneckClientCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 113. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`113Performance: Parallel Slave ThreadsBbinary logrelay logAbinary logClientClientClientCoordinatorthread (reading)Multiple workerthreads! (executing)Crash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 114. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`114Performance: Parallel Slave Threads Parallelize by schema (database)– Different worker threads never update same schema– Effective if you partition data by schema Consistency– Consistent within schema– Eventually consistent between schemas– Commit order may differ between master and slave, among slavesCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 115. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`115Performance: Parallel Slave Threads Parallelize by schema (database)BTrx1: DB1Trx2: DB2Trx3: DB3+DB1relay log3 workerthreadsCoordinatorthreadw1w2w3Crash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 116. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`116Performance: Parallel Slave Threads Parallelize by schema (database)BTrx1: DB1Trx2: DB2Trx3: DB3+DB13 workerthreadsCoordinatorthreadDB1w1w2w3relay logCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 117. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`117Performance: Parallel Slave Threads Parallelize by schema (database)BTrx1: DB1Trx2: DB2Trx3: DB3+DB13 workerthreadsCoordinatorthreadDB1DB2w1w2w3relay logCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 118. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`118Performance: Parallel Slave Threads Parallelize by schema (database)BTrx1: DB1Trx2: DB2Trx3: DB3+DB13 workerthreadsCoordinatorthreadDB1DB2w1w2w3DB3relay logCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 119. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`119Performance: Parallel Slave Threads Parallelize by schema (database)BTrx1: DB1Trx2: DB2Trx3: DB3+DB13 workerthreadsCoordinatorthreadDB1DB2w1w2w3DB3Coordinator waits for w1 to finishbefore feeding DB1 update to w3relay logCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 120. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`120Performance: Parallel Slave Threads Parallelize by schema (database)BTrx1: DB1Trx2: DB2Trx3: DB3+DB13 workerthreadsCoordinatorthreadDB2w1w2w3DB3Coordinator waits for w1 to finishbefore feeding DB1 update to w3relay logCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 121. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`121Performance: Parallel Slave Threads Parallelize by schema (database)BTrx1: DB1Trx2: DB2Trx3: DB3+DB13 workerthreadsCoordinatorthreadDB2w1w2w3DB3Coordinator waits for w1 to finishbefore feeding DB1 update to w3DB1relay logCrash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 122. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`122Performance: Parallel Slave Threads: Set Up On slave:> STOP SLAVE;> SET SLAVE_PARALLEL_WORKERS = 4;> START SLAVE;Depends on number of CPUsand number of databases.No exact formula –measure whats best for you!Crash-tolerance  Fail-over  Reduce Risk for Data Loss  Performance
  • 123. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`123Crash-tolerance  Fail-over  Reduce Risk for Data Loss  PerformanceThank you,thats a lot of info!Can yousummarize?
  • 124. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`124SummaryMySQL ReplicationCrash-Tolerance Failover Reduce Risk for Data Loss– Semi-sync– Transactional meta-data Performance– Transactional meta-data– Multi-threaded slave
  • 125. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`125Semi-syncGlobalTransactionIdentifiersReplicationBaseTransactionalMetadataParallel slave My.cnf:server­id=<different number for each server>log­bin=<host>­binrelay­log=<host>­relay­binlog­slave­updatesmaster­info­repository=TABLEslave­info­repository=TABLEdefault­storage­engine=InnoDBgtid­mode=onenforce­gtid­consistency=on Client commands:> CHANGE MASTER TO MASTER_AUTO_POSITION = 1;> SET SLAVE_PARALLEL_WORKERS = 4;> SET GLOBAL rpl_semi_sync_master_enabled = {0|1};> SET GLOBAL rpl_semi_sync_slave_enabled = {0|1};Summary
  • 126. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |`126Crash-tolerance  Fail-over  Reduce Risk for Data Loss  PerformanceThank you!Questions?Email: sven.sandberg@oracle.comBlog: svenmysql.blogspot.co.uk
  • 127. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. |127

×