Creating a Best-in-Class Backup and Recovery System for Your MySQL Environment. Akshay Suryawanshi DBA Team Manager,

Similar documents
Backup & Restore. Maximiliano Bubenick Sr Remote DBA

Percona Xtrabackup: Hot Backup Solution for MySQL

MySQL Backup Best Practices and Case Study:.IE Continuous Restore Process

Taking hot backups with XtraBackup. Principal Software Engineer April 2012

Percona XtraBackup: install, usage, tricks. Do I/you need a backup?

Testing and Verifying your MySQL Backup Strategy

MySQL Backup solutions. Liz van Dijk Zarafa Summer Camp - June 2012

1 / 42. Online Backups with. Percona Live Amsterdam - October 2016

1Z Oracle. MySQL 5 Database Administrator Certified Professional Part I

Oracle 1Z MySQL 5.6 Database Administrator. Download Full Version :

Backup and Recovery Strategy

XtraBackup FOSDEM Kenny Gryp. Principal Percona

Percona XtraDB Cluster MySQL Scaling and High Availability with PXC 5.7 Tibor Korocz

Mysqldump Schema Only No Lock

MySQL usage of web applications from 1 user to 100 million. Peter Boros RAMP conference 2013

Switching to Innodb from MyISAM. Matt Yonkovit Percona

mysql Sun Certified MySQL 5.0 Database(R) Administrator Part 1

Deploying MySQL in Production Daniel Kowalewski Senior Technical Operations Engineer, Percona

Deploying MySQL in Production

Effective Testing for Live Applications. March, 29, 2018 Sveta Smirnova

Mysql Cluster Global Schema Lock

MyRocks deployment at Facebook and Roadmaps. Yoshinori Matsunobu Production Engineer / MySQL Tech Lead, Facebook Feb/2018, #FOSDEM #mysqldevroom

Database Backup and Recovery Best Practices. Manjot Singh, Data & Infrastrustructure Architect

Amazon AWS and RDS, moving towards it. Dimitri Vanoverbeke Solution Percona

Tips from the Trenches Preventing downtime for the over extended DBA. Andrew Moore Senior Remote DBA Percona Managed Services

Xtrabackup in a nutshell

'information_schema' When Using Lock Tables

Oracle Exam 1z0-883 MySQL 5.6 Database Administrator Version: 8.0 [ Total Questions: 100 ]

Continuous MySQL Restores Divij Rajkumar

Lessons from database failures

Backing up or Exporting Databases Using mysqldump

Migrating to Aurora MySQL and Monitoring with PMM. Percona Technical Webinars August 1, 2018

MySQL Replication Update

How to Backup at Petabyte Scale When Every Transaction Counts

MongoDB Backup & Recovery Field Guide

2) One of the most common question clients asks is HOW the Replication works?

Percona XtraDB Cluster

Aurora, RDS, or On-Prem, Which is right for you

Basics: Backup, Recovery, and Provisioning with a Continuent Tungsten Cluster

MySQL for Database Administrators Ed 3.1

IT Certification Exams Provider! Weofferfreeupdateserviceforoneyear! h ps://

CO MySQL for Database Administrators

Replication features of 2011

ITS. MySQL for Database Administrators (40 Hours) (Exam code 1z0-883) (OCP My SQL DBA)

Operational DBA In a Nutshell - HandsOn Reference Guide

Understanding Percona XtraDB Cluster 5.7 Operation and Key Algorithms. Krunal Bauskar PXC Product Lead (Percona Inc.)

mysql Certified MySQL 5.0 DBA Part I

Sun Microsystems. MySQL Backup and Security Best practices on how to run MySQL on Linux in a secure way. Lenz Grimmer

Scale out Read Only Workload by sharing data files of InnoDB. Zhai weixiang Alibaba Cloud

Why we re excited about MySQL 8

Which technology to choose in AWS?

MySQL Database Administrator Training NIIT, Gurgaon India 31 August-10 September 2015

Jailbreaking MySQL Replication Featuring Tungsten Replicator. Robert Hodges, CEO, Continuent

Optimizing BOINC project databases

Holland Documentation

Optimizing MySQL performance with ZFS. Neelakanth Nadgir Allan Packer Sun Microsystems

Upgrading MySQL Best Practices. Apr 11-14, 2011 MySQL Conference and Expo Santa Clara,CA by Peter Zaitsev, Percona Inc

ZFS and MySQL on Linux, the Sweet Spots

Efficiently Backing up Terabytes of Data with pgbackrest. David Steele

Migrating To MySQL The Live Database Upgrade Guide

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8

Preventing and Resolving MySQL Downtime. Jervin Real, Michael Coburn Percona

MySQL Security, Privileges & User Management Kenny Gryp Percona Live Washington DC /

How To Rock with MyRocks. Vadim Tkachenko CTO, Percona Webinar, Jan

Diagnosing Failures in MySQL Replication

Percona Software & Services Update

