SlideShare a Scribd company logo
High Availability Solutions for
           MySQL


Lenz Grimmer
<lenz@grimmer.com>
2008-08-29
DrupalCon 2008, Szeged, Hungary
Agenda
●   High Availability in General
●   MySQL Replication
●   MySQL Cluster
●   DRBD
●   Links/Tools
Why High Availability Matters
●   Downtime is expensive
●   You miss $$$
●   Your Boss complains
●   New Site visitors won't come back
What Is HA Clustering?

●   One service goes down → others take
    over its work
●   IP address takeover, service takeover
●   Not designed for high-performance
●   Not designed for high troughput (load
    balancing)
Split-Brain
●   Communications failures can lead to
    separated partitions of the cluster
●   If those partitions each try and take
    control of the cluster, then it's called a
    split-brain condition
●   If this happens, then bad things will
    happen
    http://linux-ha.org/BadThingsWillHappen
●   Use Fencing or Moderatation/Arbitration to
    avoid it
Eliminating the SPOF
●   Identify what will fail
    ●   Disks
●   Find out what can fail
    ●   Network cables
    ●   OOM
    ●   Power supplies
Rules of High Availability
●   Prepare for failure
●   Keep it simple, stupid (KISS)
●   Complexity is the enemy of reliability
●   Test your setup frequently
MySQL Replication
●   One-way, statement-based
●   One Master, many Slaves
●   Asynchronous – Slaves can lag
●   Master maintains binary logs & index
●   Easy to set up
●   Built into MySQL
●   Replication is single-threaded
MySQL Replication Overview
        Read & Write


            Web/App
             Server
                                                                      Write

                                                 Relay
                                                  Log



                  mysqld                              I/O              SQL
                                                    Thread            Thread

                       Index &
                       Binlogs
Daten


                                 Replication                 Binlog            Data

                                               mysqld

    MySQL Master                                         MySQL Slave
Replication Topologies
Master > Slave                          Master > Slaves




Master > Slave > Slaves            Masters > Slave (Multi-Source)




                                         Ring (Multi-Master)
Master < > Master (Multi-Master)
Replication & HA
●   Combined with Heartbeat
●   Virtual IP takeover
●   Slave gets promoted to Master
●   Side benefits: load balancing & backup
●   Tricky to fail back
●   No automatic conflict resolution
●   Proper failover needs to be scripted
Master-Master Replication
●   Useful for easier failover
●   Not suitable for load-balancing
    ●   Writes still end up on both machines
    ●   Neither machine has the authorative data
●   Don't write to both masters!
●   Use Sharding or Partitioning instead
    (e.g. MySQL Proxy)
MySQL Cluster

●   Shared nothing
●   Automatic partitioning
●   Distributed Fragments
●   Synchronous replication
●   Fast automatic fail-over of data nodes
●   Automatic resynchronization
●   Transparent to Application
●   Supports Transactions
MySQL Cluster
●   In-memory tables
●   Not suitable for all query patterns
●   Not suitable for large datasets
●   Latency matters
●   Can be combined with MySQL
    Replication
Drupal Con My Sql Ha 2008 08 29
DRBD
●   Distributed Replicated Block Device
●   “Raid-1 over network”
●   Synchronous block replication
●   Automatic resync on recover
●   Application-agnostic
●   Can mask local I/O errors
●   Active/passive configuration
DRBD & Heartbeat
●   Heartbeat mounts file system on
    failover (passive node becomes active)
●   Data only accessible on the active node
●   (LVM snapshots can work around this)
●   Increased I/O Latency
●   Failover is “cold” (fsck, log recovery,
    buffers/caches)
MySQL Replication &   MySQL, Heartbeat &    MySQL
                  Requirements       MySQL Replication       Heartbeat               DRBD            Cluster
               Automated IP
               Failover                     No                  Yes                   Yes               No
               Automated DB
Availability




               Failover                     No                   No                   Yes              Yes
               Typical Failover
               time                       Varies               Varies                < 30s             < 3s
               Auto resync of data         No                   No                    Yes              Yes
               Geographic                                                                             MySQL
               redundancy                  Yes                  Yes            MySQL Replication    Replication
               Built-in load
