MySQL备份之Xtrabackup 2.1.7 源码安装

转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/51785118

Xtrabackup主要包含两个工具
xtrabackup:是用于热备份innodb, xtradb表中数据的工具,不能备份其他类型的表,也不能备份数据表结构;
innobackupex:是将xtrabackup进行封装的perl脚本,可以备份和恢复MyISAM表以及数据表结构。


1.下载Xtrabackup备份工具,选source code安装包
https://www.percona.com/downloads/XtraBackup/LATEST/


2.在线安装文档
https://www.percona.com/doc/percona-xtrabackup/2.2/index.html


3.解压
tar -xzvf percona-xtrabackup-2.1.7.tar.gz
 
4.安装perl环境(DBI/DBD) 

yum install perl-DBIx-Simple.noarch
yum install perl-DBD-MySQL.x86_64
yum install perl*


5.Prerequisites
$ yum install cmake gcc gcc-c++ libaio libaio-devel automake autoconf \
  bison libtool ncurses-devel libgcrypt-devel libev-devel


6.在源码目录确认mysql-5.6.15.tar.gz包(xtrbackup2.1的版本自带有,这步不用操作)
 一是通过执行命令 AUTO_DOWNLOAD="yes" ./utils/build.sh xtradb ,允许build.sh自行下载
 二是通过手动拷贝 mysql-5.6.15.tar.gz和libtar-1.2.11.tar.gz两个文件
AUTO_DOWNLOAD="yes" ./utils/build.sh xtradb


7.开始编译
$ ./utils/build.sh           #根据版本确认build.sh的参数
$ ./utils/build.sh innodb56   #开始编译


8.把xtrabackup_56复制到/usr/bin下
cp /u01/percona-xtrabackup-2.1.7/src/xtrabackup_56 /usr/bin/


9.利用Innobackupex备份

./innobackupex --socket=/u01/my3306/run/mysql.sock --defaults-file=/u01/my3306/my.cnf /backup/mysql/3306 > /tmp/2.log

[mysql@xiangxingedu percona-xtrabackup-2.1.7]$ ./innobackupex --socket=/u01/my3306/run/mysql.sock --defaults-file=/u01/my3306/my.cnf /backup/mysql/3306 > /tmp/2.log

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona LLC and/or its affiliates 2009-2013.  All Rights Reserved.

This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.

160629 18:37:29  innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_file=/u01/my3306/my.cnf;mysql_read_default_group=xtrabackup;mysql_socket=/u01/my3306/run/mysql.sock' (using password: NO).
160629 18:37:29  innobackupex: Connected to MySQL server
160629 18:37:29  innobackupex: Executing a version check against the server...
160629 18:37:29  innobackupex: Done.
IMPORTANT: Please check that the backup run completes successfully.
           At the end of a successful backup run innobackupex
           prints "completed OK!".

innobackupex: Using mysql server version 5.6.23-log

innobackupex: Created backup directory /backup/mysql/3306/2016-06-29_18-37-29

160629 18:37:29  innobackupex: Starting ibbackup with command: xtrabackup_56  --defaults-file="/u01/my3306/my.cnf"  --defaults-group="mysqld" --backup --suspend-at-end --target-dir=/backup/mysql/3306/2016-06-29_18-37-29 --tmpdir=/u01/my3306/tmp
innobackupex: Waiting for ibbackup (pid=23161) to suspend
innobackupex: Suspend file '/backup/mysql/3306/2016-06-29_18-37-29/xtrabackup_suspended_2'

