backup of a database is a very important thing. If no backup, meet the following situation goes crazy:

  UPDATE or DELETE whitout where…

  table was DROPPed accidentally…

  INNODB was corrupt…

  entire datacenter loses power…

  Data from the safety point of view, the server disk will do raid, MySQL itself also has a master-slave, DRBD disaster recovery mechanism, but they are not completely replace the backup. Fault tolerance and high availability can help us deal with physical, hardware, machinery, and logic errors on our committed but incapable of action. The probability of each logical errors are very low, but when the various possibilities of superposition, the small probability event is enlarged into a great safety hidden trouble, this time need backup highlights. So in many ways the MySQL backup, which is suitable for us?

 Backup common

  MySQL itself provides us with mysqldump, mysqlbinlog remote backup tool, Percona also provides powerful Xtrabackup for us, With the open source mydumper, And based on the master-slave synchronization delay from the library backup, cold standby mode, And based on the file system snapshot backup, In fact, the choice has much to see things in a blur. While the backup is in order to recover, so that we can backup mode after a failure occurs rapidly, accurately and recovery, is the most suitable for us, of course, also can save money, save trouble, it is perfect. Several backup tools here I understand some comparison, discuss their applicable scene.

  1. mysqldump & mydumper

  Mysqldump is a logical backup method is the most simple. When the backup MyISAM table, if you want to obtain consistent data, you need to lock table, simple and rude. And when the backup InnoDB table, With – master-data=1 – the single-transaction option, Beginning in the transaction, Record binlog POS, Then use mvcc to obtain consistent data, Because it is a long transaction, In the write and update of large quantity of database, Will have a lot of undo, Significant performance impact, It should be used with caution.

  • Advantages: simple, for single table backup, especially useful when the total amount of export structure.
  • Disadvantages: simple and crude, single threaded, backup and recovery slow slow, span of IDC are likely to encounter the time zone. 
    Mydumper is an enhanced version of the mysqldump. Compared with mysqldump:
  • Built-in support for compression, can save storage space of 2-4 times.
  • Parallel backup and recovery, so a lot faster than mysqldump, but because it is a logical backup, still not very fast.

  2 the snapshot file system based on

  The snapshot based on file system, is a physical backup. In the backup before the need for some complex settings, in the backup time get the snapshot and record binlog POS, then the copy-on-write like mode, the snapshot dump. Dump the snapshot itself will consume some IO resources, but also in the writing case pressure, save the changes to the data block before the impression will consume IO, finally showed a decline in the overall performance of the. And the server and copy-on-write snapshots allow more disk space, which in itself is a waste of resources. This backup methods we use no more.

  3. Xtrabackup

  This is probably the most widely backup mode. Percona is make known to every family, Xtrabackup should not. It is actually the combination of physical backup, logical backup. When the backup InnoDB table, it copies the IBD file, and change constantly monitors the redo log, append to their transaction log files. In the process of copying IBD files, IBD files may be written "flower", this is not a problem, because the first prepare stage in the copy after the completion of the Xtrabackup, by a similar method to the InnoDB crash recovery, to restore data files and log files consistent state, and the transaction is rolled back the uncommitted. If at the same time the need to backup MyISAM and file InnoDB table structure, then need to use the flush tables with lock to obtain the global lock, began to copy these files no longer changes, at the same time to obtain binlog location, copy after release the lock, and stop the redo log monitor. 
