首页 / 数据库 / MySQL / 使用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分钟的还原时间..--------------------------------------推荐阅读 --------------------------------------RMAN 配置归档日志删除策略 http://www.linuxidc.com/Linux/2013-11/92670.htmOracle基础教程之通过RMAN复制数据库 http://www.linuxidc.com/Linux/2013-07/87072.htmRMAN备份策略制定参考内容 http://www.linuxidc.com/Linux/2013-03/81695.htmRMAN备份学习笔记 http://www.linuxidc.com/Linux/2013-03/81892.htmOracle数据库备份加密 RMAN加密 http://www.linuxidc.com/Linux/2013-03/80729.htm--------------------------------------分割线 --------------------------------------更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12本文永久更新链接地址