SlideShare a Scribd company logo
1 of 33
Download to read offline
Copyright 2015 Severalnines AB
Designing HA for MySQL
July 28, 2015
Krzysztof Książek
Severalnines
krzysztof@severalnines.com
1
Copyright 2015 Severalnines AB
! We want to help all non-DBA people who have to take
care of MySQL infrastructure
! Discuss most common activities
! Share tips and good practicies
! If you missed, we’d like to encourage you to watch the
replay of the “Deep Dive Into How to Monitor Galera
Cluster” and “Deciding on a relevant backup solution"
! http://www.slideshare.net/Severalnines/videos
2
“Become a MySQL DBA” series
Copyright 2015 Severalnines AB
! HA - what it is?
! Caching layer
! HA solutions
! Proxy layer
! Common problems
3
Agenda
Copyright 2015 Severalnines AB
! It’s not enough to just build a database infrastructure, you
have to keep it available
! Redundancy is your friend
! Automate as much of the failover process where possible
! Know your business requirements and then decide
! Higher availability = higher costs - you need to find a
sweet spot
4
High Availability - what it is about?
Copyright 2015 Severalnines AB
Caching layer
5
Copyright 2015 Severalnines AB
! Reduce the load on the
database
! Works as a buffer between
the application and the
database tier
! Gives you some HA features
as it can serve the data even
if database is not available
! It’s a must have for any larger
application - cheaper than a
database and easier to scale
6
Caching layer - why do I need it?
Copyright 2015 Severalnines AB
! Memcached, Redis, Couchbase, you name it
! Database access is expensive and should be avoided -
therefore we have cache to handle reads
! Avoid cache miss storm
! Serve outdated data or wait for refresh if you can’t do
that
! Refresh the cache by executing a query ONCE!
! If you can serve old results, you can partially hide issues
7
Read cache
Copyright 2015 Severalnines AB
! Do not write directly to the database, use persistent
queue for that (Kinesis or Rabbitmq for example)
! Helps you to avoid overloading data tier with writes
! You can define exact number of workers to handle the
writes
! Helps to minimize impact of the database tier not being
available by caching writes
8
Write cache
Copyright 2015 Severalnines AB
High Availability Solutions
9
Copyright 2015 Severalnines AB
! RAID 1 over the TCP
! Maintain an exact copy (or
two) of your volume in a
separate location
! Active - passive model, only
one volume can be
mounted
! Works nice if you have a
single database node
10
Distributed Redundant Block Device
Copyright 2015 Severalnines AB
! Passive -> active switch takes time (InnoDB recovery is
required)
! You can’t use the passive node for anything
! Just a single node, not feasible for larger environments
! Great tool but with limited use cases
11
Distributed Redundant Block Device
Copyright 2015 Severalnines AB
! Best known HA solution for
MySQL
! You can use it for scaling
too
! By default - asynchronous
! Failover process may be
tricky without GTID
! Many tools are available to
automate it, though
12
MySQL Replication
Copyright 2015 Severalnines AB
! Locate the most advanced slave, apply missing updates
from master’s binary logs (if needed and possible)
! Ensure all slaves are on the same position for reslaving
! Reslave rest of the slaves to the chosen node
! Perform the failover
! Whole process is error-prone and tricky
! You can use MHA to manage it for you
13
MySQL Replication - failover
Copyright 2015 Severalnines AB
! Reslaving became much easier (CHANGE MASTER TO …
MASTER_AUTO_POSITION=1)
! You still have to choose a most advanced slave to
promote
! You still have to replay binary logs (if possible) to apply
missing changes
! You still may benefit from additional tooling
14
MySQL Replication - GTID
Copyright 2015 Severalnines AB
! Handles the failover process for you
! Can be used as a standalone solution or a part of a grand
schema (Pacemaker)
! masterha_manager being a SPOF - you need to monitor it
! Can work with GTID and regular replication
! Make sure that you have shutdown_script defined for
STONITH in MHA config
15
MySQL Replication - MHA
Copyright 2015 Severalnines AB
Clustering
16
Copyright 2015 Severalnines AB
! Synchronous cluster
! Based on NDB engine (not
InnoDB!)
! Great point-select performance
! Great insert performance
! Using data partitioning for
redundancy
! Behaves differently than InnoDB
- especially range queries
! It’s not a drop-in replacement
for regular MySQL
17
MySQL Cluster
Copyright 2015 Severalnines AB
! Virtually synchronous cluster
(lag <1s, typically few ms)
! Doesn’t split the data, each
node is a full copy
! Harder to scale as you
can’t increase disk
capacity by adding new
nodes
! Easier to run reporting
queries as all data is
available on every node
18
Galera Cluster
Copyright 2015 Severalnines AB
! "almost" a drop-in replacement for regular MySQL (uses
InnoDB engine)
! Different AUTO_INCREMENT handling
! All tables should have a primary key defined
! Basically, it’s InnoDB only (avoid MyISAM)
! Large transactions may be problematic or impossible
! Schema changes may become more complex
19
Galera Cluster
Copyright 2015 Severalnines AB
Proxy layer
20
Copyright 2015 Severalnines AB
! It’s a set of servers that will work as a middle man
between the application and the database layer
! They route the traffic to the database layer
! They should detect failed instances and topology
changes
! It’s useful to hide the database layer complexity from the
application
21
Proxy layer - why do we need it?
Copyright 2015 Severalnines AB
! Popular and proven tool
! Not database-aware, it just
moves packets
! Can check if the port is
available
! Can do HTTP tests - very
useful to build a logic
22
HAProxy
Copyright 2015 Severalnines AB
! Use read_only variable to differentiate master and slaves
! Have a script that works in the background, checks the
state of a node and store it in shared memory
! Have a script that will be executed via xinetd, check the
state from shared memory and return HTTP codes (200,
503) accordingly
! Make sure that the read_only variable will be changed
after the old master was stopped (by shutdown_script in
MHA) - otherwise split brain may happen
23
HAProxy
Copyright 2015 Severalnines AB
! MySQL-aware proxy
! Read/write splitting
! Still a new software, requires
detailed tests
! Tends to use significant
amount of CPU for R/W split
! Updated frequently, you
may want to follow the
changes
24
MaxScale
Copyright 2015 Severalnines AB
! Proxies need to be highly available too
! Multiple options to choose from:
! Put a proxy in front of the proxy (ELB)
! VIP + failover (i.e. keepalived)
! Colocate proxies with web nodes and handle config
changes via orchestration tools
25
HA for proxies
Copyright 2015 Severalnines AB
! Every approach has pros and cons
! ELB - easiest but available only in AWS (similar tools may
be available for other cloud providers too)
! VIP - only one proxy node will be active at a given time -
CPU utilization may become an issue
! Colocating proxies allows you to use more of them but
maintaining configuration can become a burden and
may be error prone
26
HA for proxies
Copyright 2015 Severalnines AB
Common problems
27
Copyright 2015 Severalnines AB
! Errant transactions are transactions executed on the slave
only, not on the master
! With GTID, all transactions executed on a given host will
be requested once the host become a master
! If transactions are not available in binlogs, replication will
break
! http://www.severalnines.com/blog/mysql-replication-and-
gtid-based-failover-deep-dive-errant-transactions
28
Errant transactions in GTID
Copyright 2015 Severalnines AB
! Master loses network connection, failover is deemed
necessary
! One of the slaves is staged to be a new master, others are
reslaved
! VIP is assigned to the new master
! VIP is still assigned to the old master (as it’s not available
and VIP can’t be removed)
! Once the old master comes up, data will be written to it
29
Split Brain
Copyright 2015 Severalnines AB
! STONITH is the solution - kill it with fire
! Ensure that the old master won’t come back up (think
how your automated recovery will behave?)
! Start with dedicated network connection (if available) -
use a patchcord. Maybe it’s a network error only?
! Try to use IPMI/iLO/KVM-ish solutions to stop the server
! Try to stop the server using manageable power strip
30
Split Brain - STONITH
Copyright 2015 Severalnines AB
! In the cloud - try to stop the instance completely
! You can also try to bond your interfaces for better network
availability (although you never know what’s on the other
side of the black box)
! For MHA - STONITH process is executed as
shutdown_script. For other tools - ensure you have
implemented similar behavior
! This is relevant for MySQL replication - Galera doesn’t
require such harsh methods
31
Split Brain - STONITH
32
Synchro-
nous
Load-
balancing
reads
Load-
balancing
writes
WAN Scalable
MySQL/
InnoDB
compatible
DRBD yes no no
yes
(standby
DR site)
no yes
MySQL
replicati
on
no
(async or
semi
sync)
yes no yes
only
reads
yes
MySQL
Cluster
yes yes yes yes yes
expect
different
behavior
Galera virtually yes yes yes
reads,
writes to
some
extend
almost
Copyright 2015 Severalnines AB
! More blogs in “Become a MySQL DBA” series:
! http://www.severalnines.com/blog/become-dba-blog-
series-monitoring-and-trending
! http://www.severalnines.com/blog/become-mysql-
dba-blog-series-backup-restore
! Contact: krzysztof@severalnines.com
33
Thank You!

