1.讲目标数据库启动到nomount状态,
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 1241513984 bytes
Fixed Size 2065376 bytes
Variable Size 318770208 bytes
Database Buffers 905969664 bytes
Redo Buffers 14708736 bytes
SQL>
2.恢复控制文件,进入ramn target/
restore controlfile from 'E:\RMANBACK\CTL_ORCL_20140729_6'
3.讲数据库启动到mount状态
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN>
更改rman路径
catalog backuppiece 'E:\RMANBACK\DBFULL_ORCL_01PEK20S_1_1.BAK';
catalog backuppiece 'E:\RMANBACK\DBFULL_ORCL_02PEK20S_1_2.BAK';
catalog backuppiece 'E:\RMANBACK\DBFULL_ORCL_03PEK20V_1_3.BAK';
catalog backuppiece 'E:\RMANBACK\DBFULL_ORCL_04PEK225_1_4.BAK';
catalog backuppiece 'E:\RMANBACK\DBFULL_ORCL_05PEK226_1_5.BAK';
4.在主库上执行sql
select 'set newname for datafile '||''||''''||file_Name||''''||''||' to '||''''|| 'E:\oracle\product\10.2.0\oradata\orcl\' ||replace
(file_Name,'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\','')||''''||';' from dba_data_files order by file_id
--把查询出来的结果替换下面脚本里面的内容,然后再rman target/ 执行
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\SYSTEM01.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\UNDOTBS01.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\SYSAUX01.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\USERS01.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZLTOOLSTBS.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZLTOOLSTBS.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9BASEITEM.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9BASEITEM.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9PATIENT.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9PATIENT.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9EXPENSE.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9EXPENSE.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9MEDLST.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9MEDLST.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9DUEREC.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9DUEREC.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9CISREC.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9CISREC.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9EPRLOB.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9EPRLOB.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9EPRDAT.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9EPRDAT.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9CISAUDIT.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9CISAUDIT.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9INDEXHIS.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9INDEXHIS.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9INDEXCIS.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9INDEXCIS.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZLBAKZLHIS.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZLBAKZLHIS.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9IFTBASE.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9IFTBASE.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9IFTREC.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9IFTREC.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9INDEXIFT.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9INDEXIFT.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9DEVBASE.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9DEVBASE.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9DEVREC.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9DEVREC.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9DEVUSE.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9DEVUSE.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9INDEXDEV.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9INDEXDEV.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9MTLBASE.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9MTLBASE.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9MTLREC.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9MTLREC.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9INDEXMTL.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9INDEXMTL.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9MEDBASE.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9MEDBASE.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9MEDREC.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9MEDREC.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9MEDDAY.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9MEDDAY.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9INDEXMDR.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9INDEXMDR.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9PEISDATA.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9PEISDATA.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9WIZARDDATA.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9WIZARDDATA.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9INDEXPSS.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9INDEXPSS.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9LISDATA.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9LISDATA.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9INDEXLIS.DBF' to 'E:\oracle\product\10.2.0\oradata\orcl\ZL9INDEXLIS.DBF';
release channel c1;
release channel c2;
release channel c3;
restore database;
switch datafile all;
}
--5.sql下执行,主库查询 select * from V$logfile
alter database rename file 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01.LOG' to 'E:\oracle\product\10.2.0\oradata\orcl\REDO01.LOG';
alter database rename file 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO02.LOG' to 'E:\oracle\product\10.2.0\oradata\orcl\REDO02.LOG';
alter database rename file 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO03.LOG' to 'E:\oracle\product\10.2.0\oradata\orcl\REDO03.LOG';
--6.重新创建控制文件
--sql下执行,生成控制文件脚本
alter database backup controlfile to trace as 'd:\cont.trc';
--数据库启动到mount状态下执行:
CREATE CONTROLFILE REUSE DATABASE "ORCL" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01.LOG' SIZE 50M,
GROUP 2 'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO02.LOG' SIZE 50M,
GROUP 3 'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO03.LOG' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF',
'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF',
'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF',
'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF',
'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZLTOOLSTBS.DBF',
'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9BASEITEM.DBF',
'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9PATIENT.DBF',
'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9EXPENSE.DBF',
'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9MEDLST.DBF',
'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9DUEREC.DBF',
'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9CISREC.DBF',
'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9EPRLOB.DBF',
'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9EPRDAT.DBF',
'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9CISAUDIT.DBF',
'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9INDEXHIS.DBF',
'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZL9INDEXCIS.DBF',
'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ZLBAKZLHIS.DBF'
CHARACTER SET ZHS16GBK
;
7.注册归档日志文件路径,mount状态下ramn target/
catalog start with 'E:\ARCHIVE'
8.截止恢复,mount状态下ramn target/
recover database
9.启动数据库
alter database open resetlogs;
10.增加临时表空间数据文件
alter tablespace temp add tempfile 'E:\oracle\product\10.2.0\oradata\orcl\temp02.dbf' size 2048M;
alter tablespace ZLTOOLSTMP add tempfile 'E:\oracle\product\10.2.0\oradata\orcl\zltooltemp01.dbf' size 2048M;