MySQL 5.6 Global Transaction Identifier - Use case: Failover
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

MySQL 5.6 Global Transaction Identifier - Use case: Failover

on

  • 8,043 views

MySQL 5.6 significantly improves availability of a MySQL replication cluster. Built-in global transaction identifier make slave to master promotion easy after the master has failed. Learn what idea ...

MySQL 5.6 significantly improves availability of a MySQL replication cluster. Built-in global transaction identifier make slave to master promotion easy after the master has failed. Learn what idea takes the MySQL primary copy based replication approach to the next level. See also, how PECL/mysqlnd_ms integrates with it for seamless client connection failover.

Statistics

Views

Total Views
8,043
Views on SlideShare
2,607
Embed Views
5,436

Actions

Likes
2
Downloads
47
Comments
0

28 Embeds 5,436

http://blog.ulf-wendel.de 4175
http://www.planet-php.net 634
http://it-republik.de 176
http://planet-php.net 148
http://planet-php.org 81
http://entwickler.com 60
http://www.planet-php.org 59
http://entwickler.de 44
http://localhost 11
http://www.newsblur.com 8
http://translate.googleusercontent.com 7
http://entwickler-magazin.de 5
http://php5.planet-php.org 5
http://127.0.0.1 4
http://phpmagazin.de 3
http://www.blog.ulf-wendel.de 2
http://www.btekd.com 2
http://www.hanrss.com 2
https://twitter.com 1
http://blog.ulfwendel.de 1
http://webcache.googleusercontent.com 1
http://www.planet-php.org&_=1331807440545 HTTP 1
http://blog.planet-php.org 1
http://www.planet-php.org&_=1331902226304 HTTP 1
http://wall.bit-tests.1and1.com 1
http://www.planet-php.org&_=1331816144115 HTTP 1
http://www.planet-php.org&_=1331816140631 HTTP 1
http://www.tuicool.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

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