More Related Content

What's hot

Webinar slides: ClusterControl 1.4: The MySQL Replication & MongoDB Edition -...
Webinar slides: ClusterControl 1.4: The MySQL Replication & MongoDB Edition -...Webinar slides: ClusterControl 1.4: The MySQL Replication & MongoDB Edition -...
Webinar slides: ClusterControl 1.4: The MySQL Replication & MongoDB Edition -...
Severalnines
 
Methods of Sharding MySQL
Methods of Sharding MySQLMethods of Sharding MySQL
Methods of Sharding MySQL
Laine Campbell
 
Using MySQL in Automated Testing
Using MySQL in Automated TestingUsing MySQL in Automated Testing
Using MySQL in Automated Testing
Morgan Tocker
 

What's hot (20)

Webinar slides: ClusterControl 1.4: The MySQL Replication & MongoDB Edition -...
Webinar slides: ClusterControl 1.4: The MySQL Replication & MongoDB Edition -...Webinar slides: ClusterControl 1.4: The MySQL Replication & MongoDB Edition -...
Webinar slides: ClusterControl 1.4: The MySQL Replication & MongoDB Edition -...
 
Enterprise Drupal Application & Hosting Infrastructure Level Monitoring
Enterprise Drupal Application & Hosting Infrastructure Level MonitoringEnterprise Drupal Application & Hosting Infrastructure Level Monitoring
Enterprise Drupal Application & Hosting Infrastructure Level Monitoring
 
