mysql 高可用性

23
MySQL High Availability Baron Schwartz February 2011

Upload: yucheng-hu

Post on 03-Jul-2015

225 views

Category:

Technology


13 download

DESCRIPTION

MySQL 高可用性 http://www.ossez.com/forum.php?mod=viewthread&tid=26847&fromuid=426 (出处: OSSEZ)

TRANSCRIPT

Page 1: MySQL 高可用性

MySQL High AvailabilityBaron Schwartz

February 2011

Page 2: MySQL 高可用性

Agenda

● Defining High Availability● High Availability Techniques● High Availability Technologies● Recommendations (?)

Page 3: MySQL 高可用性

What is High Availability?

● What is Availability?● How high is enough?

○ "I need six nines"● MTTR and MTBF● Service availability versus data availability

Page 4: MySQL 高可用性

Achieving HA

● Increase MTBF○ "Best practices" and proactive measures○ Monitoring and alerting○ Build systems that can soft-fail or run degraded

● Reduce MTTR○ This is reactive, not proactive○ Add redundancy to remove SPOFs○ Add failover/takeover capabilities

Page 5: MySQL 高可用性

Increasing MTBF

● Test regularly; find failures before they matter● Least privilege● Keep things neat, clean, systematic● Manage changes carefully

○ More about this in "causes of downtime" talk● Good system architecture & design

○ Loose coupling, degraded functionality, load shedding, etc

Page 6: MySQL 高可用性

Decreasing MTTR

● Two important components:1. Notice problems quickly2. Resolve them quickly

● Technical measures help with part 2○ Systems that have no SPOF, etc○ Redundancy and failover capability

Page 7: MySQL 高可用性

Data Availability

● This is a related topic, but distinct from HA● Typically want a strong D guarantee in ACID● Usually implemented with synchronous replication● In practice, usually inseparable from HA● Makes HA much harder

○ It's easy to be HA if it's OK to lose your data!

Page 8: MySQL 高可用性

Technologies

● Replication● SAN● DRBD● MySQL Cluster (NDB)● Percona XtraDB Cluster (Galera)● Clustrix and similar● Load Balancing and Proxies

Page 9: MySQL 高可用性

Replication

● The classic approach, used for years by many● Can have very short MTTR● Essential problem: asynchronous● Has a "glass ceiling"● Some failover managers available, but most aren't great

Page 10: MySQL 高可用性

SAN

● "Enterprise" approach● Really a zero-data-loss technique, not HA● MTTR can be (very) high● SAN is still a SPOF (can be mitigated)

Page 11: MySQL 高可用性

DRBD

● Replicated storage● "Enterprise" zero-data-loss approach● Relatively high MTTR● DRBD + replication historically not a great approach● There is Percona-PRM; worth knowing about

Page 12: MySQL 高可用性

Percona XtraDB Cluster

● Built on modified InnoDB + Galera sync replication library● Multi-master, synchronous, write-anywhere● Beta; see percona.com/software/

Page 13: MySQL 高可用性

Percona XtraDB Cluster

● Strengths?○ Transparent, familiar technology*○ Real HA and protection from data loss○ No lagging replicas○ Data stored redundantly; all nodes equal

● Weaknesses?○ As slow as the slowest node○ Data stored redundantly; probably limits total size○ Deadlocks and rollbacks can increase

* Uses optimistic conflict resolution, not pessimistic

Page 14: MySQL 高可用性

MySQL Cluster (NDB)

● Shared-nothing approach: true HA● Not fully general-purpose, but good for lots of things● Not "vanilla MySQL" - NDB is a separate database● Improving rapidly; MySQL Cluster 7.2 GA today!● Unbeatable for specific purposes

Page 15: MySQL 高可用性

Clustrix et al.

● Clustrix○ NDB-ish, but queries execute fully on the nodes○ Validated extensively by Percona

● Xeround○ Ditto; for the cloud; not evaluated by Percona yet

● Continuent Tungsten○ Replacement for MySQL replication○ Kind of an opensource GoldenGate

Page 16: MySQL 高可用性

Load Balancing and Proxies

● Usually used in combination with replication● Usually require some scripting/integration● $YOUR_LOAD_BALANCER_HERE● HAProxy, pen, etc● MySQL Proxy● ScaleBase, ScaleArc

Page 17: MySQL 高可用性

Recommendations

● Sorry, too complex for these slides :)● Usual approach:

○ Cross off unsuitable solutions○ Examine what's left

● Anti-recommendations:○ Be careful with replication-based HA○ MMM can be troublesome in some configurations○ MySQL Proxy doesn't really excel in most cases

Page 18: MySQL 高可用性

Percona XtraDB Cluster

● Writes update all nodes● Reads execute locally

Comparison of Clustering Methods

Page 19: MySQL 高可用性

MySQL Cluster (NDB)

● Writes update all copies of data● Reads execute locally + distributed

Comparison of Clustering Methods

Page 20: MySQL 高可用性

Clustrix

● Writes update all copies of data● Reads execute fully distributed

Comparison of Clustering Methods

Page 21: MySQL 高可用性

What's Percona Been Up To?

http://tools.percona.com/

Page 22: MySQL 高可用性

Resources

● Free webinars: www.percona.com/webinars● White papers on preventing downtime:

○ www.percona.com/about-us/mysql-white-papers○ "Causes of downtime" paper○ "Preventing downtime" paper

● Slides from Percona Live DC 2012○ Yves's talk on Percona-PRM and MySQL Cluster○ percona.com/live/

Page 23: MySQL 高可用性

Santa Clara, CAApril 10-13Be There!