楼主: grassbell

[精华] 对多种情况下控制文件的理解与疑问,请指正。

[复制链接]
论坛徽章:
117
ITPUB元老
日期:2005-02-28 12:57:002012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20版主7段
日期:2012-05-15 15:24:11ITPUB 11周年纪念徽章
日期:2012-09-28 17:34:42ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:32紫蛋头
日期:2013-03-04 17:00:07优秀写手
日期:2013-12-18 09:29:09
31#
发表于 2004-6-17 15:48 | 只看该作者
对于这个问题,我做点补充说明

通过以下测试得出结果:

1.dump出数据文件的header

[php]
[oracle@jumper udump]$ sqlplus "/ as sysdba"

SQL*Plus: Release 9.2.0.3.0 - Production on Thu Jun 17 15:27:37 2004

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.3.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.3.0 - Production

SQL> ALTER SESSION SET EVENTS ' IMMEDIATE TRACE NAME FILE_HDRS LEVEL 10';

Session altered.

.
[/php]

检查跟踪文件,我只摘录system表空间的
大家注意红字部分

DATA FILE #1:
  (name #4) /opt/oracle/oradata/hsjf/system01.dbf
creation size=32000 block size=8192 status=0xe head=4 tail=4 dup=1
tablespace 0, index=1 krfil=1 prev_file=0
unrecoverable scn: 0x0000.00000000 04/23/2004 01:20:52
Checkpoint cnt:1557 scn: 0x0000.014338dc 06/13/2004 01:19:38
Stop scn: 0xffff.ffffffff 06/13/2004 01:18:07
Creation Checkpointed at scn:  0x0000.000000ae 07/16/2003 03:40:10
thread:1 rba0x1.3.10)
enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
Offline scn: 0x0000.013b46fd prev_range: 0
Online Checkpointed at scn:  0x0000.013b46fe 05/28/2004 23:37:17
thread:1 rba0x1.2.0)
enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
Hot Backup end marker scn: 0x0000.00000000
aux_file is NOT DEFINED
FILE HEADER:
        Software vsn=153092096=0x9200000, Compatibility Vsn=134217728=0x8000000
        Db ID=1052178311=0x3eb6f787, Db Name='HSJF'
        Activation ID=0=0x0
        Control Seq=18062=0x468e, File size=38400=0x9600
        File Number=1, Blksiz=8192, File Type=3 DATA
Tablespace #0 - SYSTEM  rel_fn:1
Creation   at   scn: 0x0000.000000ae 07/16/2003 03:40:10
Backup taken at scn: 0x0000.01301f8d 05/12/2004 00:16:20 thread:1
reset logs count:0x1f6f3ead scn: 0x0000.013b46fe recovered at 06/06/2004 22:45:27
status:0x4 root dba:0x004001a1 chkpt cnt: 1557 ctl cnt:1556
begin-hot-backup file size: 38400
Checkpointed at scn:  0x0000.014338dc 06/13/2004 01:19:38
thread:1 rba0x6a.18fd.10)
enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
Backup Checkpointed at scn:  0x0000.01301f8d 05/12/2004 00:16:20
thread:1 rba0x2ac.1f42.10)
enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
External cache id: 0x0 0x0 0x0 0x0
Absolute fuzzy scn: 0x0000.00000000
Recovery fuzzy scn: 0x0000.00000000 05/05/2004 18:09:43
Terminal Recovery Stamp scn: 0x0000.00000000 01/01/1988 00:00:00

使用道具 举报

回复
论坛徽章:
117
ITPUB元老
日期:2005-02-28 12:57:002012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20版主7段
日期:2012-05-15 15:24:11ITPUB 11周年纪念徽章
日期:2012-09-28 17:34:42ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:32紫蛋头
日期:2013-03-04 17:00:07优秀写手
日期:2013-12-18 09:29:09
32#
发表于 2004-6-17 15:51 | 只看该作者
做一次checkpoint
然后再dump一次

我们看一下变化部分
检查点部分我没有标出了

DATA FILE #1:
  (name #4) /opt/oracle/oradata/hsjf/system01.dbf
creation size=32000 block size=8192 status=0xe head=4 tail=4 dup=1
tablespace 0, index=1 krfil=1 prev_file=0
unrecoverable scn: 0x0000.00000000 04/23/2004 01:20:52
Checkpoint cnt:1558 scn: 0x0000.01454116 06/17/2004 15:55:10
Stop scn: 0xffff.ffffffff 06/13/2004 01:18:07
Creation Checkpointed at scn:  0x0000.000000ae 07/16/2003 03:40:10
thread:1 rba0x1.3.10)
enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
Offline scn: 0x0000.013b46fd prev_range: 0
Online Checkpointed at scn:  0x0000.013b46fe 05/28/2004 23:37:17
thread:1 rba0x1.2.0)
enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
Hot Backup end marker scn: 0x0000.00000000
aux_file is NOT DEFINED
FILE HEADER:
        Software vsn=153092096=0x9200000, Compatibility Vsn=134217728=0x8000000
        Db ID=1052178311=0x3eb6f787, Db Name='HSJF'
        Activation ID=0=0x0
        Control Seq=18277=0x4765, File size=38400=0x9600
        File Number=1, Blksiz=8192, File Type=3 DATA
