oracle10g_rman_語法測試_restore專題
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
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 <
SIZE 1M AUTOEXTEND ON NEXT 10K MAXSIZE 10M";
EXIT
EOF
# connect in catalog mode and resynchronize
rman TARGET / CATAOG rman/rman@catdb <
EOF
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-615556/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle10g_rman_語法測試_show專題Oracle
- oracle10g_rman_語法測試_1Oracle
- oracle10g_rman_語法測試_2Oracle
- oracle10g_rman_語法測試_3Oracle
- oracle10g_rman_語法測試_4Oracle
- oracle10g_rman_語法測試_5Oracle
- oracle10g_rman_語法測試_6Oracle
- oracle10g_rman_語法測試_7Oracle
- oracle10g_rman_語法測試_8Oracle
- oracle10g_rman_語法測試_10Oracle
- oracle10g_rman_語法測試_spool_sql_startupOracleSQL
- oracle10g_rman_語法測試_reset database_allocate channel_OracleDatabase
- if測試和語法規則
- 前端測試框架Jest——語法篇前端框架
- python語法-測試程式碼Python
- 資料庫測試專用術語資料庫
- TPA測試專案管理系統-測試問題管理專案管理
- 測試開發專題-開篇
- 挨踢專案求生法則——測試篇
- 軟體測試培訓之:白盒測試的語句覆蓋法和判定覆蓋法
- dbms_backup_restore恢復測試!nocatalog,丟失controlfile的恢復辦法!REST
- 【專題】深入解析軟體測試外包
- rman_restore controlfile_and_autobackup之關係測試REST
- C語言上機測試模擬題-1C語言
- C語言上機測試模擬題2C語言
- 語法問題
- 軟體測試實戰專案,問題答疑
- 【專題】測試人員 VS 開發人員
- C語言[工程專案應用]gtest測試框架編寫以及自定義測試框架C語言框架
- PJzhang:搜尋引擎高階語法與滲透測試
- 常見112個測試英語面試題面試題
- 測試CMS同步問題測試CMS同步問題
- 軟體測試專業中英文術語對照表
- 測試面試題面試題
- 面試測試題面試
- ORACLE 測試題:Oracle
- 專訪測試資深大神“雲層”,深入解答測試行業7大問題行業
- 我使用jest測試專案中常見的問題