码迷,mamicode.com
首页 > 数据库 > 详细

MySQL备份之xtrabackup

时间:2019-01-28 19:20:00      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:soc   rand   3.5   ast   keygen   download   版本   aes   无法   

目录

1.xtrabackup安装

2.xtrabackup原理

3.xtrabackup命令详解

 

1)xtrabackup安装

wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.12/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.12-1.el7.x86_64.rpm

yum -y localinstall percona-xtrabackup-24-2.4.12-1.el7.x86_64.rpm

 

2)xtrabackup原理

2.1)xtrabackup备份流程

start xtrabackup_log   启动innobackupex;

          开启xtrabackup线程

copy redo log              开启os_thread_create 线程 拷贝 redo log文件

copy ibd;ibdata1         开启os_thread_create 拷贝idb data文件

          等待拷贝完idb data文件后下发一个flush tables with read lock锁

flush tables with read lock             

copy .FRM;MYD;MYI;misc files      拷贝文件frm;myd,myi,misc文件

show master status       show master status输出get binary log position and so on;

stop copy redo log         停止拷贝redo log后 unlock table;

unlock table

stop and copy xtrabackup_log

 

2.2)观察方法

innobackupex -S /tmp/mysql3306.sock -uroot -p666666 /data/backup/ 2>&1 |tee 1.log
 

3)xtrabackup命令详解

3.1)备份

innobackupex -S /tmp/mysql3306.sock -uroot -p666666  --no-timestamp /data/backup/db3306-`date +%F`

 

3.2)恢复

innobackupex --apply-log /data/backup/db3306-2019-01-28

service mysqld stop

cd /data/mysql/mysql3306/

mv data data_`date +%F`

mkdir data

提示:(innodb_log_group_home_dir =./  需要删掉)

innobackupex --copy-back /data/backup/db3306-2019-01-28/

chown -R mysql:mysql /data/mysql/mysql3306/data

 

3.3)加密备份

openssl rand -base64 24

innobackupex  --encrypt=AES256 --encrypt-key=1CaXAN1nI+MMhSgpVLuENBM9rq3OLKpO -S /tmp/mysql3306.sock -uroot -p666666  --no-timestamp /data/backup/db3306-`date +%F_%T`

 

3.4)恢复

innobacupex --encrypt=AES256 --encrypt-key=1CaXAN1nI+MMhSgpVLuENBM9rq3OLKpO /data/backup/db3306-2019-01-25_09:46:52

innobackupex --apply-log /data/backup/db3306-2019-01-25_09:46:52

service mysqld stop

cd /data/mysql/mysql3306/

mv data data_`date +%F`

mkdir data

提示:(innodb_log_group_home_dir =./  需要删掉)

innobackupex --copy-back /data/backup/db3306-2019-01-28/

chown -R mysql:mysql /data/mysql/mysql3306/data

 
3.5)远程备份

ssh-keygen -t rsa

ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.20.212

innobackupex -uroot -p666666 --no-timestamp -S /tmp/mysql3306.sock --stream=tar ./ |ssh -p 22 192.168.20.212 "gzip - >/data/backup/db3306_`date +%F_%T`.tat.gz"(测试:无法解压可能跟版本有关)

 

MySQL备份之xtrabackup

标签:soc   rand   3.5   ast   keygen   download   版本   aes   无法   

原文地址:https://www.cnblogs.com/beebon/p/10331262.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!