本地准备:

##安装和RDS相同的mysql版本,拿mysql5.6为例

http://www.cnblogs.com/37yan/p/7513605.html

##安装Xtrabackup 包

cd /data/source

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

yum install  percona-xtrabackup-24-2.4.8-1.el7.x86_64.rpm

##去RDS控制台下载备份包放到 /data/source 目录下

##下载解压脚本

wget http://oss.aliyuncs.com/aliyunecs/rds_backup_extract.sh?spm=5176.7741817.2.4.dzPsOP&file=rds_backup_extract.sh -O rds_backup_extract.sh

##准备一个backup-my.cnf

vim backup-my.cnf
# This MySQL options file was generated by innobackupex. # The MySQL server
[mysqld]
innodb_checksum_algorithm=innodb
#innodb_log_checksum_algorithm=innodb
innodb_data_file_path=ibdata1:200M:autoextend
innodb_log_files_in_group=
innodb_log_file_size=
#innodb_fast_checksum=false
innodb_page_size=
#innodb_log_block_size=
innodb_undo_directory=.
innodb_undo_tablespaces= #rds_encrypt_data=false
#innodb_encrypt_algorithm=aes_128_ecb

##使用脚本还原

#!/bin/bash

db_dir=/data/source/mysql/data
systemctl stop mysqld
ps -ef | grep mysqld | grep -v grep | awk '{ print "kill -9 " $2}' | bash #创建文件夹
cd /data/source
if [ -d $db_dir ];then
rm -rf /data/source/mysql
echo "Delete directory '$db_dir'"
fi
mkdir -p $db_dir
echo "Create directory '$db_dir'" #解压数据
if [ $ ];then
echo "Backup file is: '$1'"
bash rds_backup_extract.sh -f $ -C $db_dir
else
read -p "Please enter a backup file name:" bak_file
if [ $bak_file ];then
echo "Backup file is: '$bak_file'"
bash rds_backup_extract.sh -f $bak_file -C $db_dir
else
echo "Input error"
exit
fi
fi
echo "`ls -l $db_dir`" #还原数据库 innobackupex --defaults-file=$db_dir/backup-my.cnf --apply-log $db_dir
chown -R mysql:mysql $db_dir
cp -f backup-my.cnf $db_dir/backup-my.cnf
#启动实例
mysqld_safe --defaults-file=$db_dir/backup-my.cnf --user=mysql --datadir=$db_dir > /tmp/mysql_demo.lo
g >& &
sleep
mysql_upgrade -uroot #设置密码 while :
do
read -p "Please enter the root@% password:" password if [ $password ];then
echo "The root@% password is ‘$password’ "
break
else
echo "Input error"
fi
done mysql -uroot << EOF
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '$password' WITH GRANT OPTION;
EOF exit

阿里云RDS备份在本地mysql快速还原的更多相关文章

  1. 阿里云rds 备份和还原

    阿里云rds 备份和还原 转发:https://www.cnblogs.com/lin1/p/8617764.html 转发:https://help.aliyun.com/knowledge_det ...

  2. 阿里云RDS备份 恢复到本地

    目录 一.恢复准备 二.具体操作 一.恢复准备 阿里云RDS默认配置了全备份+binlog,可以精准恢复到某个时间点上. 可以下载备份的包到本地,进行本地恢复,要预留好本地的数据库容量和cpu等规格, ...

  3. MongoDB自建和阿里云RDS备份还原

    MongoDB是一个基于分布式文件存储的数据库.由C++语言编写.旨在为WEB应用提供可扩展的高性能数据存储解决方案. MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功 ...

  4. 阿里云RDS备份的tar格式包恢复到本地自建数据库

    说明 阿里云RDS-mysql数据库是通过percona-Xtrabackup进行备份的,所以恢复时也需要安装该软件. 另外注意的是:你自己下载的MySQL版本要和阿里云上的MySQL版本一致,不然会 ...

  5. 阿里云RDS同步到本地自建mysql数据库从库

    RDS mysql版本为5.6.29 x86_64 1.下载数据备份.binlog备份 内网中转?数据量不大,直接下载 下载数据备份(外网下载链接) wget -c "https://rds ...

  6. 用xtrabackup实现mysql的主从复制 阿里云rds到自己创建mysql

    来源 http://blog.51cto.com/825536458/1803968参考https://segmentfault.com/a/1190000003063874 如果我们用传统的mysq ...

  7. wget下载阿里云RDS备份集

    [root@localhost tmp]# more wget.sh #!/bin/bash download_url=`python /tmp/geturl.py` echo $download_u ...

  8. 阿里云rds实例恢复到本地

    摘要: 前提: 1,阿里云数据库备份实例,恢复数据的时候需要将数据恢复到本地数据库,是不能直接恢复到RDS上的. 2,需要在本地服务器上下载一个数据库,尽量和RDS数据库版本保持一致.(我现在用的是5 ...

  9. 为更强大而生的开源关系型数据库来了!阿里云RDS for MySQL 8.0 正式上线!

    2019年5月29日15时,阿里云RDS for MySQL 8.0正式上线,使得阿里云成为紧跟社区步伐,发布MySQL最新版本的云厂商.RDS for MySQL 8.0 产品是阿里云推出的 MyS ...

随机推荐

  1. html5__Notifications API 桌面通知

    MDN地址 google 文档 https://developers.google.cn/web/fundamentals/push-notifications/ const koa2 = requi ...

  2. 关于SMI、MSI、SCI、INTx各种中断小结【转】

    转载自http://blog.csdn.net/huangkangying/article/details/11178425 目录(?)[-] MSI VS INTxPin-based interru ...

  3. VMWARE虚拟机不显示主机共享的文件夹解决办法

    执行如下命令重新配置,不用重启. #sudo vmware-config-tools.pl

  4. System.InvalidOperationException: 此实现不是 Windows 平台 FIPS 验证的加密算法的一部分。

    x 昨天还好好地,然后清理一下电脑垃圾,就突然报这个错误了; 网上搜索了一下:找到解决方案了,但是由于底层知识的功力不够,至今未知具体怎么导致的... 解决方案↓ 进注册表 按Win+R运行reged ...

  5. Sharding与数据库分区(Partition) 分表、分库、分片和分区

    Sharding与数据库分区(Partition) http://blog.sina.com.cn/s/blog_72ef7bea0101cjtb.html https://www.2cto.com/ ...

  6. URL编码问题

    一般来说,URL只能使用英文字母.阿拉伯数字和某些标点符号,不能使用其他文字和符号. 比如,世界上有英文字母的网址"http://www.abc.com", 但是没有希腊字母的网址 ...

  7. go,gcvis,golang, privoxy,and git proxy

    /etc/init.d/privoxy restartexport http_proxy=http://127.0.0.1:8118export https_proxy=http://127.0.0. ...

  8. PHP进阶-PHP执行和加速原理

  9. [daily][nfs] nfs客户端设置

    [daily] 主机间目录共享 1. 安装nfs工具,其实是mount需要mount.fs 否则会出现类似如下错误: [root@stds ~]# mount -t nfs 192.168.7.1:/ ...

  10. airflow

    基于airflow官方镜像制作自己的镜像,如给镜像安装pymongo FROM /common/air_grpc: MAINTAINER zhangchunyang@goldwind.com.cn U ...