Scalability




               balancing             MySQL Replication   MySQL Replication     MySQL Replication       Yes
               Read-intensive              Yes                 Yes             MySQL Replication       Yes
               Write-intensive             No                  No                  Possible            Yes
               #Nodes/Cluster         Master/Slave(s)     Master/Slave(s)       Active/Passive         255
Related tools / Links
●   Linux Heartbeat
    http://linux-ha.org/
●   DRBD
    http:/drbd.org/
●   Linux Cluster Information Center
    http://www.lcic.org/ha.html
●   Red Hat Cluster Suite
    http://www.redhat.com/cluster_suite/
●   Sun Open High Availability Cluster
    http://opensolaris.org/os/project/ha-mysql/
Tools/Links
●   MySQL Multi-Master Replication
    Manager
    http://code.google.com/p/mysql-master-master/
●   Maatkit
    http://maatkit.sourceforge.net/
●   Mon – scheduler and alert management
    http://www.kernel.org/software/mon/
●   Continuent Tungsten Replicator
    https://community.continuent.com/community/tungsten-replicator
Q&A




Questions, Comments?
Thank you!
Lenz Grimmer <lenz@grimmer.com>
Ad

More Related Content

What's hot (20)

Galera cluster - SkySQL Paris Meetup 17.12.2013
Galera cluster - SkySQL Paris Meetup 17.12.2013Galera cluster - SkySQL Paris Meetup 17.12.2013
Galera cluster - SkySQL Paris Meetup 17.12.2013
MariaDB Corporation
 
Galera cluster for MySQL - Introduction Slides
Galera cluster for MySQL - Introduction SlidesGalera cluster for MySQL - Introduction Slides
Galera cluster for MySQL - Introduction Slides
Severalnines
 
PERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schemaPERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schema
FromDual GmbH
 
RESTEasy Reactive: Why should you care? | DevNation Tech Talk
RESTEasy Reactive: Why should you care? | DevNation Tech TalkRESTEasy Reactive: Why should you care? | DevNation Tech Talk
RESTEasy Reactive: Why should you care? | DevNation Tech Talk
Red Hat Developers
 
The Full MySQL and MariaDB Parallel Replication Tutorial
The Full MySQL and MariaDB Parallel Replication TutorialThe Full MySQL and MariaDB Parallel Replication Tutorial
The Full MySQL and MariaDB Parallel Replication Tutorial
Jean-François Gagné
 
How Booking.com avoids and deals with replication lag
How Booking.com avoids and deals with replication lagHow Booking.com avoids and deals with replication lag
How Booking.com avoids and deals with replication lag
Jean-François Gagné
 
Getting ready to java 8
Getting ready to java 8Getting ready to java 8
Getting ready to java 8
DataArt
 
M|18 Under the Hood: Galera Cluster
M|18 Under the Hood: Galera ClusterM|18 Under the Hood: Galera Cluster
M|18 Under the Hood: Galera Cluster
MariaDB plc
 
What's New in MySQL 5.7
What's New in MySQL 5.7What's New in MySQL 5.7
What's New in MySQL 5.7
Olivier DASINI
 
M|18 PolarDB: Extending Shared-storage to MyRocks
M|18 PolarDB: Extending Shared-storage to MyRocksM|18 PolarDB: Extending Shared-storage to MyRocks
M|18 PolarDB: Extending Shared-storage to MyRocks
MariaDB plc
 
M|18 Battle of the Online Schema Change Methods
M|18 Battle of the Online Schema Change MethodsM|18 Battle of the Online Schema Change Methods
M|18 Battle of the Online Schema Change Methods
MariaDB plc
 
M|18 Creating a Reference Architecture for High Availability at Nokia
M|18 Creating a Reference Architecture for High Availability at NokiaM|18 Creating a Reference Architecture for High Availability at Nokia
M|18 Creating a Reference Architecture for High Availability at Nokia
MariaDB plc
 
How to Monitor MySQL
How to Monitor MySQLHow to Monitor MySQL
How to Monitor MySQL
Server Density
 
Getting ready to java 8
Getting ready to java 8Getting ready to java 8
Getting ready to java 8
Strannik_2013
 
MySQL Parallel Replication by Booking.com
MySQL Parallel Replication by Booking.comMySQL Parallel Replication by Booking.com
MySQL Parallel Replication by Booking.com
Jean-François Gagné
 
