oracle10g_rman_語法測試_reset database_allocate channel_
archivelog 'filename'|primary key
backupset primarykey
backuppiece 'media_handle'|primary key|tag='tag_name'
controlfilecopy 'filename'|primary key|tag='tag_name' noduplicates
datafilecopy 後同上
datafilecopy all noduplicates
like 'string_pattern' noduplicates
NODUPLICATES With CONTROLFILECOPY or DATAFILECOPY, specifies that only one copy of the control file or datafile copy specified by the rest of the clause should be the target of the operation,
even when there are multiple copies.
Examples
Crosschecking Backups: Example
This example crosschecks backup sets specified by primary key:
CROSSCHECK BACKUPSET 507, 509;
Deleting Datafile Copies: Example
This example deletes a specified datafile copy:
DELETE NOPROMPT DATAFILECOPY '?/oradata/users01.cpy';
Examples
Recovering a Tablespace in an Open Database: Example
The following example takes tablespace tools offline, uses automatic channels to restore and recover it (deleting the logs that it restored from tape), then brings it back online:
SQL "ALTER TABLESPACE tbs_1 OFFLINE IMMEDIATE";
RESTORE TABLESPACE tbs_1;
# restore only 2M of logs at a time, then delete them
RECOVER TABLESPACE tools DELETE ARCHIVELOG MAXSIZE 2M;
SQL "ALTER TABLESPACE tools ONLINE";
Recovering Datafiles Restored to New Locations: Example
The following example uses the preconfigured disk channel and manually allocates one media management channel to use datafile copies on disk and backups on tape, and restores one of the datafiles in tablespace users to a different location:
RMAN> RUN
{
ALLOCATE CHANNEL dev2 DEVICE TYPE sbt;
SQL "ALTER TABLESPACE users OFFLINE IMMEDIATE";
SET NEWNAME FOR DATAFILE '?/oradata/trgt/users01.dbf'
TO '/tmp/users01.dbf';
RESTORE TABLESPACE users;
SWITCH DATAFILE ALL;
RECOVER TABLESPACE users;
SQL "ALTER TABLESPACE users ONLINE";
}
Performing DBPITR with a Backup Control File and Recovery Catalog: Example
Assume that all datafiles and control files as well as archived redo log 40 were lost due to a disk failure. Also assume that you do not have incremental backups. You need to recover the database with available archived redo logs. You do not need to restore tablespace history because it has not changed since log 40. After connecting to the target and recovery catalog, follow the example shown here:
RMAN> STARTUP FORCE NOMOUNT;
RMAN> RUN
{
SET UNTIL SEQUENCE 40 THREAD 1; # Recover database until log sequence 40
RESTORE CONTROLFILE;
ALTER DATABASE MOUNT;
RESTORE DATABASE SKIP TABLESPACE temp, history;
RECOVER DATABASE SKIP FOREVER TABLESPACE temp;
}
RMAN> ALTER DATABASE OPEN RESETLOGS;
If the database uses locally-managed temporary tablespaces, and you restore a backup control file, and you do not have a recovery catalog, then you must add tempfiles to these tablespaces afterwards, using the SQL ALTER TABLESPACE... ADD TEMPFILE command:
RMAN> SQL "ALTER TABLESPACE temp ADD TEMPFILE ''?/oradata/trgt/temp01.dbf'' REUSE";
RECOVER an Image Copy of a Datafile to a Point in Time: Example
Assume that you have an image copy backup of a datafile and you want to roll it forward in time using incremental backups. Use RECOVER DATAFILECOPY with the UNTIL TIME option. For example, run the following command:
RMAN> RECOVER DATAFILECOPY '/disk1/3img.df' UNTIL TIME 'SYSDATE-7';
Available incremental backups are applied to the datafile copy to recover it to the desired point in time. Redo from the archived redo logs is not applied by this command.
Example
Registering a Database: Example
The following commands register a new target database, catalogs an existing datafile copy, then opens the database for use:
% rman TARGET / CATALOG rman/rman@catdb
RMAN> STARTUP FORCE MOUNT;
RMAN> REGISTER DATABASE;
RMAN> CATALOG DATAFILECOPY '?/oradata/system01.cpy';
RMAN> ALTER DATABASE OPEN;
Releasing a Channel: Example
This example makes three identical backup sets of datafiles 1 to 4 to tape with channel ch1, then releases it. RMAN then makes three identical backups of datafiles 5 to 7 to tape with channel ch2 and then releases it:
RUN {
SET BACKUP COPIES = 3;
ALLOCATE CHANNEL ch1 DEVICE TYPE sbt FORMAT 'bkup_%U';
ALLOCATE CHANNEL ch2 DEVICE TYPE sbt MAXPIECESIZE = 5M;
BACKUP CHANNEL ch1 DATAFILE 1,2,3,4;
RELEASE CHANNEL ch1;
BACKUP DATAFILE 5,6,7;
}
Requirements
Execute this command only at the RMAN prompt, not within a RUN block.
You must have a maintenance channel allocated in order to release it.
Examples
Releasing a Maintenance Channel After a Delete Operation: Example
This example allocates and then releases a maintenance channel to the media manager:
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE sbt;
DELETE NOPROMPT BACKUPPIECE 100;
RUN
{
ALLOCATE CHANNEL ch1 DEVICE TYPE DISK;
BACKUP DATAFILE 1;
RELEASE CHANNEL ch1; # releases RUN channel but not maintenance channel
}
RELEASE CHANNEL; # releases maintenance channel
Examples
Resetting RMAN to a Previous Incarnation in NOCATALOG Mode: Example
In NOCATALOG mode, you must mount a control file that knows about the incarnation that you want to recover. The following scenario makes an old incarnation of database trgt current again:
CONNECT TARGET / NOCATALOG
# step 1: start and mount a control file that knows about the incarnation to which
# you want to return. if the current control file does not know about it, then
# you must restore an older control file
STARTUP NOMOUNT;
RESTORE CONTROLFILE UNTIL TIME 'SYSDATE-250';
ALTER DATABASE MOUNT;
# step 2: obtain the primary key of old incarnation
LIST INCARNATION OF DATABASE trgt;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ------------- ------- ---------- ----------
1 2 TRGT 1334358386 PARENT 154381 OCT 30 2001 16:02:12
1 116 TRGT 1334358386 CURRENT 154877 OCT 30 2001 16:37:39
# step 3: in this example, reset database to incarnation key 2
RESET DATABASE TO INCARNATION 2;
# step 4: restore and recover the database to a point before the RESETLOGS
RESTORE DATABASE UNTIL SCN 154876;
RECOVER DATABASE UNTIL SCN 154876;
# step 5: make this incarnation the current incarnation and then list incarnations:
ALTER DATABASE OPEN RESETLOGS;
LIST INCARNATION OF DATABASE trgt;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- ------- ---------- ----------
1 2 TRGT 1334358386 PARENT 154381 OCT 30 2001 16:02:12
1 116 TRGT 1334358386 PARENT 154877 OCT 30 2001 16:37:39
1 311 TRGT 1334358386 CURRENT 154877 AUG 13 2002 17:17:03
Resetting the Database After Incomplete Recovery: Example
This example assumes that an incomplete recovery or recovery with a backup control file was performed in NOCATALOG mode. Later, RMAN is started in CATALOG mode, but the RESYNC command fails because the incarnation has not been reset in the catalog.
% rman target / catalog rman/rman@catdb
Recovery Manager: Release 10.1.0.2.0 - Production
Copyright (c) 1995, 2003, Oracle. All rights reserved.
connected to target database: TRGT (DBID=1334531173)
connected to recovery catalog database
RMAN> RESYNC CATALOG;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of resync command on default channel at 11/01/2001 12:00:43
RMAN-20003: target database incarnation not found in recovery catalog
RMAN> RESET DATABASE;
new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
backupset primarykey
backuppiece 'media_handle'|primary key|tag='tag_name'
controlfilecopy 'filename'|primary key|tag='tag_name' noduplicates
datafilecopy 後同上
datafilecopy all noduplicates
like 'string_pattern' noduplicates
NODUPLICATES With CONTROLFILECOPY or DATAFILECOPY, specifies that only one copy of the control file or datafile copy specified by the rest of the clause should be the target of the operation,
even when there are multiple copies.
Examples
Crosschecking Backups: Example
This example crosschecks backup sets specified by primary key:
CROSSCHECK BACKUPSET 507, 509;
Deleting Datafile Copies: Example
This example deletes a specified datafile copy:
DELETE NOPROMPT DATAFILECOPY '?/oradata/users01.cpy';
Examples
Recovering a Tablespace in an Open Database: Example
The following example takes tablespace tools offline, uses automatic channels to restore and recover it (deleting the logs that it restored from tape), then brings it back online:
SQL "ALTER TABLESPACE tbs_1 OFFLINE IMMEDIATE";
RESTORE TABLESPACE tbs_1;
# restore only 2M of logs at a time, then delete them
RECOVER TABLESPACE tools DELETE ARCHIVELOG MAXSIZE 2M;
SQL "ALTER TABLESPACE tools ONLINE";
Recovering Datafiles Restored to New Locations: Example
The following example uses the preconfigured disk channel and manually allocates one media management channel to use datafile copies on disk and backups on tape, and restores one of the datafiles in tablespace users to a different location:
RMAN> RUN
{
ALLOCATE CHANNEL dev2 DEVICE TYPE sbt;
SQL "ALTER TABLESPACE users OFFLINE IMMEDIATE";
SET NEWNAME FOR DATAFILE '?/oradata/trgt/users01.dbf'
TO '/tmp/users01.dbf';
RESTORE TABLESPACE users;
SWITCH DATAFILE ALL;
RECOVER TABLESPACE users;
SQL "ALTER TABLESPACE users ONLINE";
}
Performing DBPITR with a Backup Control File and Recovery Catalog: Example
Assume that all datafiles and control files as well as archived redo log 40 were lost due to a disk failure. Also assume that you do not have incremental backups. You need to recover the database with available archived redo logs. You do not need to restore tablespace history because it has not changed since log 40. After connecting to the target and recovery catalog, follow the example shown here:
RMAN> STARTUP FORCE NOMOUNT;
RMAN> RUN
{
SET UNTIL SEQUENCE 40 THREAD 1; # Recover database until log sequence 40
RESTORE CONTROLFILE;
ALTER DATABASE MOUNT;
RESTORE DATABASE SKIP TABLESPACE temp, history;
RECOVER DATABASE SKIP FOREVER TABLESPACE temp;
}
RMAN> ALTER DATABASE OPEN RESETLOGS;
If the database uses locally-managed temporary tablespaces, and you restore a backup control file, and you do not have a recovery catalog, then you must add tempfiles to these tablespaces afterwards, using the SQL ALTER TABLESPACE... ADD TEMPFILE command:
RMAN> SQL "ALTER TABLESPACE temp ADD TEMPFILE ''?/oradata/trgt/temp01.dbf'' REUSE";
RECOVER an Image Copy of a Datafile to a Point in Time: Example
Assume that you have an image copy backup of a datafile and you want to roll it forward in time using incremental backups. Use RECOVER DATAFILECOPY with the UNTIL TIME option. For example, run the following command:
RMAN> RECOVER DATAFILECOPY '/disk1/3img.df' UNTIL TIME 'SYSDATE-7';
Available incremental backups are applied to the datafile copy to recover it to the desired point in time. Redo from the archived redo logs is not applied by this command.
Example
Registering a Database: Example
The following commands register a new target database, catalogs an existing datafile copy, then opens the database for use:
% rman TARGET / CATALOG rman/rman@catdb
RMAN> STARTUP FORCE MOUNT;
RMAN> REGISTER DATABASE;
RMAN> CATALOG DATAFILECOPY '?/oradata/system01.cpy';
RMAN> ALTER DATABASE OPEN;
Releasing a Channel: Example
This example makes three identical backup sets of datafiles 1 to 4 to tape with channel ch1, then releases it. RMAN then makes three identical backups of datafiles 5 to 7 to tape with channel ch2 and then releases it:
RUN {
SET BACKUP COPIES = 3;
ALLOCATE CHANNEL ch1 DEVICE TYPE sbt FORMAT 'bkup_%U';
ALLOCATE CHANNEL ch2 DEVICE TYPE sbt MAXPIECESIZE = 5M;
BACKUP CHANNEL ch1 DATAFILE 1,2,3,4;
RELEASE CHANNEL ch1;
BACKUP DATAFILE 5,6,7;
}
Requirements
Execute this command only at the RMAN prompt, not within a RUN block.
You must have a maintenance channel allocated in order to release it.
Examples
Releasing a Maintenance Channel After a Delete Operation: Example
This example allocates and then releases a maintenance channel to the media manager:
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE sbt;
DELETE NOPROMPT BACKUPPIECE 100;
RUN
{
ALLOCATE CHANNEL ch1 DEVICE TYPE DISK;
BACKUP DATAFILE 1;
RELEASE CHANNEL ch1; # releases RUN channel but not maintenance channel
}
RELEASE CHANNEL; # releases maintenance channel
Examples
Resetting RMAN to a Previous Incarnation in NOCATALOG Mode: Example
In NOCATALOG mode, you must mount a control file that knows about the incarnation that you want to recover. The following scenario makes an old incarnation of database trgt current again:
CONNECT TARGET / NOCATALOG
# step 1: start and mount a control file that knows about the incarnation to which
# you want to return. if the current control file does not know about it, then
# you must restore an older control file
STARTUP NOMOUNT;
RESTORE CONTROLFILE UNTIL TIME 'SYSDATE-250';
ALTER DATABASE MOUNT;
# step 2: obtain the primary key of old incarnation
LIST INCARNATION OF DATABASE trgt;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ------------- ------- ---------- ----------
1 2 TRGT 1334358386 PARENT 154381 OCT 30 2001 16:02:12
1 116 TRGT 1334358386 CURRENT 154877 OCT 30 2001 16:37:39
# step 3: in this example, reset database to incarnation key 2
RESET DATABASE TO INCARNATION 2;
# step 4: restore and recover the database to a point before the RESETLOGS
RESTORE DATABASE UNTIL SCN 154876;
RECOVER DATABASE UNTIL SCN 154876;
# step 5: make this incarnation the current incarnation and then list incarnations:
ALTER DATABASE OPEN RESETLOGS;
LIST INCARNATION OF DATABASE trgt;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- ------- ---------- ----------
1 2 TRGT 1334358386 PARENT 154381 OCT 30 2001 16:02:12
1 116 TRGT 1334358386 PARENT 154877 OCT 30 2001 16:37:39
1 311 TRGT 1334358386 CURRENT 154877 AUG 13 2002 17:17:03
Resetting the Database After Incomplete Recovery: Example
This example assumes that an incomplete recovery or recovery with a backup control file was performed in NOCATALOG mode. Later, RMAN is started in CATALOG mode, but the RESYNC command fails because the incarnation has not been reset in the catalog.
% rman target / catalog rman/rman@catdb
Recovery Manager: Release 10.1.0.2.0 - Production
Copyright (c) 1995, 2003, Oracle. All rights reserved.
connected to target database: TRGT (DBID=1334531173)
connected to recovery catalog database
RMAN> RESYNC CATALOG;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of resync command on default channel at 11/01/2001 12:00:43
RMAN-20003: target database incarnation not found in recovery catalog
RMAN> RESET DATABASE;
new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-615538/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 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_語法測試_restore專題OracleREST
- oracle10g_rman_語法測試_show專題Oracle
- oracle10g_rman_語法測試_spool_sql_startupOracleSQL
- if測試和語法規則
- 前端測試框架Jest——語法篇前端框架
- python語法-測試程式碼Python
- 軟體測試培訓之:白盒測試的語句覆蓋法和判定覆蓋法
- PJzhang:搜尋引擎高階語法與滲透測試
- python介面自動化測試之python基礎語法Python
- 軟體測試術語
- 程式測試第一法則?
- ESlint語法檢測工具EsLint
- 測試工程師必知的10大測試法則工程師
- C語言單元測試C語言
- 測試測試測試測試測試測試
- 《shell條件測試語句,字串測試apache是否開啟》字串Apache
- 整合測試時 MockMvc 無法注入MockMVC
- 八大藝術測試法
- oracle儲存過程plsql_sp_多個out引數測試語法Oracle儲存過程SQL
- Go語言中的單元測試Go
- 軟體測試常用術語表
- 測試TOM=SQLLDR使用CASE語句SQL
- 邏輯注入漏洞滲透測試檢測辦法
- 效能測試學習(1)-效能測試分類與常見術語
- 百萬資料查詢測試 只需1秒--Sql語句效率測試SQL
- warning:reset()[function.reset]:passedvariableisnotanarrayorobjectFunctionObject
- SQLTest系列之INSERT語句測試SQL
- Julia語言的一些測試
- 資料庫測試專用術語資料庫