登录  /  注册
使用RMAN进行数据迁移
php中文网
发布: 2016-06-07 15:55:00
原创
813人浏览过

使用RMAN进行数据迁移 1.查看SCN,然后备份数据库 run{ allocate channel c1 type disk; allocate channel c2 type disk; allocat

使用RMAN进行数据迁移

1.查看SCN,然后备份数据库

run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
allocate channel c5 type disk;
sql 'alter system archive log current';
backup database tag 'db0' include current controlfile plus archivelog;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
}

备份的文件249G,备份用时20分钟

2.将备份传输至目标服务器 (53分钟)

3.在目标服务器还原
先在$Oracle_HOME/dbs下创建文件 initmvbox.ora
里面只有一行
db_name=mvbox

将数据库启动至nomount
restore spfile to '/xxxx/spfilemvbox.ora' from '/xxxx/2015_06_11/o1_mf_nnsnf_DB0_bqky8s7r_.bkp';

还原控制文件
shutdown abort;
startup mount;
restore controlfile from '/xxxx/2015_06_11/o1_mf_ncnnf_DB0_bqky8pq9_.bkp';
sql 'alter database mount';

挂载备份
catalog start with '/xxxx/2015_06_11';

还原数据库
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
allocate channel c5 type disk;
restore database;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
}

还原数据库用时 30分钟

4.在目标服务器进行数据库恢复(业务实际停机时间)
首先,业务停机
然后查看当前的SCN
select to_char(CURRENT_SCN) from v$database;

备份归档日志
sql 'alter system archive log current';
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
allocate channel c5 type disk;
backup archivelog all tag 'arch0';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
}

因为在迁移之前,清空过归档日志,所以归档日志只是从备份开始到现在的这段时间
日志量不大,10分钟以内就可以完成 备份和传输

清空归档日志的命令(delete noprompt archivelog all;)

挂载归档日志
catalog start with '/xxxx/2015_06_11';

进行不完全恢复,
set until scn xxx
这个数字就是备份归档日志之前查看的SCN

run{
shutdown immediate;
startup mount;
set until scn 79377202898;
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
allocate channel c5 type disk;
recover database;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
}

恢复用时11分钟(应用归档日志从10:40至14:39,4个小时)

alter database open resetlogs;

迁移完成.

比对MySQL的不完全恢复
可以发现
MySQL先恢复,再应用binlog,最后还原
他恢复的时间比较短,主要的时间是应用binlog(每恢复一小时的binlog需要15分钟),最后的还原不需要时间(直接改datadir..)

而Oracle,先还原再恢复
还原的时间比较长(30分钟),而恢复的时间比较短(每推进一小时的数据需要2到3分钟)
所以,在备份的服务器,保持一个最近还原的备份很重要..最起码会节省30分钟的还原时间..

--------------------------------------推荐阅读 --------------------------------------

RMAN 配置归档日志删除策略

Oracle基础教程之通过RMAN复制数据库

RMAN备份策略制定参考内容

RMAN备份学习笔记

Oracle数据库备份加密 RMAN加密

--------------------------------------分割线 --------------------------------------

本文永久更新链接地址

来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 技术文章
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2023 //m.sbmmt.com/ All Rights Reserved | 苏州跃动光标网络科技有限公司 | 苏ICP备2020058653号-1

 | 本站CDN由 数掘科技 提供

登录PHP中文网,和优秀的人一起学习!
全站2000+教程免费学