The Real Thing: Java Virtual Machine
The Real Thing: Java Virtual MachineThe Real Thing: Java Virtual Machine
The Real Thing: Java Virtual Machine
Frontech
 
DIY: A distributed database cluster, or: MySQL Cluster
DIY: A distributed database cluster, or: MySQL ClusterDIY: A distributed database cluster, or: MySQL Cluster
DIY: A distributed database cluster, or: MySQL Cluster
Ulf Wendel
 
Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with server
Eugene Yokota
 
Scaling the Rails
Scaling the RailsScaling the Rails
Scaling the Rails
elliando dias
 
Almost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
Almost Perfect Service Discovery and Failover with ProxySQL and OrchestratorAlmost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
Almost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
Jean-François Gagné
 
Galera cluster - SkySQL Paris Meetup 17.12.2013
Galera cluster - SkySQL Paris Meetup 17.12.2013Galera cluster - SkySQL Paris Meetup 17.12.2013
Galera cluster - SkySQL Paris Meetup 17.12.2013
MariaDB Corporation
 
Galera cluster for MySQL - Introduction Slides
Galera cluster for MySQL - Introduction SlidesGalera cluster for MySQL - Introduction Slides
Galera cluster for MySQL - Introduction Slides
Severalnines
 
PERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schemaPERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schema
FromDual GmbH
 
RESTEasy Reactive: Why should you care? | DevNation Tech Talk
RESTEasy Reactive: Why should you care? | DevNation Tech TalkRESTEasy Reactive: Why should you care? | DevNation Tech Talk
RESTEasy Reactive: Why should you care? | DevNation Tech Talk
Red Hat Developers
 
The Full MySQL and MariaDB Parallel Replication Tutorial
The Full MySQL and MariaDB Parallel Replication TutorialThe Full MySQL and MariaDB Parallel Replication Tutorial
The Full MySQL and MariaDB Parallel Replication Tutorial
Jean-François Gagné
 
How Booking.com avoids and deals with replication lag
How Booking.com avoids and deals with replication lagHow Booking.com avoids and deals with replication lag
How Booking.com avoids and deals with replication lag
Jean-François Gagné
 
Getting ready to java 8
Getting ready to java 8Getting ready to java 8
Getting ready to java 8
DataArt
 
M|18 Under the Hood: Galera Cluster
M|18 Under the Hood: Galera ClusterM|18 Under the Hood: Galera Cluster
M|18 Under the Hood: Galera Cluster
MariaDB plc
 
What's New in MySQL 5.7
What's New in MySQL 5.7What's New in MySQL 5.7
What's New in MySQL 5.7
Olivier DASINI
 
M|18 PolarDB: Extending Shared-storage to MyRocks
M|18 PolarDB: Extending Shared-storage to MyRocksM|18 PolarDB: Extending Shared-storage to MyRocks
M|18 PolarDB: Extending Shared-storage to MyRocks
MariaDB plc
 
M|18 Battle of the Online Schema Change Methods
M|18 Battle of the Online Schema Change MethodsM|18 Battle of the Online Schema Change Methods
M|18 Battle of the Online Schema Change Methods
MariaDB plc
 
M|18 Creating a Reference Architecture for High Availability at Nokia
M|18 Creating a Reference Architecture for High Availability at NokiaM|18 Creating a Reference Architecture for High Availability at Nokia
M|18 Creating a Reference Architecture for High Availability at Nokia
MariaDB plc
 
Getting ready to java 8
Getting ready to java 8Getting ready to java 8
Getting ready to java 8
Strannik_2013
 
MySQL Parallel Replication by Booking.com
MySQL Parallel Replication by Booking.comMySQL Parallel Replication by Booking.com
MySQL Parallel Replication by Booking.com
Jean-François Gagné
 
The Real Thing: Java Virtual Machine
The Real Thing: Java Virtual MachineThe Real Thing: Java Virtual Machine
The Real Thing: Java Virtual Machine
Frontech
 
DIY: A distributed database cluster, or: MySQL Cluster
DIY: A distributed database cluster, or: MySQL ClusterDIY: A distributed database cluster, or: MySQL Cluster
DIY: A distributed database cluster, or: MySQL Cluster
Ulf Wendel
 
Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with server
Eugene Yokota
 
