Hi,
I recently created a script wrapped around RMAN which does the following:
- delete all datafiles from a duplicate (auxiliary) directory (Fast Recovery Area)
- startup the duplicate (auxiliary) instance in nomount phase
- start a duplicate from target database to duplicate (auxiliary) database
Two things that had to be taken care of are at first:
1. add the (UR=A)(in tnsnames.ora on target side) to allow connections to blocked services (see My Oracle Support ID 362656.1)
2. issue an alter system register; to register the database service with the listener when starting the duplicate after a shutdown abort; rm -rf /dir/SID/datafile/* ; startup nomount
3. use password file for authentication
Both databases use Fast Recovery Area (FRA) and Oracle Managed Files (OMF). All this is automated in a script, wrapped around RMAN, and every time the script ran into an error:
ORA-19906: recovery target incarnation changed during recovery
So, what is happening here?
This is typically caused by older archivelogs stored in the Fast Recovery Area (FRA) on the auxiliary system.
During the recovery phase, rman will catalog all files found in the FRA and if there are older archivelogs (eg. from a previous duplicate attempt and different incarnation), the incarnation is changed in the controlfile, hence the error.
So my problem was solved when also doing a rm -rf /dir/SID/FRA/archivelogs/* (deleting the achivelogs, before starting the duplicate)