• Aucun résultat trouvé

InnoDB Hot Backup

Dans le document Effective MySQL (Page 44-55)

For an InnoDB only MySQL instance there are two products that can perform a hot non-blocking backup. These are MySQL Enterprise Backup (MEB), formally known as InnoDB Hot Backup, and XtraBackup.

The process of performing a hot backup is different from both the mysqldump and filesystem snapshot approaches, as it integrates with features and functionality within InnoDB to produce a solution that provides a consistent version of data in a non-locking manner. These tools duplicate some of the features of the InnoDB storage engine by keeping a copy of all InnoDB transactional log engines (aka redo logs) and performing a copy of data consistent with InnoDB data page management. Both products will also perform a warm backup of a MySQL installation that has a mixture of InnoDB and other storage engines.

NOTE In addition to supporting an InnoDB only application, these hot backup options do support MyISAM backups for the mysql meta-schema and any other tables; however, this requires table locking.

MySQL Enterprise Backup (MEB)

MEB is available as part of MySQL Enterprise Edition, a commercial offering that is provided by Oracle when purchasing a MySQL subscription. MEB provides a hot backup solution for a MySQL environment.

Downloading the Software You can download MySQL Enterprise Backup for evaluation from the Oracle Software Delivery website at https://edelivery.oracle.com/. You must first sign up for free, accept the licensing agreement, and download the appropriate version via a web browser. Currently MySQL Enterprise Backup is available in the following

• Windows 32bit/64bit

• Solaris 10 32bit/64bit

The following steps install a downloaded version of the generic Linux 64bit software:

Running a Full Backup

NOTE The --with-timestamp option will create an appropriate date/time sub-directory for each backup using MySQL Enterprise Backup.

This example showed the backup-and-apply-log option. It is also possible to create a backup with two separate commands by running MEB with backup and then apply-log.

For more information see the MySQL documentation at http://dev.mysql.com/doc/mysql-enterprise-backup/3.7/en/mysqlbackup.backup.html.

Chapter 8 discusses additional options for MySQL Enterprise Backup including compression, incremental, and remote backups.

Security To improve access permissions for a privileged user performing a backup with MEB, the following privileges are required:

For more information refer to the MEB manual at http://dev.mysql.com/doc/mysql-enterprise-backup/3.7/en/mysqlbackup.privileges.html.

Monitoring In addition to text output of the mysqlbackup command, information is recorded in the mysql schema. For example:

This can be disabled with the --no-history-logging option.

More Information For more information on the features of MySQL Enterprise Backup visit http://www.mysql.com/products/enterprise/backup.html.

XtraBackup

XtraBackup is an open source offering by Percona that can perform an InnoDB hot backup. This tool also has additional features for the support of the XtraDB storage engine, an open source variant of InnoDB.

Downloading the Software XtraBackup is available in three different versions. This is because XtraBackup actually includes an embedded version of the MySQL server and MySQL client libraries. You can download the software from http://www.percona.com/downloads/XtraBackup/.

For example, when using the Ubuntu 64bit MySQL 5.5 version of XtraBackup, the following commands download and install the software. Refer to the previously mentioned link to obtain the most current version of XtraBackup for your applicable operating system. At the publication of this book the current version is 2.0.0.

CAUTION XtraBackup may require the installation of the library package for Asynchronous I/O (libaio1 on Ubuntu, libaio on RHEL). This is also required for MySQL versions 5.5 or greater.

NOTE In the prior version of XtraBackup, the package name was xtrabackup. It is now

percona-xtrabackup.

—backup The XtraBackup backup process is a two stage operation. The first operation with the --backup option performs the physical backup. The second operation with the

--prepare option performs an internal crash recovery of the copied tablespace files and accumulated transactional logs to produce a consistent backup that can then be restored in a timely manner.

Using the directory structure of the MySQL installation that was referenced in the LVM section the following syntax will perform a backup. The --datadir parameter should be adjusted accordingly for your MySQL instance.

—prepare The prepare step of XtraBackup launches the embedded version of InnoDB, performs a crash recovery of the data and accumulated transaction logs, and produces a clean and consistent version that is ready for any recovery requirements.

This step can occur on any server that has the backup files and the same version of XtraBackup installed. This does not need to occur on the machine the backup was taken.

For saving additional time in the recovery process, you can run the --prepare option a second time to prepare clean InnoDB transaction logs. This is not a required step.

NOTE The xtrabackup command does not create date/time based subdirectories during the backup process.

Backing Up All MySQL Data As you can see from the XtraBackup commands, only InnoDB specific data is included. To capture all MySQL data, the innobackupex wrapper script packages all the necessary work into a single command. For example:

This command will automatically place the backup in a date/time defined sub-directory.

This can be disabled with the --no-timestamp option.

More Information For more information on XtraBackup visit http://www.percona.com/docs/wiki/percona-xtrabackup:xtrabackup:start.

Dans le document Effective MySQL (Page 44-55)

Documents relatifs