Almost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
Almost Perfect Service Discovery and Failover with ProxySQL and OrchestratorAlmost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
Almost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
Jean-François Gagné
 

Viewers also liked (9)

武汉大学2010新生住宿指南
武汉大学2010新生住宿指南武汉大学2010新生住宿指南
武汉大学2010新生住宿指南
liufabin 66688
 
中山大学2010新生住宿指南
中山大学2010新生住宿指南中山大学2010新生住宿指南
中山大学2010新生住宿指南
liufabin 66688
 
天津大学2010新生住宿指南
天津大学2010新生住宿指南天津大学2010新生住宿指南
天津大学2010新生住宿指南
liufabin 66688
 
复旦2010新生住宿指南
复旦2010新生住宿指南复旦2010新生住宿指南
复旦2010新生住宿指南
liufabin 66688
 
人大2010新生住宿指南
人大2010新生住宿指南人大2010新生住宿指南
人大2010新生住宿指南
liufabin 66688
 
北京师范大学2010新生住宿指南
北京师范大学2010新生住宿指南北京师范大学2010新生住宿指南
北京师范大学2010新生住宿指南
liufabin 66688
 
清华2010新生住宿指南
清华2010新生住宿指南清华2010新生住宿指南
清华2010新生住宿指南
liufabin 66688
 
南京大学2010新生住宿指南
南京大学2010新生住宿指南南京大学2010新生住宿指南
南京大学2010新生住宿指南
liufabin 66688
 
Best Practices of HA and Replication of PostgreSQL in Virtualized Environments
Best Practices of HA and Replication of PostgreSQL in Virtualized EnvironmentsBest Practices of HA and Replication of PostgreSQL in Virtualized Environments
Best Practices of HA and Replication of PostgreSQL in Virtualized Environments
Jignesh Shah
 
武汉大学2010新生住宿指南
武汉大学2010新生住宿指南武汉大学2010新生住宿指南
武汉大学2010新生住宿指南
liufabin 66688
 
中山大学2010新生住宿指南
中山大学2010新生住宿指南中山大学2010新生住宿指南
中山大学2010新生住宿指南
liufabin 66688
 
天津大学2010新生住宿指南
天津大学2010新生住宿指南天津大学2010新生住宿指南
天津大学2010新生住宿指南
liufabin 66688
 
复旦2010新生住宿指南
复旦2010新生住宿指南复旦2010新生住宿指南
复旦2010新生住宿指南
liufabin 66688
 
人大2010新生住宿指南
人大2010新生住宿指南人大2010新生住宿指南
人大2010新生住宿指南
liufabin 66688
 
北京师范大学2010新生住宿指南
北京师范大学2010新生住宿指南北京师范大学2010新生住宿指南
北京师范大学2010新生住宿指南
liufabin 66688
 
清华2010新生住宿指南
清华2010新生住宿指南清华2010新生住宿指南
清华2010新生住宿指南
liufabin 66688
 
南京大学2010新生住宿指南
南京大学2010新生住宿指南南京大学2010新生住宿指南
南京大学2010新生住宿指南
liufabin 66688
 
Best Practices of HA and Replication of PostgreSQL in Virtualized Environments
Best Practices of HA and Replication of PostgreSQL in Virtualized EnvironmentsBest Practices of HA and Replication of PostgreSQL in Virtualized Environments
Best Practices of HA and Replication of PostgreSQL in Virtualized Environments
Jignesh Shah
 
Ad

Similar to Drupal Con My Sql Ha 2008 08 29 (20)

MySQL High Availability Solutions
MySQL High Availability SolutionsMySQL High Availability Solutions
MySQL High Availability Solutions
Lenz Grimmer
 
MySQL High Availability Solutions
MySQL High Availability SolutionsMySQL High Availability Solutions
MySQL High Availability Solutions
Lenz Grimmer
 
Mysqlhacodebits20091203 1260184765-phpapp02
Mysqlhacodebits20091203 1260184765-phpapp02Mysqlhacodebits20091203 1260184765-phpapp02
Mysqlhacodebits20091203 1260184765-phpapp02
Louis liu
 
Buytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerBuytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemaker
kuchinskaya
 
RDS for MySQL, No BS Operations and Patterns
RDS for MySQL, No BS Operations and PatternsRDS for MySQL, No BS Operations and Patterns
RDS for MySQL, No BS Operations and Patterns
Laine Campbell
 
