MySQL Replication. openark.org

Similar documents
High Availability Solutions for the MariaDB and MySQL Database

Architectures Haute-Dispo Joffrey MICHAÏE Consultant MySQL

MySQL High Availability Solutions. Lenz Grimmer OpenSQL Camp St. Augustin Germany

High Availability, Disaster Recovery and Extreme Read Scaling using Binlog Servers. Jean-François Gagné jeanfrancois DOT gagne AT booking.

Comparing MySQL and Postgres 9.0 Replication

High Availability Solutions for MySQL. Lenz Grimmer DrupalCon 2008, Szeged, Hungary

MySQL backups: strategy, tools, recovery scenarios. Akshay Suryawanshi Roman Vynar

Zero Downtime Deployments with Database Migrations. Bob Feldbauer

High Availability and Scalability for Online Applications with MySQL

Flash Databases: High Performance and High Availability

Tushar Joshi Turtle Networks Ltd

Percona Server features for OpenStack and Trove Ops

Top 10 Reasons why MySQL Experts Switch to SchoonerSQL - Solving the common problems users face with MySQL

Boost SQL Server Performance Buffer Pool Extensions & Delayed Durability

MySQL Enterprise Backup

The Future of PostgreSQL High Availability Robert Hodges - Continuent, Inc. Simon Riggs - 2ndQuadrant

Eloquence Training What s new in Eloquence B.08.00

Online Schema Changes for Maximizing Uptime. David Turner - Dropbox Ben Black - Tango

How To Scale Myroster With Flash Memory From Hgst On A Flash Flash Flash Memory On A Slave Server

Preparing for the Big Oops! Disaster Recovery Sites for MySQL. Robert Hodges, CEO, Continuent MySQL Conference 2011

Dave Stokes MySQL Community Manager

5 Percona Toolkit tools that could save your day. Stéphane Combaudon FOSDEM February 3rd, 2013

MySQL High-Availability and Scale-Out architectures

Adding Indirection Enhances Functionality

This article Includes:


PostgreSQL Backup Strategies

Websense Support Webinar: Questions and Answers

Synchronous multi-master clusters with MySQL: an introduction to Galera

MySQL Backup and Recovery: Tools and Techniques. Presented by: René Senior Operational DBA

DBA Tutorial Kai Voigt Senior MySQL Instructor Sun Microsystems Santa Clara, April 12, 2010

Performance Monitoring AlwaysOn Availability Groups. Anthony E. Nocentino

MySQL. Leveraging. Features for Availability & Scalability ABSTRACT: By Srinivasa Krishna Mamillapalli

High Availability Using MySQL in the Cloud:

How to choose High Availability solutions for MySQL MySQL UC 2010 Yves Trudeau Read by Peter Zaitsev. Percona Inc MySQLPerformanceBlog.

XDB. Shared MySQL hosting at Facebook scale. Evan Elias Percona Live MySQL Conference, April 2015

Redundancy Options. Presented By: Chris Williams

Portable Scale-Out Benchmarks for MySQL. MySQL User Conference 2008 Robert Hodges CTO Continuent, Inc.

Database Replication with MySQL and PostgreSQL

MySQL Cluster New Features. Johan Andersson MySQL Cluster Consulting johan.andersson@sun.com

MySQL Reference Architectures for Massively Scalable Web Infrastructure

Availability Digest. MySQL Clusters Go Active/Active. December 2006

MySQL Backup IEDR

General DBA Best Practices

SQL Server AlwaysOn (HADRON)

Guideline on Vulnerability and Patch Management

MySQL always-up with Galera Cluster

StruxureWare Power Monitoring Database Upgrade FAQ

MySQL and the Open Source Sphere. openark.org

XtraBackup. Vadim Tkachenko CTO, Co-Founder, Percona Inc Percona Live SF Feb 2011

High Availability and Disaster Recovery for Exchange Servers Through a Mailbox Replication Approach

MySQL synchronous replication in practice with Galera

XtraBackup: Hot Backups and More

How to evaluate which MySQL High Availability solution best suits you

MySQL Enterprise Edition Most secure, scalable MySQL Database, Online Backup, Development/Monitoring Tools, backed by Oracle Premier Lifetime Support

Optimizing Performance. Training Division New Delhi

vsphere Replication for Disaster Recovery to Cloud

Antelope Enterprise. Electronic Documents Management System and Workflow Engine

Scaling Graphite Installations

Backups and Maintenance

vsphere Replication for Disaster Recovery to Cloud