Management and Automation of MongoDB Clusters - Slides
Management and Automation of MongoDB Clusters - SlidesManagement and Automation of MongoDB Clusters - Slides
Management and Automation of MongoDB Clusters - Slides
 
MySQL highav Availability
MySQL highav AvailabilityMySQL highav Availability
MySQL highav Availability
 
The Complete MariaDB Server Tutorial - Percona Live 2015
The Complete MariaDB Server Tutorial - Percona Live 2015The Complete MariaDB Server Tutorial - Percona Live 2015
The Complete MariaDB Server Tutorial - Percona Live 2015
 
Webinar slides: 9 DevOps Tips for Going in Production with Galera Cluster for...
Webinar slides: 9 DevOps Tips for Going in Production with Galera Cluster for...Webinar slides: 9 DevOps Tips for Going in Production with Galera Cluster for...
Webinar slides: 9 DevOps Tips for Going in Production with Galera Cluster for...
 
Best practices for MySQL High Availability
Best practices for MySQL High AvailabilityBest practices for MySQL High Availability
Best practices for MySQL High Availability
 
Maria DB Galera Cluster for High Availability
Maria DB Galera Cluster for High AvailabilityMaria DB Galera Cluster for High Availability
Maria DB Galera Cluster for High Availability
 
Master master vs master-slave database
Master master vs master-slave databaseMaster master vs master-slave database
Master master vs master-slave database
 
Automated MySQL failover with MHA: Getting started & moving past its quirks
Automated MySQL failover with MHA: Getting started & moving past its quirksAutomated MySQL failover with MHA: Getting started & moving past its quirks
Automated MySQL failover with MHA: Getting started & moving past its quirks
 
MySQL Multi Master Replication
MySQL Multi Master ReplicationMySQL Multi Master Replication
MySQL Multi Master Replication
 
9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides
9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides
9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides
 
MySQL High Availability Solutions
MySQL High Availability SolutionsMySQL High Availability Solutions
MySQL High Availability Solutions
 
Galera Cluster for MySQL vs MySQL (NDB) Cluster: A High Level Comparison
Galera Cluster for MySQL vs MySQL (NDB) Cluster: A High Level Comparison Galera Cluster for MySQL vs MySQL (NDB) Cluster: A High Level Comparison
Galera Cluster for MySQL vs MySQL (NDB) Cluster: A High Level Comparison
 
Choosing a MySQL High Availability solution - Percona Live UK 2011
Choosing a MySQL High Availability solution - Percona Live UK 2011Choosing a MySQL High Availability solution - Percona Live UK 2011
Choosing a MySQL High Availability solution - Percona Live UK 2011
 
Methods of Sharding MySQL
Methods of Sharding MySQLMethods of Sharding MySQL
Methods of Sharding MySQL
 
Using and Benchmarking Galera in different architectures (PLUK 2012)
Using and Benchmarking Galera in different architectures (PLUK 2012)Using and Benchmarking Galera in different architectures (PLUK 2012)
Using and Benchmarking Galera in different architectures (PLUK 2012)
 
Nagios Conference 2014 - Jeremy Rust - Avoiding Downtime Using Linux High Ava...
Nagios Conference 2014 - Jeremy Rust - Avoiding Downtime Using Linux High Ava...Nagios Conference 2014 - Jeremy Rust - Avoiding Downtime Using Linux High Ava...
Nagios Conference 2014 - Jeremy Rust - Avoiding Downtime Using Linux High Ava...
 
Using MySQL in Automated Testing
Using MySQL in Automated TestingUsing MySQL in Automated Testing
Using MySQL in Automated Testing
 
Choosing between Codership's MySQL Galera, MariaDB Galera Cluster and Percona...
Choosing between Codership's MySQL Galera, MariaDB Galera Cluster and Percona...Choosing between Codership's MySQL Galera, MariaDB Galera Cluster and Percona...
Choosing between Codership's MySQL Galera, MariaDB Galera Cluster and Percona...
 

