http://blog.csdn.net/dbanote/article/details/13295727
http://blog.csdn.net/yangzhawen/article/details/50457922
http://blog.csdn.net/yangzhawen/article/details/28864763
Xtrabackup是由percona开发的一个开源软件,它是innodb热备工具ibbackup(收费的商业软件)的一个开源替代品。Xtrabackup由个部分组成:xtrabackup和innobackupex,其中xtrabackup工具用于备份innodb和 xtraDB引擎的表;而innobackupex工具用于备份myisam和innodb引擎的表,本文将介绍如何用innobackupex工具做全量和增量备份。
官网:http://www.percona.com/docs/wiki/percona-xtrabackup:start
安装
声明:以下操作最好以MySQL用户执行。
首先,通过wget下载源码tar包:
- wget http://www.percona.com/redir/downloads/XtraBackup/LATEST/source/percona-xtrabackup-2.1.5.tar.gz
安装依赖包:
- yum install cmake gcc gcc-c++ libaio libaio-devel automake autoconf bzr bison libtool ncurses-devel zlib-devel
解压缩tar:
- tar -zxvf percona-xtrabackup-2.1.5.tar.gz
- cd percona-xtrabackup-2.1.5
utils/build.sh脚本会根据指定的引擎版本,自动解压缩适当的MySQL源码包并进行编译,这是最简单的安装方式。当你在命令行下不带任何参数执行该脚本时,出现如下提示:
- [mysql@epay100 ~/software/percona-xtrabackup-2.1.5 ]$ ./utils/build.sh
- Build an xtrabackup binary against the specified InnoDB flavor.
- Usage: build.sh CODEBASE
- where CODEBASE can be one of the following values or aliases:
- innodb51 | plugin build against InnoDB plugin in MySQL 5.1
- innodb55 | 5.5 build against InnoDB in MySQL 5.5
- innodb56 | 5.6,xtradb56, build against InnoDB in MySQL 5.6
- | mariadb100
- xtradb51 | xtradb,mariadb51 build against Percona Server with XtraDB 5.1
- | mariadb52,mariadb53
- xtradb55 | galera55,mariadb55 build against Percona Server with XtraDB 5.5
根据上面提示和你使用的存储引擎及版本,选择相应的参数即可。因为我用的是MySQL 5.6,所以执行如下语句安装:
- ./utils/build.sh innodb56
以上语句执行成功后,表示安装完成。最后,把生成的二进制文件拷贝到一个自定义目录下(本例中为/home/mysql/admin/bin/percona-xtrabackup-2.1.5),并把该目录放到环境变量PATH中。
- cp ./innobackupex /home/mysql/admin/bin/percona-xtrabackup-2.1.5
- cp ./src/xtrabackup_56 ./src/xbstream /home/mysql/admin/bin/percona-xtrabackup-2.1.5
- 这里我是把他直接cp到/usr/bin目录下
我这里的MySQL版本是5.6.23
我这里用的xtrabackup的版本是2.1.9
安装的过程遇到的问题
1:./utils/build.sh: line 173: patch: command not found
解决方法是:yum -y install patch
然后再次执行
./utils/build.sh innodb56
这里我们创建一个普通的用户来进行热备
用户拥有的权限有
SELECT, RELOAD, SHOW DATABASES, LOCK TABLES
权限列表
1.Select 读取
2.SHOW DATABASES 允许访问完整的数据库列表
4. LOCK TABLES 允许锁定表
5.RELOAD 允许载入和刷新服务器缓存
#####
这里我采取另外一种安装方法:
文章摘自http://blog.csdn.net/yangzhawen/article/details/50457922
http://www.cnblogs.com/galengao/p/5755835.html
安装 ***************************************************************** ----1.编译安装percona-xtrabackup
yum -y install cmake gcc gcc-c++ libaio libaio-devel automake autoconf bzr bison libtool zlib-devel libgcrypt-devel libcurl-devel crypt* libgcrypt* python-sphinx openssl imake libxml2-devel expat-devel ncurses5-devel ncurses-devle vim-common libgpg-error-devel libidn-devel
NOTE:2.2.16 需要python-sphinx openssl两个依赖包. ---2.安装相关插件 yum -y install perl-DBI yum -y install perl-DBD-MySQL yum -y install perl-Time-HiRes yum -y install perl-IO-Socket-SSL wget http://www.percona.com/downloads/percona-toolkit/2.2.16/RPM/percona-toolkit-2.2.16-1.noarch.rpm rpm -ivh percona-toolkit-2.2.16-1.noarch.rpm ---3.安装xtrabackup wget http://www.percona.com/downloads/XtraBackup/XtraBackup-2.2.11/source/tarball/percona-xtrabackup-2.2.11.tar.gz mkdir -p /usr/local/xtrabackup tar xvzf percona-xtrabackup-2.3.3.tar.gz -C /usr/local/xtrabackup/ && cd /usr/local/xtrabackup/percona-xtrabackup-2.3.3 chown -R mysql:mysql /usr/local/xtrabackup cd /usr/local/xtrabackup/percona-xtrabackup-2.3.3 cmake -DBUILD_CONFIG=xtrabackup_release -DWITH_MAN_PAGES=OFF && make -j4 --DINSTALL_LAYOUT=/usr/local/xtrabackup make make install /**************编译安装相关参数 cmake . -LH --查看cmake支持的mysql相关参数 shell> cmake . -L # overview shell> cmake . -LH # overview with help text shell> cmake . -LAH # all params with help text shell> cmake . # interactive display ****************** make ********************make可能遇到的错误 1.重新编译时,需要清除旧的对象文件和缓存信息 Could not import extension sphinx.ext.extlinks (exception: No module named extlinks) make clean rm -f CMakeCache.txt 2.LIBEV_INCLUDE_DIRS CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: LIBEV_INCLUDE_DIRS (ADVANCED) used as include directory in directory /usr/local/xtrabackup/percona-xtrabackup-2.3.3/storage/innobase/xtrabackup/src used as include directory in directory /usr/local/xtrabackup/percona-xtrabackup-2.3.3/storage/innobase/xtrabackup/src used as include directory in directory /usr/local/xtrabackup/percona-xtrabackup-2.3.3/storage/innobase/xtrabackup/src used as include directory in directory /usr/local/xtrabackup/percona-xtrabackup-2.3.3/storage/innobase/xtrabackup/src used as include directory in directory /usr/local/xtrabackup/percona-xtrabackup-2.3.3/storage/innobase/xtrabackup/src -- Configuring incomplete, errors occurred! See also "/usr/local/xtrabackup/percona-xtrabackup-2.3.3/CMakeFiles/CMakeOutput.log". See also "/usr/local/xtrabackup/percona-xtrabackup-2.3.3/CMakeFiles/CMakeError.log". http://dist.schmorp.de/libev/ #tar xvzf libev-4.22.tar.gz # ./configure # make # make install # find / -name 'libev.so*' /usr/local/lib/libev.so.4 /usr/local/lib/libev.so.4.0.0 /usr/local/lib/libev.so ******************8 make install /*****重新安装需要 rm -rf /usr/bin/innobackupex rm -rf /usr/bin/xtrabackup ***********/ #vi ~/.bash_profile export PATH=/usr/local/xtrabackup/bin:$PATH #source ~/.bash_profile ----链接命令到/usr/bin目录 ln -sf /usr/local/xtrabackup/bin/innobackupex /usr/bin/ ln -sf /usr/local/xtrabackup/bin/xtrabackup /usr/bin/ ---测试结果 # xtrabackup --version xtrabackup version 2.3.3 based on MySQL server 5.6.24 Linux (x86_64) (revision id: 525ca7d)