mysql backup solutions - percona · shared with mysql enterprise backup non-blocking support for...

Post on 06-Aug-2020

17 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

MySQL Backup solutionsLiz van Dijk - @lizztheblizz

Zarafa Summer Camp - June 2012

Percona

MySQL/LAMP Consulting● MySQL Support● (co-)Developers of

○ Percona Server (XtraDB)○ Percona XtraBackup○ Percona Toolkit (Maatkit, Aspersa)○ Percona XtraDB Cluster

http://www.percona.comhttp://www.mysqlperformanceblog.com

Topics

● Why MySQL Backup is hard to get right● What's available on the market?● Percona's Solution: XtraBackup● Demo

MySQL Backup Challenges

● MySQL is multi-engine○ Different storage engines call for different strategies

■ Are we using filecopy or dumps?■ MyISAM tables handle filecopy quite well■ InnoDB files cannot simply be copied elsewhere

● MySQL can be quite busy○ Do we need to shut it down?○ If not, how much load is generated?○ How quickly can we restore?

● MySQL is more than the sum of its datafiles○ How about binary logging, replication?○ Does the tool impact MySQL in other ways?

Available backup solutions (InnoDB)

InnoDB Impact Warmth Backup Time

Restore Time

Cold Backup very high cold very fast fast

mysqldump medium hot medium slow

snapshotting high/medium hot/warm fast fast

MySQL EB (Enterprise Backup)

low hot fast fast

XtraBackup low hot fast fast

Available backup solutions (mixed)

InnoDB/MyISAM Impact Warmth Backup

TimeRestore

TimeCold Backup very high cold very fast fast

mysqldump high warm medium slow

snapshotting high/medium hot/warm fast fast

MySQL EB (Enterprise Backup)

low/medium warm fast fast

XtraBackup low/medium warm fast fast

XtraBackup Features

● Shared with MySQL Enterprise Backup○ Non-blocking○ Support for MyISAM○ Compression○ Partial Backups○ Throttling○ Incremental Backups

● Unique to XtraBackup○ Exporting/Importing individual tables○ Streaming (including incremental streaming since 2.0!)○ Parallel copying (with use of innodb_file_per_table)

http://www.percona.com/doc/percona-xtrabackup/intro.html

XtraBackup Inner Workings

XtraBackup/innobackupex Operation

Performing and restoring a mixed full backup:

Backing up (1):1. Copy datafiles while recording transaction log changes2. FLUSH TABLES WITH READ LOCK;3. Get binlog position�4. Copy all .MYD, .MYI, .TRG, .TRN, ... files5. Stop recording transaction log changes6. UNLOCK TABLES;

Preparing/Restoring:7. Prepare backup by applying recorded tlog changes (2)8. Restoring files to original location (3)

Getting down to business...

innobackupex vs. xtrabackup? xtrabackup - Compiled C application, focuses on InnoDB only innobackupex - Perl script, automates surrounding tasks

3 separate "manual" steps are required: (1) - Backing up (2) - Preparing InnoDB files for recovery (3) - Restoring the files

All of these are easily scriptable!

Some recipes

Simple full backup and restore:(1) # innobackupex /path/to/your/backups

(2) # innobackupex --apply-log \ /path/to/your/backups/2012-06-21_13-45-00/

(3) # innobackupex --copy-back \ /path/to/your/backups/2012-06-21_13-45-00/ # chown -R mysql:mysql /var/lib/mysql

Options

● Specified as --variable-name=value● innobackupex/xtrabackup will read options from your config

○ [client] or [mysql] for credentials

○ [mysqld] for location of datadir, InnoDB startup options

○ Lastly, [xtrabackup] to override any of the previous and specify xtrabackup-specific options*

* percona.com/doc/percona-xtrabackup/xtrabackup_bin/xbk_option_reference.html* percona.com/doc/percona-xtrabackup/innobackupex/innobackupex_option_reference.html

Some recipes

Incremental backup:● Repeat (1) to create a full backup at location $fullbackup● # innobackupex --incremental $incbackup \ --incremental-

basedir=$fullbackup● # innobackupex --apply-log --redo-only \ $fullbackup

■ Preparing the base backup FIRST● # innobackupex --apply-log --redo-only \ $fullbackup --incremental-

basedir=$incbackup■ Applying each incremental backup to the base

● # innobackupex --apply-log $fullbackup■ Finish preparing the now completed base backup

Some recipes

Streaming:# innobackupex --stream=tar ./ | ssh user@desthost \ "cat - > /data/backups/backup.tar"Note: Extract with tar -i!

Filtering tablespaces: --tables, --databases, --tables-fileThrottling:

● Limit to 100 read/writes IOs: --throttle=100● In streaming backup, use pv to limit to 10MB/s

○ # innobackupex --stream=tar ./ | pv -q -L10m | \ ssh user@desthost "cat - > \ /data/backups/backup.tar"

Parallel copying of tablespaces: --parallel 2 #threads

A note about versions

● xtrabackup 1.6● xtrabackup 2.0 (GA since 4 April 2012)

○ Backs up galera cluster information○ Supports parallel compression○ Streaming incremental backups○ Backs up LRU dumpfile

Note: When using the xtrabackup binary directly, make sure to use the correct binary for your MySQL version!

Short demo

Percona Live New York MySQL ConferenceNYC, NY - October 1 & 2 2012

top related