xtrabackup备份与恢复实践
- 开源,在线备份innodb表
- 支持限速备份,避免对业务造成影响
- 支持流备
- 支持增量备份
- 支持备份文件压缩与加密
- 支持并行备份与恢复,速度快
- 基于innodb的crash-recovery功能
- 备份期间允许用户读写,写请求产生redo日志
- 从磁盘上拷贝数据文件
- 从innodb redo log file实时拷贝走备份期间产生的所有redo日志
- 恢复的时候 数据文件+redo日志 = 一致性数据
- 开源Perl脚本,封装调用xtrabackup及一系列相关工具与OS操作,最终完成备份过程
- 支持备份Innodb和其他引擎的表
- 备份一致性保证
- 全量备份
- 增量备份
- 流方式备份
- 并行备份
- 限流备份
- 压缩备份
- 常用参数介绍
aiapple@ubuntu:~$ innobackupex-1.5. --user=root --password= --defaults-file=/tmp/mysqldata/my.cnf dbbackup/ innobackupex-1.5.: Backup created in directory '/home/aiapple/dbbackup/2016-08-20_06-16-26'
innobackupex-1.5.: MySQL binlog position: filename 'mysql-bin.000001', position
:: innobackupex-1.5.: Connection to database server closed
:: innobackupex-1.5.: completed OK!
aiapple@ubuntu:~$ innobackupex-1.5. --user=root --password= --defaults-file=/tmp/mysqldata/my.cnf --incremental --incremental-dir dbbackup/--20_06--/ dbbackup/ innobackupex-1.5.: Backup created in directory '/home/aiapple/dbbackup/2016-08-20_06-24-08'
innobackupex-1.5.: MySQL binlog position: filename 'mysql-bin.000001', position
:: innobackupex-1.5.: Connection to database server closed
:: innobackupex-1.5.: completed OK! #备份成功
aiapple@ubuntu:~$ ls dbbackup/
--20_06-- --20_06--
aiapple@ubuntu:~$ innobackupex-1.5. --user=root --password= --defaults-file=/tmp/mysqldata/my.cnf --stream=xbstream dbbackup/ > dbbackup/stream.bak innobackupex-1.5.: Backup created in directory '/home/aiapple/dbbackup'
innobackupex-1.5.: MySQL binlog position: filename 'mysql-bin.000001', position
:: innobackupex-1.5.: Connection to database server closed
:: innobackupex-1.5.: completed OK! #备份成功
aiapple@ubuntu:~$ ls dbbackup/
--20_06-- --20_06-- stream.bak
aiapple@ubuntu:~$ innobackupex-1.5. --user=root --password= --defaults-file=/tmp/mysqldata/my.cnf --parallel= dbbackup/ innobackupex-1.5.: Backup created in directory '/home/aiapple/dbbackup/2016-08-20_06-36-34'
innobackupex-1.5.: MySQL binlog position: filename 'mysql-bin.000001', position
:: innobackupex-1.5.: Connection to database server closed
:: innobackupex-1.5.: completed OK! #备份成功
aiapple@ubuntu:~$ ls dbbackup/
--20_06-- --20_06-- --20_06-- stream.bak
aiapple@ubuntu:~$ innobackupex-1.5. --user=root --password= --defaults-file=/tmp/mysqldata/my.cnf --throttle= dbbackup/ innobackupex-1.5.: Backup created in directory '/home/aiapple/dbbackup/2016-08-20_06-38-26'
innobackupex-1.5.: MySQL binlog position: filename 'mysql-bin.000001', position
:: innobackupex-1.5.: Connection to database server closed
:: innobackupex-1.5.: completed OK! #备份成功
aiapple@ubuntu:~$ ls dbbackup/
--20_06-- --20_06-- stream.bak
--20_06-- --20_06--
aiapple@ubuntu:~$ innobackupex-1.5. --user=root --password= --defaults-file=/tmp/mysqldata/my.cnf --compress --compress-thread dbbackup/ innobackupex-1.5.: Backup created in directory '/home/aiapple/dbbackup/2016-08-20_06-40-26'
innobackupex-1.5.: MySQL binlog position: filename 'mysql-bin.000001', position
:: innobackupex-1.5.: Connection to database server closed
:: innobackupex-1.5.: completed OK! #备份成功
aiapple@ubuntu:~$ ls dbbackup/
--20_06-- --20_06-- --20_06--
--20_06-- --20_06-- stream.bak
innobackupex --help | less
mysql> show tables;
+--------------+
| Tables_in_tt |
+--------------+
| course |
| t1 |
+--------------+
rows in set (0.00 sec) aiapple@ubuntu:~$ innobackupex --user=root --password= --defaults-file=/tmp/mysqldata/my.cnf dbbackup/ #备份成功;
aiapple@ubuntu:~$ ls dbbackup/
--20_06--
mysql> drop table t1;
Query OK, rows affected (0.02 sec) mysql> show tables;
+--------------+
| Tables_in_tt |
+--------------+
| course |
+--------------+
row in set (0.00 sec)
aiapple@ubuntu:~$ innobackupex --apply-log dbbackup/--20_06-- InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number
:: innobackupex: completed OK!
aiapple@ubuntu:~/dbbackup/--20_06--$ ls
backup-my.cnf mysql xtrabackup_binlog_info
ibdata1 performance_schema xtrabackup_checkpoints
ib_logfile0 tt xtrabackup_logfile
ib_logfile1 xtrabackup_binary
aiapple@ubuntu:~/dbbackup$ innobackupex --defaults-file=/tmp/mysqldata/my.cnf --user=root --password= --copy-back --20_06--/ innobackupex-1.5.: Copying '/home/aiapple/dbbackup/2016-08-20_06-16-26/ib_logfile1' to '/tmp/mysqldata/node1/ib_logfile1'
innobackupex-1.5.: Finished copying back files.
:: innobackupex-1.5.: completed OK!
mysql> show tables;
+--------------+
| Tables_in_tt |
+--------------+
| course |
| t1 |
+--------------+
rows in set (0.00 sec)
mysql> show tables;
+--------------+
| Tables_in_tt |
+--------------+
| course |
| t1 |
+--------------+
rows in set (0.00 sec) mysql> create table zengliang(a int ,b int);
Query OK, rows affected (0.06 sec)
aiapple@ubuntu:~$ innobackupex --user=root --password= --defaults-file=/tmp/mysqldata/my.cnf --incremental --incremental-dir dbbackup/--20_06--/ dbbackup/ innobackupex-1.5.: MySQL binlog position: filename 'mysql-bin.000001', position
:: innobackupex-1.5.: Connection to database server closed
:: innobackupex-1.5.: completed OK!
aiapple@ubuntu:~$ ls dbbackup/
--20_06-- --20_06--
aiapple@ubuntu:~/dbbackup$ innobackupex --apply-log --redo-only --20_06--
aiapple@ubuntu:~/dbbackup$ innobackupex --apply-log --incremental-dir=(增量备份目录) (基础备份目录)
aiapple@ubuntu:~/dbbackup$ innobackupex --defaults-file=/tmp/mysqldata/my.cnf --user=root --password= --copy-back --20_06--/ innobackupex-1.5.: Copying '/home/aiapple/dbbackup/2016-08-20_06-16-26/ib_logfile1' to '/tmp/mysqldata/node1/ib_logfile1'
innobackupex-1.5.: Finished copying back files. :: innobackupex-1.5.: completed OK!
aiapple@ubuntu:~/dbbackup/mysql3309$ cat xtrabackup_binlog_info
mysql-bin.
aiapple@ubuntu:/tmp/mysqldata/node1$ mysqlbinlog -vv mysql-bin. | less
# at
# :: server id end_log_pos CRC32 0x683bcdc6 Query thread_id= exec_time= error_code=
SET TIMESTAMP=/*!*/;
insert into t6 values(,),(,),(,)
/*!*/;
# at
# :: server id end_log_pos CRC32 0xf264071a Xid =
COMMIT/*!*/;
# at
# :: server id end_log_pos CRC32 0x3f63ae99 Query thread_id= exec_time= error_code=
SET TIMESTAMP=/*!*/;
BEGIN
/*!*/;
# at
# :: server id end_log_pos CRC32 0x5c3b7667 Query thread_id= exec_time= error_code=
SET TIMESTAMP=/*!*/;
insert into t6 values(,),(,),(,)
/*!*/;
# at
# :: server id end_log_pos CRC32 0x4ea5c481 Xid =
COMMIT/*!*/;
aiapple@ubuntu:/tmp/mysqldata/node1$ mysqlbinlog -vv --start-position= --stop-position= mysql-bin. | mysql -uroot -p --socket=/home/aiapple/dbbackup/mysql3309/mysql.sock
aiapple@ubuntu:/tmp/mysqldata/node1$ mysqlbinlog -vv --start-datetime='2016-08-20 9:03:58' --stop-datetime='2016-08-20 9:11:51' mysql-bin. | cat
xtrabackup备份与恢复实践的更多相关文章
- RMAN备份与恢复实践(转)
1 RMAN备份与恢复实践 1.1 备份 1.1.1 对数据库进行全备 使用backup database命令执行备份 RMAN> BACKUP DATABASE; 执行上述命令后将对目标 ...
- MySQL入门篇(七)之Xtrabackup备份与恢复
一.Xtrabackup介绍 MySQL冷备.mysqldump.MySQL热拷贝都无法实现对数据库进行增量备份.在实际生产环境中增量备份是非常实用的,如果数据大于50G或100G,存储空间足够的情况 ...
- Xtrabackup备份与恢复MySQL
1.innobackupex备份原理 .innobackupex启动并fork一个进程启动xtrabackup,然后等待xtrabackup备份InnoDB文件; .xtrabackup备份时存在两个 ...
- Xtrabackup备份与恢复
一.Xtrabackup介绍 MySQL冷备.mysqldump.MySQL热拷贝都无法实现对数据库进行增量备份.在实际生产环境中增量备份是非常实用的,如果数据大于50G或100G,存储空间足够的情况 ...
- 16、Xtrabackup备份与恢复
XTRABACKUP xtrabackup是percona公司开发的第三方备份软件,只备份innodb引擎表的ibd文件(frm不备份),不备份myisam引擎表.备份性能很高,备份期间没有任和锁,d ...
- XtraBackup 备份与恢复实例讲解
前一篇文章我们讲到了PXB的原理以及安装方法,接下来将详细介绍 XtraBackup 备份和恢复的具体过程. xtrabackup 选项 xtrabackup 工具有许多参数,具体可去官网查询(xtr ...
- KubeSphere 日志备份与恢复实践
为什么需要日志备份 KubeSphere 日志系统使用 Fluent Bit + ElasticSearch 的日志采集存储方案,并通过 Curator 实现对 Index 的生命周期管理,定期清理久 ...
- xtrabackup 备份与恢复
书上摘抄 ---深入浅出mysql 448页 grant reload on *.* to 'backup'@'localhost' identified by '123456'; grant re ...
- mysql 开发进阶篇系列 46 物理备份与恢复( xtrabackup的 选项说明,增加备份用户,完全备份案例)
一. xtrabackup 选项说明 在操作xtrabackup备份与恢复之前,先看下该工具的选项,下面记录了xtrabackup二进制文件的部分命令行选项,后期把常用的选项在补上.点击查看xtrab ...
随机推荐
- python数据结构与算法——图的最短路径(Floyd-Warshall算法)
使用Floyd-Warshall算法 求图两点之间的最短路径 不允许有负权边,时间复杂度高,思路简单 # 城市地图(字典的字典) # 字典的第1个键为起点城市,第2个键为目标城市其键值为两个城市间的直 ...
- H5 认识canvas
不同于SVG,HTML中的元素canvas只支持一种原生的图形绘制:矩形.所有其他的图形的绘制都至少需要生成一条路径.不过,我们拥有众多路径生成的方法让复杂图形的绘制成为了可能. canvas提供了三 ...
- 修改MySQL用户的密码
=====知道当前用户密码时===== P.S.:此文只针对windows下的用户密码更改. 1.使用进入MySQL的bin文件夹下: cd path\to\bin\mysqladmin.exe 2. ...
- 快速开发CSS的利器-LESS
快速开发CSS的利器-LESS? 天下功夫,唯快不破!效率,在项目开发上,这是极其重要的.要做到快.精.准,在人任何时候都不是一件轻松容易的事.但是如果借助一些相应的工具,那就另当别论了!那么要想快速 ...
- ooize节点的属性控制
<workflow-app name="[WF-DEF-NAME]" xmlns="uri:oozie:workflow:[version]"> & ...
- Python asyncio库的学习和使用
因为要找工作,把之前自己搞的爬虫整理一下,没有项目经验真蛋疼,只能做这种水的不行的东西...T T,希望找工作能有好结果. 之前爬虫使用的是requests+多线程/多进程,后来随着前几天的深入了解 ...
- 认识C++中的临时对象temporary object 分类: C/C++ 2015-05-11 23:20 137人阅读 评论(0) 收藏
C++中临时对象又称无名对象.临时对象主要出现在如下场景. 1.建立一个没有命名的非堆(non-heap)对象,也就是无名对象时,会产生临时对象. Integer inte= Integer(5); ...
- C# 中Join( )的理解
在MSDN中对Join( )的解释比较模糊:在继续执行标准的 COM 和 SendMessage 消息泵处理期间,阻塞调用线程(线程A),直到某个线程终(线程B)止为止. 首先来看一下有关的概念: 我 ...
- Python decode与encode
字符串在Python内部的表示是unicode编码(8-bit string),因此,在做编码转换时,通常需要以unicode作为中间编码,即先将其他编码的字符串解码(decode)成unicod ...
- .Net 请求Web接口Post和Get方法
#region web服务请求 get post static string DefaultUserAgent = "www.zhiweiworld.com"; public st ...