ITPub博客

首页 > Linux操作系统 > Linux操作系统 > RMAN中SET命令的常見用法的小結 (ZT)

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

原创 Linux操作系统 作者:tolywang 时间:2007-07-17 00:00:00 0 删除 编辑
-------------------------------------------
*** 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/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
Oracle , MySQL, SAP IQ, SAP HANA, PostgreSQL, Tableau 技术讨论,希望在这里一起分享知识,讨论技术,畅谈人生 。

注册时间:2007-12-10

  • 博文量
    5595
  • 访问量
    13129163