楼主: biti_rainy

[精华] 关于数据库open的深入探究

[复制链接]
论坛徽章:
26
授权会员
日期:2006-09-10 23:30:242013年新春福章
日期:2013-02-25 14:51:24紫蛋头
日期:2013-02-20 10:54:332012新春纪念徽章
日期:2012-01-04 11:49:542010广州亚运会纪念徽章:三项全能
日期:2011-04-08 22:52:542010广州亚运会纪念徽章:藤球
日期:2011-03-15 17:02:18ITPUB9周年纪念徽章
日期:2010-10-08 09:34:022010世博会纪念徽章
日期:2010-09-03 09:04:352010新春纪念徽章
日期:2010-03-01 11:04:562010新春纪念徽章
日期:2010-01-04 08:33:08
61#
发表于 2006-9-14 10:35 | 只看该作者
大师们继续讨论呀!

使用道具 举报

回复
论坛徽章:
41
兰博基尼
日期:2013-12-02 15:01:20兰博基尼
日期:2013-12-03 11:25:17兰博基尼
日期:2013-12-03 10:55:21兰博基尼
日期:2013-12-03 11:24:43兰博基尼
日期:2013-12-03 11:22:55兰博基尼
日期:2013-12-03 11:23:51兰博基尼
日期:2013-12-07 22:01:29兰博基尼
日期:2013-12-02 15:01:20兰博基尼
日期:2013-12-02 15:01:20兰博基尼
日期:2013-12-02 15:01:20
62#
发表于 2006-10-29 11:42 | 只看该作者
由于BOLG中奖, 昨天收到Itpub  的赠书了,"深入浅出......."  看到里面的链接就来了
学习

使用道具 举报

回复
论坛徽章:
22
2010新春纪念徽章
日期:2010-03-01 11:08:33马上有对象
日期: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:08:092012新春纪念徽章
日期:2012-02-13 15:08:092012新春纪念徽章
日期:2012-02-13 15:08:092012新春纪念徽章
日期:2012-02-13 15:08:092012新春纪念徽章
日期:2012-02-13 15:08:09
63#
发表于 2006-10-30 14:29 | 只看该作者
最初由 eygle 发布
[B]

你所论述的其他问题都和前面的讨论差别不大。
关键就在于最后这一句。

如果bootstrap$的位置是可以修改的。
那么Oracle是怎样找到这个对象的?

显然在源程序里不会标记这个位置。
那么还能怎么办呢?

我猜测Oracle是启动时到数据文件上去找的

你可以试试看把SYSTEM表空间建的大一些,比如搞个2G,把bootstrap$放到后面去,看看启动时,速度是不是慢了 [/B]



Root dba: This field only occurs in data file #1, and is the location of blocks required
during bootstrapping the data dictionary (bootstrap$)

不过从我的测试系统上开来, root DBA 都是指向一个以数字命名的segment_type为cache的segment..

本机测试机相关dump

file_hdrs level 10
FILE HEADER:
        Software vsn=153092096=0x9200000, Compatibility Vsn=134217728=0x8000000
        Db ID=1073838953=0x40017b69, Db Name='WEBORA9'
        Activation ID=0=0x0
        Control Seq=3091=0xc13, File size=62720=0xf500
        File Number=1, Blksiz=8192, File Type=3 DATA
Tablespace #0 - SYSTEM  rel_fn:1
Creation   at   scn: 0x0000.0000000b 05/12/2002 16:17:58
Backup taken at scn: 0x0000.00000000 01/01/1988 00:00:00 thread:0
reset logs count:0x2177cb2a scn: 0x0000.0002e872 recovered at 10/30/2006 14:44:18
status:0x4 root dba:0x004001a1 chkpt cnt: 634 ctl cnt:633
begin-hot-backup file size: 0

-----------------------------------------------------------------------------------------------------------------
root dba对应的segment以及bootstrap$对应的file/block
SQL> select * from dba_extents where file_id = 1 and block_id between 417 and 41
7 + blocks - 1;

OWNER
------------------------------
SEGMENT_NAME
--------------------------------------------------------------------------------

PARTITION_NAME                 SEGMENT_TYPE       TABLESPACE_NAME
------------------------------ ------------------ ------------------------------

EXTENT_ID    FILE_ID   BLOCK_ID      BYTES     BLOCKS RELATIVE_FNO
---------- ---------- ---------- ---------- ---------- ------------
SYS
1.417
                               CACHE              SYSTEM
         0          1        417      65536          8            1


SQL>
SQL> select * from dba_extents where segment_name = 'BOOTSTRAP$';

OWNER
------------------------------
SEGMENT_NAME
--------------------------------------------------------------------------------

PARTITION_NAME                 SEGMENT_TYPE       TABLESPACE_NAME
------------------------------ ------------------ ------------------------------

