oracle10g_rman_語法測試_restore專題

wisdomone1發表於2009-09-25
The primary use of RESTORE is to restore files from backups or image copies. Typically, you restore when a media failure has damaged a current datafile, control file, or archived log or prior to performing a point-in-time recovery.

There are other uses of RESTORE that do not actually restore files from backup:

RESTORE... VALIDATE causes RMAN to select existing backups that it would use to perform. a RESTORE operation, and scan them all to ensure that they are present and free of corruption.

RESTORE... PREVIEW identifies the backups which RMAN will use to perform. any RESTORE operation. Output from a RESTORE... PREVIEW is in the same format as the output of the LIST command.

RESTORE... PREVIEW RECALL is used to request the recall of backups needed for a RESTORE operation that are stored on remote storage.

Examples

Restoring a Tablespace: Example
This example takes a tablespace offline, restores it, then performs media recovery:

SQL "ALTER TABLESPACE users OFFLINE IMMEDIATE";
RESTORE TABLESPACE users;
RECOVER TABLESPACE users;  
SQL "ALTER TABLESPACE users ONLINE";
Restoring the Control File When Using a Recovery Catalog: Example
This example restores the control file to its default location, replicates it automatically to all CONTROL_FILES locations, and mounts the database:

RUN
{ # SET DBID is not necessary when connected to a recovery catalog
  STARTUP FORCE NOMOUNT;
  RESTORE CONTROLFILE;
  ALTER DATABASE MOUNT;
}
Restoring the Control File with a Tag: Example
This NOCATALOG example restores the control file specified by a tag, and then mounts the database:

CONNECT TARGET /
STARTUP NOMOUNT;
SET DBID 320066378;  # required when restoring control file in NOCATALOG mode
RESTORE CONTROLFILE FROM TAG 'monday_cf_backup';
ALTER DATABASE MOUNT;
Restoring the Database with a Backup Control File: Example
This example restores the control file to a temporary location, replicates it to all control file locations specified in the CONTROL_FILES initialization parameter, and then restores and recovers the database:

CONNECT TARGET /
STARTUP NOMOUNT;
SET DBID 320066378;  # required when restoring control file in NOCATALOG mode
RUN
{
  ALLOCATE CHANNEL c1 DEVICE TYPE sbt;
  RESTORE CONTROLFILE FROM AUTOBACKUP;
  ALTER DATABASE MOUNT;
  RESTORE DATABASE;
  RECOVER DATABASE;
}
ALTER DATABASE OPEN RESETLOGS;
Restoring Archived Redo Logs to a New Location: Example
This example restores all archived redo logs to the /oracle/temp_restore directory:

RMAN> RUN
{
  SET ARCHIVELOG DESTINATION TO '/oracle/temp_restore';
  RESTORE ARCHIVELOG ALL;
}
Restoring a Control File Autobackup to a Nondefault Location: Example
This example restores the latest control file autobackup made on or before June 23, 2000 with a nondefault format of PROD_CF_AUTOBACKUP_%F. It starts searching for backups with a sequence number of 20, and searches backward for 5 months:

RMAN> SET DBID 320066378;  # required when restoring control file in NOCATALOG mode
RMAN> RUN
{
  SET UNTIL TIME '23-JUN-2001 00:00:00';
  SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE sbt TO 'prod_cf_autobackup_%F';
  ALLOCATE CHANNEL CHANNEL_1 DEVICE TYPE sbt;
  RESTORE CONTROLFILE TO '/tmp/autobackup_20001002.dbf' FROM AUTOBACKUP
    MAXSEQ 20 MAXDAYS 150;
}
Restoring the Server Parameter File to Current Location: Example
The following series of commands restores the current server parameter file in NOCATALOG mode:

rman TARGET /
RMAN> SET DBID 1447326980 # set dbid to dbid of target database
RMAN> STARTUP FORCE NOMOUNT; # start instance with dummy SPFILE
RMAN> RUN
{
  ALLOCATE CHANNEL c1 DEVICE TYPE sbt;
  RESTORE SPFILE FROM AUTOBACKUP; # FROM AUTOBACKUP needed in NOCATALOG mode
}
RMAN> STARTUP FORCE; # start with restored SPFILE and open database
Identifying Needed Backups with RESTORE... PREVIEW: Example
The following example shows the results of a RESTORE PREVIEW, which identifies the backupsets RMAN selects for use in restoring archivelogs from backup. (Note that in this output, one of the archivelog backups is stored remotely.)

RMAN> restore archivelog all preview;
 
Starting restore at 10-JUN-05
using channel ORA_DISK_1
using channel ORA_SBT_TAPE_1
 
 
List of Backup Sets
===================
 
BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
31      12.75M     SBT_TAPE    00:00:02     10-JUN-05    
        BP Key: 33   Status: AVAILABLE  Compressed: NO  Tag: TAG20050610T152755
        Handle: 15gmknbs   Media: /v1,15gmknbs
 
  List of Archived Logs in backup set 31
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    1       221154     06-JUN-05 222548     06-JUN-05
  1    2       222548     06-JUN-05 222554     06-JUN-05
  1    3       222554     06-JUN-05 222591     06-JUN-05
  1    4       222591     06-JUN-05 246629     07-JUN-05
  1    5       246629     07-JUN-05 262451     10-JUN-05
 
BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
32      256.00K    SBT_TAPE    00:00:01     10-JUN-05    
        BP Key: 34   Status: AVAILABLE  Compressed: NO  Tag: TAG20050610T153105
        Handle: 17gmknhp_1_1   Media: /v1,17gmknhp_1_1
 
  List of Archived Logs in backup set 32
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    6       262451     10-JUN-05 262547     10-JUN-05
  1    7       262547     10-JUN-05 262565     10-JUN-05
 
