10G/11G/12cr1版本中backup archivelog命令是否會觸發歸檔current logfile操作

還不算暈發表於2017-01-21

被同事指出備份指令碼中缺少手動切換日誌的命令,事實上在10G及以上版本已經不需要此在指令碼中加上此語句。主要通過查閱官方文件及實驗,驗證10G/11G/12cr1版本中backup archivelog命令是否會觸發歸檔current logfile操作。

結果如下;
如果資料庫在OPEN狀態,執行BACKUP ARCHIVELOG命令時,如果不使用UNTIL/SEQUENCE關鍵字,會自動執行日誌切換命令。

參考官方文件中描述:http://docs.oracle.com/cd/E11882_01/backup.112/e10643/rcmsynta007.htm#CHDCFGEI
http://docs.oracle.com/database/121/RCMRF/rcmsynta006.htm


If the database is open when you run BACKUP ARCHIVELOG, and if the UNTIL clause or SEQUENCE parameter is not specified, then RMAN runs ALTER SYSTEM ARCHIVE LOG CURRENT.  ---這一句,如果資料庫在OPEN狀態,執行BACKUP ARCHIVELOG命令時,如果不使用UNTIL/SEQUENCE關鍵字,會執行日誌切換命令。

Note: If you run BACKUP ARCHIVELOG ALL, or if the specified log range includes logs from prior incarnations, then RMAN backs up logs from prior incarnations to ensure availability of all logs that may be required for recovery through an OPEN RESETLOGS.
----------------------------------