Similar to Become a MySQL DBA - webinar series - slides: Which High Availability solution?

Webinar slides: MySQL & MariaDB load balancing with ProxySQL & ClusterControl...
Webinar slides: MySQL & MariaDB load balancing with ProxySQL & ClusterControl...Webinar slides: MySQL & MariaDB load balancing with ProxySQL & ClusterControl...
Webinar slides: MySQL & MariaDB load balancing with ProxySQL & ClusterControl...
Severalnines
 
Growing MongoDB on AWS
Growing MongoDB on AWSGrowing MongoDB on AWS
Growing MongoDB on AWS
colinthehowe
 

Similar to Become a MySQL DBA - webinar series - slides: Which High Availability solution? (20)

Webinar slides: The Holy Grail Webinar: Become a MySQL DBA - Database Perform...
Webinar slides: The Holy Grail Webinar: Become a MySQL DBA - Database Perform...Webinar slides: The Holy Grail Webinar: Become a MySQL DBA - Database Perform...
Webinar slides: The Holy Grail Webinar: Become a MySQL DBA - Database Perform...
 
Webinar slides: Top 9 Tips for building a stable MySQL Replication environment
Webinar slides: Top 9 Tips for building a stable MySQL Replication environmentWebinar slides: Top 9 Tips for building a stable MySQL Replication environment
Webinar slides: Top 9 Tips for building a stable MySQL Replication environment
 
Webinar slides: Our Guide to MySQL & MariaDB Performance Tuning
Webinar slides: Our Guide to MySQL & MariaDB Performance TuningWebinar slides: Our Guide to MySQL & MariaDB Performance Tuning
Webinar slides: Our Guide to MySQL & MariaDB Performance Tuning
 
Slides: Introducing the new ClusterControl 1.2.10 for MySQL, MongoDB and Post...
Slides: Introducing the new ClusterControl 1.2.10 for MySQL, MongoDB and Post...Slides: Introducing the new ClusterControl 1.2.10 for MySQL, MongoDB and Post...
Slides: Introducing the new ClusterControl 1.2.10 for MySQL, MongoDB and Post...
 
EXPERIENCE WITH MYSQL HA SOLUTION AND GROUP REPLICATION
EXPERIENCE WITH MYSQL HA SOLUTION AND GROUP REPLICATIONEXPERIENCE WITH MYSQL HA SOLUTION AND GROUP REPLICATION
EXPERIENCE WITH MYSQL HA SOLUTION AND GROUP REPLICATION
 
MySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated EnvironmentMySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated Environment
 
Performance and Scalability
Performance and ScalabilityPerformance and Scalability
Performance and Scalability
 
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
 
PoC: Using a Group Communication System to improve MySQL Replication HA
PoC: Using a Group Communication System to improve MySQL Replication HAPoC: Using a Group Communication System to improve MySQL Replication HA
PoC: Using a Group Communication System to improve MySQL Replication HA
 
WinConnections Spring, 2011 - 30 Bite-Sized Tips for Best vSphere and Hyper-V...
WinConnections Spring, 2011 - 30 Bite-Sized Tips for Best vSphere and Hyper-V...WinConnections Spring, 2011 - 30 Bite-Sized Tips for Best vSphere and Hyper-V...
WinConnections Spring, 2011 - 30 Bite-Sized Tips for Best vSphere and Hyper-V...
 
MySQL 5.7: Focus on InnoDB
MySQL 5.7: Focus on InnoDBMySQL 5.7: Focus on InnoDB
MySQL 5.7: Focus on InnoDB
 
MySQL HA Presentation
MySQL HA PresentationMySQL HA Presentation
MySQL HA Presentation
 
Webinar slides: MySQL & MariaDB load balancing with ProxySQL & ClusterControl...
Webinar slides: MySQL & MariaDB load balancing with ProxySQL & ClusterControl...Webinar slides: MySQL & MariaDB load balancing with ProxySQL & ClusterControl...
Webinar slides: MySQL & MariaDB load balancing with ProxySQL & ClusterControl...
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011
 
MySQL Tech Tour 2015 - 5.7 InnoDB
MySQL Tech Tour 2015 - 5.7 InnoDBMySQL Tech Tour 2015 - 5.7 InnoDB
MySQL Tech Tour 2015 - 5.7 InnoDB
 
Growing MongoDB on AWS
Growing MongoDB on AWSGrowing MongoDB on AWS
Growing MongoDB on AWS
 
MySQL's NoSQL -- Texas Linuxfest August 22nd 2015
MySQL's NoSQL  -- Texas Linuxfest August 22nd 2015MySQL's NoSQL  -- Texas Linuxfest August 22nd 2015
MySQL's NoSQL -- Texas Linuxfest August 22nd 2015
 
