Ulf Wendel, Oracle     MySQL 5.6Global Transaction Ids  Use case: Failover   MySQL 5.6, PECL/mysqlnd_ms 1.3
The speaker says...It is all about MySQL Replication. MySQL Replication is thedatabase scale-out solution of the LAMP stac...
MySQL ReplicationPrimary copy (master/slave) for read-scale out  Writes/updates: master  Reads: slaves                    ...
The speaker says...Use case #1: Master failover.In a MySQL Replication setup all writes/updates must beexecuted at the mas...
Using GTIDs for master failoverSlave to master promotion after master outage  Which slave is the most current?  How to cop...
The speaker says...The master fails, it becomes unavailable alltogether. A slavemust be promoted to become the new master....
Global transaction identifierCombination of server id and sequence number  Emulation: PECL/mysqlnd_ms 1.2, MySQL Proxy  Bu...
The speaker says...A global transaction identifier is a cluster-wideunique transaction identifier. MySQL 5.6 can generate ...
Availability improved, solved?Master failover improved!  Scriptable, unattended failover possible  No 3rd party solution r...
The speaker says...The introduction of GTIDs is a milestone towards improvingthe availability of a MySQL Replication clust...
PECL/mysqlnd_ms failoverSlave connection failover is easy...  Catch error, rerun statement, plugin picks next server  Conn...
The speaker says...Failing over a read-only client connection to a slaveis easy. In case of an error PECL/mysqlnd_ms can e...
PECL/mysqlnd_ms deploymentCluster topology change requires deployment  Client configuration lists servers and roles  Slave...
The speaker says...Load balancers, including those load balancers that are partof the driver, must be reconfigured after c...
In the next slide set...GTID Use case #2: consistency  Session consistency (read-your-writes)  PECL/mysqlnd_ms 1.2 and above
THE ENDContact: ulf.wendel@oracle.com
Upcoming SlideShare
Loading in...5
×

MySQL 5.6 Global Transaction Identifier - Use case: Failover

7,938

Published on

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.

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

No Downloads
Views
Total Views
7,938
On Slideshare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
51
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

MySQL 5.6 Global Transaction Identifier - Use case: Failover

  1. 1. Ulf Wendel, Oracle MySQL 5.6Global Transaction Ids Use case: Failover MySQL 5.6, PECL/mysqlnd_ms 1.3
  2. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 15. In the next slide set...GTID Use case #2: consistency Session consistency (read-your-writes) PECL/mysqlnd_ms 1.2 and above
  16. 16. THE ENDContact: ulf.wendel@oracle.com
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×