backing up the mysql database

37
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 1

Upload: sanjay-manwani

Post on 09-May-2015

896 views

Category:

Business


0 download

DESCRIPTION

Presentation at MySQL Connect 2013

TRANSCRIPT

Page 1: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 1

Page 2: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 2

Backing Up the MySQL Database

Sanjay Manwani

MySQL India Director

Page 3: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 3

Page 4: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 4

Program Agenda

Understanding Backup

MySQL Enterprise Backup (MEB)

Backup Strategies

What’s New in MEB 3.9

Page 5: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 5

Understanding Backup

Page 6: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 6

Why Backup is important

Audits

Disasters

Is HA setup a backup ?

Is LVM a backup ?

Page 7: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 7

Types of Backup and Tools for these types

Logical

– Mysqldump

– Mysqldbexport/import

Physical

– MySQL Enterprise Backup (MEB)

Page 8: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 8

Logical Backup

Advantages

– Easy of use - simple commands allow you to easily backup and restore

– Good for small database or tables – minimum impact on backup and

restore performance

– Flexibility – logical backup allows you to choose what you want to backup

and not backup. Change the scripts to restore partially etc.

– Readability - Good assurance that database files are not corrupt - all the

data is read and it is read using standard SQL queries.

Collection of SQL Queries to recreate the database

Page 9: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 9

Logical Backup

Disadvantages

– Not an online solution - write operations are locked while performing the

backup, thereby blocking use of the database.

– Poor performance for larger databases – backup and especially restore

times are very slow for larger databases.

– Not consistent – database won’t necessarily be restored to a consistent

state.

– No incremental backup – all backups are full backups, can be time

consuming and require more storage.

Collection of SQL Queries to recreate the database

Page 10: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 10

Physical Backup (MEB)

Advantages

– Performance –faster for backups and faster for restore

– Flexible – support for incremental backups, partial backups, backup

compression, point in time recovery and more.

– Archival Backups – suitable archival format for historical purposes

– Scalable – performance is near linear for larger databases.

– Consistent – delivers consistent point in time recovery

Copy of the internal files that constitute the MySQL database

Page 11: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 11

Physical v/s Logical Backup

0

1

2

3

4

5

6

Category 1 Category 2 Category 3 Category 4

Series 1 Series 2 Series 3

Comparison Summary

Page 12: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 12

MySQL Enterprise Backup

Page 13: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 13

MEB Backup

Full Backup

Incremental Backup – File based

and Redo log only

Compressed Backup

Backup to Single File/Image

Backup to tape

Partial Backup

What is methods are available to choose from

Page 14: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 14

MEB – Apply log

InnoDB consists of pages with

information about the LSN

number applicable to the page

Applylog scans the InnoDB redo

log and applies the relavant

changes to the InnoDB page and

upto the correct LSN to be

applied

The intermediate step

Page 15: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 15

MEB – Recovery

Copyback

New! copyback-and-apply-log

Validate

Recovery is what is important

Page 16: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 16

MEB Single image manipulation

validate

– Ensure that the checksums are consistent

list image

– Find the files that this image contains

Extract

– Extract files from the image

image-to-backup-dir

– Extract the full image into a directory

backup-dir-to-image

– Convert a backup directory into a image

Manage the backup archive/image

Page 17: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 17

Some internal performance benchmarks

1.2 TB of Data was generated using TPC-H

Linux 2.6.32-220.2.1.el6.x86_64 OEL6.2/64 32 GB, 8 x 3000 MHz (8), 2X2 TB 2X1TB Disk, 1

Graphs

0 20 40 60 80 100 120

Time (mm:ss)

Avg CPU%

Avg USER%

Avg. SYS%

Avg IOWAIT%

Compressed Image

Compress

Image

Backup

Page 18: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 18

MEB External Interaction

Tape and Backup Solutions

– Oracle secure backup

– Netbackup

Workbench

– Scheduling

– Monitoring

MySQL Enterprise Monitor

– Advisors

MEB integrates with external products

Page 19: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 19

SBT Interface Tape and Backup Solutions

Page 20: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 20

Oracle Secure Backup Tape and Backup Solutions

A general-purpose network

data protection tool that

simplifies and automates

the backup and restore of

files on a file system.

A media management

layer for Recovery

Manager through the SBT

interface.

Integrates with a wide

variety of tertiary devices

Page 21: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 21

Workbench MEB & Workbench

Integrates with

MEB

Allows setup of

automatic backup

schedules

Page 22: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 22

Workbench MEB & Workbench

Allows some

options

Keeps information

about backups

Page 23: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 23

Workbench MEB & Workbench

Helps setup and

validates the

setup

Helps in recovery

Page 24: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 24

MEM – MySQL Enterprise Monitor

Integrates with MEB

Generates events if

the backup is not

taken within specified

amount of time

MEB advisors in MEM

Page 25: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 25

MEM

Allows thresholds to be

set

Advises users to backup

within their thresholds

MEB advisors in MEM

Page 26: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 26

Backup Strategies

Page 27: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 27

Backup Strategies

Always need to be tailored based on environment

– data growth, read v/s write usage, size of DB, user base, distribution

Based on backup policies of your organization

Account for spurts in data growth

Account for schema modification – Before and after

Needs to take into account quiet periods

Needs to take into account your H/W and storage infrastructure

IMPORTANTLY – Based on your restore requirement

.

A comprehensive plan for backup and recovery

Page 28: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 28

Example Backup Strategy A comprehensive plan for backup and recovery

Page 29: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 29

Example Recovery Strategy A comprehensive plan for backup and recovery

Recover log to Full Backup • For past 3 days

Recover Incremental Backup • 3 days to 1 week

Archive Backup • Archive full

backups more than 1 week old to tape.

• Delete backups more than 6 months old

Page 30: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 30

Validate

No backup strategy is complete without validating backup

Validate by MEB command • Every week

Validate by reinstall • Every

month

Reinstall and run regression • Every 2

months

Page 31: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 31

What’s New in MEB 3.9

Page 32: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 32

What’s New in MEB

New! Single Step

– Restore directly.

New! Full Instance

– Config/Settings/…

New! Selective

– Leverages TTS

– Great for large tables

New! Skip Unused Pages

– Reduces space

Continuous progress

– %, Bytes, Status

Monitor disk space

– Optional actions

Warn & Retry, Abort, Remove

Usability, usability usability

Page 33: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 33

Selective backup with TTS

MySQL 5.6 feature : Transportable Table spaces

– Online table portability : Import/Export

Why use with MEB

– Locking time

– Ease of use

What is TTS, why better than normal partial backup

Page 34: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 34

Skip Unused pages

InnoDB files don’t shrink

A small DB has many unused pages

There is a performance penalty

Cleaning up before a backup

Page 35: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 35

References

MySQL Enterprise Backup: Product Information

– www.mysql.com/products/enterprise/backup.html

MySQL Enterprise Backup Team Blog

– https://blogs.oracle.com/mysqlenterprisebackup/

MySQL Enterprise Backup: Documentation

– dev.mysql.com/doc/mysql-enterprise-backup/3.9/en/index.html

How Do I get it

– https://edelivery.oracle.com

Support and patches (My Oracle Support = MOS)

– https://support.oracle.com

Page 36: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 36

Page 37: Backing Up the MySQL Database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 37

Graphic Section Divider