溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Oracle Study之案例--RMAN備份配置參數

發布時間:2020-07-05 10:40:47 來源:網絡 閱讀:729 作者:客居天涯 欄目:關系型數據庫

Oracle Study之案例--RMAN備份配置參數

1、PARALLELISM  
我們還可以通過parallelism參數來指定同時"自動"創建多少個通道:
RMAN > configure device type disk parallelism 3 ; 
表示啟動三個通道,可以加快備份恢復的速度。

案例分析:

RMAN> show all;
using target database control file instead of recovery catalog
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
......

RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 3;

RMAN> show default device type;
RMAN configuration parameters for database with db_unique_name TEST1 are:
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
RMAN> backup datafile 4;

Starting backup at 30-DEC-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=36 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=34 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=38 device type=DISK

---rman啟動了三個channel來做備份

channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u01/app/oracle/oradata/test1/users01.dbf
channel ORA_DISK_1: starting piece 1 at 30-DEC-14
channel ORA_DISK_1: finished piece 1 at 30-DEC-14
piece handle=/dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T135425_bb4hjmod_.bkp tag=TAG20141230T135425 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 30-DEC-14

      默認情況下,自動分配通道的并行度為1,如果你通過設置PARALLELISM設置了并行通道為2,那么在run塊中,如果你沒有單獨通過ALLOCATE CHANNEL命令指定通道,它會默認使用2條并行通道,如果你在run命令塊中指定了數個ALLOCATE CHANNEL,那么rman在執行備份命令時會以你設置的channel為準,而不管configure中配置了多少個并行通道。

案例分析:

RMAN> run {
2> allocate channel c1 type disk;
3> backup datafile 4;
4> }
released channel: ORA_DISK_1
released channel: ORA_DISK_2
released channel: ORA_DISK_3

allocated channel: c1
channel c1: SID=36 device type=DISK
Starting backup at 30-DEC-14
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u01/app/oracle/oradata/test1/users01.dbf
channel c1: starting piece 1 at 30-DEC-14
channel c1: finished piece 1 at 30-DEC-14
piece handle=/dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T135628_bb4hngl2_.bkp tag=TAG20141230T135628 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:07
Finished backup at 30-DEC-14
released channel: c1

---rman只啟用了一個channel,忽略了PARALLELISM參數設置

2、FILESPERSET

FILESPERSET = integer
      Specifies the maximum number of input files in each backup set. If you set FILESPERSET = n, then RMAN never includes more than n files in a backup set. The default for

     FILESPERSET is the lesser of these two values: 64, number of input files divided by the number of channels. For example, if you back up 100 datafiles by using two channels, RMAN sets FILESPERSET to 50.

     RMAN always attempts to create enough backup sets so that all allocated channels have work to do. An exception to the rule occurs when there are more channels than files to back up. For example, if RMAN backs up two datafiles when three channels are allocated and FILESPERSET = 1, then one channel is necessarily idle.

     需要注意的一點是,在backup命令中有一個FILESPERSET參數,該參數是指rman建立的每個備份集中所能包含的數據文件的最大數(注意: 不是指備份片,也就是備份出來的文件),該參數默認值為64,如果在執行backup命令時沒有指定該參數值,那么rman會僅使用第一個通道來執行備份,其它通道將處于空閑狀態。關于通道數與FILESPERSET值之間也有一個大小關系,邏輯稍顯復雜。
比如, datafiles 的個數為25 , FILESPERSET = 8 ,那么備份
數據庫的時候生成4個backupset  (25/8=3.125), 每個備份集包含8個數據文件。
-----  并行定義通道個數, 通道定義了通道屬性。
allocate channel 提供備份并發度,若平均文件數<filesperset則會按照 平均文件數/備份集 進行備份,若超過則按照filesperset的數量生成備份集;例如:

案例分析:(1)