Vote NO for MySQL
Vote NO for MySQLVote NO for MySQL
Vote NO for MySQL
 
Severalnines Training: MySQL® Cluster - Part IX
Severalnines Training: MySQL® Cluster - Part IXSeveralnines Training: MySQL® Cluster - Part IX
Severalnines Training: MySQL® Cluster - Part IX
 
NameNode Analytics - Querying HDFS Namespace in Real Time
NameNode Analytics - Querying HDFS Namespace in Real TimeNameNode Analytics - Querying HDFS Namespace in Real Time
NameNode Analytics - Querying HDFS Namespace in Real Time
 

More from Severalnines

Webinar slides: How to Migrate from Oracle DB to MariaDB
Webinar slides: How to Migrate from Oracle DB to MariaDBWebinar slides: How to Migrate from Oracle DB to MariaDB
Webinar slides: How to Migrate from Oracle DB to MariaDB
Severalnines
 
Webinar slides: How to Automate & Manage PostgreSQL with ClusterControl
Webinar slides: How to Automate & Manage PostgreSQL with ClusterControlWebinar slides: How to Automate & Manage PostgreSQL with ClusterControl
Webinar slides: How to Automate & Manage PostgreSQL with ClusterControl
Severalnines
 
Webinar slides: How to Manage Replication Failover Processes for MySQL, Maria...
Webinar slides: How to Manage Replication Failover Processes for MySQL, Maria...Webinar slides: How to Manage Replication Failover Processes for MySQL, Maria...
Webinar slides: How to Manage Replication Failover Processes for MySQL, Maria...
Severalnines
 
Webinar slides: Backup Management for MySQL, MariaDB, PostgreSQL & MongoDB wi...
Webinar slides: Backup Management for MySQL, MariaDB, PostgreSQL & MongoDB wi...Webinar slides: Backup Management for MySQL, MariaDB, PostgreSQL & MongoDB wi...
Webinar slides: Backup Management for MySQL, MariaDB, PostgreSQL & MongoDB wi...
Severalnines
 
Webinar slides: Free Monitoring (on Steroids) for MySQL, MariaDB, PostgreSQL ...
Webinar slides: Free Monitoring (on Steroids) for MySQL, MariaDB, PostgreSQL ...Webinar slides: Free Monitoring (on Steroids) for MySQL, MariaDB, PostgreSQL ...
Webinar slides: Free Monitoring (on Steroids) for MySQL, MariaDB, PostgreSQL ...
Severalnines
 
Webinar slides: An Introduction to Performance Monitoring for PostgreSQL
Webinar slides: An Introduction to Performance Monitoring for PostgreSQLWebinar slides: An Introduction to Performance Monitoring for PostgreSQL
Webinar slides: An Introduction to Performance Monitoring for PostgreSQL
Severalnines
 
Webinar slides: Migrating to Galera Cluster for MySQL and MariaDB
Webinar slides: Migrating to Galera Cluster for MySQL and MariaDBWebinar slides: Migrating to Galera Cluster for MySQL and MariaDB
Webinar slides: Migrating to Galera Cluster for MySQL and MariaDB
Severalnines
 
Webinar slides: How to Measure Database Availability?
Webinar slides: How to Measure Database Availability?Webinar slides: How to Measure Database Availability?
Webinar slides: How to Measure Database Availability?
Severalnines
 
Webinar slides: Designing Open Source Databases for High Availability
Webinar slides: Designing Open Source Databases for High AvailabilityWebinar slides: Designing Open Source Databases for High Availability
Webinar slides: Designing Open Source Databases for High Availability
Severalnines
 
Webinar slides: How to Get Started with Open Source Database Management
Webinar slides: How to Get Started with Open Source Database ManagementWebinar slides: How to Get Started with Open Source Database Management
Webinar slides: How to Get Started with Open Source Database Management
Severalnines
 
Webinar slides: How to Achieve PCI Compliance for MySQL & MariaDB with Cluste...
Webinar slides: How to Achieve PCI Compliance for MySQL & MariaDB with Cluste...Webinar slides: How to Achieve PCI Compliance for MySQL & MariaDB with Cluste...
Webinar slides: How to Achieve PCI Compliance for MySQL & MariaDB with Cluste...
Severalnines
 

More from Severalnines (20)

Cloud's future runs through Sovereign DBaaS
Cloud's future runs through Sovereign DBaaSCloud's future runs through Sovereign DBaaS
Cloud's future runs through Sovereign DBaaS
 
Working with the Moodle Database: The Basics
Working with the Moodle Database: The BasicsWorking with the Moodle Database: The Basics
Working with the Moodle Database: The Basics
 
SysAdmin Working from Home? Tips to Automate MySQL, MariaDB, Postgres & MongoDB
SysAdmin Working from Home? Tips to Automate MySQL, MariaDB, Postgres & MongoDBSysAdmin Working from Home? Tips to Automate MySQL, MariaDB, Postgres & MongoDB
SysAdmin Working from Home? Tips to Automate MySQL, MariaDB, Postgres & MongoDB
 
