xtrabackup之Innobackupex全备数据库
一、Xtrabackup是什么:
- Xtrabackup是一个对InnoDB做数据备份的工具,支持在线热备份(备份时不影响数据读写),是商业备份工具InnoDB Hotbackup的一个很好的替代品。
- Xtrabackup有两个主要的工具:xtrabackup、innobackupex
- xtrabackup只能备份InnoDB和XtraDB两种数据表,而不能备份MyISAM数据表
- innobackupex是参考了InnoDB Hotbackup的innoback脚本修改而来的.innobackupex是一个perl脚本封装,封装了xtrabackup。主要是为了方便的 同时备份InnoDB和MyISAM引擎的表,但在处理myisam时需要加一个读锁。并且加入了一些使用的选项。如slave-info可以记录备份恢 复后,作为slave需要的一些信息,根据这些信息,可以很方便的利用备份来重做slave。
二、利用二进制包安装xtrabackup
[root@DBMysql ~]# tar xvfz percona-xtrabackup-2.0.-.tar.gz -C /usr/local
[root@DBMysql local]# mv percona-xtrabackup-2.0. xtrabackup
[root@DBMysql local]# chown mysql:mysql -R /usr/local/xtrabackup/ 在mysql用户下的 .bash_profile文件中添加环境变量
export PATH=/usr/local/xtrabackup/bin:$PATH
三、创建备份专用账户
[mysql@DBMysql ~]$ mysql --defaults-file=/mysql/mysqldata//my.cnf -usystem -p''
[(none) ::]>create user xtrabk@'127.0.0.1' identified by 'onlybackup';
Query OK, rows affected (0.08 sec) [(none) ::]>grant reload,lock tables,Replication client, super on *.* to xtrabk@'127.0.0.1';
Query OK, rows affected (0.07 sec)
[(none) ::]>
四.innobackupex全量备份
[mysql@hadoop1 ~]$ innobackupex --defaults-file=/mysql/mysqldata//my.cnf --host=127.0.0.1 --user=xtrabk --password='onlybackup' /mysql/mysqldata/backup/3306_full InnoDB Backup Utility v1.5.1-xtrabackup; Copyright , Innobase Oy
and Percona Ireland Ltd -. All Rights Reserved. This software is published under
the GNU GENERAL PUBLIC LICENSE Version , June . :: innobackupex: Starting mysql with options: --defaults-file='/mysql/mysqldata/3306/my.cnf' --password=xxxxxxxx --user='xtrabk' --host='127.0.0.1' --unbuffered --
:: innobackupex: Connected to database with mysql child process (pid=)
:: innobackupex: Connection to database server closed
IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!". innobackupex: Using mysql Ver 14.12 Distrib 5.0., for redhat-linux-gnu (x86_64) using readline 5.1
innobackupex: Using mysql server version Copyright (c) , , Oracle and/or its affiliates. All rights reserved. innobackupex: Created backup directory /mysql/mysqldata/backup/3306_full/--27_00--
:: innobackupex: Starting mysql with options: --defaults-file='/mysql/mysqldata/3306/my.cnf' --password=xxxxxxxx --user='xtrabk' --host='127.0.0.1' --unbuffered --
:: innobackupex: Connected to database with mysql child process (pid=)
:: innobackupex: Connection to database server closed :: innobackupex: Starting ibbackup with command: xtrabackup_56 --defaults-file="/mysql/mysqldata/3306/my.cnf" --defaults-group="mysqld" --backup --suspend-at-end --target-dir=/mysql/mysqldata/backup/3306_full/--27_00-- --tmpdir=/mysql/mysqldata//tmp
innobackupex: Waiting for ibbackup (pid=) to suspend
innobackupex: Suspend file '/mysql/mysqldata/backup/3306_full/2016-05-27_00-23-05/xtrabackup_suspended' xtrabackup_56 version 2.0. for MySQL server 5.6. Linux (x86_64) (revision id: )
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /mysql/mysqldata//data
xtrabackup: Target instance is assumed as followings.
xtrabackup: innodb_data_home_dir = ./
xtrabackup: innodb_data_file_path = ibdata01:100M:autoextend
xtrabackup: innodb_log_group_home_dir = /mysql/mysqldata//redo
xtrabackup: innodb_log_files_in_group =
xtrabackup: innodb_log_file_size =
xtrabackup: using O_DIRECT
InnoDB: Allocated tablespace , old maximum was
InnoDB: Opened undo tablespaces
>> log scanned up to ()
[] Copying ./ibdata01 to /mysql/mysqldata/backup/3306_full/--27_00--/ibdata01
>> log scanned up to ()
[] ...done
[] Copying ./mysql/innodb_table_stats.ibd to /mysql/mysqldata/backup/3306_full/--27_00--/mysql/innodb_table_stats.ibd
>> log scanned up to ()
[] ...done
[] Copying ./mysql/innodb_index_stats.ibd to /mysql/mysqldata/backup/3306_full/--27_00--/mysql/innodb_index_stats.ibd
[] ...done
[] Copying ./mysql/slave_relay_log_info.ibd to /mysql/mysqldata/backup/3306_full/--27_00--/mysql/slave_relay_log_info.ibd
[] ...done
[] Copying ./mysql/slave_master_info.ibd to /mysql/mysqldata/backup/3306_full/--27_00--/mysql/slave_master_info.ibd
[] ...done
[] Copying ./mysql/slave_worker_info.ibd to /mysql/mysqldata/backup/3306_full/--27_00--/mysql/slave_worker_info.ibd
[] ...done
[] Copying ./pls_innodb/t_polestar02.ibd to /mysql/mysqldata/backup/3306_full/--27_00--/pls_innodb/t_polestar02.ibd
[] ...done
[] Copying /mysql/mysqldata//undo/undo001 to /mysql/mysqldata/backup/3306_full/--27_00--/undo001
[] ...done
[] Copying /mysql/mysqldata//undo/undo002 to /mysql/mysqldata/backup/3306_full/--27_00--/undo002
[] ...done
[] Copying /mysql/mysqldata//undo/undo003 to /mysql/mysqldata/backup/3306_full/--27_00--/undo003
[] ...done
[] Copying /mysql/mysqldata//undo/undo004 to /mysql/mysqldata/backup/3306_full/--27_00--/undo004
>> log scanned up to ()
[] ...done
[] Copying /mysql/mysqldata//undo/undo005 to /mysql/mysqldata/backup/3306_full/--27_00--/undo005
[] ...done
>> log scanned up to () :: innobackupex: Continuing after ibbackup has suspended
:: innobackupex: Starting mysql with options: --defaults-file='/mysql/mysqldata/3306/my.cnf' --password=xxxxxxxx --user='xtrabk' --host='127.0.0.1' --unbuffered --
:: innobackupex: Connected to database with mysql child process (pid=)
>> log scanned up to ()
>> log scanned up to ()
:: innobackupex: Starting to lock all tables...
>> log scanned up to ()
>> log scanned up to ()
>> log scanned up to ()
>> log scanned up to ()
>> log scanned up to ()
>> log scanned up to ()
>> log scanned up to ()
>> log scanned up to ()
>> log scanned up to ()
>> log scanned up to ()
:: innobackupex: All tables locked and flushed to disk :: innobackupex: Starting to backup non-InnoDB tables and files
innobackupex: in subdirectories of '/mysql/mysqldata/3306/data'
innobackupex: Backing up files '/mysql/mysqldata/3306/data/mysql/*.{frm,isl,MYD,MYI,MAD,MAI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' ( files)
innobackupex: Backing up files '/mysql/mysqldata/3306/data/performance_schema/*.{frm,isl,MYD,MYI,MAD,MAI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' ( files)
innobackupex: Backing up file '/mysql/mysqldata/3306/data/pls_innodb/db.opt'
innobackupex: Backing up file '/mysql/mysqldata/3306/data/pls_innodb/t_polestar02.frm'
innobackupex: Backing up file '/mysql/mysqldata/3306/data/pls_myisam/t_polestar01.MYD'
innobackupex: Backing up file '/mysql/mysqldata/3306/data/pls_myisam/db.opt'
innobackupex: Backing up file '/mysql/mysqldata/3306/data/pls_myisam/t_polestar01.MYI'
innobackupex: Backing up file '/mysql/mysqldata/3306/data/pls_myisam/t_polestar01.frm'
:: innobackupex: Finished backing up non-InnoDB tables and files :: innobackupex: Waiting for log copying to finish xtrabackup: The latest check point (for incremental): ''
xtrabackup: Stopping log copying thread.
.>> log scanned up to () xtrabackup: Transaction log of lsn () to () was copied.
:: innobackupex: All tables unlocked
:: innobackupex: Connection to database server closed innobackupex: Backup created in directory '/mysql/mysqldata/backup/3306_full/2016-05-27_00-23-05'
innobackupex: MySQL binlog position: filename 'mysql-bin.000003', position
:: innobackupex: completed OK!
[mysql@hadoop1 ~]$
五、innobackupexe备份产生的相关文件
[mysql@hadoop1 --27_00--]$ ls -l
total
-rw-rw-r-- mysql mysql May : backup-my.cnf
-rw-rw---- mysql mysql May : ibdata01
drwx------ mysql mysql May : mysql
drwxrwxr-x mysql mysql May : performance_schema
drwx------ mysql mysql May : pls_innodb
drwxrwxr-x mysql mysql May : pls_myisam
drwxrwxr-x mysql mysql May : test
-rw-rw---- mysql mysql May : undo001
-rw-rw---- mysql mysql May : undo002
-rw-rw---- mysql mysql May : undo003
-rw-rw---- mysql mysql May : undo004
-rw-rw---- mysql mysql May : undo005
-rw-rw-r-- mysql mysql May : xtrabackup_binary
-rw-rw-r-- mysql mysql May : xtrabackup_binlog_info
-rw-rw---- mysql mysql May : xtrabackup_checkpoints
-rw-rw---- mysql mysql May : xtrabackup_logfile
[mysql@hadoop1 --27_00--]$
xtrabackup之Innobackupex全备数据库的更多相关文章
- Innobackupex 全备数据库
对于MySQL数据库的热备.xtrabackup是除了MySQL enterprise backup之外的不二之选. 该工具提供了基于innodb存储引擎的热备.支持全量,增量备份,部分备份,时点恢复 ...
- xtrabackup之Innobackupex全备恢复
一.当前环境 [mysql@hadoop1 ~]$ mysql --defaults-/my.cnf -uroot -p123456 -P3306 mysql> show variables l ...
- MySQL5.7.18 备份、Mysqldump,mysqlpump,xtrabackup,innobackupex 全量,增量备份,数据导入导出
粗略介绍冷备,热备,温暖,及Mysqldump,mysqlpump,xtrabackup,innobackupex 全量,增量备份 --备份的目的 灾难恢复:意外情况下(如服务器宕机.磁盘损坏等)对损 ...
- 每天进步一点点——mysql——Percona XtraBackup(innobackupex)
一. 简单介绍 Percona XtraBackup是开源免费的MySQL数据库热备份软件,它能对InnoDB和XtraDB存储引擎的数据库非堵塞地备份(对于MyISAM的备份相同须要加表锁).Xt ...
- xtrabackup备份还原mariadb数据库
一.xtrabackup 简介 xtrabackup 是由percona公司开源免费的数据库热备软件,它能对InnoDB数据库和XtraDB存储引擎的数据库非阻塞地备份,对于myisam的备份同样需要 ...
- Xtrabackup之innobackupex备份恢复详解(转)
add by zhj:对于Xtrabackup2.2来说,已经解决了本文结尾提到的那个bug,当使用--copy-back时,同时加--force-non-empty-directories 即可.这 ...
- Percona Xtrabackup备份mysql大数据库(完整备份与增量备份)
Percona Xtrabackup备份mysql大数据库(完整备份与增量备份) 文章目录 [隐藏] Xtrabackup简介 Xtrabackup安装 Xtrabackup工具介绍 inno ...
- 通过xtrabackup工具对mysql数据库做全备
需求描述: 使用xtrabackup工具对mysql实例中的所有的数据库进行备份,并且将备份的过程输出到指定的日志文件中. 操作过程: 1.使用xtrabacup工具备份mysql实例 xtrabac ...
- Innobackupex全备恢复(原理、演示)
一. Innobackupex恢复原理 After creating a backup, the data is not ready to be restored. There might b ...
随机推荐
- (转)C# MD5
本文原地址:http://blog.csdn.net/zhoufoxcn/article/details/1497099 作者:周公 代码如下: using System; using System. ...
- 【Unity Shaders】学习笔记——SurfaceShader(九)Cubemap
[Unity Shaders]学习笔记——SurfaceShader(九)Cubemap 如果你想从零开始学习Unity Shader,那么你可以看看本系列的文章入门,你只需要稍微有点编程的概念就可以 ...
- 【LeetCode】6. ZigZag Conversion 锯齿形转换
题目: 思路: 以图为例:s={'A','B','C','D','E','F','G','H'.....} 1.先不考虑中间元素F.G.H.N...,每一行前后元素在数组中对应下标相差size=2*n ...
- 【测试】DG的主切备,备切主
1.首先要应用日志,保持主备库一致: 备库:SBDB@SYS> recover managed standby database using current logfile disconnect ...
- socket学习笔记——实现收发文件(Windows)
记录下来,供自己学习! server.c #define _CRT_SECURE_NO_DEPRECATE #include <stdio.h> #include <stdlib.h ...
- 图的强连通分量-Kosaraju算法
输入一个有向图,计算每个节点所在强连通分量的编号,输出强连通分量的个数 #include<iostream> #include<cstring> #include<vec ...
- 使用ngin的静态文件下载
1,主配置文件nginx.xml #user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error. ...
- Duilib学习笔记《03》— 控件使用
在前面已经对duilib有个一个基本的了解,并且创建了简单的空白窗体.这仅仅只是一个开始,如何去创建一个绚丽多彩的界面呢?这就需要一些控件元素(按钮.文本框.列表框等等)来完善. 一. Duilib控 ...
- php获取文件创建时间、修改时间
filemtime ( string filename ) 返回文件上次被修改的时间,出错时返回 FALSE.时间以 Unix 时间戳的方式返回,可用于 date(). 例如:$a=filemtime ...
- Oracle笔记 三、function 、select
Scott表下有这么几个常用的表,而且还带有数据.分别是emp.dept.salgrade: 1.查看表结构用desc desc emp; 2.空表dual,最常用的空表,如: select 2 * ...