Tablespace #0 - SYSTEM  rel_fn:1
Creation   at   scn: 0x0000.000000ae 07/16/2003 03:40:10
Backup taken at scn: 0x0000.01301f8d 05/12/2004 00:16:20 thread:1
reset logs count:0x1f6f3ead scn: 0x0000.013b46fe recovered at 06/06/2004 22:45:27
status:0x4 root dba:0x004001a1 chkpt cnt: 1558 ctl cnt:1557
begin-hot-backup file size: 38400
Checkpointed at scn:  0x0000.01454116 06/17/2004 15:55:10
thread:1 rba0x6a.4578.10)
enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
Backup Checkpointed at scn:  0x0000.01301f8d 05/12/2004 00:16:20
thread:1 rba0x2ac.1f42.10)
enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
External cache id: 0x0 0x0 0x0 0x0
Absolute fuzzy scn: 0x0000.00000000
Recovery fuzzy scn: 0x0000.00000000 05/05/2004 18:09:43
Terminal Recovery Stamp scn: 0x0000.00000000 01/01/1988 00:00:00

使用道具 举报

回复
论坛徽章:
117
ITPUB元老
日期:2005-02-28 12:57:002012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20版主7段
日期:2012-05-15 15:24:11ITPUB 11周年纪念徽章
日期:2012-09-28 17:34:42ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:32紫蛋头
日期:2013-03-04 17:00:07优秀写手
日期:2013-12-18 09:29:09
33#
发表于 2004-6-17 15:54 | 只看该作者
这个RBA是什么?


Recent entries in the redo thread of an Oracle instance are addressed using a 3-part redo byte address, or RBA. An RBA is comprised of
the log file sequence number (4 bytes)
the log file block number (4 bytes)
the byte offset into the block at which the redo record starts (2 bytes)



thread:1 rba0x6a.18fd.10)

0x6a = 106

这就是log sequence了

[php]
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /opt/oracle/oradata/hsjf/archive
Oldest online log sequence     104
Next log sequence to archive   106
Current log sequence           106

.
[/php]

使用道具 举报

回复
论坛徽章:
86
ITPUB元老
日期:2005-02-28 12:57:002012新春纪念徽章
日期:2012-01-04 11:49:542012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20咸鸭蛋
日期:2012-05-08 10:27:19版主8段
日期:2012-05-15 15:24:112013年新春福章
日期:2013-02-25 14:51:24
34#
发表于 2004-6-17 15:54 | 只看该作者
thread:1 rba  0x6a.4578.10)   

这对应的是 日志的物理地址位置 ,我只去搜索了
grep  -i  log
grep  -i  seq

没注意 RBA 这个问题,呵呵

RBA 应该是包含了 日志文件+日志块+日志slot

6a  是不是你的日志文件序号    6*16 + a  =   106

使用道具 举报

回复
论坛徽章:
16
ITPUB元老
日期:2005-04-27 08:46:182013年新春福章
日期:2013-02-25 14:51:242012新春纪念徽章
日期:2012-01-04 11:49:54鲜花蛋
日期:2011-12-27 22:39:17ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412010新春纪念徽章
日期:2010-03-01 11:20:51生肖徽章2007版:牛
日期:2009-07-13 12:53:13生肖徽章2007版:蛇
日期:2009-03-19 13:57:24生肖徽章2007版:牛
日期:2008-12-17 10:30:43奥运会纪念徽章:足球
日期:2008-10-24 13:28:14
35#
发表于 2004-6-23 10:41 | 只看该作者
整理一下
1.1对这个概念比较模糊?
1.3,问题同1.1,这个值比CURRENTlog.FIRST_CHANGE#稍微大一点,代表什么呢?

v$database.CONTROLFILE_CHANGE#应该就是oracle在更新控制文件的时间点上的SCN号。

1.2 既然是Last SCN archived,那起码应该比log1.FIRST_CHANGE#还要大吧,log1归档了呀?
http://www.ixora.com.au/notes/log_switch_triggers.htm有这么一段话
Whenever a log file is reused in any thread, the force SCN recorded in the database entry of the controlfile is advanced to 1 beyond the high SCN of the reused log file (unless the force SCN was already higher).
同时http://www.ixora.com.au/tips/tuning/log_switch.htm还有这么一段话
A log switch is forced whenever the current SCN for a thread falls behind the force SCN recorded in the database entry section of the controlfile. The force SCN is one more than the highest high SCN of any log file reused in any thread.

实际上说明在控制文件中记载的force scn记录了下一个要重新写入的redo log file的低scn号。
这样,每次要归档时,都会强制把所有SCN号低于force scn同时没有归档的日志文件进行归档。这主要是为了防止下一个要写入的日志文件在没有归档的情况下就被重新覆盖了。

我试了几次,dump出来的控制文件里的force scn都是当前日志文件的下一个要重新写入的日志文件的first_change#号。

使用道具 举报