(slides) Polyglot persistence: utilizing open source databases as a Swiss poc...
(slides) Polyglot persistence: utilizing open source databases as a Swiss poc...(slides) Polyglot persistence: utilizing open source databases as a Swiss poc...
(slides) Polyglot persistence: utilizing open source databases as a Swiss poc...
 
Webinar slides: How to Migrate from Oracle DB to MariaDB
Webinar slides: How to Migrate from Oracle DB to MariaDBWebinar slides: How to Migrate from Oracle DB to MariaDB
Webinar slides: How to Migrate from Oracle DB to MariaDB
 
Webinar slides: How to Automate & Manage PostgreSQL with ClusterControl
Webinar slides: How to Automate & Manage PostgreSQL with ClusterControlWebinar slides: How to Automate & Manage PostgreSQL with ClusterControl
Webinar slides: How to Automate & Manage PostgreSQL with ClusterControl
 
Webinar slides: How to Manage Replication Failover Processes for MySQL, Maria...
Webinar slides: How to Manage Replication Failover Processes for MySQL, Maria...Webinar slides: How to Manage Replication Failover Processes for MySQL, Maria...
Webinar slides: How to Manage Replication Failover Processes for MySQL, Maria...
 
Webinar slides: Backup Management for MySQL, MariaDB, PostgreSQL & MongoDB wi...
Webinar slides: Backup Management for MySQL, MariaDB, PostgreSQL & MongoDB wi...Webinar slides: Backup Management for MySQL, MariaDB, PostgreSQL & MongoDB wi...
Webinar slides: Backup Management for MySQL, MariaDB, PostgreSQL & MongoDB wi...
 
Disaster Recovery Planning for MySQL & MariaDB
Disaster Recovery Planning for MySQL & MariaDBDisaster Recovery Planning for MySQL & MariaDB
Disaster Recovery Planning for MySQL & MariaDB
 
MariaDB Performance Tuning Crash Course
MariaDB Performance Tuning Crash CourseMariaDB Performance Tuning Crash Course
MariaDB Performance Tuning Crash Course
 
Performance Tuning Cheat Sheet for MongoDB
Performance Tuning Cheat Sheet for MongoDBPerformance Tuning Cheat Sheet for MongoDB
Performance Tuning Cheat Sheet for MongoDB
 
Advanced MySql Data-at-Rest Encryption in Percona Server
Advanced MySql Data-at-Rest Encryption in Percona ServerAdvanced MySql Data-at-Rest Encryption in Percona Server
Advanced MySql Data-at-Rest Encryption in Percona Server
 
Polyglot Persistence Utilizing Open Source Databases as a Swiss Pocket Knife
Polyglot Persistence Utilizing Open Source Databases as a Swiss Pocket KnifePolyglot Persistence Utilizing Open Source Databases as a Swiss Pocket Knife
Polyglot Persistence Utilizing Open Source Databases as a Swiss Pocket Knife
 
Webinar slides: Free Monitoring (on Steroids) for MySQL, MariaDB, PostgreSQL ...
Webinar slides: Free Monitoring (on Steroids) for MySQL, MariaDB, PostgreSQL ...Webinar slides: Free Monitoring (on Steroids) for MySQL, MariaDB, PostgreSQL ...
Webinar slides: Free Monitoring (on Steroids) for MySQL, MariaDB, PostgreSQL ...
 
Webinar slides: An Introduction to Performance Monitoring for PostgreSQL
Webinar slides: An Introduction to Performance Monitoring for PostgreSQLWebinar slides: An Introduction to Performance Monitoring for PostgreSQL
Webinar slides: An Introduction to Performance Monitoring for PostgreSQL
 
Webinar slides: Migrating to Galera Cluster for MySQL and MariaDB
Webinar slides: Migrating to Galera Cluster for MySQL and MariaDBWebinar slides: Migrating to Galera Cluster for MySQL and MariaDB
Webinar slides: Migrating to Galera Cluster for MySQL and MariaDB
 
Webinar slides: How to Measure Database Availability?
Webinar slides: How to Measure Database Availability?Webinar slides: How to Measure Database Availability?
Webinar slides: How to Measure Database Availability?
 
Webinar slides: Designing Open Source Databases for High Availability
Webinar slides: Designing Open Source Databases for High AvailabilityWebinar slides: Designing Open Source Databases for High Availability
Webinar slides: Designing Open Source Databases for High Availability
 
Webinar slides: How to Get Started with Open Source Database Management
Webinar slides: How to Get Started with Open Source Database ManagementWebinar slides: How to Get Started with Open Source Database Management
Webinar slides: How to Get Started with Open Source Database Management
 