MySQL Replication. Rick Golba and Stephane Combaudon April 15, 2015

Improvements in MySQL 5.5 and 5.6. Peter Zaitsev Percona Live NYC May 26,2011

MySQL Point-in-Time Recovery like a Rockstar

Introduction To MySQL Replication. Kenny Gryp Percona Live Washington DC /

How to get MySQL to fail

MongoDB Backup and Recovery Field Guide. Tim Vaillancourt Sr Technical Operations Architect, Percona

Resolving and Preventing MySQL Downtime

<Insert Picture Here> New MySQL Enterprise Backup 4.1: Better Very Large Database Backup & Recovery and More!

MySQL for Database Administrators Ed 4

Top 15 MySQL parameters for beginners

Kenny Gryp. Ramesh Sivaraman. MySQL Practice Manager. QA Engineer 2 / 60

MariaDB 10.3 vs MySQL 8.0. Tyler Duzan, Product Manager Percona

Percona XtraDB Cluster 5.7 Enhancements Performance, Security, and More

Load Data Fast! BILL KARWIN PERCONA LIVE OPEN SOURCE DATABASE CONFERENCE 2017

Choosing a MySQL HA Solution Today. Choosing the best solution among a myriad of options

Load Testing Tools. for Troubleshooting MySQL Concurrency Issues. May, 23, 2018 Sveta Smirnova

Setting up Multi-Source Replication in MariaDB 10.0

High availability with MariaDB TX: The definitive guide

Deep Dive on MySQL Databases on Amazon RDS. Chayan Biswas Sr. Product Manager Amazon RDS

Backup Strategies with MySQL Enterprise Backup

Delegates must have a working knowledge of MariaDB or MySQL Database Administration.

MySQL 8.0: Atomic DDLs Implementation and Impact

Mysql Workbench Doesn't Show

Migrating and living on RDS/Aurora. life after Datacenters

MySQL for Database Administrators Volume I Student Guide

Why Choose Percona Server For MySQL? Tyler Duzan

MyRocks in MariaDB. Sergei Petrunia MariaDB Tampere Meetup June 2018

Troubleshooting Best Practices

Design Patterns for Large- Scale Data Management. Robert Hodges OSCON 2013

The Exciting MySQL 5.7 Replication Enhancements

Choosing a MySQL HA Solution Today

Common MySQL Scalability Mistakes AUTHOR

MySQL Utilities, part 1. Sheeri Cabral. Senior DB Admin/Architect,

Dave Stokes MySQL Community Manager

Transcription:

Creating a Best-in-Class Backup and Recovery System for Your MySQL Environment Akshay Suryawanshi DBA Team Manager, 2015-07-15

Agenda Why backups? Backup Types Binary or Raw Backups Logical Backups Binlog mirroring Backups Locks Examples Tips

Why Backups?

Why Backups? At some point anything can and will fail Hardware issues Application bugs Operational mistakes Attacks

Why Backups? Depending on the fail you will need to: Restore a complete server Restore a complete DB A complete table A few rows

Backup types

Different Backup types Logical Plain text files Can be Remote Slower on large datasets Sometimes the only option

Different Backup types Binary or Raw Filesystem level access Local Faster on large datasets Storage engine dependent Can be useless on filesystem corruption

Different Backup types Binlog For point in time recovery PITR even for a single schema

Binary Backups

Binary Backups Tools Percona XtraBackup mylvmsnapshot MySQL Enterprise Backup

Binary Backups Percona XtraBackup Fast, limited by IO Almost no locks (--rsync) Compress on the fly (--compress) Best option for full server restore or setting up new slaves

Logical Backups

Logical Backups Tools mysqldump Mydumper

Logical Backups mysqldump General use Simple to use By default lock tables One big output file Can be piped to mysql client

Logical Backups mysqldump --opt = --add-drop-table --add-locks --create-options --quick --extended-insert --lock-tables --set-charset disable-keys (default) --single-transaction (innodb) --master-data (FTWRL) for binlog coordinates --dump-slave --innodb-optimize-keys (PS only feature) --triggers (ON) --routines (OFF)

Logical Backups Mydumper Faster logical backups as is multithread Almost no locking with innodb tables Compress on the fly Doesn't handle Views, Triggers and Procedures Separate files per table, one row per line

Logical Backups Mydumper --threads --outputdir --rows, --chunk-filesize --compress --less-locking --kill-long-queries --use-savepoints

Logical Backups Without chunks 60 50 Time 40 30 20 Table D Table C Table B Table A 10 0 Thread 1 Thread 2 Thread 3 Thread 4

Logical Backups With chunks (--rows) 25 20 Time 15 10 Table D Table C Table B Table A 5 0 Thread 1 Thread 2 Thread 3 Thread 4

Logical Backups Less-locking, without it Mydumper needs to keep FTWRL until all non-innodb tables are dumped 14 12 10 Time 8 6 Innodb non-innodb 4 2 0 Thread 1 Thread 2 Thread 3 Thread 4