MySQL 5.6 Global Transaction Identifier - Use case: Failover Presentation Transcript

  • 1. Ulf Wendel, Oracle MySQL 5.6Global Transaction Ids Use case: Failover MySQL 5.6, PECL/mysqlnd_ms 1.3
  • 2. The speaker says...It is all about MySQL Replication. MySQL Replication is thedatabase scale-out solution of the LAMP stack. MySQLReplication is using lazy primary copy (master/slave).Built-in global transaction identifier of MySQL 5.6make server failover semi-automatic.PECL/mysqlnd_ms features connection failover since1.0, comes with a client-side emulation of globaltransaction identifier since 1.2, supports the use ofthe MySQL 5.6 built-in global transaction identifiersince 1.3 (under development) but goes beyond thefailover aspect. In this slide set – use case #1 failover.
  • 3. MySQL ReplicationPrimary copy (master/slave) for read-scale out Writes/updates: master Reads: slaves MySQL Master Log 7, Pos 34: UPDATE x=1 Log 7, Pos 35: UPDATE x=9 MySQL Slave 1 MySQL Slave 2 Log 2, Pos 1: UPDATE x=1 Log 8, Pos 1: UPDATE x=1 Log 2, Pos 2: UPDATE x=9
  • 4. The speaker says...Use case #1: Master failover.In a MySQL Replication setup all writes/updates must beexecuted at the master. PECL/mysqlnd_ms, a transparentplugin for the PHP mysqlnd library, does the necessary R/Wsplit for you.The master logs all updates. Slaves read the updatesand replay them. Slaves copy updates from theprimary, thus the name primary copy. The copyprocess is asynchronous. Replicas may lag behind. There isone master – it is a single point of failure.
  • 5. Using GTIDs for master failoverSlave to master promotion after master outage Which slave is the most current? How to copy transactions from S1 to S2? MySQL Master Log 7, Pos 34: UPDATE x=1 Log 7, Pos 35: UPDATE x=9 MySQL Slave 1 MySQL Slave 2 Log 2, Pos 1: UPDATE x=1 Log 8, Pos 1: UPDATE x=1 Log 2, Pos 2: UPDATE x=9
  • 6. The speaker says...The master fails, it becomes unavailable alltogether. A slavemust be promoted to become the new master.It is hard to tell which slave has the latesttransactions. Transactions are referenced by log fileoffsets. The highest log position does not necessarilythe refer to the latest transaction.Identification of transactions is hard. Log positions cannotbe compared among replicas because different logfile settings may result in different offsets. Forexample, two replicas may use different setting for logrotation.
  • 7. Global transaction identifierCombination of server id and sequence number Emulation: PECL/mysqlnd_ms 1.2, MySQL Proxy Built-in: MySQL 5.6 MySQL Master Log 7, Pos 34, GTID M:1: UPDATE x=1 Log 7, Pos 35, GTID M:2: UPDATE x=9 MySQL Slave 1 MySQL Slave 2 … , GTID M:1: UPDATE x=1 … , GTID M:1: UPDATE x=1 … , GTID M:2: UPDATE x=9
  • 8. The speaker says...A global transaction identifier is a cluster-wideunique transaction identifier. MySQL 5.6 can generate itautomatically. MySQL Proxy and PECL/mysqlnd_ms 1.2feature client-side emulations for use with any MySQLversion.The sequence number makes it easy to identify thelatest transactions for a given master. This helps toidentify the most current slave. Because it is now easyto uniquely identify a transaction it is clear Slave 1 shouldbe the new master. Slave 2 becomes a slave of Slave 1.Slave 2 continues replication with transaction M:2.
  • 9. Availability improved, solved?Master failover improved! Scriptable, unattended failover possible No 3rd party solution requiredMySQL Master (was: Slave 1) MySQL Master … , GTID M:1: UPDATE x=1 … , GTID M:2: UPDATE x=9 … , GTID S:1: UPDATE x=0 MySQL Slave 2 … , GTID S:2: UPDATE x=9 … , GTID M:1: UPDATE x=1 … , GTID M:2: UPDATE x=9 … , GTID S:1: UPDATE x=0
  • 10. The speaker says...The introduction of GTIDs is a milestone towards improvingthe availability of a MySQL Replication cluster. The MySQL5.6 Reference manual will give details, including somelimitations of GTIDs.The client side has not been considered yet. How tohandle connection failures, how to handle permanentserver failures?
  • 11. PECL/mysqlnd_ms failoverSlave connection failover is easy... Catch error, rerun statement, plugin picks next server Connection handle remains useable Automatic (no error) mode exists (not recommended) PECL/mysqlnd_ms Fail... … over MySQL Master MySQL Slave MySQL Slave
  • 12. The speaker says...Failing over a read-only client connection to a slaveis easy. In case of an error PECL/mysqlnd_ms can eithersilently failover to the next slave or master or, the pluginreturns an error. Automatic and silent failover is notrecommended as connection state is lost. Instead,applications should catch the error, handle the failedtransaction and rerun their transaction. Upon execution ofthe next statement, PECL/mysqlnd_ms fails over to anotherserver. The connection handle remains valid and useable.Failover in a single master primary copy cluster isimpossible: where to sent the write?
  • 13. PECL/mysqlnd_ms deploymentCluster topology change requires deployment Client configuration lists servers and roles Slave to master promotion requires deployment Addition or removal of slave requires deployment PECL/mysqlnd_ms Where to fail over? MySQL Master MySQL Slave MySQL Slave
  • 14. The speaker says...Load balancers, including those load balancers that are partof the driver, must be reconfigured after cluster topologyhas changed (membership, roles).Deploy the PECL/mysqlnd_ms configuration as partof your slave to master promotion! The load balancerconfiguration update should be done after the cluster hasbeen reconfigured and the new master is in place.
  • 15. In the next slide set...GTID Use case #2: consistency Session consistency (read-your-writes) PECL/mysqlnd_ms 1.2 and above
  • 16. THE ENDContact: ulf.wendel@oracle.com