rman backup command concepts [message #393372] |
Sun, 22 March 2009 05:54 |
kytemanaic
Messages: 55 Registered: February 2009
|
Member |
|
|
with reference to http://download.oracle.com/docs/cd/B19306_01/backup.102/b14191/rcmrecov.htm#sthref555
case 1
RUN
{
# allocate a channel to the tape device
ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS='...';
# 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;
}
EXIT
case 2
RMAN> RUN
{
# If you need to restore the files to new locations, tell Recovery Manager
# to do this using SET NEWNAME commands:
SET NEWNAME FOR DATAFILE 1 TO '/dev/vgd_1_0/rlvt5_500M_1';
SET NEWNAME FOR DATAFILE 2 TO '/dev/vgd_1_0/rlvt5_500M_2';
SET NEWNAME FOR DATAFILE 3 TO '/dev/vgd_1_0/rlvt5_500M_3';
ALLOCATE CHANNEL t1 DEVICE TYPE sbt;
RESTORE CONTROLFILE FROM AUTOBACKUP;
ALTER DATABASE MOUNT;
SET UNTIL SEQUENCE 124 THREAD 1;
RESTORE DATABASE;
SWITCH DATAFILE ALL; # Update control file with new location of datafiles.
RECOVER DATABASE;
}
RMAN> ALTER DATABASE OPEN RESETLOGS;
Quetion 1
for case 1 we mount the database first before set newname.
for case 2 we set newname first before mount the database.
since there's discrepancy, at what stage of recovery can we set newname, mount the database?
Question 2
for case 1
ALLOCATE CHANNEL first before SET NEWNAME
for case 2
SET NEWNAME before ALLOCATE CHANNEL
since there's discrepancy, at what stage of recovery can we allocate channel and SET NEWNAME?
Question 3
after in both cases
the following commands are in sequence
SET UNTIL ......
RESTORE DATABASE;
SWITCH DATAFILE ALL;
RECOVER DATABASE;
SET UNTIL is to make sure we set to restore and recovery point, right?
Why do SWTICH DATAFILE ALL comes between RESTORE DATABASE and RECOVER DATABASE commands?
thanks a lot!
|
|
|
Re: rman backup command concepts [message #393385 is a reply to message #393372] |
Sun, 22 March 2009 08:02 |
|
Mahesh Rajendran
Messages: 10708 Registered: March 2002 Location: oracleDocoVille
|
Senior Member Account Moderator |
|
|
>>since there's discrepancy, at what stage of recovery can we set newname, mount the database?
You restore the control file, mount the database, do a set new name/rename log files and proceed with restore/recovery.
It appears to be a discrepancy (thanks to the kind people at Oracle for clear documentation) because
in first case, you are restoring control file in a separate rman run block and just doing restore in second block.
>>since there's discrepancy, at what stage of recovery can we allocate channel and SET NEWNAME?
Same as above.
You can altogether allocate channels upfront or allocate them as you need for each operation.
You allocate channels, set new name, restore / recover /duplicate.
>>Why do SWTICH DATAFILE ALL comes between RESTORE DATABASE and RECOVER DATABASE commands?
Because the datafile name/location has changed and controlfile should be notified about this.
Quoting documentation.
Quote: | DATAFILE ALL : Specifies that all datafiles for which a SET NEWNAME FOR DATAFILE command has been issued in this job are switched to their new name.
|
Again quoting the docs
Quote: |
For example, if you restore datafile ?/oradata/trgt/tools01.dbf to its default location, then RMAN restores the file ?/oradata/trgt/tools01.dbf and overwrites any file that it finds with the same filename. If you run a SET NEWNAME command before you restore a file, then RMAN creates a datafile copy with the name that you specify. For example, assume that you run the following commands:
SET NEWNAME FOR DATAFILE '?/oradata/trgt/tools01.dbf' TO '/tmp/tools01.dbf';
RESTORE DATAFILE '?/oradata/trgt/tools01.dbf';
In this case, RMAN creates a datafile copy of ?/oradata/trgt/tools01.dbf named /tmp/tools01.dbf and records it in the repository. To change the name for datafile ?/oradata/trgt/tools01.dbf to /tmp/tools01.dbf in the control file, run a SWITCH command so that RMAN considers the restored file as the current database file. For example:
SWITCH DATAFILE '/tmp/tools01.dbf' TO DATAFILECOPY '?/oradata/trgt/tools01.dbf';
The SWITCH command is the RMAN equivalent of the SQL statement ALTER DATABASE RENAME FILE.
|
[Updated on: Sun, 22 March 2009 08:18] Report message to a moderator
|
|
|
Re: rman backup command concepts [message #393912 is a reply to message #393372] |
Tue, 24 March 2009 21:15 |
alexzeng
Messages: 133 Registered: August 2005 Location: alexzeng.wordpress.com
|
Senior Member |
|
|
hi,
I think whether you mount the database first or set newname first is not a problem. But the set newname must in the same rman block of restore/recover.
SWITCH DATAFILE ALL before or after RECOVER DATABASE is not a problem as well. As Mahesh said, the SWITCH DATAFILE ALL is to change the datafile names in controlfile. You can not do SWITCH DATAFILE ALL, but use parameter DB_FILE_NAME_CONVERT instead.
This is just my understanding of oracle backup and recovery. If I have time I will have a test to verify it. You can have a test and let us know.
Regards,
Alex
[Updated on: Wed, 25 March 2009 02:08] by Moderator Report message to a moderator
|
|
|