percona_xtrabackup
原理
percona xtrabackup备份过程主要分为以下几点:
1、xtrabackup在启动时会记住LSN(log sequence number),然后复制所有的数据文件
2、xtrabackup会运行一个后台进程,用于监控事务日志(redo.log),并从事务日志中复制最新的修改
3、准备过程(prepare),xtrabackup使用之前复制的事务日志,对各个数据文件执行灾难恢复
4、执行flush tables with read lock来阻止新的写入进来,并把MyISAM表数据刷写到硬盘上,之后复制MyISAM数据文件,最后释放锁。
其中1-3步骤是xtrabackup来实现,第4步由innobackupex来实现。
备份MyISAM和Innodb表最终会处于一致,在prepare过程结束后,Innodb表数据已经前滚到整个备份数据结束的点,而不是回滚到xtrabackuo刚开始的点。
通过复制数据文件、日志文件和提交日志到数据文件(前滚)实现各种复合备份方式。
innobackupex备份对MyISAM表之前要对全库进行加READ LOCK,阻塞写操作,对Innodb表备份不会阻塞读写。
备份演练
、创建备份目录
mkdir -p /data1/backup 、拷贝全量数据
innobackupex --defaults-file=/data1/mysql6011/my6011.cnf --user=root --password='xxx' --tmpdir=/data1/tmp/ --socket=/tmp/mysql6011.sock --no-timestamp --slave-info /data1/backup/mysql6011 > innobackupex.log >& 注意点:
a、设置tmp为目录较大的位置
b、设置no-timestamp,否则以时间作为前缀
c、设置备份的目录,/data1/backup先提前创建好,然后再以mysql6011作为备份的目录名称
d、配置文件中character_set_client=utf8,导致错误 、拷贝配置文件到另一台机器上 4、回放redolog(apply-log)
如果给主库搭建从库:
http://www.percona.com/doc/percona-xtrabackup/2.1/howtos/setting_up_replication.html
binlog点的位置为xtrabackup_binlog_info文件中
apply-log产生的日志:
[root@eos177 data1]# innobackupex -defaults-file=/data1/mysql6011/my6011.cnf --apply-log /data1/mysql6011/ InnoDB Backup Utility v1.5.1-xtrabackup; Copyright , Innobase Oy
and Percona Inc -. All Rights Reserved. This software is published under
the GNU GENERAL PUBLIC LICENSE Version , June . IMPORTANT: Please check that the apply-log run completes successfully.
At the end of a successful apply-log run innobackupex
prints "completed OK!". :: innobackupex: Starting ibbackup with command: xtrabackup_55 --defaults-file="/data1/mysql6011/my6011.cnf" --prepare --target-dir=/data1/mysql6011 xtrabackup_55 version 1.6. for Percona Server 5.5. Linux (x86_64) (revision id: )
xtrabackup: cd to /data1/mysql6011
xtrabackup: This target seems to be not prepared yet.
xtrabackup: xtrabackup_logfile detected: size=, start_lsn=()
xtrabackup: Temporary instance for recovery is set as followings.
xtrabackup: innodb_data_home_dir = ./
xtrabackup: innodb_data_file_path = ibdata1:100M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group =
xtrabackup: innodb_log_file_size =
:: InnoDB: Using Linux native AIO
xtrabackup: Starting InnoDB instance for recovery.
xtrabackup: Using bytes for buffer pool (set by --use-memory parameter)
:: InnoDB: The InnoDB memory heap is disabled
:: InnoDB: Mutexes and rw_locks use GCC atomic builtins
:: InnoDB: Compressed tables use zlib 1.2.
:: InnoDB: Using Linux native AIO
:: InnoDB: Warning: innodb_file_io_threads is deprecated. Please use innodb_read_io_threads and innodb_write_io_threads instead
:: InnoDB: Initializing buffer pool, size = 100.0M
:: InnoDB: Completed initialization of buffer pool
:: InnoDB: highest supported file format is Barracuda.
InnoDB: Log scan progressed past the checkpoint lsn
:: InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Doing recovery: scanned up to log sequence number ( %)
:: InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents:
InnoDB: Apply batch completed
InnoDB: Last MySQL binlog file position , file name ./mysql-bin.
:: InnoDB: Waiting for the background threads to start
:: Percona XtraDB (http://www.percona.com) 1.1.5-20.0 started; log sequence number 37043837591 [notice (again)]
If you use binary log and don't use any hack of group commit,
the binary log position seems to be:
InnoDB: Last MySQL binlog file position , file name ./mysql-bin. xtrabackup: starting shutdown with innodb_fast_shutdown =
:: InnoDB: Starting shutdown...
:: InnoDB: Shutdown completed; log sequence number :: innobackupex: Restarting xtrabackup with command: xtrabackup_55 --defaults-file="/data1/mysql6011/my6011.cnf" --prepare --target-dir=/data1/mysql6011
for creating ib_logfile* xtrabackup_55 version 1.6. for Percona Server 5.5. Linux (x86_64) (revision id: )
xtrabackup: cd to /data1/mysql6011
xtrabackup: This target seems to be already prepared.
xtrabackup: notice: xtrabackup_logfile was already used to '--prepare'.
xtrabackup: Temporary instance for recovery is set as followings.
xtrabackup: innodb_data_home_dir = ./
xtrabackup: innodb_data_file_path = ibdata1:100M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group =
xtrabackup: innodb_log_file_size =
:: InnoDB: Using Linux native AIO
xtrabackup: Starting InnoDB instance for recovery.
xtrabackup: Using bytes for buffer pool (set by --use-memory parameter)
:: InnoDB: The InnoDB memory heap is disabled
:: InnoDB: Mutexes and rw_locks use GCC atomic builtins
:: InnoDB: Compressed tables use zlib 1.2.
:: InnoDB: Using Linux native AIO
:: InnoDB: Warning: innodb_file_io_threads is deprecated. Please use innodb_read_io_threads and innodb_write_io_threads instead
:: InnoDB: Initializing buffer pool, size = 100.0M
:: InnoDB: Completed initialization of buffer pool
:: InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Progress in MB:
:: InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Progress in MB:
:: InnoDB: Log file ./ib_logfile2 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile2 size to MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Progress in MB:
:: InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
:: InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Last MySQL binlog file position , file name ./mysql-bin.
:: InnoDB: Waiting for the background threads to start
:: Percona XtraDB (http://www.percona.com) 1.1.5-20.0 started; log sequence number 37043847180 [notice (again)]
If you use binary log and don't use any hack of group commit,
the binary log position seems to be:
InnoDB: Last MySQL binlog file position , file name ./mysql-bin. xtrabackup: starting shutdown with innodb_fast_shutdown =
:: InnoDB: Starting shutdown...
:: InnoDB: Shutdown completed; log sequence number
:: innobackupex: completed OK!
copy-back
innobackupex: Error: Original data directory '/data1/mysql6011' does not exist! at /etc/dbCluster/innobackupex line .
[root@eos177 data1]# innobackupex -defaults-file=/data1/backup/mysql6011/my6011.cnf /data1/backup/mysql6011 --copy-back InnoDB Backup Utility v1.5.1-xtrabackup; Copyright , Innobase Oy
and Percona Inc -. All Rights Reserved. This software is published under
the GNU GENERAL PUBLIC LICENSE Version , June . IMPORTANT: Please check that the copy-back run completes successfully.
At the end of a successful copy-back run innobackupex
prints "completed OK!". innobackupex: Starting to copy MyISAM tables, indexes,
innobackupex: .MRG, .TRG, .TRN, .ARM, .ARZ, .CSM, .CSV, .opt, and .frm files
innobackupex: in '/data1/backup/mysql6011'
innobackupex: back to original data directory '/data1/mysql6011'
innobackupex: Copying directory '/data1/backup/mysql6011/performance_schema'
innobackupex: Copying file '/data1/backup/mysql6011/xtrabackup_checkpoints'
innobackupex: Copying file '/data1/backup/mysql6011/xtrabackup_slave_info'
innobackupex: Copying directory '/data1/backup/mysql6011/mysql'
innobackupex: Copying file '/data1/backup/mysql6011/xtrabackup_binary'
innobackupex: Copying file '/data1/backup/mysql6011/xtrabackup_binlog_info'
innobackupex: Copying directory '/data1/backup/mysql6011/zjmdmm'
innobackupex: Copying file '/data1/backup/mysql6011/my6011.cnf'
innobackupex: Copying directory '/data1/backup/mysql6011/elink'
innobackupex: Copying file '/data1/backup/mysql6011/xtrabackup_binlog_pos_innodb'
innobackupex: Copying directory '/data1/backup/mysql6011/test' innobackupex: Starting to copy InnoDB tables and indexes
innobackupex: in '/data1/backup/mysql6011'
innobackupex: back to original InnoDB data directory '/data1/mysql6011'
innobackupex: Copying file '/data1/backup/mysql6011/ibdata1' innobackupex: Starting to copy InnoDB log files
innobackupex: in '/data1/backup/mysql6011'
innobackupex: back to original InnoDB log directory '/data1/mysql6011'
innobackupex: Copying file '/data1/backup/mysql6011/ib_logfile0'
innobackupex: Copying file '/data1/backup/mysql6011/ib_logfile2'
innobackupex: Copying file '/data1/backup/mysql6011/ib_logfile1'
innobackupex: Finished copying back files. :: innobackupex: completed OK!
使用xtrabackup进行备份数据的压缩和加密
percona_xtrabackup的更多相关文章
随机推荐
- Java视频扩展知识 线程池的了解
Java视频扩展知识 线程池的了解 1.简单介绍: Jdk1.5之后加入了java.util.concurrent包,这个包中主要介绍java中线程以及线程池的使用.为我们在开发中处理线程的 ...
- flex的三个属性:
(1)flex-grow:指的是相对于其他的子元素的扩展比率:默认值为0:数字 (2)flex-basis:指的是子元素的具体长度:可以为长度(rem,px,em)也可以为百分比: (3)flex-s ...
- HttpHelper类使用方法
HttpHelper http = new HttpHelper(); HttpItem item = new HttpItem() { URL = "http://www.sufeinet ...
- 【学习】文本框输入监听事件oninput
真实项目中遇到的,需求是:一个文本框,一个按钮,当文本框输入内容时,按钮可用,当删除内容时,按钮不可用. 刚开始用的focus和blur, $(".pay-text").focus ...
- Django自定义过滤器中is_safe和need_autoescape两个参数的理解
自定义template过滤器的方法参考文档,不再赘述 is_safe 文档说明过滤的两种最终形态,其中一种是设置register.filter(is_safe=True),但是对is_safe的具体作 ...
- 转:扩展方法(C# 编程指南)
扩展方法使你能够向现有类型“添加”方法,而无需创建新的派生类型.重新编译或以其他方式修改原始类型.扩展方法是一种特殊的静态方法,但可以像扩展类型上的实例方法一样进行调用.对于用 C# 和 Visual ...
- 为UWP应用开启回环访问权限
最近在项目中遇到UWP调用WCF的需求,考虑到UWP不能寄宿WCF服务(如果能,或者有类似技术,请告知),于是写了一个WPF程序寄宿WCF服务,然后再用UWP调用服务. 写的时候并没有碰到什么问题,直 ...
- C#实现局域网内远程开机
1.远程开机原理 远程开机Wake on LAN(WOL),俗称远程唤醒,远程唤醒的实现主要是向目标主机发送特殊格式的数据包,是AMD公司制作的MagicPacket这套软件以生成网络唤醒所需要的特殊 ...
- 自学LinkedBlockingQueue源码
自学LinkedBlockingQueue源码 参考:http://www.jianshu.com/p/cc2281b1a6bc 本文需要关注的地方 生产者-消费者模式好处: 读取和插入操作所使用的锁 ...
- Hadoop(十七)之MapReduce作业配置与Mapper和Reducer类
前言 前面一篇博文写的是Combiner优化MapReduce执行,也就是使用Combiner在map端执行减少reduce端的计算量. 一.作业的默认配置 MapReduce程序的默认配置 1)概述 ...