MySQL Enterprise Backup - PDF Documents

MySQL Enterprise Backup - PDF Documents
MySQL Enterprise Backup
Fast, Consistent, Online Backups
A MySQL® White Paper
February, 2011
© 2011, Oracle Corporation and/or its affiliates
Table of Contents
Introduction ................................................................................................................................. 3 Database Backup Terms ............................................................................................................ 3 Requirements Assessment........................................................................................................ 3 Database Backup Methods ........................................................................................................ 3 Determining Your Backup Strategy .......................................................................................... 3 Backup and Recovery Attributes .............................................................................................. 3 MySQL Enterprise Backup......................................................................................................... 4 MySQL Backup Comparisons ................................................................................................... 5 How MySQL Enterprise Backup Works .................................................................................... 5 Examples ..................................................................................................................................... 6 Conclusion .................................................................................................................................. 6 Additional Resources ................................................................................................................. 8 © 2011, Oracle Corporation and/or its affiliates
2
Introduction
Organizations are facing an expanding set of data protection challenges. Not only do
they rely on database applications for every area of their business including sales,
customer service, finance, marketing, manufacturing and human resources, but many of
these applications needs to be available 24x7. At the same time, the volumes of data
that need to be managed are growing exponentially putting added pressure on available
storage and storage costs.
Implementing proper database backup and disaster recovery plans to protect against
accidental loss of data, database corruption, hardware/operating system crashes or any
natural disasters has become one of the most important responsibilities of the Database
Administrator (DBAs). Unfortunately, if you don’t have an adequate database backup
and recovery strategy and implementation in place then you are left with nothing to fall
back on.
As a DBA you need to make sure that the databases are backed up regularly and timely
recovery procedures are in place. MySQL Enterprise Backup provides DBAs with a highperformance, online “hot” backup solution with data compression technology to ensure
your data is protected in case of downtime or an outage.
Database Backup Terms
Before we dive into backup strategies and methodologies lets first cover some backup
and recovery terminology.
Online Backup – An online or “hot” backup is a backup that can be performed while the
database is running. Read and write operations can continue while the database is
being backed up. There is no need to shutdown the database or lock database files
which results in zero business interruption.
Incremental Backup – An incremental backup is a backup that only contains data that
has changed since the last complete full backup. An incremental backup is the fastest
backup and requires the least amount of storage space. However, incremental backups
also require the longest time to restore.
Partial Backup – A partial backup is a backup of only part of the database such as
selected tables.
Consistent Point in Time Recovery – Consistent Point in Time recovery enables
recovery of a database to a consistent state at a specific target time.
Roll Forward Recovery – Roll forward recovery makes it possible to restore a database
to the most recent state before a failure occurred.
Requirements Assessment
In order to develop a backup strategy you must first assess your needs. Your backup
and recovery implementation will depend on a lot of factors including value of the data,
data change frequency, industry regulations, corporate governance and many more.
Here are some questions to ask yourself in order to get started:
© 2011, Oracle Corporation and/or its affiliates
3
•
What point in time do I need to recover to? Is it a week, a day or hour or minute?
This is referred to as the Recovery Point Objective (RPO). It is the point in time that the
restarted database will reflect. What you define as the RPO will depend on your
business, how critical the data is and how frequently your data changes. Your RPO will
help determine what types of backups you need to run and how frequently. Another
important question to ask yourself is:
•
When I have a failure, how quickly do I need to get back online?
This is referred to as the Recovery Time Objective (RTO). It is the amount of time
elapsed between the outage and restoration of your database. Answering these 2
questions will help you to start to formulate a data retention policy.
In addition to the these questions, your data retention policy may also be driven by
regulations or corporate governance requirements, which may dictate things like how
long you need to keep historical data. Other considerations what will come into play are
storage requirements and storage availability. If data amounts to multiple terabytes or
more, the cost of storage needs to be weighed against budget constraints.
Database Backup Methods
Lets take a look at the different backup methods you can implement to help achieve your
backup strategy. There are many different backup methods but lets take a look at 4
primary backup methods you can use with MySQL Enterprise Backup.
Full Backups
Full backups make a complete copy of your data. If you don’t have to recover to a
specific point in time, then a strategy of using only full backups will fit your needs. For
example, you can run full backups on a daily basis or even on a weekly basis if your data
does not change frequently or is not critical and you can afford to lose a few days of data.
MySQL Enterprise Backup also gives you an option to compress your data if you are
faced with storage limitations. In addition, you can move your full backups to tape for
archival purposes if needed.
Full + Incremental Backups
Complementing full backups with incremental backups enables you to run more backups,
more often and reduce recovery time to within a few hours of when a disaster or
corruption occurred. Since incremental backups don’t require as much disk space,
organizations can reduce their storage requirements and costs. Using this method also
gives you the option of moving the full backups to tape while retaining incremental
backups on disk. The incremental backups can then be deleted over time to clear disk
space.
Full + Incremental + Log
If you need to return to within a few minutes or get back to a very specific point in time of
when a disaster or corruption occurred, then combining a full backups and incremental
backups with a backup of the transaction log is a good fit. This allows you to apply a full
backup, incremental backup and roll forward prior to the point in time when the disaster
occurred using the backup of the transaction log.
© 2011, Oracle Corporation and/or its affiliates
4
Determining Your Backup Strategy
When you formulate your backup strategy and try to decide which backup methods to
implement, you need to look at least 2 or maybe more criteria to define your backup
strategy. Two popular criteria are:
•
•
Change Frequency of Data
Value of Data
The illustration above provides some guidelines for choosing your backup method. For
example, if your data only changes infrequently, such as every few months, then a full
monthly backup might be all you need. On the other hand, if you have transactional data
that is changing continuously and it is critical high value data then you should consider
daily full backups, hourly incrementals, combined with transaction log backups. You may
also consider doing backups on a replication slave if the master is burdened with heavy
traffic. These criteria, along with the size of the data, RPO and RTO are going to help
you formulate your backup strategy.
Backup and Recovery Attributes
Each Backup Method has different attributes that an organization should consider when
developing their backup strategy. For example organizations should consider:
•
•
•
•
•
Backup Time
Restore Time
Recovery Grade
Storage Requirements
Storage Limitations
© 2011, Oracle Corporation and/or its affiliates
5
The table below describes the various backup and recovery attributes associated with the
backup methods described above.
Backup Method
Method 1:
Full Backups
Backup Factors
• Longest Backup Times
• Largest Storage Space
• Save space with compression
Recovery Factors
• Easy to Recover
• Fastest Restore Times
Method 2:
Full + Incremental
Backup
• Reduced Storage Requirements
• Requires 1X production storage
for copy
• Finer-grained Recovery
• Slower Restore Times
• First Restore Full Backup
• Then Restore Incrementals
Method 3:
Full + Incremental +
Log Backup
• Added Storage Requirements
• Requires more than 1X
production storage for copy
• Finest-grained Recovery
• Slowest Restore Times
• First Restore Full Backup
• Then Restore Incrementals
• Then Apply Logs
Method 4:
Offload Backups Slave
Replication
• Used with 1 of the above
• Frees Master for more workload
• Requires 1X production
hardware and storage for standby
database
• Fast failover to standby
• Backups are last resort, in
event of double site failure or
need to perform PITR
MySQL Enterprise Backup
MySQL has run many polls and surveys that indicate the importance of online backup.
Over the years, online backup has been the #1 requested feature that MySQL users
want. Among the biggest concerns are:
• Time duration for doing backup
• Time duration for doing recovery
• Performance impact on the database.
MySQL Enteprise Backup provides a rich set of back and recovery features and
functionality including significant performance improvements over existing MySQL
backup methods.
Backup
Online Backup
Full Backup
Incremental Backup
Partial Backup
Restore
Full Restore
Consistent Point in Time Recovery
© 2011, Oracle Corporation and/or its affiliates
Backup of InnoDB tables takes place entirely
online, without preventing queries or updates
Full backup is performed on all InnoDB data
Only data that changed since a previous backup
(full or incremental)
A backup of particular tables or tablespaces.
A full restore can be performed from a full backup
of all InnoDB data
Perform a recovery and roll forward to a point in
6
(PITR)
Roll Forward Recovery
Partial Restore
Restore to a separate location
Advanced Features
Compressed Backups
Corruption Detection
Task Synchronization
High performance
Scriptable Interface
Backup for MyISAM tables
Cross Platform
Unlimited Database Size
time
Backups can be rolled to specific transaction for
finer grained recovery
Restore of particular tables or tablespaces
Restore to separate location, create clones for
fast replication setup or administration
Backup of InnoDB files can be compressed saving
over 90% of the storage
Checks page checksums when copying InnoDB
data and log files
Allows point-in-time task synchronization of other
tasks with backup
Backup: 3x faster than mysqldump
Restore: 16x faster than mysqldump
Command Line Interface enables you easily
integrate within various scheduling systems
While the MyISAM tables are being copied, users
can read MyISAM tables, but cannot modify them
Linux, Windows, Unix, Mac
Scalable, works well for small to very large
databases
Performance
Lets take a look at some performance benchmarks for MySQL Enterprise Backup. The
charts below summarize the performance of MySQL Enterprise Backup compared to
mysqldump for backup and restore operations. The backup benchmark compares the
number of minutes it takes for a full backup for 26GB and 32GB databases. As you can
see, MySQL Enterprise Backup delivers 3.5x better performance for a 32GB database.
Individual performance will depend on the complexity of your data model, but you can
assume a significant performance increase for backups using MySQL Enterprise Backup.
MySQL Enterprise Backup delivers 3.5x better backup performance for a 32GB database
© 2011, Oracle Corporation and/or its affiliates
7
Lets take a look at the performance of MySQL Enterprise Backup compared to mysqldump
for restoring your database. This is where you will see the largest performance advantage
for MySQL Enterprise Backup. Online recovery of MySQL Enterprise Backup is 16x faster
than mysqldump, enabling you to significantly reduce your Restore Time Objective (RTO).
In addition, recovery using mysqldump is non-linear because indexes and tables need to be
recreated. One of the reasons why MySQL Enterprise Backup is so much faster is that
there is little to no reorganization processing upon restoring the database.
MySQL Enterprise Backup delivery 16x better recovery performance for a 32 GB
database
Compression
MySQL Enterprise Backup offer data compression that can help organizations save on
storage costs. As you can see below MySQL Enterprise Backup can save from 65% to
93% reduction in storage space.
© 2011, Oracle Corporation and/or its affiliates
8
MySQL Enterprise Backup compression reduces backup size between 65% and 93%.
MySQL Backup Comparisons
Lets look at the advantages and disadvantages of various MySQL Backup options. In
many cases, this is not an “either/or” decision. Your solution may include multiple
methods.
Mysqldump: Import/Export
Advantages
• Easy to 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.
• Good assurance that database files are not corrupt - all the data is read and
it is read using standard SQL queries.
Disadvantages
• Not an online solution - tables 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.
MySQL Replication: Standby Copy
MySQL Master Slave Replication allows users to fail over to a slave in case a master
server fails. It is not a pure backup solution but rather a recovery tool that can be very
valuable to recover quickly from a master hardware failure or software problem.
Advantages
© 2011, Oracle Corporation and/or its affiliates
9
•
•
•
•
Rolling snapshot – users can revert to when database snapshots were taken
Quick recovery – if master fails users can quickly recover and fail over to slave
Non blocking – master is not blocked while replication snapshot is taken
Complements other backup options – works well with other backup
technologies.
Disadvantages
• Backup is only latest point in time – can’t roll forward to specific point-in-time
• Doesn’t protect from user error – user errors (e.g. dropped tables) are also
replicated to slaves.
• Not an archival backup – not suitable for historical purposes
LVM Snapshots
LVM snapshots provide a complete, physical copy of the actual MySQL database/table
files. ZFS and SAN systems also have mirrored snapshot options to apply for backup
purposes.
Advantages
• Fast – Snapshot time is not dependent on the size of the database
• Feature of Linux - LVM has built-in snapshot functionality
• Complements other backup options – works well with other backup
technologies.
Disadvantages
• Point in Time Snapshot - still need to make a backup copy of snapshots if you
want to keep them.
• Size – Snapshot backup copies are equivalent to a full backup in size.
• Performance - too many concurrent snapshots will degrade performance
• Portability - doesn’t work across file system so that could lead to
inconsistencies.
MySQL Enterprise Backup
MySQL Enterprise Backup performs online "Hot", non-blocking backups of your MySQL
databases. Consistent Point-in-Time Recovery (PITR) enables DBAs to perform a restore
to a specific point in time and backup compression reduces backup size from 70% to
over 90% helping organization reduce storage costs.
Advantages
• Performance – Up to 3.5x faster for backups and 16x faster for restore than
mysqldump
• 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
• Supported – developed and supported by Oracle MySQL team
Disadvantages
• Planning & Scheduling – robust solution that requires planning and scheduling
The chart below summarizes the various attributes of all of the backup methods that have
been discussed. MySQL Enterprise Backup provides a robust set of features and the
flexibility to implement a strong data retention policy based on your customized needs.
© 2011, Oracle Corporation and/or its affiliates
10
How MySQL Enterprise Backup Works
MySQL Enterprise Backup provides a command line interface. Backups are written to
disk and since most recoveries occur with a week or day, this serves as a quickly
accessible disk storage area. Longer term you may need to reach back to a tape
archive, especially for full backups.
MySQL Enterprise backup also provides intrinsic knowledge of database file formats:
• Performs block validation
• Understands tablespace and data file recovery
• Only backs up actual data and delivers unused block compression
• Provides consistent recovery
• Reduces backup file size by over 90% using file compression
© 2011, Oracle Corporation and/or its affiliates
11
MySQL Enterprise Backup Terms
To help understand how MySQL Enterprise Backup works, below are some important
MySQL Enterprise Backup terms that you should familiarize yourself with:
•
•
•
•
•
•
mysqlbackup: backup executable which includes InnoDB, MyISAM and other
MySQL Data. mysqlbackup is a compatible replacement for the innobackup post
3.5.1 and includes additional features and capabilities
ibbackup: finer grained raw innodb backup executable for innodb files alone
binlog: contains database changes – e.g. DDL and DML
LSN: Log Sequence Number – the unique monotonically increasing id for each
change in the binlog
Ibdata: system tablespace files
ibd: single table space file
How Does MySQL Enterprise Backup Work
1. Backing Up InnoDB Data File
Backups are started using ibbackup whereby InnoDB data files are copied and
compressed.
Backup files can be compressed by 70%-90% by omitting unused storage in each block
and empty pages. While files are being copied and compressed, the earliest and latest
LSN is noted.
© 2011, Oracle Corporation and/or its affiliates
12
2. Backing up InnoDB Log Files
The InnoDB log files, accumulated during the copying of the data files, are copied using
the LSN from the start and finish.
Only the portion of the log file necessary to redo the information is copied and covers the
time from the beginning to the end of the backup. This is how consistency is achieved.
3. Backing up MyISAM Tables
mysqlbackup acts as a wrapper for ibbackup. It is a higher level, easier to use interface
for backing up MyISAM data along with InnoDB data so it can be brought back
consistently. InnoDB tables are fully accessible during the backup but MyISAM tables
are locked and cannot be updated.
© 2011, Oracle Corporation and/or its affiliates
13
4. Restoring the Database
Restoring the database starts with uncompressing the InnoDB files to the data dir.
MySQL Enterprise Backup recreates the InnoDB log files and applies those logs so that
InnoDB files are restored to a consistent state followed by restoring the MyISAM data.
Examples
The MySQL Enterprise Backup documentation includes numerous examples of
mysqlbackup commands for performing Full Online Backups, Incremental Backups,
Partial Backups, Restoring a Database and more.
MySQL Enterprise Backup Users Guide:
http://dev.mysql.com/doc/mysql-enterprise-backup/3.5/en/index.html
mysqlbackup Command Reference
http://dev.mysql.com/doc/mysql-enterprise-backup/3.5/en/mysqlbackup.html
Example: Backing Up InnoDB and MyISAM Tables
http://dev.mysql.com/doc/mysql-enterprise-backup/3.5/en/mysqlbackup.backup.html
Example: Making an Incremental Backup of InnoDB and MyISAM tables
http://dev.mysql.com/doc/mysql-enterprise-backup/3.5/en/mysqlbackup.incremental.html
© 2011, Oracle Corporation and/or its affiliates
14
Example: Restoring a Database at its Original Location
http://dev.mysql.com/doc/mysql-enterprise-backup/3.5/en/mysqlbackup.restore.html
Conclusion
MySQL Enterprise Backup provides multiple methods for backup and recovery of MySQL
databases. MySQL Enterprise Backup supports full, incremental partial, and compressed
backups that allow you to perform consistent Point-in-Time Recovery, as well as saving
both time and money.
© 2011, Oracle Corporation and/or its affiliates
15
Additional Resources
MySQL Enterprise Backup: Product Information
http://www.mysql.com/products/enterprise/backup.html
MySQL Enterprise Backup: Documentation
http://dev.mysql.com/doc/mysq-enterprise-backup/3.5/en/index.html
MySQL Backup Forum
http://forums.mysql.com/list.php?28
Download (30 Day Trial)
http://edelivery.oracle.com
MySQL Customers and Case Studies
http://www.mysql.com/customers
MySQL Enterprise Edition
http://mysql.com/products/enterprise/
MySQL Professional Services and Consulting
http://mysql.com/consulting/
MySQL for ISVs and OEMs
http://mysql.com/why-mysql/isv-oem-corner/
© 2011, Oracle Corporation and/or its affiliates
16
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement