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 ...
随机推荐
- system_call的处理过程
一. 跟踪time系统调用 使用gdb调试跟踪系统调用内核函数sys_time 过程如下: 对sys_time设置断点之后,在menuOS中执行time命令,发现系统停在systime处,输入S单步执 ...
- iOS- UITextField限制输入长度
限制输入长度的问题,在这里完美的解决了! //先创建一个textField 和 一个button. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...
- WampServe修改默认网站目录的方法(转)
1wamp简介 WampServe集成了Apache.MySQL.PHP.phpmyadmin,支持Apache的mod_rewrite,PHP扩展.Apache模块只需要在菜单“开启/关闭”上点点就 ...
- D - Half of and a Half 大数
D - Half of and a Half Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I ...
- C++ Primer : 第十四章 : 重载运算与类型转换之重载运算符
重载前须知 重载运算符是特殊的函数,它们的名字由operator和其后要重载的运算符号共同组成. 因为重载运算符时函数, 因此它包含返回值.参数列表和函数体. 对于重载运算符是成员函数时, 它的第一个 ...
- ajax 中$.each(json,function(index,item){ }); 中的2个参数表示什么意思?
$.each(json,function(index,item)里面的index代表当前循环到第几个索引,item表示遍历后的当前对象,比如json数据为:[{"name":&qu ...
- JSP知识点汇总
有几种方法可以实现服务器内部跳转? 使用request对象提供的方法:request.getRequestDispatcher(String URI).forward(ServletRequest r ...
- 黑马程序员——JAVA基础之正则表达式,网络爬虫
------Java培训.Android培训.iOS培训..Net培训.期待与您交流! ------- 正则表达式: 概念:用于操作字符串的符合一定规则的表达式 特点:用于一些特定的符号来表示一些代码 ...
- osip结构体
/** * Structure for SIP Message (REQUEST and RESPONSE). * @struct osip_message */ struct osip_messa ...
- android图像与图像处理系列(一、Bitmap和BitmapFactory)
1.Drawable对象 Android应用添加了Drawabe资源之后,Android SDK会为这份资源文件在R清单文件中创建一个索引项:R.drawable.file_name,接着我们可以在x ...