Module 14: Scalability and High Availability

Microsoft SharePoint 2010 on VMware Availability and Recovery Options. Microsoft SharePoint 2010 on VMware Availability and Recovery Options

Not Your Grandpa s Replication

Microsoft SQL Server Guide. Best Practices and Backup Procedures

SQL Server 2014 New Features/In- Memory Store. Juergen Thomas Microsoft Corporation

SafeCom G2 Enterprise Disaster Recovery Manual

VirtualCenter Database Maintenance VirtualCenter 2.0.x and Microsoft SQL Server

Comparison of ITTIA DB and SQLite

SQL Server Training Course Content

Software Performance, Scalability, and Availability Specifications V 3.0

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2007 Lecture 5 - DBMS Architecture

MySQL Enterprise Backup User's Guide (Version 3.5.4)

MIGRATING TO AVALANCHE 5.0 WITH MS SQL SERVER

Managing MySQL Scale Through Consolidation

Contents. SnapComms Data Protection Recommendations

Andrew Moore Amsterdam 2015

Using MS-SQL Server with Visual DataFlex March, 2009

SQL Server Database Administrator s Guide

Getting Started with Attunity CloudBeam for Azure SQL Data Warehouse BYOL

Data Management in the Cloud

Parallel Replication for MySQL in 5 Minutes or Less

Tips and Tricks for Using Oracle TimesTen In-Memory Database in the Application Tier

DB2 9 for LUW Advanced Database Recovery CL492; 4 days, Instructor-led

<Insert Picture Here> MySQL Update

Testing and Verifying your MySQL Backup Strategy

Real-time Data Replication

How To Backup and Restore in Infobright

Solving Large-Scale Database Administration with Tungsten

Enterprise Advanced Configuration

Basics Of Replication: SQL Server 2000

SCALABILITY AND AVAILABILITY

Active/Active DB2 Clusters for HA and Scalability

Practical Cassandra. Vitalii

MySQL Storage Engines

Cloud DBMS: An Overview. Shan-Hung Wu, NetDB CS, NTHU Spring, 2015

Transcription:

MySQL Replication Solutions & Enhancements Shlomi Noach June 2011

What is MySQL Replication? Replication is a mechanism built into MySQL. It allows a MySQL server (Master) to log changes made to schema & data. A second server (Slave) can pick up those logs and apply them. When both servers are initially identical, it follows that a replicating slave reflects the schema & data on the master. Essentially, it becomes a duplicate of the master. MySQL Replication: solutions & enhancements 2

Replication workflow Master Slave connects to master, Reads binary log Slave Master writes events to binary log Binary logs Relay logs Slave writes local copy of master's binary log as relay log MySQL Replication: solutions & enhancements 3

Replication properties Replication is asynchronous. The master does not wait upon the slave. With MySQL 5.5 semi-sync replication, this changes. Replication is only consistent only to some point. While binary logs manage random, time & session variables info, it is possible to break consistency using nondeterministic functions. MySQL Replication: solutions & enhancements 4

Replication properties A master can have any number of slaves. A slave can only be connected to one master. The slave follows up on its master using binary log coordinates: Binary log file Position within binary log file The slave uses two threads: One for reading master binary log and writing as relay log One for applying relay log entries It follows that slave SQL execution is single threaded. We thus call replication to be single threaded. MySQL Replication: solutions & enhancements 5

Replication solutions Replication solves, or helps in solving a wide range of problems: Scale out Backups High Availability Version upgrades Schema upgrades Reporting More... We discuss these, in no particular order MySQL Replication: solutions & enhancements 6

Backups Acquiring a MySQL server backup involves some interruption to normal workload Some backup solutions require locks to be taken, if only for an instant moment Increased I/O is usually noticed during backup time Solution: use replication, backup from slave The master does not care if the slave is down, or lagging Connections to the master are completely unaware of the slave being backed up MySQL Replication: solutions & enhancements 7

Backups Can we be absolutely certain that slave data is 100% compatible with master data? What can make for data changes (data drift)? We discuss shortly MySQL Replication: solutions & enhancements 8

Version upgrades Upgrading a MySQL version can always have hidden risks. There are many steps to make for a safer version upgrade Upgrading a slave's version is key part to the safe approach. The master is unaware of the upgrade; the application is unaffected By thoroughly testing behavior on slave, we lower the chances of getting affected by version changes or newly introduced bugs. See: http://www.mysqlperformanceblog.com/2010/01/05/upgrading-mysql/ Once the slave is upgraded and tested, we switch over to the slave. We call this Slave promotion. MySQL Replication: solutions & enhancements 9

