oracle文档里有这么一个案例,我整理了一下:
1. 设置ORACLE_SID
export ORACLE_SID=central
2. 启动RAMN
rman TARGET / NOCATALOG
3. 设置DBID
SET DBID 1331322689;
4. 启动数据库(no mount状态)
STARTUP NOMOUNT
会出现以下信息
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/net/hostb/oracle/dbs/inittrgta.ora'
trying to start the Oracle instance without parameter files ...
Oracle instance started
#5. 恢复参数文件
RESTORE SPFILE TO PFILE '?/oradata/test/inittrgta.ora' FROM AUTOBACKUP;
SHUTDOWN ABORT;
#6. 编辑参数文件中的文件路径
如路径和原来一样,则不需修改
eg:
- *_DUMP_DEST
- LOG_ARCHIVE_DEST*
- CONTROL_FILES
#7. 重启实例,使用已编辑好的参数文件
STARTUP FORCE NOMOUNT PFILE='?/oradata/test/inittrgta.ora';
8.恢复控制文件,装载数据库
RESTORE CONTROLFILE FROM AUTOBACKUP;
ALTER DATABASE MOUNT;
9.查询记录在控制文件中的数据文件信息
% sqlplus '/ AS SYSDBA'
SQL> COLUMN NAME FORMAT a60
SQL> SPOOL LOG 'db_filenames.out'
SQL> SELECT FILE# AS "File/Grp#", NAME FROM V$DATAFILE
UNION
SELECT GROUP#,MEMBER FROM V$LOGFILE;
SQL> SPOOL OFF
10.数据库恢复
如果路径和原来的一样,则不需要指定数据文件的恢复路径
RUN
{
# rename the datafiles and online redo logs
SET NEWNAME FOR DATAFILE 1 TO '?/oradata/test/system01.dbf';
SET NEWNAME FOR DATAFILE 2 TO '?/oradata/test/undotbs01.dbf';
SET NEWNAME FOR DATAFILE 3 TO '?/oradata/test/cwmlite01.dbf';
SET NEWNAME FOR DATAFILE 4 TO '?/oradata/test/drsys01.dbf';
SET NEWNAME FOR DATAFILE 5 TO '?/oradata/test/example01.dbf';
SET NEWNAME FOR DATAFILE 6 TO '?/oradata/test/indx01.dbf';
SET NEWNAME FOR DATAFILE 7 TO '?/oradata/test/tools01.dbf';
SET NEWNAME FOR DATAFILE 8 TO '?/oradata/test/users01.dbf';
SQL "ALTER DATABASE RENAME FILE ''/dev3/oracle/dbs/redo01.log''
TO ''?/oradata/test/redo01.log'' ";
SQL "ALTER DATABASE RENAME FILE ''/dev3/oracle/dbs/redo02.log''
TO ''?/oradata/test/redo02.log'' ";
# Do a SET UNTIL to prevent recovery of the online logs
#SET UNTIL SCN 123456;
# restore the database and switch the datafile names
RESTORE DATABASE;
SWITCH DATAFILE ALL;
# recover the database
RECOVER DATABASE;
}
11.以重置日志的方式打开数据库
ALTER DATABASE OPEN RESETLOGS;