xtrabackup_56 version 2.1.7 for MySQL server 5.6.15 Linux (x86_64) (revision id: undefined)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /u01/my3306/data
xtrabackup: using the following InnoDB configuration:
xtrabackup:   innodb_data_home_dir = /u01/my3306/log/iblog
xtrabackup:   innodb_data_file_path = ibdata1:32M;ibdata2:16M:autoextend
xtrabackup:   innodb_log_group_home_dir = /u01/my3306/log/iblog
xtrabackup:   innodb_log_files_in_group = 4
xtrabackup:   innodb_log_file_size = 1048576000
xtrabackup: using O_DIRECT
>> log scanned up to (1671755)
InnoDB: Allocated tablespace 3, old maximum was 0
[01] Copying /u01/my3306/log/iblog/ibdata1 to /backup/mysql/3306/2016-06-29_18-37-29/ibdata1
[01]        ...done
>> log scanned up to (1671755)
[01] Copying /u01/my3306/log/iblog/ibdata2 to /backup/mysql/3306/2016-06-29_18-37-29/ibdata2
[01]        ...done
[01] Copying ./mysql/slave_relay_log_info.ibd to /backup/mysql/3306/2016-06-29_18-37-29/mysql/slave_relay_log_info.ibd
[01]        ...done
[01] Copying ./mysql/slave_worker_info.ibd to /backup/mysql/3306/2016-06-29_18-37-29/mysql/slave_worker_info.ibd
[01]        ...done
[01] Copying ./mysql/slave_master_info.ibd to /backup/mysql/3306/2016-06-29_18-37-29/mysql/slave_master_info.ibd
[01]        ...done
[01] Copying ./mysql/innodb_index_stats.ibd to /backup/mysql/3306/2016-06-29_18-37-29/mysql/innodb_index_stats.ibd
[01]        ...done
[01] Copying ./mysql/innodb_table_stats.ibd to /backup/mysql/3306/2016-06-29_18-37-29/mysql/innodb_table_stats.ibd
[01]        ...done
[01] Copying ./test/t1.ibd to /backup/mysql/3306/2016-06-29_18-37-29/test/t1.ibd
[01]        ...done
>> log scanned up to (1671755)
xtrabackup: Creating suspend file '/backup/mysql/3306/2016-06-29_18-37-29/xtrabackup_suspended_2' with pid '23161'

160629 18:37:32  innobackupex: Continuing after ibbackup has suspended
160629 18:37:32  innobackupex: Starting to lock all tables...
>> log scanned up to (1671755)
160629 18:37:32  innobackupex: All tables locked and flushed to disk

160629 18:37:32  innobackupex: Starting to backup non-InnoDB tables and files
innobackupex: in subdirectories of '/u01/my3306/data'
innobackupex: Backing up files '/u01/my3306/data/mysql/*.{frm,isl,MYD,MYI,MAD,MAI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (74 files)
innobackupex: Backing up files '/u01/my3306/data/performance_schema/*.{frm,isl,MYD,MYI,MAD,MAI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (53 files)
innobackupex: Backing up file '/u01/my3306/data/test/t1.frm'
160629 18:37:33  innobackupex: Finished backing up non-InnoDB tables and files

160629 18:37:33  innobackupex: Waiting for log copying to finish

xtrabackup: The latest check point (for incremental): '1671755'
xtrabackup: Stopping log copying thread.
.>> log scanned up to (1671755)

xtrabackup: Creating suspend file '/backup/mysql/3306/2016-06-29_18-37-29/xtrabackup_log_copied' with pid '23161'
xtrabackup: Transaction log of lsn (1671755) to (1671755) was copied.
160629 18:37:34  innobackupex: All tables unlocked

innobackupex: Backup created in directory '/backup/mysql/3306/2016-06-29_18-37-29'
innobackupex: MySQL binlog position: filename 'binlog.000024', position 322
160629 18:37:34  innobackupex: Connection to database server closed
160629 18:37:34  innobackupex: completed OK!


10.确认备份

[mysql@xiangxingedu 2016-06-29_18-37-29]$ ll
total 49184
-rw-rw-r-- 1 mysql mysql      371 Jun 29 18:37 backup-my.cnf
-rw-rw---- 1 mysql mysql 33554432 Jun 29 18:37 ibdata1
-rw-rw---- 1 mysql mysql 16777216 Jun 29 18:37 ibdata2
drwx------ 2 mysql mysql     4096 Jun 29 18:37 mysql
drwxrwxr-x 2 mysql mysql     4096 Jun 29 18:37 performance_schema
drwx------ 2 mysql mysql     4096 Jun 29 18:37 test
-rw-rw-r-- 1 mysql mysql       13 Jun 29 18:37 xtrabackup_binary
-rw-rw-r-- 1 mysql mysql       20 Jun 29 18:37 xtrabackup_binlog_info
-rw-rw---- 1 mysql mysql       89 Jun 29 18:37 xtrabackup_checkpoints
-rw-rw---- 1 mysql mysql     2560 Jun 29 18:37 xtrabackup_logfile



  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值