rman uses level 0 backup set for different recovery
$ rman target /
/*
It is used for testing. It is found that the test fails. It is very useful if you need to restore spfile
There is no parameter file. An instance of DUMMY will be generated under the command of RMAN
RMAN> set dbid=1234567890;
*/
Start database to nomunt state
RMAN> startup nomount pfile='/ebsfs/EBSPROD2/db/tech_st/11.2.0/dbs/initEBSPROD.ora';
Restore control file
RMAN> run {
ALLOCATE CHANNEL ch00 TYPE disk;
restore controlfile to '/ebsfs/EBSPROD2/db/apps_st/data/cntrl01.dbf' from '/ebstar/ebsclonetar2/CTL_c-xxxxxxxx-04';
restore controlfile to '/ebsfs/EBSPROD2/db/apps_st/data/cntrl02.dbf' from '/ebstar/ebsclonetar2/CTL_c-xxxxxxxx-04';
restore controlfile to '/ebsfs/EBSPROD2/db/apps_st/data/cntrl03.dbf' from '/ebstar/ebsclonetar2/CTL_c-xxxxxxxx-04';
RELEASE CHANNEL ch00;
}
Modify database to mount state
RMAN> alter database mount;
Validation backup set
RMAN> crosscheck backupset;
Delete backup set
RMAN> delete expired backup;
Register local directory, make sure the last '/'
RMAN>catalog start with '/ebstar/ebsclonetar2/';
Check for restore
RMAN> run{
ALLOCATE CHANNEL ch00 TYPE disk;
restore database preview summary;
RELEASE CHANNEL ch00;
}
Media recovery start SCN is xxxxxxxx
Recovery must be done beyond SCN xxxxxxxx to clear datafile fuzziness
Finished restore at xx-xxx-xx
released channel: ch00
Open a new shell session, splice and restore SQL
$ Sqlplus /nolog
SQL> conn / as sysdba;
Connected.
SQL> set lines 500;
SQL> set pages 500;
SQL> select 'set newname for datafile '''||dd.name||''' to '''||replace(replace(dd.name,'/EBSPROD/','/EBSPROD2/'),'/ebsfs2/','/ebsfs/')||''';' as set_dbname
from v$datafile dd
where 1=1
order by dd.name
;
Restore the database and open 4 channel s
Paste the above output statement to the following place
RMAN> run{
ALLOCATE CHANNEL ch00 TYPE disk;
ALLOCATE CHANNEL ch01 TYPE disk;
ALLOCATE CHANNEL ch02 TYPE disk;
ALLOCATE CHANNEL ch03 TYPE disk;
----------
----------
restore database;
switch datafile all;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
RELEASE CHANNEL ch02;
RELEASE CHANNEL ch03;
}
Archive as many applications as possible, and remember not to open the database rashly
RMAN> run{
ALLOCATE CHANNEL ch00 TYPE disk;
recover database ;
RELEASE CHANNEL ch00;
}
After completion, an ora error will be reported, indicating that the specified archive file cannot be found
At this time, you can copy the generated archive file from the source library
Register the local directory again, and make sure the last '/'
RMAN> catalog start with '/ebstar/ebsclonetar2/';
RMAN> list backup summary;
RMAN> list backup ;
Restore database again
RMAN> run{
ALLOCATE CHANNEL ch00 TYPE disk;
recover database ;
RELEASE CHANNEL ch00;
}
Open a new sqlplus session and modify the file
sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Mon Feb 24 09:34:38 2016
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> conn / as sysdba;
Connected.
SQL> select instance_name,status from v$instance;
SQL> set lines 500;
SQL> set pages 500;
SQL> select 'alter database rename file '''||dd.file_name||''' to '''||replace(replace(dd.file_name,'/EBSPROD/','/EBSPROD2/'),'/ebsfs2/','/ebsfs/') ||''';' as alter_tmpname
from (
select name as file_name from v$tempfile
union all
select member as file_name from v$logfile l
) dd
Order by dd.file_name
Just copy it and execute it
Open database
SQL> select instance_name,status from v$instance;
SQL> alter database open resetlogs;