RMAN> run {
2> allocate channel c1 type disk;
3> allocate channel c2 type disk;
4> backup datafile 3,4,5,6 filesperset 3;
5> }
allocated channel: c1
channel c1: SID=36 device type=DISK
allocated channel: c2
channel c2: SID=34 device type=DISK
Starting backup at 30-DEC-14
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/app/oracle/oradata/test1/perfs.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/test1/test1.dbf
channel c1: starting piece 1 at 30-DEC-14
channel c2: starting full datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00004 name=/u01/app/oracle/oradata/test1/users01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/test1/dict1.dbf
channel c2: starting piece 1 at 30-DEC-14
channel c1: finished piece 1 at 30-DEC-14
piece handle=/dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T140541_bb4j5tcl_.bkp tag=TAG20141230T140541 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:27
channel c2: finished piece 1 at 30-DEC-14
piece handle=/dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T140541_bb4j5sk4_.bkp tag=TAG20141230T140541 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:26
Finished backup at 30-DEC-14
released channel: c1
released channel: c2

RMAN> list backup of datafile 3,4,5,6;
List of Backup Sets
===================
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
355     Full    91.77M     DISK        00:00:19     30-DEC-14
        BP Key: 355   Status: AVAILABLE  Compressed: NO  Tag: TAG20141230T140541
        Piece Name: /dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T140541_bb4j5sk4_.bkp
  List of Datafiles in backup set 355
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  4       Full 11327185   30-DEC-14 /u01/app/oracle/oradata/test1/users01.dbf
  6       Full 11327185   30-DEC-14 /u01/app/oracle/oradata/test1/dict1.dbf
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
356     Full    19.44M     DISK        00:00:22     30-DEC-14
        BP Key: 356   Status: AVAILABLE  Compressed: NO  Tag: TAG20141230T140541
        Piece Name: /dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T140541_bb4j5tcl_.bkp
  List of Datafiles in backup set 356
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  3       Full 11327183   30-DEC-14 /u01/app/oracle/oradata/test1/test1.dbf
  5       Full 11327183   30-DEC-14 /u01/app/oracle/oradata/test1/perfs.dbf

---平均數是 4(文件數)/2(channel數) = 2 ,小于filesperset 3,則生成2個備份集,每個備份集包含2個數據文件
案例分析:(2)

RMAN> run {
2> allocate channel ch2 type disk;
3> allocate channel ch3 type disk;
4> backup datafile 3,4,5,6 filesperset 1;
5> release channel ch2;
6> release channel ch3;
7> }
allocated channel: ch2
channel ch2: SID=36 device type=DISK
allocated channel: ch3
channel ch3: SID=34 device type=DISK
Starting backup at 30-DEC-14
channel ch2: starting full datafile backup set
channel ch2: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/app/oracle/oradata/test1/perfs.dbf
channel ch2: starting piece 1 at 30-DEC-14
channel ch3: starting full datafile backup set
channel ch3: specifying datafile(s) in backup set
input datafile file number=00004 name=/u01/app/oracle/oradata/test1/users01.dbf
channel ch3: starting piece 1 at 30-DEC-14
channel ch2: finished piece 1 at 30-DEC-14
piece handle=/dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T141001_bb4jfvks_.bkp tag=TAG20141230T141001 comment=NONE
channel ch2: backup set complete, elapsed time: 00:00:17
channel ch2: starting full datafile backup set
channel ch2: specifying datafile(s) in backup set
input datafile file number=00006 name=/u01/app/oracle/oradata/test1/dict1.dbf
channel ch2: starting piece 1 at 30-DEC-14
channel ch3: finished piece 1 at 30-DEC-14
piece handle=/dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T141001_bb4jfxp0_.bkp tag=TAG20141230T141001 comment=NONE
channel ch3: backup set complete, elapsed time: 00:00:17
channel ch3: starting full datafile backup set
channel ch3: specifying datafile(s) in backup set
input datafile file number=00003 name=/u01/app/oracle/oradata/test1/test1.dbf
channel ch3: starting piece 1 at 30-DEC-14
channel ch3: finished piece 1 at 30-DEC-14
piece handle=/dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T141001_bb4jghg2_.bkp tag=TAG20141230T141001 comment=NONE
channel ch3: backup set complete, elapsed time: 00:00:08
channel ch2: finished piece 1 at 30-DEC-14
piece handle=/dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T141001_bb4jgffw_.bkp tag=TAG20141230T141001 comment=NONE
channel ch2: backup set complete, elapsed time: 00:00:19
Finished backup at 30-DEC-14
released channel: ch2
released channel: ch3

