os: centos 7.4
db: mysql 5.7
dbbackup: xtrabackup 2.4.9
xtrabackup是一款优秀的mysql开源备份(物理备份)工具,是由percona公司开发的。
下载
官网下载
https://www.percona.com/software/mysql-database/percona-xtrabackup
https://www.percona.com/downloads/XtraBackup/LATEST/
也有git的支持
https://github.com/percona/percona-xtrabackup
文档
https://www.percona.com/doc/percona-xtrabackup/LATEST/index.html
https://www.percona.com/doc/percona-xtrabackup/2.4/index.html
Percona-XtraBackup-2.4.9.pdf
安装
主要有几种方式
1)yum Repositories方式
yum install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm
yum list|grep -i percona
yum install percona-xtrabackup-24.x86_64
2)手动rpm包安装
Percona-XtraBackup-2.4.9-ra467167cdd4-el7-x86_64-bundle.tar
3)二进制的方式
percona-xtrabackup-2.4.9-Linux-x86_64.tar.gz
4)源码编译
percona-xtrabackup-2.4.9.tar.gz
5)git方式,越来越多的项目提供git支持了
https://github.com/percona/percona-xtrabackup.git
https://github.com/percona/percona-xtrabackup
本次采用手动rpm方式
# yum install cmake openssl-devel libaio libaio-devel automake autoconf \
bison libtool ncurses-devel libgcrypt-devel libev-devel libcurl-devel zlib-devel \
vim-common libev
# cd /tmp/xtrabackup
# tar -xvf ./Percona-XtraBackup-2.4.9-ra467167cdd4-el7-x86_64-bundle.tar
# rpm -ivh ./percona-xtrabackup-24-2.4.9-1.el7.x86_64.rpm
至此,xtrabackup就算安装好了,下面来简述如何备份和还原,更灵活的用法计划再写几篇xtrabackup专题blog
# which innobackupex
/usr/bin/innobackupex
# which xtrabackup
/usr/bin/xtrabackup
# ls -l /usr/bin/innobackupex
lrwxrwxrwx 1 root root 10 Mar 26 21:06 /usr/bin/innobackupex -> xtrabackup
可以看到 innobackupex 是到 xtrabackup 的软链
# innobackupex --help
# xtrabackup --help
这两个的输出还是不太一样innobackupex --help 有这样一句描述
NOTICE: ‘innobackupex’ is deprecated, please switch to ‘xtrabackup’
所以还是安心使用 xtrabackup
Percona XtraBackup is a set of following tools:
innobackupex
innobackupex is the symlink for xtrabackup. innobackupex still supports all features and
syntax as 2.2 version did, but is now deprecated and will be removed in next major release.
xtrabackup
a compiled C binary that provides functionality to backup a whole MySQL database instance with MyISAM, InnoDB, and XtraDB tables.
xbcrypt
utility used for encrypting and decrypting backup files.
xbstream
utility that allows streaming and extracting files to/from the xbstream format.
xbcloud
utility used for downloading and uploading full or part of xbstream archive from/to cloud.
After Percona XtraBackup 2.3 release the recommend way to take the backup is using the xtrabackup script. More
information on script options can be found in how to use xtrabackup.