Cloudcon East Presentation
Cloudcon East PresentationCloudcon East Presentation
Cloudcon East Presentation
br7tt
 
Cloudcon East Presentation
Cloudcon East PresentationCloudcon East Presentation
Cloudcon East Presentation
br7tt
 
Seminar : &quot;The Future of MySQL - Roadmap to Success&quot; session MySQL ...
Seminar : &quot;The Future of MySQL - Roadmap to Success&quot; session MySQL ...Seminar : &quot;The Future of MySQL - Roadmap to Success&quot; session MySQL ...
Seminar : &quot;The Future of MySQL - Roadmap to Success&quot; session MySQL ...
Software Park Thailand
 
Introduction to XtraDB Cluster
Introduction to XtraDB ClusterIntroduction to XtraDB Cluster
Introduction to XtraDB Cluster
yoku0825
 
MariaDB Galera Cluster - Simple, Transparent, Highly Available
MariaDB Galera Cluster - Simple, Transparent, Highly AvailableMariaDB Galera Cluster - Simple, Transparent, Highly Available
MariaDB Galera Cluster - Simple, Transparent, Highly Available
MariaDB Corporation
 
MySQL highav Availability
MySQL highav AvailabilityMySQL highav Availability
MySQL highav Availability
Baruch Osoveskiy
 
MySQL HA Alternatives 2010
MySQL  HA  Alternatives 2010MySQL  HA  Alternatives 2010
MySQL HA Alternatives 2010
Kris Buytaert
 
Master master vs master-slave database
Master master vs master-slave databaseMaster master vs master-slave database
Master master vs master-slave database
Wipro
 
Has MySQL grown up?
Has MySQL grown up?Has MySQL grown up?
Has MySQL grown up?
Mark Stanton
 
Running MySQL in AWS
Running MySQL in AWSRunning MySQL in AWS
Running MySQL in AWS
Laine Campbell
 
MySQL高可用
MySQL高可用MySQL高可用
MySQL高可用
thinkinlamp
 
Running MariaDB in multiple data centers
Running MariaDB in multiple data centersRunning MariaDB in multiple data centers
Running MariaDB in multiple data centers
MariaDB plc
 
My sql with enterprise storage
My sql with enterprise storageMy sql with enterprise storage
My sql with enterprise storage
Caroline_Rose
 
MySQL HA
MySQL HAMySQL HA
MySQL HA
Kris Buytaert
 
Redis ndc2013
Redis ndc2013Redis ndc2013
Redis ndc2013
DaeMyung Kang
 
MySQL High Availability Solutions
MySQL High Availability SolutionsMySQL High Availability Solutions
MySQL High Availability Solutions
Lenz Grimmer
 
MySQL High Availability Solutions
MySQL High Availability SolutionsMySQL High Availability Solutions
MySQL High Availability Solutions
Lenz Grimmer
 
Mysqlhacodebits20091203 1260184765-phpapp02
Mysqlhacodebits20091203 1260184765-phpapp02Mysqlhacodebits20091203 1260184765-phpapp02
Mysqlhacodebits20091203 1260184765-phpapp02
Louis liu
 
Buytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerBuytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemaker
kuchinskaya
 
RDS for MySQL, No BS Operations and Patterns
RDS for MySQL, No BS Operations and PatternsRDS for MySQL, No BS Operations and Patterns
RDS for MySQL, No BS Operations and Patterns
Laine Campbell
 
Cloudcon East Presentation
Cloudcon East PresentationCloudcon East Presentation
Cloudcon East Presentation
br7tt
 
Cloudcon East Presentation
Cloudcon East PresentationCloudcon East Presentation
Cloudcon East Presentation
br7tt
 
Seminar : &quot;The Future of MySQL - Roadmap to Success&quot; session MySQL ...
Seminar : &quot;The Future of MySQL - Roadmap to Success&quot; session MySQL ...Seminar : &quot;The Future of MySQL - Roadmap to Success&quot; session MySQL ...
Seminar : &quot;The Future of MySQL - Roadmap to Success&quot; session MySQL ...
Software Park Thailand
 