It works as follows:

  Because MySQL is inevitably contains the MyISAM table, At the same time, innobackup is not a backup file table structure, So you want to backup the MySQL instance, Will not have to execute flush tables with read lock, This statement will be any query (including select) obstruction, During a jam, It in turn blocking any query (including select). If you happen to back up the instance is executed before flush tables with read lock query, database hang. When flush tables with read lock to obtain the global lock, although the query can be executed, but still blocking update, so, we hope that flush tables with read lock from the beginning to the end, the duration of the shorter the better.

  In order to solve this problem, two methods are effective:

  1 as far as possible without MyISAM table.

  2 Xtrabackup increase – Rsync options, to reduce holdings of global locking time by two Rsync.

  The backup process optimized as follows:

  • Advantages: online hot backup, all increased by + + flow speed, support, support compression, encryption is supported.
  • Disadvantages: the need to obtain a global lock, if meet the query, the waiting time is not controllable, so to do a good job monitoring, kill the long queries or Dutch act when necessary; encountered large examples, the backup process is longer, redo log is the effect of the recovery rate, in this case the best delay backup.

  4. mysqlbinlog 5.6

  All the above backup, only to recover the database to a point in time the backup: mysqldump and mydumper, and snapshot is a backup starting time; Xtrabackup is the backup end point in time. In order to realize the point in time recovery, must also backup binlog. At the same time, binlog is also the precious resources increased by.

  Fortunately, MySQL 5.6 offers binlog remote backup options:

  mysqlbinlog --raw --read-from-remote-server --stop-never

  It will be disguised as a MySQL from the database, obtaining binlog from a remote and then dump. This is not on the line capacity cannot save more binlog scene is very useful. However, it is after all not a true MySQL from the database instance, state monitoring and synchronization requires a separate deployment. So personally think that using Blackhole to backup the full amount of binlog is the better choice. The author has implemented an automated build Blackhole from the database tools, slightly modified, can perfect build Blackhole from the library. Once the basic synchronous up, put things right once and for all, little problems, when the switch with cut on the line.

  Prompt:

  • Don't underestimate binlog backup. When 5.6 of the multithreading replication large-scale use, from the library after the main library command point of time will be greatly reduced, so we put every day a full backup to once every 3 days, and weekly full backup, incremental backup and persistent binlog. When a failure to recover the data, reproducing 3, 5 days binlog is extremely fast. Reduce the benefits of backup frequency is the most direct, save money, save trouble.
  • Blackhole is excellent for backup binlog. On the one hand can be used to recover the database backup binlog for a long time, on the other hand, in the semi synchronous replication, which can effectively prevent the main library binlog is missing.

 Summary

  Each has its own merits. backup mode, and to us, in the face of thousands of examples, select the appropriate backup tool to achieve unified configuration, unified planning, construction of backup cloud platform of intelligent scheduling is the kingly way. After all, cost of operation and maintenance of coexistence of multiple backup modes can not be ignored.

  From experience, with Xtrabackup full data, preparation of binlog by Blackhole enrichment, and regularly on the effectiveness of the backup data to verify, is the good choice.

MYSQL 备份工具的更多相关文章

  1. MySQL备份工具之mysqldump使用

    MySQL备份工具之mysqldump使用说明 一.备份分类 根据能否停用数据库,将备份类型分为: 1. 冷备:数据库服务停止后备份 2. 温备:只能对数据库进行读操作,不能进行写操作 3. 热备:在 ...

  2. mysql备份工具innobackupex,xtrabackup-2.1的原理和安装

    mysql备份工具innobackupex,xtrabackup-2.1的原理和安装 http://bbs.2cto.com/read.php?tid=310496 一.Xtrabackup介绍 1. ...

  3. Mysql备份工具xtraback全量和增量测试

    Mysql备份工具xtraback全量和增量测试   xtrabackup 是 percona 的一个开源项目,可以热备份innodb ,XtraDB,和MyISAM(会锁表) 官方网址http:// ...

  4. Mysql备份工具比较

    Mysql备份工具比较 大 | 中 | 小 [ 2012/12/25 12:10 | by Sonic ] 1. 使用automysqlbackup http://sourceforge.net/pr ...

  5. shell编写mysql备份工具

    如需转载,请经本人同意. 这是之前写的一个备份脚本,调用的备份工具是xtrabackup 编写思路是:每周一全备份,备份后提取lSN号,对备份文件进行压缩,其余时候在LSN的基础上进行增量备份,并对3 ...

  6. mysql备份工具 :mysqldump mydumper Xtrabackup 原理

    备份是数据安全的最后一道防线,对于任何数据丢失的场景,备份虽然不一定能恢复百分之百的数据(取决于备份周期),但至少能将损失降到最低.衡量备份恢复有两个重要的指标:恢复点目标(RPO)和恢复时间目标(R ...

  7. Mysql备份工具mysqldump和mysqlhotcopy

    (1).Mysql备份类型 1)按照备份时对数据库的影响分为 Hot backup(热备):也叫在线备份.指在数据库运行中直接备份,对正在运行的数据库没有任何影响. Cold backup(冷备):也 ...

  8. mysql二进制日志和mysql备份工具介绍以及日志恢复

    mysql备份: 三种备份方式 冷备:数据库停机,在进行备份 热备:lock table锁表,read   数据库只可以读不能写,在备份 温备:备份时数据库正常运行 备份类型:完整备份:全部备份,部分 ...

  9. Mysql备份工具Xtrabackup

    Xtrabackup是一个开源的免费的热备工具,在Xtrabackup包中主要有Xtrabackup和innobackupex两个工具.其中Xtrabackup只能备份InnoDB和XtraDB两种引 ...

  10. MySQL备份工具percona-xtrabackup安装

    1.安装xtrabackup的yum源 rpm -ivh https://www.percona.com/redir/downloads/percona-release/redhat/latest/p ...

