SlideShare a Scribd company logo
1 of 41
Download to read offline
MySQL High Availability Solutions


     Lenz Grimmer <lenz@grimmer.com>
                  <
     http://lenzg.net/ | Twitter: @lenzgr
2011-01-26 | San Francisco MySQL Meetup | USA
$ whoami




1998              2002



2008              2010
Agenda
●   High Availability: Concepts &
    Considerations
●   MySQL Replication
●   DRBD / Pacemaker
●   MySQL Cluster
●   Other HA tools/applications
Single MySQL Server

            MySQL Client



   SQL (SELECT, INSERT,
      UPDATE, DELETE)

   MySQL Storage Engines
(InnoDB, MyISAM, PBXT...)



             Disk Storage
(XFS, ReiserFS, JFS, ext3...)
Why HA?
●   Something can and will fail
●   Service Maintenance
●   Downtime is expensive
●   Adding HA to an existing system is complex
Elimination of the SPOF
●   Identify what will fail eventually
     ●   Hard disks
     ●   Fans
●   Consider what might fail
     ●   Application crashes
     ●   OOM-Situations, Kernel-Panics
     ●   Network connections, Cables
     ●   Power supply
What is HA Clustering?
●   Redundancy
●   One system or service goes down → others
    take over
●   IP address takeover, service takeover
●   Ensuring data availability & integrity
●   Not designed for high-performance
High Availability Levels
Rules of High Availability
●   Prepare for failure
●   Aim to ensure that no important data is
    lost
●   Keep it simple, stupid (KISS)
●   Complexity is the enemy of reliability
●   Automate it
●   Test your setup frequently!
HA Components
●   Heartbeat
     ●   Checks that services that are monitored, are alive.
     ●   Can check individual servers, software services,
         networking etc.
●   HA Monitor
     ●   Configuration of the services
     ●   Ensures proper shutdown and startup
     ●   Allows manual control
●   Shared storage / Replication
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
●   Use Fencing or Moderation/Arbitration to
    avoid it
Redundancy Using MySQL Replication




           MySQL Replication
MySQL Replication
●   Unidirectional
●   Statement- or row-based (MySQL 5.1)
●   Built into MySQL
●   Easy to use and set up
●   One Master, many Slaves
●   Asynchronous – Slaves can lag behind
●   New in MySQL 5.5: Semisync Replication
MySQL Replication (2)
●   Master maintains Binary logs & index
●   Replication on Slave is single-threaded
    http://forge.mysql.com/wiki/ReplicationFeatures/ParallelSlave
●   No automated fail-over
●   No heartbeat, no monitoring
●   New in 5.5: replication heartbeat
MySQL Replication - Overview

        Read & Write


            Web/App
             Server
                                                                       Write

                                                 Relay
                                                  Log



                  mysqld                                                SQL
                                                       I/O
                                                                       Threa
                                                     Thread
                                                                         d
                       Index &
                       Binlogs

Data

                                 Replication                  Binlog           Data

                                               mysqld

       MySQL Master                                       MySQL Slave
Statement-based Replication
●   Pro
     ✔   Proven (around since MySQL 3.23)
     ✔   Smaller log files
     ✔   Auditing of actual SQL statements
     ✔   No primary key requirement for replicated tables
●   Con
     ✗   Non-deterministic functions and UDFs
     ✗   LOAD_FILE(), UUID(), CURRENT_USER(),
         FOUND_ROWS()
         (but RAND() and NOW() work)
Row-based Replication
●   Pro
     ✔   All changes can be replicated
     ✔   Similar technology used by other RDBMSes
     ✔   Fewer locks required for some INSERT, UPDATE or
         DELETE statements
●   Con
     ✗   More data to be logged
     ✗   Log file size increases (backup/restore implications)
     ✗   Replicated tables require explicit primary keys
     ✗   Possible different result sets on bulk INSERTs
Replication Topologies

Master > Slave                          Master > Slaves




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




                                         Ring (Multi-Master)
Master < > Master (Multi-Master)
Master-Master Replication
●   Two nodes are both master and slave to
    each other
●   Useful for easier failover
●   Not suitable for (write) load-balancing
●   Don't write to both masters
    simultaneously!
●   Use Sharding or Partitioning instead
    (e.g. MySQL Proxy)
MySQL Replication as a HA Solution
●   What happens if the Master fails?
●   What happens if the Slave fails?
●   This doesn’t sound like High Availability!
●   Yes!
●   Replication is only part of a HA
    configuration
