xtrabackup的备份实现
备份原理:利用innodb crash recovery
恢复的步骤
use-memory也可以使用到内存
Redo log记录那个page变更得到page no再去读到内存在内存中合并持久化到数据文件里面
备份的流程
3.6步骤只有innobackupex才有,Xtrabackup 不会copy *.frm(不会拷贝)schema文件,innobackupex是xtrabackup备份工具里面封装的一个备份脚本
创建最小化备份用户
>GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'bakuser'@'localhost' IDENTIFIED BY PASSWORD '123456'
# innobackupex --defaults-file=/data/mysql/mysql_3307/my.cnf --user=bakuser --password=123456 --socket=/tmp/mysql3307.sock /backup/db-3307-20160227
查看备份出来的东西
backup-my.cnf
ibdata1
mysql
performance_schema
test
xtrabackup_binlog_info
xtrabackup_checkpoints
xtrabackup_info
xtrabackup_logfile
# cat xtrabackup_binlog_info --mysql服务器当前正在使用的二进制日志文件及备份这一刻为止的二进制日志位置
mybinlog.000005 844
# cat xtrabackup_checkpoints --备份类型,备份状态,和LSN范围信息
backup_type = full-backuped
from_lsn = 0
to_lsn = 1626028
last_lsn = 1626028
compact = 0
recover_binlog_info = 0
# cat xtrabackup_info ---用什么备份,命令是什么,备份到哪,版本是什么,MySQL版本是什么,开始时间,结束时间,锁时间binlog的位置等等
uuid = 261daf7e-b855-11e5-ac15-000c29b69f06
name =
tool_name = innobackupex
tool_command = --defaults-file=/data/mysql/mysql_3307/my.cnf --user=bakuser --password=... --socket=/tmp/mysql3307.sock /backup/db-3307-20160227
tool_version = 2.3.2
ibbackup_version = 2.3.2
server_version = 5.6.27-log
start_time = 2016-01-11 03:19:08
end_time = 2016-01-11 03:19:15
lock_time = 0
binlog_pos = filename 'mybinlog.000005', position '844'
innodb_from_lsn = 0
innodb_to_lsn = 1626028
partial = N
incremental = N
format = file
compact = N
compressed = N
encrypted = N
xtrabackup_logfile 相当于redo log就是xtrabackup备份的日志用于 innodb crash-recovery恢复,这个文件有可能很大,由--apply-log处理
# innobackupex --defaults-file=/data/mysql/mysql_3307/my.cnf --apply-log --user=bakuser --password=123456 --socket=/tmp/mysql3307.sock /backup/db-3307-20160227/
# ls -1
backup-my.cnf
ibdata1
ib_logfile0
ib_logfile1
ib_logfile2
mysql
performance_schema
test
xtrabackup_binlog_info
xtrabackup_checkpoints
xtrabackup_info
xtrabackup_logfile
恢复
# rm -rf *
# innobackupex --defaults-file=/data/mysql/mysql_3307/my.cnf --copy-back --user=bakuser --password=123456 --socket=/tmp/mysql3307.sock /backup/db-3307-20160227/