学习Mechanics of Datafile Restore Operations的注意点

来源:互联网 发布:c语言源代码 编辑:程序博客网 时间:2024/05/18 16:14
 

学习Mechanics of Datafile Restore Operations的注意点

When you issue a RESTORE command, RMAN directs a server session to restore a suitable backup to either:

 

The default location, overwriting the files with the same name currently there

 

A new location, which you can specify with the SET NEWNAME command

 

To restore a datafile, either mount the database, or keep it open and take the datafile to be restored offline. When RMAN performs a restore, it creates the restored files as datafile image copies and records them in the repository.

 

The following table describes the behavior of the RESTORE, SET NEWNAME, and SWITCH commands.

Run SET NEWNAME?

RESTORE Behavior

Run SWITCH?

No

RMAN restores the files to their current path names.

N/A

Yes

RMAN restores the files to the path names specified by SET NEWNAME and creates repository records for each datafile copy after the restore.

If yes, then RMAN replaces the current datafile names in the control file to the names of the restored files and current datafile names (if exists) are stored as datafile copies. If no, then RMAN doesn't update current datafile names and the restored file is retained as datafile copies.

 

 

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:

RUN {

    SET NEWNAME FOR DATAFILE '/opt/oracle/oradata/ge02/users01.dbf' TO '/test/users01.dbf';

    RESTORE DATAFILE '/opt/oracle/oradata/ge02/users01.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 update the control file to use the datafile copy at ?/oradata/trgt/tools01.dbf to /tmp/tools01.dbf as the datafile, use the SWITCH command as shown in the following example:

 

SWITCH DATAFILE 5 TO COPY;

或者

SWITCH DATAFILE '/opt/oracle/oradata/ge02/users01.dbf' TO COPY;

 

The SWITCH command is the RMAN equivalent of the SQL statement ALTER DATABASE RENAME FILE.

 

注意红色的部分,只有这样写才正确,如果象下面的写法,则会报错:

 

RMAN> SWITCH DATAFILE '/opt/oracle/oradata/ge02/users01.dbf' TO COPY   '/test/users01.dbf' ;

 

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-00558: error encountered while parsing input commands

RMAN-01009: syntax error: found "single-quoted-string": expecting one of: ";"

RMAN-01007: at line 1 column 66 file: standard input

 

RMAN> SWITCH DATAFILE 5 TO COPY   '/test/users01.dbf' ;

 

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-00558: error encountered while parsing input commands

RMAN-01009: syntax error: found "single-quoted-string": expecting one of: ";"

RMAN-01007: at line 1 column 29 file: standard input

 

如果是上面红色的写法,则步会报错:

RMAN> SWITCH DATAFILE 5 TO COPY;

datafile 5 switched to datafile copy "/test/users01.dbf"

starting full resync of recovery catalog

full resync complete

 

RMAN> SWITCH DATAFILE '/opt/oracle/oradata/ge02/users01.dbf'  TO COPY;

datafile 5 switched to datafile copy "/test/users01.dbf"

starting full resync of recovery catalog

full resync complete

原创粉丝点击