使用RMAN进行数据迁移

使用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分钟的还原时间..


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29254281/viewspace-1696223/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29254281/viewspace-1696223/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值