本地准备:

##安装和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. 用SpannableString打造绚丽多彩的文本显示效果

    extends:http://www.jianshu.com/p/84067ad289d2 引语 TeXtView大家应该都不陌生,文本展示控件嘛! 就用TextView显示普普通通的文本,OK,很简 ...

  2. Configure GenieACS

    GenieACS General Config config.json acts as the main configuration file and is stored in /path_to_ge ...

  3. thinkphp5---使用自定义助手函数

    在进行项目开发的时候,系统自带的助手函数往往满足不了自己的需求,就需要通过自定义助手函数来实现某个功能,具体做法: 新建:myhelper.php 写入: <?php if (!function ...

  4. mui---自定义页面打开的方向

    在使用MUI做APP的时候,会考虑对页面的打开方向做规定,MUI也给我们提供了很多种页面的打开方式. 具体参考: http://ask.dcloud.net.cn/question/174 MUI做A ...

  5. 10.11 rbac权限

    2018-10-11 12:25:11 现在写代码时候,不要好多代码放在一块!注重解耦!!!!! 把权限放到中间件里面,每次访问的时候都用到! 自己的网站弄完了,博客网站已经正式上线,就是有点丑! w ...

  6. Xshell登录Ubuntu12.04

    Ubuntu安装ssh服务: sudo apt-get install openssh-server 打开Xshell,选择“新建”,“连接”设置里选择SSH,主机填入需要连接的主机的IP地址.在“用 ...

  7. Media Session API 为当前正在播放的视频,音频,提供元数据来自定义媒体通知

    google 文档 https://developers.google.cn/web/updates/2017/02/media-session <html lang="zh-cmn- ...

  8. 数据库系统Informix为例,介绍改善用户查询计划的方法。

    数据库系统Informix为例,介绍改善用户查询计划的方法. 1.合理使用索引 索引是数据库中重要的数据结构,它的根本目的就是为了提高查询效率.现在大多数的数据库产品都采用IBM最先提出的ISAM索引 ...

  9. Latest China Scam: I've Been Arrested in the Brothel Crackdown!

    Latest China Scam: I've Been Arrested in the Brothel Crackdown! If the sex industry is fastest to se ...

  10. Saltstack之通过grains在配置文件中赋值

    案例,使用salt给客户端安装zabbix agent时需要在配置文件中自动生成主机名信息 zabbix agent安装sls zabbix-agent-install: file.managed: ...