Introduction to XtraDB Cluster
Introduction to XtraDB ClusterIntroduction to XtraDB Cluster
Introduction to XtraDB Cluster
yoku0825
 
MariaDB Galera Cluster - Simple, Transparent, Highly Available
MariaDB Galera Cluster - Simple, Transparent, Highly AvailableMariaDB Galera Cluster - Simple, Transparent, Highly Available
MariaDB Galera Cluster - Simple, Transparent, Highly Available
MariaDB Corporation
 
MySQL HA Alternatives 2010
MySQL  HA  Alternatives 2010MySQL  HA  Alternatives 2010
MySQL HA Alternatives 2010
Kris Buytaert
 
Master master vs master-slave database
Master master vs master-slave databaseMaster master vs master-slave database
Master master vs master-slave database
Wipro
 
Has MySQL grown up?
Has MySQL grown up?Has MySQL grown up?
Has MySQL grown up?
Mark Stanton
 
Running MariaDB in multiple data centers
Running MariaDB in multiple data centersRunning MariaDB in multiple data centers
Running MariaDB in multiple data centers
MariaDB plc
 
My sql with enterprise storage
My sql with enterprise storageMy sql with enterprise storage
My sql with enterprise storage
Caroline_Rose
 
Ad

More from liufabin 66688 (14)

北大2010新生住宿指南
北大2010新生住宿指南北大2010新生住宿指南
北大2010新生住宿指南
liufabin 66688
 
Mysql Replication Excerpt 5.1 En
Mysql Replication Excerpt 5.1 EnMysql Replication Excerpt 5.1 En
Mysql Replication Excerpt 5.1 En
liufabin 66688
 
Application Partitioning Wp
Application Partitioning WpApplication Partitioning Wp
Application Partitioning Wp
liufabin 66688
 
090507.New Replication Features(2)
090507.New Replication Features(2)090507.New Replication Features(2)
090507.New Replication Features(2)
liufabin 66688
 
High Performance Mysql
High Performance MysqlHigh Performance Mysql
High Performance Mysql
liufabin 66688
 
high performance mysql
high performance mysqlhigh performance mysql
high performance mysql
liufabin 66688
 
Lecture28
Lecture28Lecture28
Lecture28
liufabin 66688
 
Refactoring And Unit Testing
Refactoring And Unit TestingRefactoring And Unit Testing
Refactoring And Unit Testing
liufabin 66688
 
Refactoring Simple Example
Refactoring Simple ExampleRefactoring Simple Example
Refactoring Simple Example
liufabin 66688
 
Refactoring Example
Refactoring ExampleRefactoring Example
Refactoring Example
liufabin 66688
 
Refactoring 重构
Refactoring 重构Refactoring 重构
Refactoring 重构
liufabin 66688
 
北大2010新生住宿指南
北大2010新生住宿指南北大2010新生住宿指南
北大2010新生住宿指南
liufabin 66688
 
Mysql Replication Excerpt 5.1 En
Mysql Replication Excerpt 5.1 EnMysql Replication Excerpt 5.1 En
Mysql Replication Excerpt 5.1 En
liufabin 66688
 
Application Partitioning Wp
Application Partitioning WpApplication Partitioning Wp
Application Partitioning Wp
liufabin 66688
 
090507.New Replication Features(2)
090507.New Replication Features(2)090507.New Replication Features(2)
090507.New Replication Features(2)
liufabin 66688
 
High Performance Mysql
High Performance MysqlHigh Performance Mysql
High Performance Mysql
liufabin 66688
 
high performance mysql
high performance mysqlhigh performance mysql
high performance mysql
liufabin 66688
 
Refactoring And Unit Testing
Refactoring And Unit TestingRefactoring And Unit Testing
Refactoring And Unit Testing
liufabin 66688
 
Refactoring Simple Example
Refactoring Simple ExampleRefactoring Simple Example
Refactoring Simple Example
liufabin 66688
 