Webinar slides: How to Achieve PCI Compliance for MySQL & MariaDB with Cluste...
Webinar slides: How to Achieve PCI Compliance for MySQL & MariaDB with Cluste...Webinar slides: How to Achieve PCI Compliance for MySQL & MariaDB with Cluste...
Webinar slides: How to Achieve PCI Compliance for MySQL & MariaDB with Cluste...
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Become a MySQL DBA - webinar series - slides: Which High Availability solution?

  • 1. Copyright 2015 Severalnines AB Designing HA for MySQL July 28, 2015 Krzysztof Książek Severalnines krzysztof@severalnines.com 1
  • 2. Copyright 2015 Severalnines AB ! We want to help all non-DBA people who have to take care of MySQL infrastructure ! Discuss most common activities ! Share tips and good practicies ! If you missed, we’d like to encourage you to watch the replay of the “Deep Dive Into How to Monitor Galera Cluster” and “Deciding on a relevant backup solution" ! http://www.slideshare.net/Severalnines/videos 2 “Become a MySQL DBA” series
  • 3. Copyright 2015 Severalnines AB ! HA - what it is? ! Caching layer ! HA solutions ! Proxy layer ! Common problems 3 Agenda
  • 4. Copyright 2015 Severalnines AB ! It’s not enough to just build a database infrastructure, you have to keep it available ! Redundancy is your friend ! Automate as much of the failover process where possible ! Know your business requirements and then decide ! Higher availability = higher costs - you need to find a sweet spot 4 High Availability - what it is about?
  • 5. Copyright 2015 Severalnines AB Caching layer 5
  • 6. Copyright 2015 Severalnines AB ! Reduce the load on the database ! Works as a buffer between the application and the database tier ! Gives you some HA features as it can serve the data even if database is not available ! It’s a must have for any larger application - cheaper than a database and easier to scale 6 Caching layer - why do I need it?
  • 7. Copyright 2015 Severalnines AB ! Memcached, Redis, Couchbase, you name it ! Database access is expensive and should be avoided - therefore we have cache to handle reads ! Avoid cache miss storm ! Serve outdated data or wait for refresh if you can’t do that ! Refresh the cache by executing a query ONCE! ! If you can serve old results, you can partially hide issues 7 Read cache
  • 8. Copyright 2015 Severalnines AB ! Do not write directly to the database, use persistent queue for that (Kinesis or Rabbitmq for example) ! Helps you to avoid overloading data tier with writes ! You can define exact number of workers to handle the writes ! Helps to minimize impact of the database tier not being available by caching writes 8 Write cache
  • 9. Copyright 2015 Severalnines AB High Availability Solutions 9
  • 10. Copyright 2015 Severalnines AB ! RAID 1 over the TCP ! Maintain an exact copy (or two) of your volume in a separate location ! Active - passive model, only one volume can be mounted ! Works nice if you have a single database node 10 Distributed Redundant Block Device
  • 11. Copyright 2015 Severalnines AB ! Passive -> active switch takes time (InnoDB recovery is required) ! You can’t use the passive node for anything ! Just a single node, not feasible for larger environments ! Great tool but with limited use cases 11 Distributed Redundant Block Device
  • 12. Copyright 2015 Severalnines AB ! Best known HA solution for MySQL ! You can use it for scaling too ! By default - asynchronous ! Failover process may be tricky without GTID ! Many tools are available to automate it, though 12 MySQL Replication
  • 13. Copyright 2015 Severalnines AB ! Locate the most advanced slave, apply missing updates from master’s binary logs (if needed and possible) ! Ensure all slaves are on the same position for reslaving ! Reslave rest of the slaves to the chosen node ! Perform the failover ! Whole process is error-prone and tricky ! You can use MHA to manage it for you 13 MySQL Replication - failover
  • 14. Copyright 2015 Severalnines AB ! Reslaving became much easier (CHANGE MASTER TO … MASTER_AUTO_POSITION=1) ! You still have to choose a most advanced slave to promote ! You still have to replay binary logs (if possible) to apply missing changes ! You still may benefit from additional tooling 14 MySQL Replication - GTID
  • 15. Copyright 2015 Severalnines AB ! Handles the failover process for you ! Can be used as a standalone solution or a part of a grand schema (Pacemaker) ! masterha_manager being a SPOF - you need to monitor it ! Can work with GTID and regular replication ! Make sure that you have shutdown_script defined for STONITH in MHA config 15 MySQL Replication - MHA
  • 16. Copyright 2015 Severalnines AB Clustering 16
  • 17. Copyright 2015 Severalnines AB ! Synchronous cluster ! Based on NDB engine (not InnoDB!) ! Great point-select performance ! Great insert performance ! Using data partitioning for redundancy ! Behaves differently than InnoDB - especially range queries ! It’s not a drop-in replacement for regular MySQL 17 MySQL Cluster
  • 18. Copyright 2015 Severalnines AB ! Virtually synchronous cluster (lag <1s, typically few ms) ! Doesn’t split the data, each node is a full copy ! Harder to scale as you can’t increase disk capacity by adding new nodes ! Easier to run reporting queries as all data is available on every node 18 Galera Cluster
  • 19. Copyright 2015 Severalnines AB ! "almost" a drop-in replacement for regular MySQL (uses InnoDB engine) ! Different AUTO_INCREMENT handling ! All tables should have a primary key defined ! Basically, it’s InnoDB only (avoid MyISAM) ! Large transactions may be problematic or impossible ! Schema changes may become more complex 19 Galera Cluster
  • 20. Copyright 2015 Severalnines AB Proxy layer 20
  • 21. Copyright 2015 Severalnines AB ! It’s a set of servers that will work as a middle man between the application and the database layer ! They route the traffic to the database layer ! They should detect failed instances and topology changes ! It’s useful to hide the database layer complexity from the application 21 Proxy layer - why do we need it?
  • 22. Copyright 2015 Severalnines AB ! Popular and proven tool ! Not database-aware, it just moves packets ! Can check if the port is available ! Can do HTTP tests - very useful to build a logic 22 HAProxy
  • 23. Copyright 2015 Severalnines AB ! Use read_only variable to differentiate master and slaves ! Have a script that works in the background, checks the state of a node and store it in shared memory ! Have a script that will be executed via xinetd, check the state from shared memory and return HTTP codes (200, 503) accordingly ! Make sure that the read_only variable will be changed after the old master was stopped (by shutdown_script in MHA) - otherwise split brain may happen 23 HAProxy
  • 24. Copyright 2015 Severalnines AB ! MySQL-aware proxy ! Read/write splitting ! Still a new software, requires detailed tests ! Tends to use significant amount of CPU for R/W split ! Updated frequently, you may want to follow the changes 24 MaxScale
  • 25. Copyright 2015 Severalnines AB ! Proxies need to be highly available too ! Multiple options to choose from: ! Put a proxy in front of the proxy (ELB) ! VIP + failover (i.e. keepalived) ! Colocate proxies with web nodes and handle config changes via orchestration tools 25 HA for proxies
  • 26. Copyright 2015 Severalnines AB ! Every approach has pros and cons ! ELB - easiest but available only in AWS (similar tools may be available for other cloud providers too) ! VIP - only one proxy node will be active at a given time - CPU utilization may become an issue ! Colocating proxies allows you to use more of them but maintaining configuration can become a burden and may be error prone 26 HA for proxies
  • 27. Copyright 2015 Severalnines AB Common problems 27
  • 28. Copyright 2015 Severalnines AB ! Errant transactions are transactions executed on the slave only, not on the master ! With GTID, all transactions executed on a given host will be requested once the host become a master ! If transactions are not available in binlogs, replication will break ! http://www.severalnines.com/blog/mysql-replication-and- gtid-based-failover-deep-dive-errant-transactions 28 Errant transactions in GTID
  • 29. Copyright 2015 Severalnines AB ! Master loses network connection, failover is deemed necessary ! One of the slaves is staged to be a new master, others are reslaved ! VIP is assigned to the new master ! VIP is still assigned to the old master (as it’s not available and VIP can’t be removed) ! Once the old master comes up, data will be written to it 29 Split Brain
  • 30. Copyright 2015 Severalnines AB ! STONITH is the solution - kill it with fire ! Ensure that the old master won’t come back up (think how your automated recovery will behave?) ! Start with dedicated network connection (if available) - use a patchcord. Maybe it’s a network error only? ! Try to use IPMI/iLO/KVM-ish solutions to stop the server ! Try to stop the server using manageable power strip 30 Split Brain - STONITH
  • 31. Copyright 2015 Severalnines AB ! In the cloud - try to stop the instance completely ! You can also try to bond your interfaces for better network availability (although you never know what’s on the other side of the black box) ! For MHA - STONITH process is executed as shutdown_script. For other tools - ensure you have implemented similar behavior ! This is relevant for MySQL replication - Galera doesn’t require such harsh methods 31 Split Brain - STONITH
  • 32. 32 Synchro- nous Load- balancing reads Load- balancing writes WAN Scalable MySQL/ InnoDB compatible DRBD yes no no yes (standby DR site) no yes MySQL replicati on no (async or semi sync) yes no yes only reads yes MySQL Cluster yes yes yes yes yes expect different behavior Galera virtually yes yes yes reads, writes to some extend almost
  • 33. Copyright 2015 Severalnines AB ! More blogs in “Become a MySQL DBA” series: ! http://www.severalnines.com/blog/become-dba-blog- series-monitoring-and-trending ! http://www.severalnines.com/blog/become-mysql- dba-blog-series-backup-restore ! Contact: krzysztof@severalnines.com 33 Thank You!