回复
招聘 : 数据库管理员
论坛徽章:
21
授权会员
日期:2005-10-30 17:05:332012新春纪念徽章
日期:2012-02-13 15:11:362012新春纪念徽章
日期:2012-02-13 15:11:362012新春纪念徽章
日期:2012-02-13 15:11:362012新春纪念徽章
日期:2012-02-13 15:11:36马上有车
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:142012新春纪念徽章
日期:2012-02-13 15:11:36
36#
 楼主| 发表于 2004-6-23 14:00 | 只看该作者
最初由 hanson 发布
[B]
1.2 既然是Last SCN archived,那起码应该比log1.FIRST_CHANGE#还要大吧,log1归档了呀?

实际上说明在控制文件中记载的force scn记录了下一个要重新写入的redo log file的低scn号。
这样,每次要归档时,都会强制把所有SCN号低于force scn同时没有归档的日志文件进行归档。这主要是为了防止下一个要写入的日志文件在没有归档的情况下就被重新覆盖了。
[/B]


谢谢!

但是单从这句话,有些地方还不太理解:
A log switch is forced whenever the current SCN for a thread falls behind the force SCN recorded in the database entry section of the controlfile. The force SCN is one more than the highest high SCN of any log file reused in any thread.

the current SCN for a thread 是指什么?并且这句话的前提是在In a parallel server environment,这又是指什么?

我觉得你最后那个结论是否应该这样说:
这样,每次要[B]切换日志[/B]时,都会强制把所有[B]以FORCE SCN为LOW SCN的日志组[/B]进行归档(如果没有归档的话)。这主要是为了防止下一个要写入的日志文件在没有归档的情况下就被重新覆盖了。

使用道具 举报

回复
论坛徽章:
86
ITPUB元老
日期:2005-02-28 12:57:002012新春纪念徽章
日期:2012-01-04 11:49:542012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20咸鸭蛋
日期:2012-05-08 10:27:19版主8段
日期:2012-05-15 15:24:112013年新春福章
日期:2013-02-25 14:51:24
37#
发表于 2004-6-23 15:02 | 只看该作者
the current SCN for a thread 是指什么?并且这句话的前提是在In a parallel server environment,这又是指什么?

thread 可以看作一个 lgwr 进程
parallel  server  env 是 ops/rac 环境下
由于有多个instance,所以有多个 lgwr
而每个 lgwr 都有自己的 scn,也就是说每个instance 对应的 日志文件中scn是不一样的

使用道具 举报

回复
论坛徽章:
16
ITPUB元老
日期:2005-04-27 08:46:182013年新春福章
日期:2013-02-25 14:51:242012新春纪念徽章
日期:2012-01-04 11:49:54鲜花蛋
日期:2011-12-27 22:39:17ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412010新春纪念徽章
日期:2010-03-01 11:20:51生肖徽章2007版:牛
日期:2009-07-13 12:53:13生肖徽章2007版:蛇
日期:2009-03-19 13:57:24生肖徽章2007版:牛
日期:2008-12-17 10:30:43奥运会纪念徽章:足球
日期:2008-10-24 13:28:14
38#
发表于 2004-6-24 08:49 | 只看该作者
最初由 grassbell 发布
[B]
我觉得你最后那个结论是否应该这样说:
这样,每次要[B]切换日志[/B]时,都会强制把所有[B]以FORCE SCN为LOW SCN的日志组[/B]进行归档(如果没有归档的话)。这主要是为了防止下一个要写入的日志文件在没有归档的情况下就被重新覆盖了。 [/B]


呵呵,这样好像更准确些

使用道具 举报

回复
论坛徽章:
0
39#
发表于 2004-8-14 22:28 | 只看该作者
不明白为什么,但是可以发现:
控制文件中的force scn总是对应到当前最早被achive的relog的first_change,跟在force scn后头的scn表示的最迟被achive的relog的next_change

使用道具 举报

回复
论坛徽章:
86
ITPUB元老
日期:2005-02-28 12:57:002012新春纪念徽章
日期:2012-01-04 11:49:542012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20咸鸭蛋
日期:2012-05-08 10:27:19版主8段
日期:2012-05-15 15:24:112013年新春福章
日期:2013-02-25 14:51:24
40#
发表于 2004-8-14 22:39 | 只看该作者
最初由 lifeng@itpub 发布
[B]不明白为什么,但是可以发现:
控制文件中的force scn总是对应到当前最早被achive的relog的first_change,跟在force scn后头的scn表示的最迟被achive的relog的next_change [/B]


http://www.ixora.com.au/tips/tuning/log_switch.htm

In a parallel server environment, the LGWR process in each instance holds a KK instance lock on its own thread. The id2 field identifies the thread number. This lock is used to trigger forced log switches from remote instances. A log switch is forced whenever the current SCN for a thread falls behind the force SCN recorded in the database entry section of the controlfile. The force SCN is one more than the highest high SCN of any log file reused in any thread.

For local log switches, the process initiating the log switch allocates a message buffer in the SGA and constructs a message to LGWR indicating that a log switch is required, before posting LGWR's semaphore.


这种控制文件记录的跨时间段的东西,应该和备份恢复(尤其是rman)相关

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表