RMAN中SET命令的常見用法的小結 (ZT)

tolywang發表於2007-07-17
-------------------------------------------
*** set command***
-------------------------------------------
[b]使用set命令可以定義只應用於當前RMAN會話的設定,
它於configure命令非常相似,但它設定的值不是永久的
可以用兩種方法使用set命令:在run的塊內和塊外[/b]
-----------------------------------------------------------------
[color=Blue][b]--set 位於 run 塊外[/b][/color]
------------------------
1. set echo ON|OFF;
2. set DBID=1234566789;
3. set controlfile autobackup format for device type [disk|stb] to 'd:control.bak';

-------------------------------------------------------------------
[color=Blue][b]--set 位於 run 塊內[/b][/color]
------------------------
1. set newname datafile 1 to 'E:oracleoradatasystem01.dbf';
--在執行TSPITR or 移動Datafile的位置時用
2. set maxcorrupt for datafile 1,2,3,7 to 10;
--在RMAN操作失敗前準許每個檔案有10次的錯誤
3. set archivelog destination to 'D: emp';
--設定archive_log_dest_1的目的地
4. set until time "TO_DATE('09/20/00','MM/DD/YY')"|'sysdate-2';
--基於時間的設定可用於恢復時
set until scn 1000
--基於scn的設定可用於恢復時
SET UNTIL SEQUENCE 1234 THREAD 1;
--基於sequence和thread的設定,常用於恢復時
5. set backup copies 2;
--設定一個backup file有兩份相同內容的檔案
6. set command id 'rman';
7. set controlfile autobackup format for device type [disk|stb] to 'd:control.bak';
--設定control file的auto backup

-------------------------------------------------------------------------------------
[color=Blue]for example:[/color]-
---------------------------------------
1.
Restoring the Control File When Databases Share the Same Name: Example The
following shell script uses the DBID to restore the control file because multiple
target databases share the same DB_NAME in the catalog. After you have restored the
target control file, you can mount the database to restore the rest of the database:
#!/usr/bin/tcsh
rman TARGET / CATALOG rman/rman@catdb <STARTUP FORCE NOMOUNT;
SET DBID = 862893450; # needed to distinguish target from others with same DB_NAME
RESTORE CONTROLFILE; # assuming catalog has automatic channel allocation information
ALTER DATABASE MOUNT;
EOF

2.
Setting the Command ID: Example This example sets the command ID, backs up
the users tablespace, then archives the online redo logs:
RUN
{
ALLOCATE CHANNEL t1 DEVICE TYPE DISK FORMAT '/disk1/%U';
ALLOCATE CHANNEL t2 DEVICE TYPE DISK FORMAT '/disk2/%U';
SET COMMAND ID TO 'rman';
BACKUP INCREMENTAL LEVEL 0 FILESPERSET 5 TABLESPACE users;
SQL 'ALTER SYSTEM ARCHIVE LOG ALL';
}

3.
Duplexing a Backup Set: Example Assume that you have used the CONFIGURE
command to set duplexing as follows:
CONFIGURE ARCHIVELOG COPIES FOR DEVICE TYPE sbt TO 4;
CONFIGURE DATAFILE COPIES FOR DEVICE TYPE sbt TO 3;


4.
The following example overrides these configurations and makes two copies of
each datafile and archived log in the backup:
RUN
{
ALLOCATE CHANNEL dev1 DEVICE TYPE sbt;
SET BACKUP COPIES = 2;
BACKUP FILESPERSET 1 DATAFILE 1,2,3,4,5;
BACKUP FILESPERSET 10 ARCHIVELOG ALL;
}

5.
Overriding the Autobackup Format During a Restore: Example This example sets
the DBID, sets a boundary time for the restore, then restores a control file
autobackup with a nondefault format. First start RMAN and then run:
CONNECT TARGET / NOCATALOG
STARTUP FORCE NOMOUNT
SET DBID 676549873;
RUN
{
SET UNTIL TIME '10/10/2001 13:45:00';
SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '?/oradata/cf_%F.bak';
RESTORE CONTROLFILE FROM AUTOBACKUP MAXSEQ 100;
}

6.
Restoring the Server Parameter File: Example This example restores a lost server parameter file:
CONNECT TARGET / CATALOG rman/rman@catdb
SET DBID 676549873; # set dbid so rman knows the database name
STARTUP FORCE NOMOUNT # rman starts database with a dummy server parameter file
RESTORE SPFILE;
STARTUP FORCE; # needed so that RMAN restarts database with restored server parameter file

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

相關文章