Master-master replication Master [active] Master [passive] Binary logs Binary logs Relay logs Relay logs Each server replicates the other using standard replication. The two servers are unaware of the cyclic architecture MySQL Replication: solutions & enhancements 10

High Availability A master-slave setup makes for a High Availability solution A master-master setup even more so. Since the slave follows up on the master, it makes for a hot standby replacement should the master go down. This is good in theory. Reality has its say, though... MySQL Replication: solutions & enhancements 11

Replication integrity issues Replication is asynchronous The slave could be lagging far behind the master Before promoting it to master (and before directing connections), we must verify it has completed executing all entries in relay log file. MySQL 5.5 introduces semi-synchronous replication A commit does not return to the user until the master verifies the entries have been written to a slave's relay log file This makes for less possible lag time It may also make for master slowdown MySQL Replication: solutions & enhancements 12

Replication integrity issues Replication is asynchronous in other respects as well: By default, binary logs are not flushed to disk per entry. A crashed server may not have flushed to file all entries. Use sync_binlog=1 for safest (and slower) setup Relay logs and replication info files are not flushed to disk, either. A crashed slave may lose its replication position, or worse, re-apply statements MySQL 5.6 introduces crash safe threads: replication position is written to transaction logs This feature already exists in Google Patches and Percona Server MySQL Replication: solutions & enhancements 13

Availability Zones The asynchronous nature of replication makes it particularly useful for setting up availability zones. A NY master can be replicated by a SF slave. In case of NY zone disaster (e.g. blackout), the SF slave can be promoted to master and pick from there. While VPN easily solves the issue of securely transferring data coast-to-coast, replication also natively supports SSL. MySQL Replication: solutions & enhancements 14

Replication delay What happens when a user accidentally issues a DROP DATABASE production_db? Yes. It actually happens. Replication picks up on that command and executes it. The slaves become useless as well. We can explicitly make replication lag behind the master by, say, 1 hour. This gives up time to detect the problem and fail over to the slave. Use Maatkit's mk-slave-delay MySQL 5.6 introduces time delayed replication MySQL Replication: solutions & enhancements 15

Schema upgrades On occasion, refactoring is required. An ALTER TABLE statement completely locks down the table. On very large tables this could mean hours or days. of lock down. MySQL allows replication between tables of different schemata, as long as statements are equally valid on both. In particular, new columns or indexes are typically safe. This depends on replication type (SBR vs. RBR) and constraints. MySQL Replication: solutions & enhancements 16

Schema upgrades This allows us to alter a table on the slave, without breaking down replication. Replication will have to wait for the duration of refactoring. It will take additional time to catch up with lost hours. But during that time, master is unaffected Once replication catches up, we can promote the slave. This is particularly useful in a master-master setup. MySQL Replication: solutions & enhancements 17

Schema upgrades It does require bringing the slave down. There are tools which mimic the ALTER statement online, without interruption to normal work (although with overhead): openark-kit's oak-online-alter-table Facebook's osc (Online Schema Change), derived from oak-online-alter-table Maatkit's mk-online-schema-change, based on both. MySQL Replication: solutions & enhancements 18

Scale out Replication is by far the most common scale out solution for MySQL. Google, Facebook & Wikipedia are most well known for their large install base Google and Facebook manage tens of thousands of servers, according to estimation Both use a combination of sharding and replication. Replication is used both as high availability solution, but mostly for purposes of load balancing. MySQL Replication: solutions & enhancements 19

Scale out Assuming slaves are up-to-date, a read query can be executed against any slave. Replication makes for read scale out. Writes, however, must continue to execute on master. MySQL Replication: solutions & enhancements 20

Replication data drift There are several reasons why a slave would contain data not 100% compatible with master: Statements which are nondeterministic in nature I/O failures Queries accidentally issued against the slave Master/slave failures, with non synced logs Facebook recently estimated a 0.00056% data drift between master and slaves. MySQL Replication: solutions & enhancements 21

Replication data drift Data drift can be detected, but with large data this is a lengthy process. Use Maatkit's mk-table-sync to detect data changes. MySQL 5.6 introduces replication checksums This already exists in Google Patches v3. MySQL Replication: solutions & enhancements 22

Thank you! I blog at http:// Find open source projects on http://code./forge/ Questions? MySQL Replication: solutions & enhancements 23