RMAN> list backup of datafile 3,4,5,6;
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
357     Full    18.48M     DISK        00:00:07     30-DEC-14
        BP Key: 357   Status: AVAILABLE  Compressed: NO  Tag: TAG20141230T141001
        Piece Name: /dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T141001_bb4jfxp0_.bkp
        
  List of Datafiles in backup set 357
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  4       Full 11327316   30-DEC-14 /u01/app/oracle/oradata/test1/users01.dbf
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
358     Full    18.43M     DISK        00:00:10     30-DEC-14
        BP Key: 358   Status: AVAILABLE  Compressed: NO  Tag: TAG20141230T141001
        Piece Name: /dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T141001_bb4jfvks_.bkp
        
  List of Datafiles in backup set 358
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  5       Full 11327314   30-DEC-14 /u01/app/oracle/oradata/test1/perfs.dbf
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
359     Full    1.03M      DISK        00:00:05     30-DEC-14
        BP Key: 359   Status: AVAILABLE  Compressed: NO  Tag: TAG20141230T141001
        Piece Name: /dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T141001_bb4jghg2_.bkp
        
  List of Datafiles in backup set 359
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  3       Full 11327326   30-DEC-14 /u01/app/oracle/oradata/test1/test1.dbf
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
360     Full    73.31M     DISK        00:00:15     30-DEC-14
        BP Key: 360   Status: AVAILABLE  Compressed: NO  Tag: TAG20141230T141001
        Piece Name: /dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T141001_bb4jgffw_.bkp
        
  List of Datafiles in backup set 360
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  6       Full 11327324   30-DEC-14 /u01/app/oracle/oradata/test1/dict1.dbf

---則生成4個備份集,每個包含一個數據文件

例子1 :
RMAN> configure device type disk parallelism 4;
RMAN> configure channel 1 device type disk;
RMAN> configure channel 2 device type disk;
注意: 在上面的配置中,將開啟四個通道, 通道1,2采用用戶的配置,3,4采用默認配置 。

例子2 :
RMAN> configure device type disk parallelism 3;
RMAN> configure channel 1 device type disk;
RMAN> configure channel 2 device type disk;
RMAN> configure channel 3 device type disk;
RMAN> configure channel 4 device type disk;
注意: 這時,RMAN將忽略parallelism 的設置,而以用戶設置的通道為準。

3、SKIP 選項
Excludes datafiles or archived redo logs from the backup set according to the criteria specified by the following keywords.
Note: You can also specify this option in the backupSpec clause.

4、OFFLINE
Specifies that offline datafiles should be excluded from the backup set.

5、READONLY
Specifies that read-only datafiles should be excluded from the backup set.

6、INACCESSIBLE
Specifies that datafiles or archived redo logs that cannot be read due to I/O errors should be excluded from the backup set.

A datafile is only considered inaccessible if it cannot be read. Some offline datafiles can still be read because they still exist on disk. Others have been deleted or moved and

so cannot be read, making them inaccessible.

案例分析

14:35:25 SYS@ test1 >select file#,name ,status from v$datafile;

     FILE# NAME                                               STATUS
---------- -------------------------------------------------- -------
         1 /u01/app/oracle/oradata/test1/system01.dbf         SYSTEM
         2 /u01/app/oracle/oradata/test1/sysaux01.dbf         ONLINE
         3 /u01/app/oracle/oradata/test1/test1.dbf            ONLINE
         4 /u01/app/oracle/oradata/test1/users01.dbf          ONLINE
         5 /u01/app/oracle/oradata/test1/perfs.dbf            ONLINE
         6 /u01/app/oracle/oradata/test1/dict1.dbf            ONLINE
         7 /u01/app/oracle/oradata/test1/undotbs2.dbf         ONLINE
         8 /u01/app/oracle/oradata/test1/test2.dbf            OFFLINE
        10 /u01/app/oracle/oradata/test1/index01.dbf          ONLINE
        13 /u01/app/oracle/oradata/test1/tbs_16.dbf           ONLINE

