ITPub博客

首页 > 数据库 > Oracle > redo日志文件学习笔记(一)

redo日志文件学习笔记(一)

原创 Oracle 作者:jeanron100 时间:2014-03-24 22:25:16 1 删除 编辑
关于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/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
技术文章每天更新,阵地已转移到微信公众号端。 公众号:jianrong-notes

注册时间:2012-05-14

  • 博文量
    1498
  • 访问量
    14454419