随机推荐

  1. hdu 3746 Cyclic Nacklace(KMP)

    题意: 求最少需要在后面补几个字符能凑成两个循环. 分析: 最小循环节的应用,i-next[i]为最小循环节. #include <map> #include <set> #i ...

  2. strcasecmp在VS2010中提示未定义标识符

    分析: strcasecmp(*,*)是用来比较字符串,定义在string.h头文件中,但是在windows下即使添加string.h头文件,依然会报错. 解决: 添加 #if defined(_MS ...

  3. ASP.net MVC基础

    简单了解了下MVC的基本开发步骤后,又对MVC的语法和模版详细看看了,小小总结下 对mvc开发,首先是要对布局有个基本的认识.Razor引擎使页面元素更加清晰 简单认识下 可以加载css和js等文件, ...

  4. 如何用chrome修改js代码,跳过网站等待时间

    用chrome修改js代码 By Z.H. Fu 切问录 [maplewizard.github.io](http://maplewizard.github.io ) 网页中大部分的限制都是由js编写 ...

  5. leetcode—sqrt

    1.题目描述   Implement int sqrt(int x).   Compute and return the square root of x. 2.解法分析 很明显,用二分搜索可解,但是 ...

  6. Nuttx操作系统

    前几天答辩的时候看到有同学在用,回来后查了点资料. 来源:天又亮了 1  NuttX 实时操作系统 NuttX 是一个实时操作系统(RTOS),强调标准兼容和小型封装,具有从8位到32位微控制器环境的 ...

  7. 取消本地SVN文件夹与服务器关联

    问题:之前建了一个SVN代码库,同步了代码上去,但中途发现建库时的规则搞错了,就把服务器上的库给删了重建,然后改变本地代码的svn服务器关联地址,但使用Relocate一直报错. 错误有两种情况:1. ...

  8. 转】Maven学习总结(二)——Maven项目构建过程练习

    原博文出自于:http://www.cnblogs.com/xdp-gacl/p/4051690.html 感谢! 上一篇只是简单介绍了一下maven入门的一些相关知识,这一篇主要是体验一下Maven ...

  9. 报表服务框架:WEB前端UI

    1.Highcharts 2.ECharts 3.ichartjs 参考: http://v1.hcharts.cn/index.php http://echarts.baidu.com/ http: ...

  10. springboot+maven快速构建项目

    最近公司运用springboot构建项目,确实比ssh搭建要快很多.springboot官方学习网站 1.首先要下载maven,用maven管理项目很方便,下载完maven配置好环境,maven我就不 ...