10 rows selected.

RMAN> backup database skip offline ;
Starting backup at 30-DEC-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=36 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=17 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=16 device type=DISK
skipping offline file 8
RMAN-06060: WARNING: skipping datafile compromises tablespace TEST2 recoverability
RMAN-06060: WARNING: skipping datafile compromises tablespace TEST2 recoverability
RMAN-06060: WARNING: skipping datafile compromises tablespace TEST2 recoverability
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/test1/system01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/test1/test1.dbf
channel ORA_DISK_1: starting piece 1 at 30-DEC-14
channel ORA_DISK_2: starting full datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/test1/sysaux01.dbf
input datafile file number=00010 name=/u01/app/oracle/oradata/test1/index01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/test1/dict1.dbf
channel ORA_DISK_2: starting piece 1 at 30-DEC-14
channel ORA_DISK_3: starting full datafile backup set
channel ORA_DISK_3: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/app/oracle/oradata/test1/perfs.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/test1/undotbs2.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/test1/users01.dbf
channel ORA_DISK_3: starting piece 1 at 30-DEC-14
channel ORA_DISK_3: finished piece 1 at 30-DEC-14
piece handle=/dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T143554_bb4kymxb_.bkp tag=TAG20141230T143554 comment=NONE
channel ORA_DISK_3: backup set complete, elapsed time: 00:00:48
channel ORA_DISK_3: starting full datafile backup set
channel ORA_DISK_3: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_3: starting piece 1 at 30-DEC-14
channel ORA_DISK_2: finished piece 1 at 30-DEC-14
piece handle=/dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T143554_bb4kykmm_.bkp tag=TAG20141230T143554 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:01:24
channel ORA_DISK_2: starting full datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00013 name=/u01/app/oracle/oradata/test1/tbs_16.dbf
channel ORA_DISK_2: starting piece 1 at 30-DEC-14
channel ORA_DISK_3: finished piece 1 at 30-DEC-14
piece handle=/dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_ncnnf_TAG20141230T143554_bb4l0mbo_.bkp tag=TAG20141230T143554 comment=NONE
channel ORA_DISK_3: backup set complete, elapsed time: 00:00:23
channel ORA_DISK_3: starting full datafile backup set
channel ORA_DISK_3: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_3: starting piece 1 at 30-DEC-14
channel ORA_DISK_2: finished piece 1 at 30-DEC-14
piece handle=/dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T143554_bb4l19n6_.bkp tag=TAG20141230T143554 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:24
channel ORA_DISK_3: finished piece 1 at 30-DEC-14
piece handle=/dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnsnf_TAG20141230T143554_bb4l1c9g_.bkp tag=TAG20141230T143554 comment=NONE
channel ORA_DISK_3: backup set complete, elapsed time: 00:00:18
channel ORA_DISK_1: finished piece 1 at 30-DEC-14
piece handle=/dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T143554_bb4kylnm_.bkp tag=TAG20141230T143554 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:22
Finished backup at 30-DEC-14

