码迷,mamicode.com
首页 > 其他好文 > 详细

rman 冷备份异机迁移

时间:2015-03-04 22:46:46      阅读:293      评论:0      收藏:0      [点我收藏+]

标签:操作   恢复   数据库   归档   迁移   

rman 作为 oracle 推荐的备份、恢复方式,我们常使用它来进行异机迁移数据库。

网上的攻略都是 rman 的热备份异机迁移,相比冷备份的异机迁移需要多备份归档(未归档)日志文件、联机日志文件,操作步骤较为复杂。

如果是可以停机的数据库,更推荐使用 mount 方式下的冷备份来做异机迁移。

写了一个迁移文件,以备后用。

Part1

Env

{
‘first database’:{
‘os’:’suse11’
‘oracle_version’:’11gr2’
}
‘second database’:{
‘os’:’suse11’
‘oracle_version’:’11gr2’
}
}

Set a nfs service for first database

mkdir /nfs
chmod -R 777 /nfs
echo ‘/nfs    *(fsid=0,crossmnt,rw,root_squash,sync,no_subtree_check)‘ >>/etc/exports
service nfsserver restart

Mount nfs dir in first database

mount -t nfs x.x.x.x:/nfs /nfs

Run backup script in the nfs dir

run {
    allocate channel c1 type disk;
    allocate channel c2 type disk;
    backup database format ‘/nfs/%U‘;
    backup current controlfile format ‘/nfs/%U.bak‘;
    release channel c1;
    release channel c2;
}

Part2

Get ready in second database

Make dir for second database;

mkdir -p /opt/oracle/oradata/orcl
mkdir -p /opt/oracle/admin/orcl
cd /opt/oracle/admin/orcl
mkdir adump bdump udump cdump pfile
mkdir /opt/oracle/flash_recovery_area
mkdir /opt/oracle/flash_recovery_area/orcl

Create password file

orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=xxxxx

Recover second database

Set DBID

set dbid xxxxxxx

Start Second database numount

startup nomount

Restore pfile

restore spfile to pfile ‘/opt/oracle/product/11.2.0/db_1/dbs/initorcl.ora‘ from ‘/nfs/1aq10otf_1_1‘;

Start database by new pfile

shutdown immediate;
startup nomount;

Restore control file

restore controlfile from ‘/nfs/xxx/xxx‘

Recovery database

alter database mouont;
restore database;
alter database open resetlogs;

rman 冷备份异机迁移

标签:操作   恢复   数据库   归档   迁移   

原文地址:http://blog.csdn.net/smallfish1983/article/details/44066685

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!