EXTENT_ID    FILE_ID   BLOCK_ID      BYTES     BLOCKS RELATIVE_FNO
---------- ---------- ---------- ---------- ---------- ------------
SYS
BOOTSTRAP$
                               TABLE              SYSTEM
         0          1        377      65536          8            1


SQL>
------------------------------------------------------------------------------------------------------------------------
dump of datafile block 1/417(block of root dba)
Start dump data blocks tsn: 0 file#: 1 minblk 417 maxblk 417
WAIT #1: nam='db file sequential read' ela= 10508 p1=1 p2=417 p3=1
buffer tsn: 0 rdba: 0x004001a1 (1/417)
scn: 0x0006.c7cc8304 seq: 0x01 flg: 0x04 tail: 0x83040d01
frmt: 0x02 chkval: 0xc750 type: 0x0d=Compatibility segment
Header:  size 12   next rdba 0x0   entries 53   offset 1096f
Compatibility entry for 'COMPATSG':
   Size: 24  Release 0x134217728  By 0x153092096
Dump of memory from 0x04BF3034 to 0x04BF3038
4BF3030          00000000                        [....]        
Compatibility entry for 'BOOTSTRP':
   Size: 24  Release 0x134217728  By 0x153092096
Dump of memory from 0x04BF304C to 0x04BF3050
4BF3040                            00400179              [y.@.]
Compatibility entry for 'UNDODATA':
   Size: 36  Release 0x153092096  By 0x153092096
Dump of memory from 0x04BF3064 to 0x04BF3074

00400179 对应file_id = 1 , block_id = 377的DBA address.
--------------------------------------------------------------------------------------------------------------------

sql trace of database open
PARSING IN CURSOR #1 len=19 dep=0 uid=0 oct=35 lid=0 tim=81522298189 hv=1991530103 ad='7a7c0474'
ALTER DATABASE OPEN
END OF STMT
PARSE #1:c=0,e=2647,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=4,tim=81522298177
BINDS #1:
WAIT #1: nam='control file sequential read' ela= 268 p1=0 p2=1 p3=1
WAIT #1: nam='control file sequential read' ela= 229 p1=1 p2=1 p3=1
WAIT #1: nam='control file sequential read' ela= 356 p1=2 p2=1 p3=1
WAIT #1: nam='control file sequential read' ela= 232 p1=0 p2=240 p3=1
WAIT #1: nam='control file sequential read' ela= 213 p1=0 p2=1 p3=1
WAIT #1: nam='control file sequential read' ela= 218 p1=1 p2=1 p3=1
WAIT #1: nam='control file sequential read' ela= 253 p1=2 p2=1 p3=1
WAIT #1: nam='control file sequential read' ela= 243 p1=0 p2=240 p3=1
WAIT #1: nam='rdbms ipc reply' ela= 101866 p1=3 p2=910 p3=0
WAIT #1: nam='control file sequential read' ela= 290 p1=0 p2=1 p3=1
WAIT #1: nam='control file sequential read' ela= 195 p1=1 p2=1 p3=1
WAIT #1: nam='control file sequential read' ela= 212 p1=2 p2=1 p3=1
WAIT #1: nam='control file sequential read' ela= 226 p1=0 p2=240 p3=1
WAIT #1: nam='control file sequential read' ela= 21733 p1=0 p2=11 p3=1
WAIT #1: nam='direct path read' ela= 22 p1=1 p2=1 p3=1
WAIT #1: nam='direct path read' ela= 3 p1=2 p2=1 p3=1
WAIT #1: nam='direct path read' ela= 2 p1=3 p2=1 p3=1
WAIT #1: nam='direct path read' ela= 2 p1=4 p2=1 p3=1
WAIT #1: nam='direct path read' ela= 2 p1=8 p2=1 p3=1
WAIT #1: nam='direct path read' ela= 2 p1=201 p2=1 p3=1

这一段是读取数据文件头的信息..
     FILE# NAME
---------- --------------------------------------------------
         3 D:\ORACLE\ORADATA\WEBORA9\APPDATA1K01.DBF
         4 D:\ORACLE\ORADATA\WEBORA9\TEST01.DBF
         2 D:\ORACLE\ORADATA\WEBORA9\UNDOTBS01.DBF
         8 D:\ORACLE\ORADATA\WEBORA9\TOOLS01.DBF
         1 D:\ORACLE\ORADATA\WEBORA9\SYSTEM01.DBF


WAIT #1: nam='rdbms ipc reply' ela= 13887 p1=3 p2=2147483647 p3=0
WAIT #1: nam='control file sequential read' ela= 204 p1=0 p2=1 p3=1
WAIT #1: nam='control file sequential read' ela= 190 p1=1 p2=1 p3=1
WAIT #1: nam='control file sequential read' ela= 206 p1=2 p2=1 p3=1
WAIT #1: nam='control file sequential read' ela= 198 p1=0 p2=240 p3=1
[color]WAIT #1: nam='db file sequential read' ela= 23087 p1=1 p2=417 p3=1
WAIT #1: nam='rdbms ipc reply' ela= 287223 p1=4 p2=910 p3=0
WAIT #1: nam='control file sequential read' ela= 207 p1=0 p2=1 p3=1
WAIT #1: nam='control file sequential read' ela= 180 p1=1 p2=1 p3=1
WAIT #1: nam='control file sequential read' ela= 179 p1=2 p2=1 p3=1
WAIT #1: nam='control file sequential read' ela= 245 p1=0 p2=239 p3=1

