程序员人生 网站导航

rman 冷备份异机迁移

栏目:数据库应用时间:2015-03-28 08:34:15

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

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

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

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

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;
------分隔线----------------------------
------分隔线----------------------------

最新技术推荐