MYSQL 备份工具
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 备份工具的更多相关文章
- MySQL备份工具之mysqldump使用
MySQL备份工具之mysqldump使用说明 一.备份分类 根据能否停用数据库,将备份类型分为: 1. 冷备:数据库服务停止后备份 2. 温备:只能对数据库进行读操作,不能进行写操作 3. 热备:在 ...
- mysql备份工具innobackupex,xtrabackup-2.1的原理和安装
mysql备份工具innobackupex,xtrabackup-2.1的原理和安装 http://bbs.2cto.com/read.php?tid=310496 一.Xtrabackup介绍 1. ...
- Mysql备份工具xtraback全量和增量测试
Mysql备份工具xtraback全量和增量测试 xtrabackup 是 percona 的一个开源项目,可以热备份innodb ,XtraDB,和MyISAM(会锁表) 官方网址http:// ...
- Mysql备份工具比较
Mysql备份工具比较 大 | 中 | 小 [ 2012/12/25 12:10 | by Sonic ] 1. 使用automysqlbackup http://sourceforge.net/pr ...
- shell编写mysql备份工具
如需转载,请经本人同意. 这是之前写的一个备份脚本,调用的备份工具是xtrabackup 编写思路是:每周一全备份,备份后提取lSN号,对备份文件进行压缩,其余时候在LSN的基础上进行增量备份,并对3 ...
- mysql备份工具 :mysqldump mydumper Xtrabackup 原理
备份是数据安全的最后一道防线,对于任何数据丢失的场景,备份虽然不一定能恢复百分之百的数据(取决于备份周期),但至少能将损失降到最低.衡量备份恢复有两个重要的指标:恢复点目标(RPO)和恢复时间目标(R ...
- Mysql备份工具mysqldump和mysqlhotcopy
(1).Mysql备份类型 1)按照备份时对数据库的影响分为 Hot backup(热备):也叫在线备份.指在数据库运行中直接备份,对正在运行的数据库没有任何影响. Cold backup(冷备):也 ...
- mysql二进制日志和mysql备份工具介绍以及日志恢复
mysql备份: 三种备份方式 冷备:数据库停机,在进行备份 热备:lock table锁表,read 数据库只可以读不能写,在备份 温备:备份时数据库正常运行 备份类型:完整备份:全部备份,部分 ...
- Mysql备份工具Xtrabackup
Xtrabackup是一个开源的免费的热备工具,在Xtrabackup包中主要有Xtrabackup和innobackupex两个工具.其中Xtrabackup只能备份InnoDB和XtraDB两种引 ...
- MySQL备份工具percona-xtrabackup安装
1.安装xtrabackup的yum源 rpm -ivh https://www.percona.com/redir/downloads/percona-release/redhat/latest/p ...
随机推荐
- 对delegate进行扩展 打造通用的"计时完成"方法 z
让用户尽量少打字 每次让用户输入这么多信息的确很糟糕, 可以改进一下设计: 服务器IP和用户名可以存放在配置文件里面, 初始化的时候默认加载到相应的文本框中; 从安全角度考虑, 密码必须经过用户手动输 ...
- BufferedReader和BufferedWriter读写文件(转载)
http://375940084.blog.51cto.com/2581965/751040 1.创建Student类存储每个学生信息,属性(学号,姓名,出生日期,得分)2.从c:/test/stud ...
- bzoj 3439 Kpm的MC密码(Trie+dfs序+主席树)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=3439 [题意] 给定若干串,问一个串的作为其后缀的给定串集合中的第k小. [思路] 如 ...
- 内核源码分析之进程地址空间(基于3.16-rc4)
所谓进程的地址空间,指的就是进程的虚拟地址空间.当创建一个进程时,内核会为该进程分配一个线性的地址空间(虚拟地址空间),有了虚拟地址空间后,内核就可以通过页表将进程的物理地址地址空间映射到其虚拟地址空 ...
- C# 字符串格式
1.数字补零输出字符串 String.Format("{0:D6}",123); 2.字符串靠左输出6位 String.Format("{0,-6}",&quo ...
- mysql的point类型查询处理
mysql的point类型,很蛋疼的表示更习惯于key—value的lng,lat 假设不得不处理数据库字段poi是point类型,其中的数据为 : POINT(28.2789745229671 11 ...
- POJ 1287 Networking (最小生成树)
Networking 题目链接: http://acm.hust.edu.cn/vjudge/contest/124434#problem/B Description You are assigned ...
- POJ 1797 Heavy Transportation (dijkstra 最小边最大)
Heavy Transportation 题目链接: http://acm.hust.edu.cn/vjudge/contest/66569#problem/A Description Backgro ...
- 11235 - Frequent values
<算法竞赛入门经典-训练指南>P198 记录一下区间的左右边界就可以了 #include <iostream> #include <stack> #include ...
- uLua学习笔记(三):Unity3D和Lua之间的相互调用
这篇笔记主要集中学习一下uLua和Unity3D之间相互调用的方法,我们导入了uLua之后,现在会弹出一个类似学习屏幕的东西,如下: 先赞一个! Unity3D调用Lua Unity3D调用Lua的方 ...