Pacemaker (Linux-HA)
●   Supports 2 or more Nodes (v2)
●   Resource monitoring (Apps and HW)
●   Active fencing mechanism (STONITH)
●   Node failure detection in seconds
●   Supports many applications (incl. MySQL)
●   http://clusterlabs.org/
●   http://www.clusterlabs.org/wiki/Load_Balanced_MySQL_Replicated_Cluster
●   http://www.clusterlabs.org/wiki/DRBD_MySQL_HowTo
Replication & HA
●   Combined with Pacemaker
●   Virtual IP takeover
●   Slave gets promoted to Master
●   Side benefits: load balancing & backup
●   Can be tricky to fail back
●   No automatic conflict resolution
●   Proper failover needs to be scripted
Redundancy With Disk Replication




           Disk Replication
DRBD
●   Distributed Replicated Block Device
●   “RAID-1 over network”
●   Synchronous/asynchronous block replication
●   Automatic resynchronisation
●   Application-agnostic
●   Can mask local I/O-Errors
●   Active/passive configuration
●   Dual-primary mode (requires cluster file sytem
    like GFS or OCFS2)
●   http://drbd.org/
DRBD in Detail
●   DRBD replicates data blocks between to
    block devices
●   DRBD can be combined with Linux-HA and
    other HA solutions
●   MySQL runs normally                    Applications


    on primary node
●   MySQL is not active on   Active Node   Virtual IP     Passive Node


    the secondary node
●   DRBD is Linux only                            DRBD
Redundancy Using Shared Storage
Replication vs. SAN
●   Data Consistency / Integrity
●   Synchronous vs. asynchronous
●   SAN can become the SPOF
●   Cold caches
●   “Split brain”-Situations
●   SAN/NAS I/O Overhead
Redundancy with MySQL Cluster
MySQL Cluster
●   “Shared-nothing”-Architecture
●   Automatic partitioning
●   Distributed fragments
●   Synchronous replication
●   Fast, automatic fail-over of data nodes
●   Automatic resynchronisation
●   Transparent to MySQL applicationen
●   Supports transactions
●   http://mysql.com/products/database/cluster/
MySQL Cluster
●   In-memory indexes
●   Not suitable for all query patterns
    (cross-table JOINs, range scans)
●   No support for foreign keys
●   Not suitable for long running transactions
●   Network latency crucial
●   Can be combined with MySQL replication
    (RBR)
MySQL Cluster & Replikation
●   MySQL Cluster
     ●   Easy failover from one MySQL node to another
     ●   Scaling write load using multiple SQL nodes
●   Asynchronous replication from Cluster to
    regular MySQL slaves
●   Slaves take read load (InnoDB/MyISAM)
●   Quick setup of new slaves (Cluster Online
    Backup)
●   Easy failover and fast recovery
http://johanandersson.blogspot.com/2009/05/ha-mysql-write-scaling-using-cluster-to.html
Galera Replication
●   Patch for InnoDB plus external library
●   Synchronous replication
●   Single- or multi-master
●   Multicast-Replication
●   HA plus load sharing possible
●   Certifikate-based replikation
    (instead of 2PC)
●   http://codership.com/products/mysql_galera
MMM
●   MySQL Master-Master Replication
    Manager
●   Perl-Script for monitoring, failover and
    management
●   Master-master replication configuration
    (one active writable master)
●   Failover by moving virtual IP-Address
●   Also supports read balancing
●   http://mysql-mmm.org/
Continuent Tungsten Replicator
●   Database-external solution
●   Asynchronous, Master-Slave, Fan-out &
    Fan-in
●   Java
●   Log-based
●   Events are stored in the Transaction History
    Log (THL)
●   Modular architekture (Pipelines, Stages)
●   http://continuent.com/community/tungsten-replicator
Red Hat Cluster Suite
●   HA and load balancing
●   Supports up to 16 nodes
●   Shared storage
●   Monitors services, file systems and network
    status
●   Fencing (STONITH) or distributed lock
    manager
●   Configuration synchronization
●   http://www.redhat.com/cluster_suite/
Solaris Cluster / OpenHA Cluster
●   Provides failover and scalability services
●   Solaris / OpenSolaris (Project Colorado)
●   Kernel-level components plus userland
●   Agents monitor applications
●   Geo Edition to provide Disaster Recovery
    using Replication
