【Wonder原创】RMAN实践二--DB迁移
时间:2010-09-10 来源:遗失的星空
背景说明:
VM:Linux-wonder这台机安装完Oracle,有名字为TEST的DB
VM:Linux-RMAN是另外一台机,安装了Oracle软件,没创建DB
目标:将linux-wonder 上TEST这个DB迁移到 Linux-RMAN
以下为实践记录:
Linux-RMAN这台机上新建目录
1、新建目录,以下在Oracle系统用户下操作
cd
mkdir rmanbak
cd admin
mkdir TEST 【TEST为DB名称】
cd TEST
mkdir adump bdump cdump udump
cd oradata
mkdir TEST
linux-wonder这台机上做备份等操作:
2、RMAN备份
RMAN> backup database format '/u01/app/oracle/backup/full/full%u_%s_%p' plus archivelog format
'/u01/app/oracle/backup/full/arv%u_%s_%p' delete input;
备份得到如下文件:
/u01/app/oracle/backup/full/arv0blnb88l_11_1
/u01/app/oracle/backup/full/arv0dlnb8bn_13_1
/u01/app/oracle/backup/full/full0clnb88n_12_1
/u01/app/oracle/flash_recovery_area/TEST/autobackup/2010_09_07/o1_mf_s_729129337_68dr3tjl_.bkp
3、传送文件到 linux-RMAN这台机,以下在 oracle 系统用户下操作
cd /u01/app/oracle/backup/full
scp arv0blnb88l_11_1 arv0dlnb8bn_13_1 full0clnb88n_12_1 [email protected]:/u01/app/oracle/rmanbak
cd /u01/app/oracle/flash_recovery_area/TEST/autobackup/2010_09_07/
scp o1_mf_s_729129337_68dr3tjl_.bkp [email protected]:/u01/app/oracle/rmanbak
cd /u01/app/oracle/oradata/TEST
scp redo0[1-3].log [email protected]:/u01/app/oracle/oradata/TEST
【传送spfile,可选】
cd $ORACLE_HOME/dbs
scp initTEST.ora [email protected]:/u01/app/oracle/product/10.2.0/db_1/dbs
linux-DG这台机上的操作:
4、创建spfile,若没有传送spfile,需要如下操作,否则略过
cd $ORACLE_HOME/dbs
cp initdtserp.ora initTEST.ora
vi initTEST.ora 【将dtserp 替换为TEST,检查各路径是否正确】
export ORACLE_SID=TEST
SQL>create pfile from spfile;
4、恢复Control file
export ORACLE_SID=TEST
SQL>startup nomount pfile='/u01/app/oracle/product/10.2.0/db_1/dbs/initTEST.ora';
SQL> shutdown immediate;
SQL> startup nomount;
RMAN> restore controlfile from '/u01/app/oracle/rmanbak/o1_mf_s_729129337_68dr3tjl_.bkp';
5、恢复数据
SQL> alter database mount;
RMAN> catalog start with '/u01/app/oracle/rmanbak/arv0blnb88l_11_1';
RMAN> catalog start with '/u01/app/oracle/rmanbak/arv0dlnb8bn_13_1' ;
RMAN> catalog start with '/u01/app/oracle/rmanbak/full0clnb88n_12_1';
RMAN> catalog start with '/u01/app/oracle/rmanbak/o1_mf_s_729129337_68dr3tjl_.bkp';
RMAN> list backup; 【查看是否能找到RMAN备份记录】
RMAN> restore database;
RMAN> restore archivelog all; 【手动恢复日志】
【以下可能需要多试几次,分别使用redo01.log redo02.log redo03.log】
SQL> recover database using backup controlfile until cancel;
输入:/u01/app/oracle/oradata/TEST/redo01.log
【以下可能需要多试几次,分别使用redo01.log redo02.log redo03.log】
SQL> recover database using backup controlfile;
输入:/u01/app/oracle/oradata/TEST/redo01.log
SQL> alter database open resetlogs;