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. Period(KMP,循环节问题)

    题意: 求给你个串,前i位子串由某个字符串重复k次得到,求所有的i和k 分析: i-next[i]恰好是一个循环节 #include <map> #include <set> ...

  2. C#条件语句、循环语句

    一.程序的三种结构 顺序结构 分支结构 循环结构 二.条件语句if 语句是最有用的控制结构之一. if … else …语句的语法: if (布尔表达式)执行操作的语句  或if (布尔表达式)执行操 ...

  3. 二分+最短路 uvalive 3270 Simplified GSM Network(推荐)

    // 二分+最短路 uvalive 3270 Simplified GSM Network(推荐) // 题意:已知B(1≤B≤50)个信号站和C(1≤C≤50)座城市的坐标,坐标的绝对值不大于100 ...

  4. 二分+叉积判断方向 poj 2318 2398

    // 题意:问你每个区域有多少个点 // 思路:数据小可以直接暴力 // 也可以二分区间 #include <cstdio> #include <cstring> #inclu ...

  5. bash里,echo对换行符的处理

    echo -e "#include <stdio.h>\nint main()\n{\n printf(\"hello world\\\n\");\n ret ...

  6. java类加载与初始化

    第一段: class A{ public A(){ this.list(); } public void list(){ System.out.println("in a list..&qu ...

  7. HDU 5816 Hearthstone (状压DP)

    Hearthstone 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5816 Description Hearthstone is an onlin ...

  8. POJ 1251 && HDU 1301 Jungle Roads (最小生成树)

    Jungle Roads 题目链接: http://acm.hust.edu.cn/vjudge/contest/124434#problem/A http://acm.hust.edu.cn/vju ...

  9. STM32的GPIO使用的函数剖析

    转载http://blog.csdn.net/wuwuhuizheyisheng/article/details/8239599 STM32的GPIO总结 作者:JCY 该文是自己学习了一段STM32 ...

  10. rop框架签名功能控制

    平台级控制: 通过<rop:annotation-driven/>的 sign-enable 属性即可开启或关闭服务平台签名验证功能:<rop:annotation-driven s ...