Amazon EBS Snapshots

Amazon EC2

ZRM for MySQL can backup MySQL servers running on Amazon EC2 instances in Amazon cloud. The backups are stored in Amazon S3 cloud storage. The backup images can be restored only to an Amazon EC2 instance. The backups are performed using Elastic Block Store (EBS) snapshots to S3.

If you purchase the feature license from Zmanda (available at the Zmanda Network Downloads page), ZRM for MySQL includes an optional snapshot plugin that integrates with Amazon EBS to create consistent MySQL full backups. It creates snapshots of the EBS volumes on which to perform a full backup. When snapshots are enabled, ZRM for MySQL can perform backups with minimal impact on MySQL applications. Database writes will be blocked only during snapshot creation, which typically takes less than a second regardless of database size.

This page describes the configuration of Amazon EBS snapshot backups, including requirements for the MySQL databases in the cloud.

 

Requirements

  • ZRM server and MySQL server must be running Linux EC2 instances. Solaris and Windows platforms are not supported.
  • ZRM client software must be installed on the MySQL server EC2 instance.
  • Perl module Net::Amazon::EC2 must be installed on the ZRM server under /opt/zmanda/zrm directory. This perl module is available only from CPAN. To install this module, run the following commands as superuser on the ZRM server:
# /opt/zmanda/zrm/perl/bin/cpan

At CPAN prompt, type "install Net::Amazon::EC2"
  • The destination directory specified on the Backup Where page must exist on the MySQL server as well as the ZRM server. The MySQL backup user (OS-level) must have read/write permission to access this directory.

ebs_snapshot.png

  • All MySQL database files (data, log, indexes) must be stored in non-partitioned Amazon Elastic Block Store (EBS) volumes. ZRM user "mysql" should have permissions to read and write to the volumes. Please see Amazon documentation on how to use Elastic Block Storage in Amazon EC2.
  • Only Quick backup method is supported. Regular backups cannot be performed.
  • The number of EBS snapshots (full backups) that can be created depends on the Amazon account limit. The default limit is 500 EBS snapshots per amazon account. If full backups have to be retained for a long time, please contact Amazon to increase the EBS snapshot limit.
  • Please make sure that the system date and time on the MySQL server and ZRM server if they are running on Amazon EC2 is correct. Incorrect date and time will result in failure of EBS snapshots and hence the backups.
  • The MySQL backup user must be granted sudo privileges to execute system commands "df" and "xfs_freeze" (if XFS file system is in use) on the MySQL server. Add a line similar to the following example to /etc/sudoers on the MySQL server:
mysql ec2-75-101-206-181.compute-1.amazonaws.com=NOPASSWD:/bin/df,NOPASSWD:/usr/sbin/xfs_freeze,NOPASSWD:/bin/mount,NOPASSW
D:/bin/umount,NOPASSWD:/sbin/fuser
where ec2-75-101-206-181.compute-1.amazonaws.com is the IP address of ZRM server on Amazon EC2. Please see KB article for more information on sudo configuration.
 

 

Configuring ZRM for MySQL to use Amazon EBS Snapshots

  • Install the EBS snapshot license on the ZRM server. You will have to download the license file from Zmanda network and copy it to /etc/zmanda directory.
  • Choose the Amazon EC2 instance's private DNS name as the host name for the MySQL server in the Backup|What page. For example: domU-12-31-39-06-70-22.compute-1.internal
  • Select Snapshot Type as Amazon EBS in the Snapshot Type drop down box after selecting Backup Method in the Backup How page.
BackupHow-EBS-ZRM-3.4.png

Amazon EC2 access key 

Amazon account access key identifier. This information can be obtained from Amazon account page (Select Your Account -> Access Identifiers)
Amazon EC2 secret key 
Amazon account secret key identifier. This information can be obtained from Amazon account page (Select Your Account -> Access Identifiers)
Amazon EC2 instance id
The Instance ID of the Amazon EC2 instance where MySQL server is running. This MySQL server should be configured in the Backup|What page in the backup set. Usually, the ID begins with string "i-". This information can be obtained from the AWS Management Console (Amazon account information is required).
Backup Type
Only Quick backup is supported. The Quick (No Copy) option specifies that the snapshot itself should be used as a near-line backup. Quick backups are convenient as they provide faster backups and restores. Backups are stored in highly reliable and scalable Amazon S3 that offers protection against media or server failure. Note that if the quick option is specified, the compress and encrypt options are ignored. In addition, no checksums are performed, which means that quick snapshot backups cannot be verified. Quick snapshot backups using EBS cannot be converted into regular backups.

Fallback for Logical

If this field is set to yes and snapshot backup fails, the logical backup is attempted. Set the value to No if you do not want to do logical backup if there is a snapshot backup failure.

Remote MySQL Binary Path

Path to the MySQL commands on the MySQL server.

Binary Log Path

Location of binary logs on the MySQL server that are used for log incremental backups.

Restoring EBS snapshot backup

Elastic Block store snapshot backups can be restored only to an Amazon EC2 instance. There are two ways to do restoration of EBS snapshot backups.

  • Restoration of EBS snapshots to an EC2 where MySQL server is already running. This method is the recommended method. It can be used to restore MySQL backups back to original EC2 instance. This method is supported by Zmanda Management Console. For more details on how to configure destination Amazon EC2 instance id and other EBS parameters in the restore process, please see Restore Where page.

  • Restoration of EBS snapshots to an EC2 where MySQL server is not running. This method is useful for quick recovery of MySQL data. This restoration option is available in command line only.

mysql-zrm-manage-backup --mount-snapshots --source-directory <directory where backup images are stored> \
                        --ec2-instance-id <instance id of amazon ec2 where the snapshots have to be mounted> \
                        --device-fs-map <name of the mapping file containing devices and mount points>

The EBS devices are mounted at the mount points specified in the device mapping file on the destination amazon ec2 instance. The user can start a MySQL server with the datadir and logdir pointing to the mounted EBS devices to start accessing restored data.

An example of device mapping file:

/dev/sdf=/db
/dev/sdk=/innodb_data
/dev/sdn=/innodb_logs

and MySQL server to use the above data will have to be configured as follows in the MySQL server options file (my.cnf)

datadir=/db
innodb_data_home_dir=/innodb_data
innodb_log_group_home_dir=/innodb_logs

Use --dismount-existing option to mysql-zrm-manage-backup command if the EC2 where backups are being restored to already has EBS volumes mounted at the mount points.