Logical Backups Mydumper output files metadata Started dump at: 2014-04-18 22:01:30 SHOW MASTER STATUS: Log: mysql-bin.017436 Pos: 890402821 SHOW SLAVE STATUS: Host: 192.168.56.101 Log: mysql-bin.017057 Pos: 968001054 Finished dump at: 2014-04-19 03:10:05

Logical Backups Mydumper output files database.table.sql /*!40101 SET NAMES binary*/; /*!40014 SET FOREIGN_KEY_CHECKS=0*/; /*!40103 SET TIME_ZONE='+00:00' */; INSERT INTO `t1` VALUES (1,"abc"), (2,"def"), (4,"abc"), (5,"abc"), (6,"abc"), (7,"abc"), (8,"abc");

Binlog Mirroring

Binlog Mirroring Mysqlbinlog (5.6) Works with 5.1 and 5.5 master also Mirror binlogs on the master on a second server mysqlbinlog --read-from-remote-server --raw --stopnever

Backup Locks

Backup Locks LOCK TABLE... READ LOCAL Other sessions can read the table but can't write LOCAL allows non conflicting INSERTs to MyISAM FLUSH TABLES WITH READ LOCK Global read lock Big issue on busy servers and long running selects Requires tables be reopened which can be another bottleneck on busy servers metadata locking since 5.5 No DDLs to tables used in a transaction

Backup Locks mysqldump --lock-tables (default) LOCK TABLES READ LOCAL --lock-all-tables master-data and dump-slave FLUSH TABLES WITH READ LOCK --single-transaction (innodb only) START TRANSACTION /*!40100 WITH CONSISTENT SNAPSHOT */ --skip-lock-tables No locks

Backup Locks Mydumper Always needs FTWRL to coordinate threads but for a small time if all tables are innodb --less-locking LOCK TABLES READ LOCAL for non-innodb CONSISTENT SNAPSHOT for innodb --use-savepoints Reduce metadata locking issues --no-locks Not ensure a consistent backup

Backup Locks Percona XtraBackup FTWRL at the end to copy non transactional files and get binlog coordinates. --rsync Use rsync twice instead of cp each file, FTWRL for only the second rsync, didn't work with stream --no-locks Not ensure a consistent backup

Backup Locks Percona Server 5.6 new locks for backups LOCK TABLES FOR BACKUP Block updates to non-transactional tables Block DDL to all tables LOCK BINLOG FOR BACKUP blocks all updates to binary log UNLOCK BINLOG

Backup Locks Percona Server 5.6 new locks for backups Percona XtraBackup 2.2 Mysqldump --lock-for-backup single-transaction Mydumper 0.6.2

Examples

Using Percona XtraBackup Simple Backup: innobackupex --rsync --slave-info /backups/ Prepare innobackupex --apply-log --use-memory=2g --defaultsfile=/etc/my.cnf /backups/latest/ Restore innobackupex --copy-back /backups/latest/

Using Percona XtraBackup Stream Backup: innobackupex stream=tar./ gzip - > xb.tar Unpack tar xvif xb.tar.gz Can be piped to remote host: On destination: cd /destination/dir nc -l 873 tar xvif - On source: innobackupex stream=tar./ gzip - nc <dest_ip> 873

Using Percona XtraBackup Stream Backup: innobackupex --stream=xbstream --compress --parallel=4./ > xb.xbs Unpack xbstream -x < xb.xbs -C /destination/dir Can be piped to remote host: On destination: nc -l 873 xbstream -x -C /destination/dir On source: innobackupex --stream=xbstream./ nc <dest_ip> 873

Using Mydumper Full Backup: mydumper -h x.x.x.x - less-locking -compress -o /backup/dir Full Restore: myloader -h x.x.x.x -d /backup/dir -o

Using Mydumper Partial Restore: cd /backup/dir mkdir restore cp -l db.*./restore/ cp -l metadata./restore/ myloader -h x.x.x.x -d /backup/dir/restore/ -o

Using mysqlbinlog Copy binlogs: mysqlbinlog --stop-never --raw --read-from-remote-server --host=127.0.0.1 mysql-bin.000001

Tips

Tips Use the three types of backups Binary for full restores, new slaves Logical for partial restores Binlog for point in time recovery Store on more than one server and off-site Test your backups!!!! Document restore procedures, script them and test them!!!

Tips (cont) If taking from a slave run pt-table-checksum Configuration files, scripts Do you need to backup everything all days? Hardlinking backups can save lot of disk space in some circumstances Monitor your Backups

Percona Backup Service

Percona Backup Service Managed MySQL backup and recovery combining our best practices and software tools with your backup servers Percona ensures your backups run smoothly and reliably Backup data sets are always available Percona manages production recovery Lower TCO than managing in-house Any combination of MySQL server and backup locations Flexible backup configurations per customer More information at

Thank you and Q&A akshay.suryawanshi@percona.com We're Hiring! /about-us/careers/