List of remote backup files
============================
        Handle: 15gmknbs   Media: /v1,15gmknbs

Recalling Vaulted Backups from Remote Storage with RESTORE... PREVIEW RECALL: Example
When used with a media manager that reports information about remote storage of backups and supports recalling vaulted backups, the following command requests that any media needed in the restore of archivelogs from backup be recalled from remote storage:

RMAN> RESTORE ARCHIVELOG ALL PREVIEW RECALL;
Starting restore at 10-JUN-05
using channel ORA_DISK_1
using channel ORA_SBT_TAPE_1
 
 
List of Backup Sets
===================
 
BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
31      12.75M     SBT_TAPE    00:00:02     10-JUN-05    
        BP Key: 33   Status: AVAILABLE  Compressed: NO  Tag: TAG20050610T152755
        Handle: 15gmknbs   Media: /v1,15gmknbs
 
  List of Archived Logs in backup set 31
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    1       221154     06-JUN-05 222548     06-JUN-05
  1    2       222548     06-JUN-05 222554     06-JUN-05
  1    3       222554     06-JUN-05 222591     06-JUN-05
  1    4       222591     06-JUN-05 246629     07-JUN-05
  1    5       246629     07-JUN-05 262451     10-JUN-05
 
BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
32      256.00K    SBT_TAPE    00:00:01     10-JUN-05    
        BP Key: 34   Status: AVAILABLE  Compressed: NO  Tag: TAG20050610T153105
        Handle: 17gmknhp_1_1   Media: /v1,17gmknhp_1_1
 
  List of Archived Logs in backup set 32
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    6       262451     10-JUN-05 262547     10-JUN-05
  1    7       262547     10-JUN-05 262565     10-JUN-05
 
Initiated recall for the following list of remote backup files
==========================================================
        Handle: 15gmknbs   Media: /v1,15gmknbs
Finished restore at 10-JUN-05

Validating a Restore with RESTORE VALIDATE: Example
The following example illustrates using RESTORE... VALIDATE to confirm that backups required for the restore of datafile 1 are present on disk or tape, readable, and not corrupted:

RMAN> RESTORE DATAFILE 1 VALIDATE;

Starting restore at 10-OCT-03
using channel ORA_DISK_1

channel ORA_DISK_1: starting validation of datafile backupset
channel ORA_DISK_1: restored backup piece 1
piece handle=/disk1/oracle/work/v1/0pf3hr3o_1 tag=FOURTH_INC
channel ORA_DISK_1: validation complete
Finished restore at 10-OCT-03




"RESYNC"

 Perform. a full resynchronization, which creates a snapshot control file and then copies any new or changed information from that snapshot control file to the recovery catalog.
 


Use RESYNC CATALOG to perform. manual full resynchronizations when:

The recovery catalog is unavailable when you issue any of the commands that automatically perform. a resynchronization.

You are running in ARCHIVELOG mode, because the catalog is not updated automatically when a log switch occurs or when an online redo log is archived.

You have made changes to the physical structure of the target database such as adding or dropping a tablespace. As with archive operations, the recovery catalog is not updated automatically when the physical schema changes.

The primary use for RESYNC CONTROLFILE occurs when you re-create the control file (for example, to change the database name), which causes you to lose RMAN records. You can then resynchronize the newly created control file with an old copy.

Restrictions and Usage Notes

You must be connected to a recovery catalog when running RESYNC CATALOG, but a catalog connection is not required for RESYNC CONTROLFILE.

RMAN updates physical schema information in the recovery catalog only when the target database has the current control file mounted. If the target database has mounted a backup control file, a freshly created control file, or a control file that is less current than a control file that was used previously, then RMAN does not update physical schema information in the recovery catalog.

Keywords and Parameters

Syntax Element Description
CATALOG Updates the recovery recovery catalog with RMAN metadata in the current control file (default) or a control file copy.
CONTROLFILE Updates the current control file (and recovery catalog, if RMAN is connected to one) with RMAN metadata from a control file copy.
FROM CONTROLFILECOPY 'filename' Specifies the name of the control file copy to use for resynchronization. Physical schema information is not updated when you use this option.
Note: The control file copy can either be in the current database incarnation, or created in a prior incarnation (that is, prior to the most recent OPEN RESETLOGS).
 


Examples

Resynchronizing the Recovery Catalog in ARCHIVELOG Mode: Example
This example performs a full resynchronization after archiving all unarchived redo logs:

CONNECT TARGET / CATALOG rman/rman@catdb
SQL "ALTER SYSTEM ARCHIVE LOG ALL";
RESYNC CATALOG;
Resynchronizing the Current Control File from a Backup: Example
This example updates the RMAN repository in the current control file with metadata from a backup control file:

CONNECT TARGET / NOCATALOG
RESYNC CONTROLFILE FROM CONTROLFILECOPY '/tmp/cfile.dbf';
Resynchronizing the Recovery Catalog After a Structural Change: Example
This example adds a datafile to tablespace users and then resynchronizes the catalog:

#!/usr/bin/tcsh
# connect in nocatalog mode and add datafile
rman TARGET / NOCATALOG <SQL "ALTER TABLESPACE users ADD DATAFILE ''?/oradata/trgt/users03.dbf''
     SIZE 1M AUTOEXTEND ON NEXT 10K MAXSIZE 10M";
EXIT
EOF
# connect in catalog mode and resynchronize
rman TARGET / CATAOG rman/rman@catdb <RESYNC CATALOG;
EOF

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-615556/,如需轉載,請註明出處,否則將追究法律責任。

相關文章