redo日誌檔案學習筆記(一)

jeanron100發表於2014-03-24
關於redo日誌檔案,今天因為要做redo日誌的線上遷移,所以特意做了個簡單的總結。

1. 如果要把redo的切換資訊顯示到alert日誌中,需要設定個引數。
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> show parameter check
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_block_checking                    string      FALSE
db_block_checksum                    string      TYPICAL
log_checkpoint_interval              integer     0
log_checkpoint_timeout               integer     1800
log_checkpoints_to_alert             boolean     FALSE

SQL> alter system set log_checkpoints_to_alert=true;
System altered.

2.檢視redo的情況,current表示當前所屬的redo日誌組。
SQL> select group#,status from v$log;
    GROUP# STATUS
---------- ----------------
         1 INACTIVE
         2 INACTIVE
         3 INACTIVE
         4 CURRENT

3.強制切換日誌,使用switch logfile,切換後,current日誌組切換到了第一組,剛剛的日誌組4變成了active狀態。  表示dbwr還沒有把髒資料寫入資料檔案。
需要出發dbwr來寫入,或者等待一會兒。   
    alert日誌內容如下;   

--alter system switch logfile;
Mon Mar 24 18:16:46 2014
Beginning log switch checkpoint up to RBA [0xb1d.2.10], SCN: 10583135604156
Thread 1 advanced to log sequence 2845 (LGWR switch)
  Current log# 1 seq# 2845 mem# 0: /dbccbsPT1/oracle/PETCUS1/oracnt01/redolog_A1/redo/redo01A.log
  Current log# 1 seq# 2845 mem# 1: /dbccbsPT1/oracle/PETCUS1/oracnt02/redolog_B1/redo/redo01B.log
Mon Mar 24 18:16:46 2014
Archived Log entry 2844 added for thread 1 sequence 2844 ID 0x4a0d6000 dest 1:

SQL> select group#,status from v$log;
    GROUP# STATUS
---------- ----------------
         1 CURRENT
         2 INACTIVE
         3 INACTIVE
         4 ACTIVE

4.再強制切換一次日誌,日誌組繼續切換,可以看到有兩個日誌組成了active,
    alert日誌內容如下;   

--alter system switch logfile;
Mon Mar 24 18:17:35 2014
Beginning log switch checkpoint up to RBA [0xb1e.2.10], SCN: 10583135604180
Thread 1 advanced to log sequence 2846 (LGWR switch)
  Current log# 3 seq# 2846 mem# 0: /dbccbsPT1/oracle/PETCUS1/oracnt01/redolog_A3/redo/redo03A.log
  Current log# 3 seq# 2846 mem# 1: /dbccbsPT1/oracle/PETCUS1/oracnt02/redolog_B3/redo/redo03B.log
Mon Mar 24 18:17:35 2014
Archived Log entry 2845 added for thread 1 sequence 2845 ID 0x4a0d6000 dest 1:

SQL> select group#,status from v$log;
    GROUP# STATUS
---------- ----------------
         1 ACTIVE
         2 INACTIVE
         3 CURRENT
         4 ACTIVE

5.如果進行全量檢查點,強制dbwr寫入資料檔案,可以出發全量檢查點。
    alert日誌內容如下:

--alter system checkpoint;
Mon Mar 24 18:18:48 2014
Beginning global checkpoint up to RBA [0xb1e.4c.10], SCN: 10583135604229
Completed checkpoint up to RBA [0xb1e.4c.10], SCN: 10583135604229
Completed checkpoint up to RBA [0xb1e.2.10], SCN: 10583135604180
Completed checkpoint up to RBA [0xb1d.2.10], SCN: 10583135604156

SQL>  select group#,status from v$log;
    GROUP# STATUS
---------- ----------------
         1 INACTIVE
         2 INACTIVE
         3 CURRENT
         4 INACTIVE

6.過了一會兒,可以看到日誌中會出現增量檢查點,增量檢查點的優先順序比全量的要低。
Mon Mar 24 18:19:22 2014
Incremental checkpoint up to RBA [0xb1e.4c.0], current log tail at RBA [0xb1e.5f.0]

7.觸發日誌歸檔
--alter system archive log current;
Mon Mar 24 18:20:51 2014
ALTER SYSTEM ARCHIVE LOG
Mon Mar 24 18:20:51 2014
Beginning log switch checkpoint up to RBA [0xb1f.2.10], SCN: 10583135604443
Thread 1 advanced to log sequence 2847 (LGWR switch)
  Current log# 2 seq# 2847 mem# 0: /dbccbsPT1/oracle/PETCUS1/oracnt01/redolog_A2/redo/redo02A.log
  Current log# 2 seq# 2847 mem# 1: /dbccbsPT1/oracle/PETCUS1/oracnt02/redolog_B2/redo/redo02B.log
Archived Log entry 2846 added for thread 1 sequence 2846 ID 0x4a0d6000 dest 1:

SQL> select group#,status from v$log;
    GROUP# STATUS
---------- ----------------
         1 INACTIVE
         2 CURRENT
         3 ACTIVE
         4 INACTIVE

和alter system switch logfile的差別在於,對於日誌組3,執行alter system archive log current和alter system switch logfile會有所不同
   GROUP#    THREAD#  SEQUENCE#    MEMBERS    SIZE_MB ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
         1          1        685          2           2048                 YES     ACTIVE
         2          1        686          2           2048                 YES     ACTIVE
         3          1        687          2           2048                 NO      ACTIVE
         4          1        688          2           2048                 NO      CURRENT



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

相關文章