Chinaunix首页 | 论坛 | 博客
  • 博客访问: 646025
  • 博文数量: 66
  • 博客积分: 15
  • 博客等级: 民兵
  • 技术积分: 2204
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-26 21:43
个人简介

曾就职于阿里巴巴担任Oracle DBA,MySQL DBA,目前在新美大担任SRE。[是普罗米修斯还是一块石头,你自己选择!] 欢迎关注微信公众号 “自己的设计师”,不定期有原创运维文章推送。

文章分类

全部博文(66)

文章存档

2017年(2)

2016年(3)

2015年(7)

2014年(12)

2013年(42)

分类: Mysql/postgreSQL

2014-01-08 14:36:06

   上次在线搭建slave的时候,出现了一些问题,这次对xtrabackup进行了系统的学习,把文档中学到的东西记录下来。
 
   xtrabackup是percona在线备份的开源工具,其优点之一就是备份innodb表的时候不需要任何锁表,对于目前oltp系统来说,提高了系统的可用率。
   xtrabackup是如何来防止锁表,而又提供备份的功能呢?其实xtrabackup在备份的时候,做了以下两样事情: 
  [1]  It starts a log-copying thread in the background. This thread watches the InnoDB log files, and when they change, it copies the changed blocks
        
to a file calledxtrabackup_logfile in the backup target directory. This is necessary because the backup might take a long time,    and the recovery
        process needs all of the log file entries from the beginning to the end of the backup.
  [2]  It copies the InnoDB data files to the target directory. This is not a simple file copy; it opens and reads the files similarly to the  wayInnoDB does,
        by reading the data dictionary and copying them a page at a time
 
以上的解释如下:
  [1]  xtrabackup在后台启动了一个log_copying线程,负责监视innodb的logfile,一旦发现logfile有改动,就会将这些改动的blocks记录到一个xtrabackup_logfile
        的文件中,后续的恢复会使用这个文件的日志(这个文件的目录由运行时指定的--target-dir参数指定.备份/恢复的时间开销与数据库数据的大小,和备份这
        段时
间内生成的日志文件的大小有关)
  [2]   xtrabackup会复制所有的数据文件到--target-dir所指定的目录中。xtrabackup并不是一个简单的文件copy,而是采用 innodb读取数据文件内容的方式,copy
        相应的page到--target-dir指定的目录下的相关文件中。当备份结束后,xtrabackup停止log-copying线程,并在目标目录中生成一个叫做xtrabackup_check
        points的文件,文件中包含backup的类型(全备还是增量备份),
备份期间生成日志起止 LSN。

       一个简单的全量备份操作如下:
        xtrabackup --backup --datadir=/data/datacenter --target-dir=/data/xiaocai/。
        备份的数据文件的位置为datadir指定的位置,备份的目标目录为/data/xiaocai/。
        xtrabackup在线备份,搭建slave,对于一些24*7的oltp系统或许是一个好的解决方案。
  •   
          这篇文章只对xtrabackup做一个简单的介绍,后续会对xtrabackup作更详细的描述.
  • 阅读(1953) | 评论(0) | 转发(0) |
    给主人留下些什么吧!~~