Drupal Con My Sql Ha 2008 08 29

  • 1. High Availability Solutions for MySQL Lenz Grimmer <[email protected]> 2008-08-29 DrupalCon 2008, Szeged, Hungary
  • 2. Agenda ● High Availability in General ● MySQL Replication ● MySQL Cluster ● DRBD ● Links/Tools
  • 3. Why High Availability Matters ● Downtime is expensive ● You miss $$$ ● Your Boss complains ● New Site visitors won't come back
  • 4. What Is HA Clustering? ● One service goes down → others take over its work ● IP address takeover, service takeover ● Not designed for high-performance ● Not designed for high troughput (load balancing)
  • 5. Split-Brain ● Communications failures can lead to separated partitions of the cluster ● If those partitions each try and take control of the cluster, then it's called a split-brain condition ● If this happens, then bad things will happen http://linux-ha.org/BadThingsWillHappen ● Use Fencing or Moderatation/Arbitration to avoid it
  • 6. Eliminating the SPOF ● Identify what will fail ● Disks ● Find out what can fail ● Network cables ● OOM ● Power supplies
  • 7. Rules of High Availability ● Prepare for failure ● Keep it simple, stupid (KISS) ● Complexity is the enemy of reliability ● Test your setup frequently
  • 8. MySQL Replication ● One-way, statement-based ● One Master, many Slaves ● Asynchronous – Slaves can lag ● Master maintains binary logs & index ● Easy to set up ● Built into MySQL ● Replication is single-threaded
  • 9. MySQL Replication Overview Read & Write Web/App Server Write Relay Log mysqld I/O SQL Thread Thread Index & Binlogs Daten Replication Binlog Data mysqld MySQL Master MySQL Slave
  • 10. Replication Topologies Master > Slave Master > Slaves Master > Slave > Slaves Masters > Slave (Multi-Source) Ring (Multi-Master) Master < > Master (Multi-Master)
  • 11. Replication & HA ● Combined with Heartbeat ● Virtual IP takeover ● Slave gets promoted to Master ● Side benefits: load balancing & backup ● Tricky to fail back ● No automatic conflict resolution ● Proper failover needs to be scripted
  • 12. Master-Master Replication ● Useful for easier failover ● Not suitable for load-balancing ● Writes still end up on both machines ● Neither machine has the authorative data ● Don't write to both masters! ● Use Sharding or Partitioning instead (e.g. MySQL Proxy)
  • 13. MySQL Cluster ● Shared nothing ● Automatic partitioning ● Distributed Fragments ● Synchronous replication ● Fast automatic fail-over of data nodes ● Automatic resynchronization ● Transparent to Application ● Supports Transactions
  • 14. MySQL Cluster ● In-memory tables ● Not suitable for all query patterns ● Not suitable for large datasets ● Latency matters ● Can be combined with MySQL Replication
  • 16. DRBD ● Distributed Replicated Block Device ● “Raid-1 over network” ● Synchronous block replication ● Automatic resync on recover ● Application-agnostic ● Can mask local I/O errors ● Active/passive configuration
  • 17. DRBD & Heartbeat ● Heartbeat mounts file system on failover (passive node becomes active) ● Data only accessible on the active node ● (LVM snapshots can work around this) ● Increased I/O Latency ● Failover is “cold” (fsck, log recovery, buffers/caches)
  • 18. MySQL Replication & MySQL, Heartbeat & MySQL Requirements MySQL Replication Heartbeat DRBD Cluster Automated IP Failover No Yes Yes No Automated DB Availability Failover No No Yes Yes Typical Failover time Varies Varies < 30s < 3s Auto resync of data No No Yes Yes Geographic MySQL redundancy Yes Yes MySQL Replication Replication Built-in load Scalability balancing MySQL Replication MySQL Replication MySQL Replication Yes Read-intensive Yes Yes MySQL Replication Yes Write-intensive No No Possible Yes #Nodes/Cluster Master/Slave(s) Master/Slave(s) Active/Passive 255
  • 19. Related tools / Links ● Linux Heartbeat http://linux-ha.org/ ● DRBD http:/drbd.org/ ● Linux Cluster Information Center http://www.lcic.org/ha.html ● Red Hat Cluster Suite http://www.redhat.com/cluster_suite/ ● Sun Open High Availability Cluster http://opensolaris.org/os/project/ha-mysql/
  • 20. Tools/Links ● MySQL Multi-Master Replication Manager http://code.google.com/p/mysql-master-master/ ● Maatkit http://maatkit.sourceforge.net/ ● Mon – scheduler and alert management http://www.kernel.org/software/mon/ ● Continuent Tungsten Replicator https://community.continuent.com/community/tungsten-replicator