uc2010 xtra backup-hot-backups-and-more

16
XtraBackup: Hot Backups and More Vadim Tkachenko Morgan Tocker http://percona.com http://MySQLPerformanceBlog.com MySQL CE Apr 2010

Upload: arvids-godjuks

Post on 27-Jan-2015

112 views

Category:

Documents


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Uc2010 xtra backup-hot-backups-and-more

XtraBackup: Hot Backups

and MoreVadim Tkachenko

Morgan Tocker

http://percona.com

http://MySQLPerformanceBlog.com

MySQL CE

Apr 2010

Page 2: Uc2010 xtra backup-hot-backups-and-more

Introduction

• Vadim Tkachenko

– Percona Inc, CTO and Lead of Development

• Morgan Tocker

– Percona Inc, Director of Training

XtraBackup: Hot Backups and More

-2-

Page 3: Uc2010 xtra backup-hot-backups-and-more

Comparing Backup OptionsEngine

s

Warmth Flex

Backup

Flex

Restore

Backup

time

Restore

time

Binlog

coord

Impact

mysqldump InnoDB/X

traDB

HOT ROW MOST MED WORST YES MEDIUM

mysqldump ALL WARM ROW MOST MED WORST YES MEDIUM

Snapshot ALL MOSTLY

HOT

SYSTEM SYSTEM SLOW-

MED

BEST YES HEAVY

XtraBackup InnoDB/X

traDB

HOT TABLE TABLE FAST BEST YES LOW

InnoDB Hot

Backup

InnoDB HOT TABLE TABLE FAST BEST YES LOW

XtraBackup /

InnoDB Hot

Backup

ALL WARM TABLE TABLE FAST BEST YES MEDIUM/

LARGE

MySQLHotC

opy

MyISAM WARM TABLE TABLE FAST BEST YES LOW

Cold Backup ALL COLD SYSTEM SYSTEM BEST BEST YES VERY

HEAVY

XtraBackup: Hot Backups and More

-3-

Page 4: Uc2010 xtra backup-hot-backups-and-more

What is talk about

• XtraBackup

• Internals

• Basic and advance usage

XtraBackup: Hot Backups and More

-4-

Page 5: Uc2010 xtra backup-hot-backups-and-more

Idea

• Copy XtraDB / InnoDB tables without stopping server ( and

locking tables)

• Challenge: Tables are being changed in background

• Alternative solutions

– ZFS snapshot ( Solaris / FreeBSD)

– LVM, good if performance is not concern

• 160 ios -> 25 ios

• ~20% space reservation

– InnoDB Hot Backup / Oracle Online Backup

• Commercial, per-server, last release 2006 ?

• Can be expensive for X,000 servers

XtraBackup: Hot Backups and More

-5-

Page 6: Uc2010 xtra backup-hot-backups-and-more

Solution

• Copy tables and log changes

– InnoDB transactional redo logs are doing the same

– XtraBackup is mini instance of XtraDB / InnoDB

– Idea taken from InnoDB Hot Backup

XtraBackup: Hot Backups and More

-6-

Page 7: Uc2010 xtra backup-hot-backups-and-more

Basic design

• Copy tables, log changes into xtrabackup_logfile

• Prepare – apply log to copied tables

XtraBackup: Hot Backups and More

-7-

copy

xtrabackup_logfile

tables

New location

changes

Page 8: Uc2010 xtra backup-hot-backups-and-more

XtraBackup

• Non-blocking online backup of XtraDB / InnoDB /

InnoDB–plugin tables

• Blocking for MyISAM

XtraBackup: Hot Backups and More

-8-

Page 9: Uc2010 xtra backup-hot-backups-and-more

Tools

• Binaries

– xtrabackup

• Copy .ibd & xtrabackup_logfile

– tar4ibd

• Script

– innobackupex-1.5.1

• Taken from InnoDB Hot Backup (GPL) , heavily modified

• Copy .frm, myisam, locking etc

XtraBackup: Hot Backups and More

-9-

Page 10: Uc2010 xtra backup-hot-backups-and-more

Basic usage

• innobackupex-1.5.1 /destination/dir

• innobackupex-1.5.1 --apply-log /backup/dir

– --use-memory (1GB defaults)

• innobackupex-1.5.1 --throttle=IOS /destination/dir

XtraBackup: Hot Backups and More

-10-

Page 11: Uc2010 xtra backup-hot-backups-and-more

Stream

• innobackupex-1.5.1 --stream=tar ./ > backup.tar

• Tar compatible stream ( -i required to extract)

– Tar was replaced by libtar and tar4ibd

• Compress– innobackupex-1.5.1 --stream=tar ./ | gzip - > backup.tar.gz

• Copy to remote host– innobackupex-1.5.1 --stream=tar ./ | ssh vadim@desthost "cat - >

/data/vol1/mysqluc/backup.tar“

• The same but with throttling– innobackupex --stream=tar | pv -q -L10m | ssh vadim@desthost "tar xfi -"

XtraBackup: Hot Backups and More

-11-

Page 12: Uc2010 xtra backup-hot-backups-and-more

Slave

• To setup slave from master

– No specific actions needed• File xtrabackup_binlog_infomysql-bin.000020 70206554

• To backup from slave– innobackupex-1.5.1 --slave-info /destination/dir

• LOCK caveats

– FLUSH TABLES WITH READ LOCK to get master/slave

info and to copy MYISAM tables

– 100GB of MyISAM tables will cause a problem

XtraBackup: Hot Backups and More

-12-

Page 13: Uc2010 xtra backup-hot-backups-and-more

Incremental/Differential

• We are able to copy only changes from last backup– xtrabackup --backup --target-dir=/data/backups/incremental --incremental-

basedir=/data/backups/2010-04-11_17-55-54

• From output:– … xtrabackup: The latest check point (for incremental): '2438774348‘ …

• xtrabackup --prepare --target-dir=/data/vadim/mysqluc/2010-04-11_20-45-42 --incremental-dir=/data/vadim/mysqluc/incremental

XtraBackup: Hot Backups and More

-13-

Copy only

changes since

LSN

xtrabackup_logfile

tables

New location

changes

Page 14: Uc2010 xtra backup-hot-backups-and-more

Export/import

• Export only table to another server

– xtrabackup --table=tpcc.order_line --backup --target-

dir=/data/vadim/mysqluc/order_line/

• Prepare

– xtrabackup --prepare --export --target-

dir=/data/vadim/mysqluc/order_line/

• Copy to remote host (it has to be XtraDB)

– alter table order_line discard tablespace;

– set global innodb_expand_import=1;

– alter table order_line import tablespace;

XtraBackup: Hot Backups and More

-14-

Page 15: Uc2010 xtra backup-hot-backups-and-more

Statistics

• Show details on tablespaces / indexes

table: tpcc/order_line, index: PRIMARY, space id: 25, root page: 3, zip size: 0

estimated statistics in dictionary:

key vals: 32471816, leaf pages: 264267, size pages: 302592

real statistics:

level 2 pages: pages=1, data=8406 bytes, data/pages=51%

level 1 pages: pages=467, data=4756806 bytes, data/pages=62%

leaf pages: recs=35116662, pages=264267, data=2410713870 bytes, data/pages=55%

XtraBackup: Hot Backups and More

-15-

Page 16: Uc2010 xtra backup-hot-backups-and-more

Thank you!

• Questions?

[email protected]

[email protected]

XtraBackup: Hot Backups and More

-16-