`
hupy
  • 浏览: 186882 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

使用Xtrabackup备份MySQL数据库

阅读更多

MySQL数据库的备份,一直是个比较头痛的问题。各种工具虽然不少,但一个真正好用易用的,却又非常难找。Mysqldump做为数据的逻辑备份工具还行,但是无法进行在线热备,而没有物理备份工具,在数据量比较大的时候,恢复的时间也会长得无法接受。InnoDB倒是有个商业的InnoDB Hotbackup,可以对InnoDB引擎的表实现在线热备。最近发现了一个工具,percona出品的Xtrabackup,是InnoDB Hotbackup的一个开源替代品,可以在线对InnoDB/XtraDB引擎的表进行物理备份,试用了一下,非常的不错,值得向MySQL DBA们推荐。

下面是一个实际备份的例子,采用了gzip将备份流进行压缩,约20GB的数据库,压缩后大小为340MB,当然,压缩后的大小跟数据库中实际使用的空间是相关的。备份时间约6分44秒。

innobackupex是参考了InnoDB Hotbackup的innoback脚本修改而来的,主要是为了方便的同时备份InnoDB和MyISAM引擎的表,并且加入了一些使用的选项。如 –slave-info可以记录备份恢复后,作为slave需要的一些信息,根据这些信息,可以很方便的利用备份来重做slave。

注意,从备份后的tar包解包的时候,需要使用-i参数。最新发布的是0.7版,猛击这里下载

MySQL DBA们,你是如何做备份的呢?欢迎到这里探讨

$innobackupex-1.5.1 --user=root --stream=tar /bak/ --slave-info | gzip > /bak/bak_mysql.tar.gz

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy.
All Rights Reserved.

This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.

IMPORTANT: Please check that the backup run completes successfully.
           At the end of a successful backup run innobackup
           prints "innobackup completed OK!".

innobackupex: Using mysql  Ver 14.12 Distrib 5.0.67, for redhat-linux-gnu (x86_64)
 using  EditLine wrapper
innobackupex: Using mysql server version 5.0.67-log

innobackupex: Created backup directory /bak
090625 15:23:00  innobackupex: Starting mysql with options: --unbuffered --user=root
090625 15:23:00  innobackupex: Connected to database with mysql child process (pid=3431)
090625 15:23:04  innobackupex: Connection to database server closed

090625 15:23:04  innobackupex: Starting ibbackup with command:
xtrabackup --backup --suspend-at-end --log-stream --target-dir=./
innobackupex: Waiting for ibbackup (pid=3565) to suspend
innobackupex: Suspend file '/opt/mysqldata/xtrabackup_suspended'

xtrabackup: suspend-at-end is enabled.
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /opt/mysqldata
xtrabackup: Target instance is assumed as followings.
xtrabackup:   innodb_data_home_dir = /opt/mysqldata
xtrabackup:   innodb_data_file_path = ibdata1:10G;ibdata2:10G
xtrabackup:   innodb_log_group_home_dir = ./
xtrabackup:   innodb_log_files_in_group = 4
xtrabackup:   innodb_log_file_size = 104857600
xtrabackup: use O_DIRECT
xtrabackup: Stream mode.
>> log scanned up to (0 3053406941)

090625 15:23:06  innobackupex: Continuing after ibbackup has suspended

innobackupex: Starting to backup InnoDB tables and indexes
innobackupex: from original InnoDB data directory '/opt/mysqldata'
innobackupex: Backing up as tar stream 'ibdata1'
>> log scanned up to (0 3053416714)
...这里省略若干行
>> log scanned up to (0 3054123851)
tar: ibdata1: file changed as we read it
innobackupex: Backing up as tar stream 'ibdata2'
>> log scanned up to (0 3054142116)
...这里省略若干行
>> log scanned up to (0 3054618483)
innobackupex: Backing up file '/opt/mysqldata/test/sp.ibd'
innobackupex: Backing up file '/opt/mysqldata/test/tmp_dy.ibd'
innobackupex: Backing up files '/opt/mysqldata/testdb/*.ibd' (206 files)
>> log scanned up to (0 3054638401)
>> log scanned up to (0 3054668860)
tar: testdb/group_group_thread_0027.ibd: file changed as we read it
>> log scanned up to (0 3054695015)
>> log scanned up to (0 3054928216)
tar: testdb/group_thread_reply_0007.ibd: file changed as we read it
>> log scanned up to (0 3054952588)
>> log scanned up to (0 3055005439)
tar: testdb/group_user_0001.ibd: file changed as we read it
>> log scanned up to (0 3055028610)
>> log scanned up to (0 3055044650)
tar: testdb/group_user_0006.ibd: file changed as we read it
>> log scanned up to (0 3055060461)
innobackupex: Backing up file '/opt/mysqldata/testdb/comments.ibd'
innobackupex: Backing up file '/opt/mysqldata/testdb/testdb.ibd'
innobackupex: Backing up file '/opt/mysqldata/testdb/testdb_content.ibd'
innobackupex: Backing up file '/opt/mysqldata/testdb/testdb_ids.ibd'
090625 15:29:17  innobackupex: Starting mysql with options: --unbuffered --user=root
090625 15:29:17  innobackupex: Connected to database with mysql child process (pid=5458)
>> log scanned up to (0 3055072495)
090625 15:29:21  innobackupex: Starting to lock all tables...
>> log scanned up to (0 3055087148)
>> log scanned up to (0 3055119993)
090625 15:29:39  innobackupex: All tables locked and flushed to disk

090625 15:29:39  innobackupex: Starting to backup .frm, .MRG, .MYD, .MYI,
innobackupex: .TRG, .TRN, and .opt files in
innobackupex: subdirectories of '/opt/mysqldata'
innobackupex: Backing up file '/opt/mysqldata/test/sp.frm'
innobackupex: Backing up file '/opt/mysqldata/test/tmp_dy.frm'
innobackupex: Backing up files '/opt/mysqldata/testdb/*.{frm,MYD,MYI,MRG,TRG,TRN,opt}' (207 files)
innobackupex: Backing up file '/opt/mysqldata/testdb/comments.frm'
innobackupex: Backing up file '/opt/mysqldata/testdb/testdb.frm'
innobackupex: Backing up file '/opt/mysqldata/testdb/testdb_content.frm'
innobackupex: Backing up file '/opt/mysqldata/testdb/testdb_ids.frm'
innobackupex: Backing up file '/opt/mysqldata/testdb/db.opt'
innobackupex: Backing up files '/opt/mysqldata/mysql/*.{frm,MYD,MYI,MRG,TRG,TRN,opt}' (52 files)
090625 15:29:40  innobackupex: Finished backing up .frm, .MRG, .MYD, .MYI, .TRG, .TRN, and .opt files

innobackupex: Resuming ibbackup

xtrabackup: The latest check point (for incremental): '0:3054881736'
>> log scanned up to (0 3055120013)
xtrabackup: Transaction log of lsn (0 3053102766) to (0 3055120013) was copied.
090625 15:29:44  innobackupex: All tables unlocked
090625 15:29:44  innobackupex: Connection to database server closed

innobackupex: Backup created in directory '/bak/'
innobackupex: MySQL binlog position: filename '', position
innobackupex: MySQL slave binlog position: master host '127.0.0.1',
filename 'mysql-bin.000006', position 227207755
090625 15:29:44  innobackupex: innobackup completed OK!
innobackupex: You must use -i (--ignore-zeros) option for extraction of the tar stream.

本文网址:http://www.ningoo.net/html/2009/using_xtrabackup_backup_mysql_database.html

分享到:
评论

相关推荐

    基于xtrabackup的MySQL数据库备份及还原Shell脚本.zip

    基于xtrabackup的MySQL数据库备份及还原Shell脚本

    使用Xtrabackup进行MySQL备份

    支持完整备份、增量备份,且能非常简单的集成在shell脚本中,执行自动化备份,也可以通过管道方便的传递到另一台服务器,实为Mysql数据库备份,重放的首选利器。 文章主要讲解MySQL利用xtrabackup进行增量备份的详细...

    xtrabackup备份数据库脚本

    该脚本资源是使用xtrabackup对mysql做定时备份使用的,方便大家下载学习,如果过有是问题可以私信我,关于xtrabackup我也是没有太深入的了解,还有很多需要学习的地方,作为开发人员,也需要了解一些简单的运维知识

    XtraBackup(MySQL备份) v1.6 for Win

    XtraBackup是一个用来备份 MySQL 的 InnoDB 数据库的开源工具。例如执行增量备份的命令是: # ./xtrabackup --backup --target-dir=/backup/delta --incremental-basedir=/backup/base

    MySQL从入门到高级系列视频.zip

    7.Xtrabackup备份Mysql数据库一.mp4 8.Xtrabackup备份Mysql数据库二.mp4 9.MySQL数据库主从原理讲解.mp4 10.MySQL高效架构读写分离配置.mp4 11.MySQL主从集群构建及故障切换.mp4 12.使用Binlog日志快速恢复MySQL数据...

    基于xtrabackup8.0的数据库压缩可配置的备份脚本

    基于xtrabackup8.0的数据库备份脚本,支持全库压缩备份、排除指定数据库压缩备份以及指定数据库压缩备份。备份规则:周一至周六增量备份,周日全库备份,自动管理备份和备份日志。如果有格式问题,应该是windows的...

    xtrabackup备份还原MySQL数据库

    主要为大家详细介绍了xtrabackup备份还原MySQL数据库的方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

    使用xtrabackup实现mysql备份

    修改配置文件,设置为每张表单独一个表空间,此项必须在安装数据库的时候就设置 [root@node1 ~]# vim /etc/my.cnf [mysqld] innodb_file_per_table=ON 创建备份目录 [root@node1 ~]# mkdir /backpus/ 备份 ...

    Mysql数据库备份恢复测试报告-xtrabackup.docx

    通过已经备份的数据库文件对数据库进行恢复测试,并输出测试报告,本次测试对数据库的全量及增量备份进行恢复,并在恢复完成后验证数据是否正常,恢复时间是否与备份时间相一致。...

    XtraBackup 备份与恢复实例讲解.docx

    XtraBackup 备份与恢复实例讲解 这里简单介绍 innobackupex 一些常用的参数

    编写脚本令Xtrabackup对MySQL数据进行备份的教程

    Xtrabackup备份恢复原理 备份innodb表时,xtrabackup若干个线程拷贝独立表空间的.ibd文件,并不停监视此过程中redo log的变化,添加到自己的事务日志文件(xtrabackup_logfile)中。在此过程中,发生的物理写操作越...

    MySQL 备份工具Xtrabackup.docx

    Percona-xtrabackup是 Percona公司开发的一个用于MySQL数据库基于InnoDB的物理热备的备份工具,支持MySQL、Percona server和MariaDB,开源免费,是目前较为受欢迎的主流备份工具。xtrabackup只能备份innoDB和xtraDB...

    xtrabackup自动备份脚本

    基于xtrabackup 2.4及docker版本mysql数据库可配置的压缩备份脚本,支持mysql5.6、5.7,目前仅支持数据库全量备份,默认备份数据保留35天

    数据库备份Shell脚本.zip

    基于Xtrabackup的MySQL数据库备份Shell脚本

    MySql数据库迁移.docx

    MySql数据库迁移全文共3页,当前为第1页。MySql数据库迁移全文共3页,当前为第1页。前面分享十一主要谈到oracle数据库迁移,本分享十二集中谈谈mysql迁移解决方案。 MySql数据库迁移全文共3页,当前为第1页。 MySql...

    MySQL数据库的备份与恢复之xtrabackup工具的使用1

    1.物理备份和逻辑备份 2.热备、温备、冷备 1.XtraBackup如何对InnoDB实现备份 2.XtraBackup备份MyISAM表 3.备份创建的文件

    XtraBackup(MySQL备份) v1.6 for Linux

    XtraBackup是一个用来备份 MySQL 的 InnoDB 数据库的开源工具。例如执行增量备份的命令是: # ./xtrabackup --backup --target-dir=/backup/delta --incremental-basedir=/backup/base

    percona XtraBackup2.4.28

    本文档是Percona XtraBackup 2.4.28版本 Percona XtraBackup是一个针对基于MySQL的服务的开源热备份实用程序,它在备份期间不会锁定 数据库。可以备份MySQL 5.1、5.5...对8.0版本的数据库使用Percona XtraBackup 8.0。

Global site tag (gtag.js) - Google Analytics