●   Open Source since June 2007
●   http://hub.opensolaris.org/bin/view/Community+Group+ha-clusters/WebHome
●   http://hub.opensolaris.org/bin/view/Project+ha-mysql/WebHome
Flipper
●   Perl Script managing pairs of MySQL
    servers replicating to each other.
●   Automatic switchover, triggered manually
●   Enables one half of the pair to be taken
    offline for maintenance work while other
    half carries on
●   Moves IP addresses based on a role ("read-
    only", "writable")
●   http://provenscaling.com/software/flipper/
Q&A




Questions, Comments?
Thank you!




Lenz Grimmer <lenz@grimmer.com>
         Twitter: @lenzgr
         http://lenzg.net/

More Related Content

What's hot

Discard inport exchange table & tablespace
Discard inport exchange table & tablespaceDiscard inport exchange table & tablespace
Discard inport exchange table & tablespace
Marco Tusa
 
MySQL developing Store Procedure
MySQL developing Store ProcedureMySQL developing Store Procedure
MySQL developing Store Procedure
Marco Tusa
 
Webseminar: MariaDB Enterprise und MariaDB Enterprise Cluster
Webseminar: MariaDB Enterprise und MariaDB Enterprise ClusterWebseminar: MariaDB Enterprise und MariaDB Enterprise Cluster
Webseminar: MariaDB Enterprise und MariaDB Enterprise Cluster
MariaDB Corporation
 
UKOUG 2011: MySQL Architectures for Oracle DBA's
UKOUG 2011: MySQL Architectures for Oracle DBA'sUKOUG 2011: MySQL Architectures for Oracle DBA's
UKOUG 2011: MySQL Architectures for Oracle DBA's
FromDual GmbH
 

What's hot (20)

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
 
M|18 Why Abstract Away the Underlying Database Infrastructure
M|18 Why Abstract Away the Underlying Database InfrastructureM|18 Why Abstract Away the Underlying Database Infrastructure
M|18 Why Abstract Away the Underlying Database Infrastructure
 
Demystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash SafetyDemystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash Safety
 
MySQL Parallel Replication by Booking.com
MySQL Parallel Replication by Booking.comMySQL Parallel Replication by Booking.com
MySQL Parallel Replication by Booking.com
 
"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007
"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007
"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007
 
MyRocks in MariaDB: why and how
MyRocks in MariaDB: why and howMyRocks in MariaDB: why and how
MyRocks in MariaDB: why and how
 
Discard inport exchange table & tablespace
Discard inport exchange table & tablespaceDiscard inport exchange table & tablespace
Discard inport exchange table & tablespace
 
MySQL developing Store Procedure
MySQL developing Store ProcedureMySQL developing Store Procedure
MySQL developing Store Procedure
 
Demystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash SafetyDemystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash Safety
 
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
 
Yahoo: Experiences with MySQL GTID and Multi Threaded Replication
Yahoo: Experiences with MySQL GTID and Multi Threaded ReplicationYahoo: Experiences with MySQL GTID and Multi Threaded Replication
Yahoo: Experiences with MySQL GTID and Multi Threaded Replication
 
M|18 Writing Stored Procedures in the Real World
M|18 Writing Stored Procedures in the Real WorldM|18 Writing Stored Procedures in the Real World
M|18 Writing Stored Procedures in the Real World
 
MySQL highav Availability
MySQL highav AvailabilityMySQL highav Availability
MySQL highav Availability
 
MariaDB und mehr - MariaDB Roadshow Summer 2014 Hamburg Berlin Frankfurt
MariaDB und mehr - MariaDB Roadshow Summer 2014 Hamburg Berlin FrankfurtMariaDB und mehr - MariaDB Roadshow Summer 2014 Hamburg Berlin Frankfurt
MariaDB und mehr - MariaDB Roadshow Summer 2014 Hamburg Berlin Frankfurt
 
Webseminar: MariaDB Enterprise und MariaDB Enterprise Cluster
Webseminar: MariaDB Enterprise und MariaDB Enterprise ClusterWebseminar: MariaDB Enterprise und MariaDB Enterprise Cluster
Webseminar: MariaDB Enterprise und MariaDB Enterprise Cluster
 
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
 
The New MariaDB Offering: MariaDB 10, MaxScale and More
The New MariaDB Offering: MariaDB 10, MaxScale and MoreThe New MariaDB Offering: MariaDB 10, MaxScale and More
The New MariaDB Offering: MariaDB 10, MaxScale and More
 
Online MySQL Backups with Percona XtraBackup
Online MySQL Backups with Percona XtraBackupOnline MySQL Backups with Percona XtraBackup
Online MySQL Backups with Percona XtraBackup
 
MariaDB Enterprise & MariaDB Enterprise Cluster - MariaDB Webinar July 2014
MariaDB Enterprise & MariaDB Enterprise Cluster - MariaDB Webinar July 2014MariaDB Enterprise & MariaDB Enterprise Cluster - MariaDB Webinar July 2014
MariaDB Enterprise & MariaDB Enterprise Cluster - MariaDB Webinar July 2014
 
UKOUG 2011: MySQL Architectures for Oracle DBA's
UKOUG 2011: MySQL Architectures for Oracle DBA'sUKOUG 2011: MySQL Architectures for Oracle DBA's
UKOUG 2011: MySQL Architectures for Oracle DBA's
 

Viewers also liked

Kovalenko a
Kovalenko aKovalenko a
Kovalenko a
garasym
 
Slimmer werken met een Social Intranet
Slimmer werken met een Social IntranetSlimmer werken met een Social Intranet
Slimmer werken met een Social Intranet
Netvlies Internetdiensten
 
A place in_my_heart
A place in_my_heartA place in_my_heart
A place in_my_heart
nguyensnowy
 
Spring2012 week14 pt3-1 13-59-57
Spring2012 week14 pt3-1 13-59-57Spring2012 week14 pt3-1 13-59-57
Spring2012 week14 pt3-1 13-59-57
educw200
 
TWSS House Renaming Competition
TWSS House Renaming CompetitionTWSS House Renaming Competition
TWSS House Renaming Competition
Yuliana Tjioe
 
OS Kralj Petar I- Niš
OS Kralj Petar I- NišOS Kralj Petar I- Niš
OS Kralj Petar I- Niš
tio_marina
 
Chakryan v
Chakryan vChakryan v
Chakryan v
garasym
 
Iran National Copper Corporation
Iran National Copper CorporationIran National Copper Corporation
Iran National Copper Corporation
Reza Motaghedi
 
Поисковая оптимизация как инструмент привлечения целевой аудитории на сайт ко...
Поисковая оптимизация как инструмент привлечения целевой аудитории на сайт ко...Поисковая оптимизация как инструмент привлечения целевой аудитории на сайт ко...
Поисковая оптимизация как инструмент привлечения целевой аудитории на сайт ко...
Promodo
 

Viewers also liked (20)

Kovalenko a
Kovalenko aKovalenko a
Kovalenko a
 
Moto armonico
Moto armonicoMoto armonico
Moto armonico
 
Triển lãm "Tôi Mơ...Tôi Bay"-2012
Triển lãm "Tôi Mơ...Tôi Bay"-2012Triển lãm "Tôi Mơ...Tôi Bay"-2012
Triển lãm "Tôi Mơ...Tôi Bay"-2012
 
06
0606
06
 
Happy message
Happy messageHappy message
Happy message
 
L'archivage du Web, présentation college de france
L'archivage du Web, présentation college de franceL'archivage du Web, présentation college de france
L'archivage du Web, présentation college de france
 
Slimmer werken met een Social Intranet
Slimmer werken met een Social IntranetSlimmer werken met een Social Intranet
Slimmer werken met een Social Intranet
 
A place in_my_heart
A place in_my_heartA place in_my_heart
A place in_my_heart
 
Spring2012 week14 pt3-1 13-59-57
Spring2012 week14 pt3-1 13-59-57Spring2012 week14 pt3-1 13-59-57
Spring2012 week14 pt3-1 13-59-57
 
TWSS House Renaming Competition
TWSS House Renaming CompetitionTWSS House Renaming Competition
TWSS House Renaming Competition
 
Zatik annax
Zatik annaxZatik annax
Zatik annax
 
DRAFT MuseSocial Pres
DRAFT MuseSocial PresDRAFT MuseSocial Pres
DRAFT MuseSocial Pres
 
La pesca
La pescaLa pesca
La pesca
 
Developments in making tourism a responsible industry stephan farrant wtfl 2011
Developments in making tourism a responsible industry stephan farrant wtfl 2011Developments in making tourism a responsible industry stephan farrant wtfl 2011
Developments in making tourism a responsible industry stephan farrant wtfl 2011
 
OS Kralj Petar I- Niš
OS Kralj Petar I- NišOS Kralj Petar I- Niš
OS Kralj Petar I- Niš
 
Evaluation 3
Evaluation 3Evaluation 3
Evaluation 3
 
Chakryan v
Chakryan vChakryan v
Chakryan v
 
Iran National Copper Corporation
Iran National Copper CorporationIran National Copper Corporation
Iran National Copper Corporation
 
Vv28 mar 330
Vv28 mar 330Vv28 mar 330
Vv28 mar 330
 
Поисковая оптимизация как инструмент привлечения целевой аудитории на сайт ко...
Поисковая оптимизация как инструмент привлечения целевой аудитории на сайт ко...Поисковая оптимизация как инструмент привлечения целевой аудитории на сайт ко...
Поисковая оптимизация как инструмент привлечения целевой аудитории на сайт ко...
 

Similar to Mysqlhacodebits20091203 1260184765-phpapp02

Drupal Con My Sql Ha 2008 08 29
Drupal Con My Sql Ha 2008 08 29Drupal Con My Sql Ha 2008 08 29
Drupal Con My Sql Ha 2008 08 29
liufabin 66688
 
Buytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerBuytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemaker
kuchinskaya
 
Ukoug 2011 mysql_arch_for_orcl_dba
Ukoug 2011 mysql_arch_for_orcl_dbaUkoug 2011 mysql_arch_for_orcl_dba
Ukoug 2011 mysql_arch_for_orcl_dba
orablue11
 
UKOUG 2011: Practical MySQL Tuning
UKOUG 2011: Practical MySQL TuningUKOUG 2011: Practical MySQL Tuning
UKOUG 2011: Practical MySQL Tuning
FromDual GmbH
 

Similar to Mysqlhacodebits20091203 1260184765-phpapp02 (20)

Drupal Con My Sql Ha 2008 08 29
Drupal Con My Sql Ha 2008 08 29Drupal Con My Sql Ha 2008 08 29
Drupal Con My Sql Ha 2008 08 29
 
Buytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerBuytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemaker
 
Ukoug 2011 mysql_arch_for_orcl_dba
Ukoug 2011 mysql_arch_for_orcl_dbaUkoug 2011 mysql_arch_for_orcl_dba
Ukoug 2011 mysql_arch_for_orcl_dba
 
MySQL for Oracle DBAs
MySQL for Oracle DBAsMySQL for Oracle DBAs
MySQL for Oracle DBAs
 
Running MySQL in AWS
Running MySQL in AWSRunning MySQL in AWS
Running MySQL in AWS
 
NoSQL with MySQL
NoSQL with MySQLNoSQL with MySQL
NoSQL with MySQL
 
UKOUG 2011: Practical MySQL Tuning
UKOUG 2011: Practical MySQL TuningUKOUG 2011: Practical MySQL Tuning
UKOUG 2011: Practical MySQL Tuning
 
MySQL always-up with Galera Cluster
MySQL always-up with Galera ClusterMySQL always-up with Galera Cluster
MySQL always-up with Galera Cluster
 
Collaborate 2012 - Administering MySQL for Oracle DBAs
Collaborate 2012 - Administering MySQL for Oracle DBAsCollaborate 2012 - Administering MySQL for Oracle DBAs
Collaborate 2012 - Administering MySQL for Oracle DBAs
 
The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin
The Peoper Care and Feeding of a MySQL Server for Busy Linux AdminThe Peoper Care and Feeding of a MySQL Server for Busy Linux Admin
The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin
 
When is MyRocks good?
When is MyRocks good? When is MyRocks good?
When is MyRocks good?
 
MySQL Webinar 2/4 Performance tuning, hardware, optimisation
MySQL Webinar 2/4 Performance tuning, hardware, optimisationMySQL Webinar 2/4 Performance tuning, hardware, optimisation
MySQL Webinar 2/4 Performance tuning, hardware, optimisation
 
Open stack HA - Theory to Reality
Open stack HA -  Theory to RealityOpen stack HA -  Theory to Reality
Open stack HA - Theory to Reality
 
Proper Care and Feeding of a MySQL Database for Busy Linux Administrators
Proper Care and Feeding of a MySQL Database for Busy Linux AdministratorsProper Care and Feeding of a MySQL Database for Busy Linux Administrators
Proper Care and Feeding of a MySQL Database for Busy Linux Administrators
 
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
 
Linuxfest Northwest Proper Care and Feeding Of a MySQL for Busy Linux Admins
Linuxfest Northwest Proper Care and Feeding Of a MySQL for Busy Linux AdminsLinuxfest Northwest Proper Care and Feeding Of a MySQL for Busy Linux Admins
Linuxfest Northwest Proper Care and Feeding Of a MySQL for Busy Linux Admins
 
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best PracticesMySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
 
The Proper Care and Feeding of a MySQL Database for Busy Linux Admins -- SCaL...
The Proper Care and Feeding of a MySQL Database for Busy Linux Admins -- SCaL...The Proper Care and Feeding of a MySQL Database for Busy Linux Admins -- SCaL...
The Proper Care and Feeding of a MySQL Database for Busy Linux Admins -- SCaL...
 
High-availability with Galera Cluster for MySQL
High-availability with Galera Cluster for MySQLHigh-availability with Galera Cluster for MySQL
High-availability with Galera Cluster for MySQL
 
MariaDB 10 and Beyond
MariaDB 10 and BeyondMariaDB 10 and Beyond
MariaDB 10 and Beyond
 

More from Louis liu

基于Mongodb的压力评测工具 ycsb的一些概括
基于Mongodb的压力评测工具 ycsb的一些概括基于Mongodb的压力评测工具 ycsb的一些概括
基于Mongodb的压力评测工具 ycsb的一些概括
Louis liu
 
NetApp ef540 SSD Storage Test
NetApp ef540 SSD Storage TestNetApp ef540 SSD Storage Test
NetApp ef540 SSD Storage Test
Louis liu
 
MySQL 5.5&5.6 new features summary
MySQL 5.5&5.6 new features summaryMySQL 5.5&5.6 new features summary
MySQL 5.5&5.6 new features summary
Louis liu
 
Ssd gc review
Ssd gc reviewSsd gc review
Ssd gc review
Louis liu
 
1号店数据库架构
1号店数据库架构1号店数据库架构
1号店数据库架构
Louis liu
 
Architecture of YHD
Architecture of YHDArchitecture of YHD
Architecture of YHD
Louis liu
 

More from Louis liu (20)

Tcpcopy benchmark
Tcpcopy benchmarkTcpcopy benchmark
Tcpcopy benchmark
 
JK Log-Center architect
JK Log-Center architectJK Log-Center architect
JK Log-Center architect
 
Wdt Test
Wdt TestWdt Test
Wdt Test
 
JKDB BACKUP Introduction
JKDB BACKUP IntroductionJKDB BACKUP Introduction
JKDB BACKUP Introduction
 
Infiniflash benchmark
Infiniflash benchmarkInfiniflash benchmark
Infiniflash benchmark
 
MySQL Tokudb engine benchmark
MySQL Tokudb engine benchmarkMySQL Tokudb engine benchmark
MySQL Tokudb engine benchmark
 
Nvmfs benchmark
Nvmfs benchmarkNvmfs benchmark
Nvmfs benchmark
 
MySQL 5.7 milestone
MySQL 5.7 milestoneMySQL 5.7 milestone
MySQL 5.7 milestone
 
MySQL Oslayer performace optimization
MySQL  Oslayer performace optimizationMySQL  Oslayer performace optimization
MySQL Oslayer performace optimization
 
MySQL async message subscription platform
MySQL async message subscription platformMySQL async message subscription platform
MySQL async message subscription platform
 
HBASE Performane Test
HBASE Performane TestHBASE Performane Test
HBASE Performane Test
 
Jkcn MySQLDB 架构
Jkcn MySQLDB 架构Jkcn MySQLDB 架构
Jkcn MySQLDB 架构
 
基于Mongodb的压力评测工具 ycsb的一些概括
基于Mongodb的压力评测工具 ycsb的一些概括基于Mongodb的压力评测工具 ycsb的一些概括
基于Mongodb的压力评测工具 ycsb的一些概括
 
My sql fabric ha and sharding solutions
My sql fabric ha and sharding solutionsMy sql fabric ha and sharding solutions
My sql fabric ha and sharding solutions
 
NetApp ef540 SSD Storage Test
NetApp ef540 SSD Storage TestNetApp ef540 SSD Storage Test
NetApp ef540 SSD Storage Test
 
Exadata best practice on E-commerce area
Exadata best practice on E-commerce area Exadata best practice on E-commerce area
Exadata best practice on E-commerce area
 
MySQL 5.5&5.6 new features summary
MySQL 5.5&5.6 new features summaryMySQL 5.5&5.6 new features summary
MySQL 5.5&5.6 new features summary
 
Ssd gc review
Ssd gc reviewSsd gc review
Ssd gc review
 
1号店数据库架构
1号店数据库架构1号店数据库架构
1号店数据库架构
 
Architecture of YHD
Architecture of YHDArchitecture of YHD
Architecture of YHD
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Mysqlhacodebits20091203 1260184765-phpapp02

  • 1. MySQL High Availability Solutions Lenz Grimmer <lenz@grimmer.com> < http://lenzg.net/ | Twitter: @lenzgr 2011-01-26 | San Francisco MySQL Meetup | USA
  • 2. $ whoami 1998 2002 2008 2010
  • 3. Agenda ● High Availability: Concepts & Considerations ● MySQL Replication ● DRBD / Pacemaker ● MySQL Cluster ● Other HA tools/applications
  • 4. Single MySQL Server MySQL Client SQL (SELECT, INSERT, UPDATE, DELETE) MySQL Storage Engines (InnoDB, MyISAM, PBXT...) Disk Storage (XFS, ReiserFS, JFS, ext3...)
  • 5. Why HA? ● Something can and will fail ● Service Maintenance ● Downtime is expensive ● Adding HA to an existing system is complex
  • 6. Elimination of the SPOF ● Identify what will fail eventually ● Hard disks ● Fans ● Consider what might fail ● Application crashes ● OOM-Situations, Kernel-Panics ● Network connections, Cables ● Power supply
  • 7. What is HA Clustering? ● Redundancy ● One system or service goes down → others take over ● IP address takeover, service takeover ● Ensuring data availability & integrity ● Not designed for high-performance
  • 9. Rules of High Availability ● Prepare for failure ● Aim to ensure that no important data is lost ● Keep it simple, stupid (KISS) ● Complexity is the enemy of reliability ● Automate it ● Test your setup frequently!
  • 10. HA Components ● Heartbeat ● Checks that services that are monitored, are alive. ● Can check individual servers, software services, networking etc. ● HA Monitor ● Configuration of the services ● Ensures proper shutdown and startup ● Allows manual control ● Shared storage / Replication
  • 11. 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 ● Use Fencing or Moderation/Arbitration to avoid it
  • 12. Redundancy Using MySQL Replication MySQL Replication
  • 13. MySQL Replication ● Unidirectional ● Statement- or row-based (MySQL 5.1) ● Built into MySQL ● Easy to use and set up ● One Master, many Slaves ● Asynchronous – Slaves can lag behind ● New in MySQL 5.5: Semisync Replication
  • 14. MySQL Replication (2) ● Master maintains Binary logs & index ● Replication on Slave is single-threaded http://forge.mysql.com/wiki/ReplicationFeatures/ParallelSlave ● No automated fail-over ● No heartbeat, no monitoring ● New in 5.5: replication heartbeat
  • 15. MySQL Replication - Overview Read & Write Web/App Server Write Relay Log mysqld SQL I/O Threa Thread d Index & Binlogs Data Replication Binlog Data mysqld MySQL Master MySQL Slave
  • 16. Statement-based Replication ● Pro ✔ Proven (around since MySQL 3.23) ✔ Smaller log files ✔ Auditing of actual SQL statements ✔ No primary key requirement for replicated tables ● Con ✗ Non-deterministic functions and UDFs ✗ LOAD_FILE(), UUID(), CURRENT_USER(), FOUND_ROWS() (but RAND() and NOW() work)
  • 17. Row-based Replication ● Pro ✔ All changes can be replicated ✔ Similar technology used by other RDBMSes ✔ Fewer locks required for some INSERT, UPDATE or DELETE statements ● Con ✗ More data to be logged ✗ Log file size increases (backup/restore implications) ✗ Replicated tables require explicit primary keys ✗ Possible different result sets on bulk INSERTs
  • 18. Replication Topologies Master > Slave Master > Slaves Master > Slave > Slaves Masters > Slave (Multi-Source) Ring (Multi-Master) Master < > Master (Multi-Master)
  • 19. Master-Master Replication ● Two nodes are both master and slave to each other ● Useful for easier failover ● Not suitable for (write) load-balancing ● Don't write to both masters simultaneously! ● Use Sharding or Partitioning instead (e.g. MySQL Proxy)
  • 20. MySQL Replication as a HA Solution ● What happens if the Master fails? ● What happens if the Slave fails? ● This doesn’t sound like High Availability! ● Yes! ● Replication is only part of a HA configuration
  • 21. Pacemaker (Linux-HA) ● Supports 2 or more Nodes (v2) ● Resource monitoring (Apps and HW) ● Active fencing mechanism (STONITH) ● Node failure detection in seconds ● Supports many applications (incl. MySQL) ● http://clusterlabs.org/ ● http://www.clusterlabs.org/wiki/Load_Balanced_MySQL_Replicated_Cluster ● http://www.clusterlabs.org/wiki/DRBD_MySQL_HowTo
  • 22. Replication & HA ● Combined with Pacemaker ● Virtual IP takeover ● Slave gets promoted to Master ● Side benefits: load balancing & backup ● Can be tricky to fail back ● No automatic conflict resolution ● Proper failover needs to be scripted
  • 23. Redundancy With Disk Replication Disk Replication
  • 24. DRBD ● Distributed Replicated Block Device ● “RAID-1 over network” ● Synchronous/asynchronous block replication ● Automatic resynchronisation ● Application-agnostic ● Can mask local I/O-Errors ● Active/passive configuration ● Dual-primary mode (requires cluster file sytem like GFS or OCFS2) ● http://drbd.org/
  • 25. DRBD in Detail ● DRBD replicates data blocks between to block devices ● DRBD can be combined with Linux-HA and other HA solutions ● MySQL runs normally Applications on primary node ● MySQL is not active on Active Node Virtual IP Passive Node the secondary node ● DRBD is Linux only DRBD
  • 27. Replication vs. SAN ● Data Consistency / Integrity ● Synchronous vs. asynchronous ● SAN can become the SPOF ● Cold caches ● “Split brain”-Situations ● SAN/NAS I/O Overhead
  • 29. MySQL Cluster ● “Shared-nothing”-Architecture ● Automatic partitioning ● Distributed fragments ● Synchronous replication ● Fast, automatic fail-over of data nodes ● Automatic resynchronisation ● Transparent to MySQL applicationen ● Supports transactions ● http://mysql.com/products/database/cluster/
  • 30. MySQL Cluster ● In-memory indexes ● Not suitable for all query patterns (cross-table JOINs, range scans) ● No support for foreign keys ● Not suitable for long running transactions ● Network latency crucial ● Can be combined with MySQL replication (RBR)
  • 31.
  • 32. MySQL Cluster & Replikation ● MySQL Cluster ● Easy failover from one MySQL node to another ● Scaling write load using multiple SQL nodes ● Asynchronous replication from Cluster to regular MySQL slaves ● Slaves take read load (InnoDB/MyISAM) ● Quick setup of new slaves (Cluster Online Backup) ● Easy failover and fast recovery
  • 34. Galera Replication ● Patch for InnoDB plus external library ● Synchronous replication ● Single- or multi-master ● Multicast-Replication ● HA plus load sharing possible ● Certifikate-based replikation (instead of 2PC) ● http://codership.com/products/mysql_galera
  • 35. MMM ● MySQL Master-Master Replication Manager ● Perl-Script for monitoring, failover and management ● Master-master replication configuration (one active writable master) ● Failover by moving virtual IP-Address ● Also supports read balancing ● http://mysql-mmm.org/
  • 36. Continuent Tungsten Replicator ● Database-external solution ● Asynchronous, Master-Slave, Fan-out & Fan-in ● Java ● Log-based ● Events are stored in the Transaction History Log (THL) ● Modular architekture (Pipelines, Stages) ● http://continuent.com/community/tungsten-replicator
  • 37. Red Hat Cluster Suite ● HA and load balancing ● Supports up to 16 nodes ● Shared storage ● Monitors services, file systems and network status ● Fencing (STONITH) or distributed lock manager ● Configuration synchronization ● http://www.redhat.com/cluster_suite/
  • 38. Solaris Cluster / OpenHA Cluster ● Provides failover and scalability services ● Solaris / OpenSolaris (Project Colorado) ● Kernel-level components plus userland ● Agents monitor applications ● Geo Edition to provide Disaster Recovery using Replication ● Open Source since June 2007 ● http://hub.opensolaris.org/bin/view/Community+Group+ha-clusters/WebHome ● http://hub.opensolaris.org/bin/view/Project+ha-mysql/WebHome
  • 39. Flipper ● Perl Script managing pairs of MySQL servers replicating to each other. ● Automatic switchover, triggered manually ● Enables one half of the pair to be taken offline for maintenance work while other half carries on ● Moves IP addresses based on a role ("read- only", "writable") ● http://provenscaling.com/software/flipper/
  • 41. Thank you! Lenz Grimmer <lenz@grimmer.com> Twitter: @lenzgr http://lenzg.net/