以下以11.2.0.4版本驗證:
開始備份操作:
[oracle@bys1 ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Sat Jan 21 18:04:53 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: BYS1 (DBID=4052277609)

RMAN> backup archivelog from time 'sysdate-1' format '/home/orcale/arch_%d_%t_%s.bak';

Starting backup at 2017/01/21 18:04:55   ------------>備份命令開始時間,與ALERT日誌中可以對應。
current log archived    ------------>這句輸出可以發現是做了current redolog的歸檔;
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=58 device type=DISK


觀察ALERT日誌:
Sat Jan 21 18:02:20 2017
ALTER SYSTEM ARCHIVE LOG
Sat Jan 21 18:02:20 2017
Thread 1 advanced to log sequence 99 (LGWR switch)
  Current log# 3 seq# 99 mem# 0: /u01/app/oradata/bys1/redo03.log
Sat Jan 21 18:02:20 2017
Archived Log entry 131 added for thread 1 sequence 98 ID 0xf1898b69 dest 1:
Sat Jan 21 18:04:55 2017     ------------>ALTER SYSTEM ARCHIVE LOG命令執行時間,與備份時輸出可以對應。
ALTER SYSTEM ARCHIVE LOG
Sat Jan 21 18:04:55 2017
Thread 1 advanced to log sequence 100 (LGWR switch)
  Current log# 1 seq# 100 mem# 0: /u01/app/oradata/bys1/redo01.log
Sat Jan 21 18:04:56 2017
Archived Log entry 132 added for thread 1 sequence 99 ID 0xf1898b69 dest 1:



---------------------11GR2 RAC環境的驗證--在任意節點上執行兩個節點都進行切換

RAC節點1執行備份backup archivelog操作
[oracle@bys1 ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Tue Feb 7 12:06:02 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: BYSRAC (DBID=2682487210)

RMAN> backup archivelog from time 'sysdate-1/12' format '/home/oracle/arch_%d_%t_%s.bak';

Starting backup at 20170207 12:06:29
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=32 instance=bysrac1 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=49 RECID=79 STAMP=935323590
input archived log thread=2 sequence=34 RECID=80 STAMP=935323591
channel ORA_DISK_1: starting piece 1 at 20170207 12:06:39
channel ORA_DISK_1: finished piece 1 at 20170207 12:06:40
piece handle=/home/oracle/arch_BYSRAC_935323599_3.bak tag=TAG20170207T120639 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 20170207 12:06:40

RMAN> backup archivelog from time 'sysdate-1/12' format '/home/oracle/arch_%d_%t_%s.bak';

Starting backup at 20170207 12:08:32
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=49 RECID=79 STAMP=935323590
input archived log thread=2 sequence=34 RECID=80 STAMP=935323591
input archived log thread=1 sequence=50 RECID=81 STAMP=935323713
input archived log thread=2 sequence=35 RECID=82 STAMP=935323713
channel ORA_DISK_1: starting piece 1 at 20170207 12:08:36
channel ORA_DISK_1: finished piece 1 at 20170207 12:08:37
piece handle=/home/oracle/arch_BYSRAC_935323716_4.bak tag=TAG20170207T120835 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 20170207 12:08:37


觀察兩個節點的ALERT日誌:
節點1
Tue Feb 07 12:06:29 2017
ALTER SYSTEM ARCHIVE LOG
Tue Feb 07 12:06:30 2017
Thread 1 advanced to log sequence 50 (LGWR switch)
  Current log# 2 seq# 50 mem# 0: +DATA/bysrac/onlinelog/group_2.258.927541487
  Current log# 2 seq# 50 mem# 1: +DATA/bysrac/onlinelog/group_2.257.927541487
Tue Feb 07 12:06:30 2017
Archived Log entry 79 added for thread 1 sequence 49 ID 0x9fe402a6 dest 1:
Tue Feb 07 12:08:32 2017
ALTER SYSTEM ARCHIVE LOG
Tue Feb 07 12:08:33 2017
Thread 1 advanced to log sequence 51 (LGWR switch)
  Current log# 1 seq# 51 mem# 0: +DATA/bysrac/onlinelog/group_1.267.927541485
  Current log# 1 seq# 51 mem# 1: +DATA/bysrac/onlinelog/group_1.259.927541485
Tue Feb 07 12:08:33 2017
Archived Log entry 81 added for thread 1 sequence 50 ID 0x9fe402a6 dest 1:

節點2
Tue Feb 07 12:06:30 2017
Thread 2 advanced to log sequence 35 (LGWR switch)
  Current log# 3 seq# 35 mem# 0: +DATA/bysrac/onlinelog/group_3.261.927541697
  Current log# 3 seq# 35 mem# 1: +DATA/bysrac/onlinelog/group_3.269.927541699
Tue Feb 07 12:06:31 2017
Archived Log entry 80 added for thread 2 sequence 34 ID 0x9fe402a6 dest 1:
Tue Feb 07 12:08:33 2017
Thread 2 advanced to log sequence 36 (LGWR switch)
  Current log# 4 seq# 36 mem# 0: +DATA/bysrac/onlinelog/group_4.270.927541701
  Current log# 4 seq# 36 mem# 1: +DATA/bysrac/onlinelog/group_4.271.927541701
Tue Feb 07 12:08:33 2017
Archived Log entry 82 added for thread 2 sequence 35 ID 0x9fe402a6 dest 1:


檢視備份集資訊
RMAN> list backup of archivelog all;


List of Backup Sets
===================



BS Key  Size       Device Type Elapsed Time Completion Time  
------- ---------- ----------- ------------ -----------------
3       3.00K      DISK        00:00:00     20170207 12:06:39
        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20170207T120639
        Piece Name: /home/oracle/arch_BYSRAC_935323599_3.bak

  List of Archived Logs in backup set 3
  Thrd Seq     Low SCN    Low Time          Next SCN   Next Time
  ---- ------- ---------- ----------------- ---------- ---------
  1    49      2344159    20170207 12:04:32 2344293    20170207 12:06:30
  2    34      2344163    20170207 12:04:33 2344297    20170207 12:06:30

BS Key  Size       Device Type Elapsed Time Completion Time  
------- ---------- ----------- ------------ -----------------
4       4.50K      DISK        00:00:00     20170207 12:08:36
        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20170207T120835
        Piece Name: /home/oracle/arch_BYSRAC_935323716_4.bak

  List of Archived Logs in backup set 4
  Thrd Seq     Low SCN    Low Time          Next SCN   Next Time
  ---- ------- ---------- ----------------- ---------- ---------
  1    49      2344159    20170207 12:04:32 2344293    20170207 12:06:30
  1    50      2344293    20170207 12:06:30 2344410    20170207 12:08:33
  2    34      2344163    20170207 12:04:33 2344297    20170207 12:06:30
  2    35      2344297    20170207 12:06:30 2344414    20170207 12:08:33

相關文章