WAIT #1: nam='db file sequential read' ela= 144903 p1=1 p2=417 p3=1
WAIT #1: nam='db file sequential read' ela= 25062 p1=1 p2=377 p3=1

这段为读取root dba以及根据root dba对应的block的信息得到的bootstrap$对应的存储位置的信息
=====================
PARSING IN CURSOR #2 len=188 dep=1 uid=0 oct=1 lid=0 tim=81523003167 hv=0 ad='4c1de24'
create table bootstrap$ ( line#         number not null,   obj#           number not null,   sql_text   varchar2(4000) not null)   storage (initial 50K objno 56 extents (file 1 block 377))
END OF STMT
PARSE #2:c=0,e=558,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,tim=81523003157
BINDS #2:
EXEC #2:c=0,e=4166,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=4,tim=81523026706
=====================


根据上面的dump信息可以这么推理..
1. 系统启动的时候根据control file的信息, 得到各个数据文件的位置.
2. 根据file# = 1 (system tablespace的第一个数据文件)的文件头的信息得到root dba的地址(此处为file_id = 1 ,block_id = 417
3. 根据root dba的信息, 得到bootstrap$对应的segment的存储位置, (此处为file_id = 1, block_id = 377) 得到系统启动的那只母鸡
4. 根据bootstrap$表中的信息, 得到系统中系统表的创建信息, 完成母鸡生下主要的小鸡的过程..
5.处理主要表生成之后的进一步处理, 生成主要的数据字典信息, 以及启动相关的undo segment(rollback segments).
6. 数据库启动完毕..

使用道具 举报

回复
论坛徽章:
3
授权会员
日期:2006-11-26 10:17:00生肖徽章2007版:鸡
日期:2008-01-02 17:35:532011新春纪念徽章
日期:2011-02-18 11:42:47
64#
发表于 2006-11-30 19:25 | 只看该作者
********************************************************************************[/COLOR]

create table bootstrap$ ( line#         number not null,   obj#           
  number not null,   sql_text   varchar2(4000) not null)   storage (initial
  50K objno 56 extents (file 1 block 377))


call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.00       0.00          0          0          0           0

Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: SYS   (recursive depth: 1)
*******************************************************************************


select line#, sql_text
from
bootstrap$ where obj# != :1
********************************************************************************
上面是跟踪文件中的内容[/COLOR]

问一个问题:由于这个表数据库中本来就存在,这里只是在内存中创建了表的结构.创建后没有插入数据,而是直接从数据库中的表bootstrap$读入.各位老大,我这样理解对吗?[/SIZE][/COLOR]11[/COLOR]

使用道具 举报

回复
论坛徽章:
3
授权会员
日期:2006-11-26 10:17:00生肖徽章2007版:鸡
日期:2008-01-02 17:35:532011新春纪念徽章
日期:2011-02-18 11:42:47
65#
发表于 2006-12-1 09:12 | 只看该作者
举个例子:如果数据库打开后,如果sys模式下已经有了test表,那么再创建test表就会出现错误.而数据库打开的过程中创建了bootstrap$表,没有发生错误是因为这个时候数据字典视图还没有打开.系统在内存中创建这个表的数据结构是为了把硬盘上bootstrap$的数据"构造"出来.

使用道具 举报

回复
论坛徽章:
0
66#
发表于 2006-12-4 15:43 | 只看该作者
严重表示支持

使用道具 举报

回复
论坛徽章:
0
67#
发表于 2007-4-3 16:50 | 只看该作者
不错,深刻

使用道具 举报

回复
论坛徽章:
0
68#
发表于 2007-5-22 15:41 | 只看该作者
<ok>

使用道具 举报

回复
论坛徽章:
0
69#
发表于 2007-8-27 22:25 | 只看该作者
太强了

使用道具 举报

回复
论坛徽章:
2
授权会员
日期:2007-09-19 14:10:06ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44
70#
发表于 2007-9-5 17:25 | 只看该作者
有一个问题一直想不通:就是db mount之后从controlfile 读到了所有文件的信息(datafile,redolog,等等).
当DB open的时候,在DB 创建了bootstrap$,并创建了相关的tab$,uet$ 等等有关文件存储的信息!
那open的时候Oracle是怎么检查各个文件的一致性呢? 是通过比对controlfile读到的文件头,和datafile head存储信息匹配,还是通过其他机制?望大师能解答一下!

使用道具 举报

回复

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

本版积分规则 发表回复

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