优点
快速进行完整,可靠的备份
在备份过程中不中断进行中的事务
节省备份空间及网络带宽
支持自动备份机制,备份后自动完成校验
快速恢复
支持Percona Server, MySQL MariaDB, Drizzle 版本的热备份,流备份,压缩备份及增量备份机制
支持InnoDB, XtraDB, HailDB 存储引擎的无堵塞(在线)备份机制
对于 MyISAM, Merge Archive, 分区表,触发器,备份过程中需对引擎执行只读锁定
可在两个服务器之间在线迁移表
支持压缩的流备份到另外一台服务器上
轻松建立 MySQL AB 复制
下载地址
http://www.percona.com/software/percona-xtrabackup
编译方法
tar xf percona-xtrabackup-2.1.6.tar.gz
cd percona-xtrabackup-2.1.6
参考
================== ========= =============================================
Value Alias Server
================== ========= =============================================
innodb51 plugin build against InnoDB plugin in MySQL 5.1
innodb55 5.5 build against InnoDB in MySQL 5.5
xtradb51 xtradb build against Percona Server with XtraDB 5.1
xtradb55 xtradb55 build against Percona Server with XtraDB 5.5
innodb56 5.6 build against InnoDB in MySQL 5.6
================== ========= =============================================
根据你当前的数据库版本进行编译,如,当前使用 innodb 5.5 版本, 则编译如下
AUTO_DOWNLOAD="yes" ./utils/build.sh innodb55
获得当前数据库版本方法
如, xtradb55 返回结果如下
select PLUGIN_DESCRIPTION, PLUGIN_VERSION from information_schema.plugins where plugin_name = 'Innodb'; +----------------------------------------------------------------------------+----------------+ | PLUGIN_DESCRIPTION | PLUGIN_VERSION | +----------------------------------------------------------------------------+----------------+ | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | 5.5 | +----------------------------------------------------------------------------+----------------+ 1 row in set (0.00 sec)
如innodb55 返回结果如下
select PLUGIN_DESCRIPTION, PLUGIN_VERSION from information_schema.plugins where plugin_name = 'Innodb'; +------------------------------------------------------------+----------------+ | PLUGIN_DESCRIPTION | PLUGIN_VERSION | +------------------------------------------------------------+----------------+ | Supports transactions, row-level locking, and foreign keys | 5.5 | +------------------------------------------------------------+----------------+ 1 row in set (0.00 sec)
当前编译版本
AUTO_DOWNLOAD="yes" ./utils/build.sh xtradb55
编译成功,会生成 innobackupex 及 xtrabackup_55 二进制文件, 复制文件至 /usr/local/bin 下
[root@db2 percona-xtrabackup-2.1.6]# cp innobackupex /usr/local/bin/. [root@db2 percona-xtrabackup-2.1.6]# cp src/xtrabackup_55 /usr/local/bin/.
注: innobackup 文件是 perl 脚本,可看做是调用 xtrabackup 的工具
xtrabackup 是又 C 编译出来的二进制文件
常见编译错误
/usr/bin/ld: cannot find -laio collect2: ld 返回 1 gmake: *** [xbstream] 错误 1 gmake: *** 正在等待未完成的任务.... xtrabackup.cc: In function ‘my_bool x
解决方法
yum install -y libaio libaio-devel
权限
备份过程中系统用户需要对存放备份数据的系统文件目录具备读写执行权限
而对数据库进行备份时候,建议具备下面的权限能力
RELOAD, LOCK TABLES (除非指定 --no-lock 参数) 以便具备 flush tables with read lock 能力
REPLICATION CLIENT 具备获得二进制日志文件备份能力
CREATE TABLESPACE 具备恢复整个表空间,并导入表的能力
SUPER 用于启动/关闭从服务器复制线程环境
全库完整备份方法
innobackupex --user=DBUSER --password=DBUSERPASS /path/to/BACKUP-DIR/ innobackupex --user=root --password=123 --socket=/var/run/mysqld/mysql5.socket /backup
备份过程中可以看到 innobackupex 调用了 xtrabackup 工具
131223 14:09:34 innobackupex: Starting ibbackup with command: xtrabackup_55 --defaults-group="mysqld" --backup --suspend-at-end --target-dir=/backup/2013-12-2