RMAN> list backup of database;
List of Backup Sets
===================
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
361     Full    39.30M     DISK        00:00:39     30-DEC-14
        BP Key: 361   Status: AVAILABLE  Compressed: NO  Tag: TAG20141230T143554
        Piece Name: /dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T143554_bb4kymxb_.bkp
  List of Datafiles in backup set 361
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  4       Full 11328151   30-DEC-14 /u01/app/oracle/oradata/test1/users01.dbf
  5       Full 11328151   30-DEC-14 /u01/app/oracle/oradata/test1/perfs.dbf
  7       Full 11328151   30-DEC-14 /u01/app/oracle/oradata/test1/undotbs2.dbf
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
362     Full    199.24M    DISK        00:01:18     30-DEC-14
        BP Key: 362   Status: AVAILABLE  Compressed: NO  Tag: TAG20141230T143554
        Piece Name: /dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T143554_bb4kykmm_.bkp
  List of Datafiles in backup set 362
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  2       Full 11328149   30-DEC-14 /u01/app/oracle/oradata/test1/sysaux01.dbf
  6       Full 11328149   30-DEC-14 /u01/app/oracle/oradata/test1/dict1.dbf
  10      Full 11328149   30-DEC-14 /u01/app/oracle/oradata/test1/index01.dbf
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
364     Full    1.06M      DISK        00:00:14     30-DEC-14
        BP Key: 364   Status: AVAILABLE  Compressed: NO  Tag: TAG20141230T143554
        Piece Name: /dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T143554_bb4l19n6_.bkp
  List of Datafiles in backup set 364
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  13      Full 11328183   30-DEC-14 /u01/app/oracle/oradata/test1/tbs_16.dbf
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
366     Full    535.42M    DISK        00:02:12     30-DEC-14
        BP Key: 366   Status: AVAILABLE  Compressed: NO  Tag: TAG20141230T143554
        Piece Name: /dsk4/backup/TEST1/backupset/2014_12_30/o1_mf_nnndf_TAG20141230T143554_bb4kylnm_.bkp
  List of Datafiles in backup set 366
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 11328147   30-DEC-14 /u01/app/oracle/oradata/test1/system01.dbf
  3       Full 11328147   30-DEC-14 /u01/app/oracle/oradata/test1/test1.dbf

備份腳本:

#########################################################################  
##   t_database_backup.sh      ##  
##   created by Tianlesoftware  ##  
##        2010-7-16                 ##  
#########################################################################  
#!/bin/bash  
# ---------------------------------------------------------------------------  
# Determine the user which is executing this script.  
# ---------------------------------------------------------------------------  
CUSER=`id |cut -d"(" -f2 | cut -d ")" -f1`  
  
# ---------------------------------------------------------------------------  
# Put output in <this file name>.out. Change as desired.  
# Note: output directory requires write permission.  
# ---------------------------------------------------------------------------  
RMAN_LOG_FILE=${0}.out  
# ---------------------------------------------------------------------------  
# You may want to delete the output file so that backup information does  
# not accumulate.  If not, delete the following lines.  
# ---------------------------------------------------------------------------  
if [ -f "$RMAN_LOG_FILE" ]  
then  
rm -f "$RMAN_LOG_FILE"  
fi  
# -----------------------------------------------------------------  
# Initialize the log file.  
# -----------------------------------------------------------------  
echo >> $RMAN_LOG_FILE  
chmod 666 $RMAN_LOG_FILE  
# ---------------------------------------------------------------------------  
# Log the start of this script.  
# ---------------------------------------------------------------------------  
echo Script {1} >> $RMAN_LOG_FILE  
echo ==== started on `date` ==== >> $RMAN_LOG_FILE  
echo >> $RMAN_LOG_FILE  
# ---------------------------------------------------------------------------  
# Oracle home path.  
# ---------------------------------------------------------------------------  
ORACLE_HOME=/home/oracle/product/10.2.0/db_1  
export ORACLE_HOME  
# ---------------------------------------------------------------------------  
# the Oracle SID of the target database.  
# ---------------------------------------------------------------------------  
ORACLE_SID=oralife  
export ORACLE_SID  
# ---------------------------------------------------------------------------  
# The Oracle DBA user id (account).  
# ---------------------------------------------------------------------------  
ORACLE_USER=oracle  
export ORACLE_USER  
# ---------------------------------------------------------------------------  
# Set the Oracle Recovery Manager name.  
# ---------------------------------------------------------------------------  
RMAN=$ORACLE_HOME/bin/rman  
# ---------------------------------------------------------------------------  
# Print out the value of the variables set by this script.  
# ---------------------------------------------------------------------------  
echo >> $RMAN_LOG_FILE  
echo   "RMAN: $RMAN" >> $RMAN_LOG_FILE  
echo   "ORACLE_SID: $ORACLE_SID" >> $RMAN_LOG_FILE  
echo   "ORACLE_USER: $ORACLE_USER" >> $RMAN_LOG_FILE  
echo   "ORACLE_HOME: $ORACLE_HOME" >> $RMAN_LOG_FILE  
# ---------------------------------------------------------------------------  
# Print out the value of the variables set by bphdb.  
# ---------------------------------------------------------------------------  
#echo  >> $RMAN_LOG_FILE  
#echo   "NB_ORA_FULL: $NB_ORA_FULL" >> $RMAN_LOG_FILE  
#echo   "NB_ORA_INCR: $NB_ORA_INCR" >> $RMAN_LOG_FILE  
#echo   "NB_ORA_CINC: $NB_ORA_CINC" >> $RMAN_LOG_FILE  
#echo   "NB_ORA_SERV: $NB_ORA_SERV" >> $RMAN_LOG_FILE  
#echo   "NB_ORA_POLICY: $NB_ORA_POLICY" >> $RMAN_LOG_FILE  
# ---------------------------------------------------------------------------  
# NOTE: This script assumes that the database is properly opened. If desired,  
# this would be the place to verify that.  
# ---------------------------------------------------------------------------  
echo >> $RMAN_LOG_FILE  
# ---------------------------------------------------------------------------  
# ---------------------------------------------------------------------------  
# Call Recovery Manager to initiate the backup.  
# ---------------------------------------------------------------------------  
  
