一、 Innobackupex恢复原理
After creating a backup, the data is not ready to be restored. There might be uncommitted transactions to be undone or transactions in the logs to be replayed. Doing those pending operations will make the data files consistent and it is the purpose of the prepare stage. Once this has been done, the data is ready to be used.
To prepare a backup with innobackupex you have to use the --apply-log and the path to the backup directory as an argument:
Innobackupex replayed the committed transactions in the log files (some transactions could have been done while the backup was being done) and rolled back the uncommitted ones. Once this is done, all the information lay in the tablespace (the InnoDB files), and the log files are re-created.
在备份期间(copy数据时)事务存在不一致,即copy开始时,有些事务已开始,有些刚刚开始,而copy结束前或结束后才提交或回滚。
这些不确定的事务需要在恢复前来确定最终是否最终提交或回滚。在这个阶段的操作称之为prepare阶段。
这个prepare阶段依赖于备份时的xtrabackup log(来自innodb logfile),使用--apply-log参数实现一致性。
--apply-log参数会根据xtrabackup log做相应的前滚或回滚,完成后会重建innodb logfile文件。
The --use-memory option The preparing process can be speed up by using more memory in it. It depends on the free or available RAM on your system, it defaults to 100MB. In general, the more memory available to the process,the better. The amount of memory used in the process can be specified by multiples of bytes:
恢复期间,--use-memory选项可以加速prepare过程,如果系统可用内存够大的话,该值缺省被设置为100MB。
Innobackupex恢复示意图
二、 全备恢复流程
1. 当前环境
mysql> show variables like 'version';
+---------------+------------+
| Variable_name | Value |
+---------------+-----