本篇内容介绍了“XtraBackup全量备份与恢复的过程”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
1、全量备份
innobackupex --defaults-file=/etc/my.cnf --user=root --password=mysql /backup/xtrabackup
备份成功后会提示:
170920 17:55:25 Executing UNLOCK TABLES
170920 17:55:25 All tables unlocked
170920 17:55:25 [00] Copying ib_buffer_pool to /backup/xtrabackup/2017-09-20_17-53-54/ib_buffer_pool
170920 17:55:25 [00] ...done
170920 17:55:25 Backup created in directory '/backup/xtrabackup/2017-09-20_17-53-54/'
MySQL binlog position: filename 'mysql-bin-3306.000026', position '154'
170920 17:55:25 [00] Writing /backup/xtrabackup/2017-09-20_17-53-54/backup-my.cnf
170920 17:55:25 [00] ...done
170920 17:55:25 [00] Writing /backup/xtrabackup/2017-09-20_17-53-54/xtrabackup_info
170920 17:55:25 [00] ...done
xtrabackup: Transaction log of lsn (1833677659) to (1833677668) was copied.
170920 17:55:25 completed OK!
并且会记录当前binlog的文件名和position点,以方便同步复制用。
2、全量恢复
停止MySQL服务
service mysql stop
删除老数据库数据目录下的所有文件
cd /mysql/data
将备份文件中的日志应用到备份文件中的数据文件上
innobackupex --detaults-file=/etc/my.cnf --apply-log /backup/xtrabackup/2017-09-20_17-53-54
事务日志恢复成功后会提示:
xtrabackup: starting shutdown with innodb_fast_shutdown = 1
InnoDB: FTS optimize thread exiting.
InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number 1833677864
170920 18:10:21 completed OK!
将备份文件中的数据恢复到数据库中:
innobackupex --defaults-file=/etc/my.cnf --copy-back /backup/xtrabackup/2017-09-20_17-53-54
物理文件和事务日志恢复成功后会提示:
170920 18:15:33 [01] Copying ./weixin/admin_depart.frm to /mysql/data/weixin/admin_depart.frm
170920 18:15:33 [01] ...done
170920 18:15:33 [01] Copying ./weixin/admin_member.frm to /mysql/data/weixin/admin_member.frm
170920 18:15:33 [01] ...done
170920 18:15:33 [01] Copying ./weixin/admin_member.ibd to /mysql/data/weixin/admin_member.ibd
170920 18:15:33 [01] ...done
170920 18:15:33 [01] Copying ./weixin/admin_action.ibd to /mysql/data/weixin/admin_action.ibd
170920 18:15:33 [01] ...done
170920 18:15:33 [01] Copying ./weixin/admin_pri.frm to /mysql/data/weixin/admin_pri.frm
170920 18:15:33 [01] ...done
170920 18:15:33 [01] Copying ./weixin/admin_depart.ibd to /mysql/data/weixin/admin_depart.ibd
170920 18:15:33 [01] ...done
170920 18:15:33 [01] Copying ./weixin/wechat_conf.frm to /mysql/data/weixin/wechat_conf.frm
170920 18:15:33 [01] ...done
170920 18:15:33 completed OK!
数据恢复完成之后,需要修改相关文件的权限:
chown -R mysql:mysql /mysql/data
重启启动MySQL
service mysql start
“XtraBackup全量备份与恢复的过程”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。