CMD_STR="  
ORACLE_HOME=$ORACLE_HOME  
export ORACLE_HOME  
ORACLE_SID=$ORACLE_SID  
export ORACLE_SID  
$RMAN nocatalog target sys/admin  msglog $RMAN_LOG_FILE append << EOF  
RUN {  
allocate channel c1 type disk;  
allocate channel c2 type disk;  
  
BACKUP FORMAT '/home/oracle/backup/oralife_%U_%T' skip inaccessible filesperset 5  DATABASE TAG oralife_hot_db_bk;  
  
sql 'alter system archive log current';  
  
BACKUP FORMAT '/home/oracle/backup/arch_%U_%T' skip inaccessible filesperset 5 ARCHIVELOG ALL DELETE INPUT;  
  
backup current controlfile tag='bak_ctlfile' format='/home/oracle/backup/ctl_file_%U_%T';  
backup spfile tag='spfile' format='/home/oracle/backup/oralife_spfile_%U_%T';  
  
release channel c2;  
release channel c1;  
}  
report obsolete;  
delete noprompt obsolete;  
crosscheck backup;  
delete noprompt expired backup;  
list backup summary;  
#EOF  
"  
# Initiate the command string  
  
if [ "$CUSER" = "root" ]  
then  
    echo "Root Command String: $CMD_STR" >> $RMAN_LOG_FILE  
    su - $ORACLE_USER -c "$CMD_STR" >> $RMAN_LOG_FILE  
    RSTAT=$?  
else  
    echo "User Command String: $CMD_STR" >> $RMAN_LOG_FILE  
    /bin/sh -c "$CMD_STR" >> $RMAN_LOG_FILE  
    RSTAT=$?  
fi  
  
# ---------------------------------------------------------------------------  
# Log the completion of this script.  
# ---------------------------------------------------------------------------  
if [ "$RSTAT" = "0" ]  
then  
    LOGMSG="ended successfully"  
else  
    LOGMSG="ended in error"  
fi  
  
echo >> $RMAN_LOG_FILE  
echo Script {1} >> $RMAN_LOG_FILE  
echo ==== $LOGMSG on `date` ==== >> $RMAN_LOG_FILE  
echo >> $RMAN_LOG_FILE  
  
#/bin/mailx -s "RMAN Backup SID " daimm@sf-express.com < $RMAN_LOG_FILE  
  
exit $RSTAT



向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女