在Oracle10g之前,数据库中存在一个独一无二的Cache对象,这个对象就是:
SQL> select segment_name,segment_type
,header_file,header_block
2 from dba_segments where
segment_type='CACHE';
SEGMENT_NAME SEGMENT_TYPE HEADER_FILE HEADER_BLOCK
------------- -------------- ------- --------
1.417 CACHE 1 417 |
这个对象的名称来自于文件号和数据块号,1.417正好就是文件1的第417个数据块。
这个Cache对象在Oracle数据库中的含义非同一般,在bootstrap$的过程中,这个对象之前的所有对象都需要用来bootstrap。
我们看一下1.417之前的所有对象:
SQL>
select b.object_id,a.segment_name,
a.segment_type,a.header_block from
dba_segments a,dba_objects b
2 where a.segment_name=b.object_name(+) and
a.header_file=1 and a.header_block <= 417
3 order by a.header_block
4 /
OBJECT_ID SEGMENT_NAME SEGMENT_TYPE HEADER_BLOCK
---------- -------------------- ------------------ ------------
SYSTEM ROLLBACK 9
2 C_OBJ# CLUSTER 25
3 I_OBJ# INDEX 49
6 C_TS# CLUSTER 57
7 I_TS# INDEX 65
8 C_FILE#_BLOCK# CLUSTER 73
9 I_FILE#_BLOCK# INDEX 81
10 C_USER# CLUSTER 89
11 I_USER# INDEX 97
15 UNDO$ TABLE 105
17 FILE$ TABLE 113
18 OBJ$ TABLE 121
23 PROXY_DATA$ TABLE 129
24 I_PROXY_DATA$ INDEX 137
25 PROXY_ROLE_DATA$ TABLE 145
26 I_PROXY_ROLE_DATA$_1 INDEX 153
27 I_PROXY_ROLE_DATA$_2 INDEX 161
28 CON$ TABLE 169
29 C_COBJ# CLUSTER 177
30 I_COBJ# INDEX 185
OBJECT_ID SEGMENT_NAME SEGMENT_TYPE HEADER_BLOCK
---------- -------------------- ------------------ ------------
33 I_TAB1 INDEX 193
34 I_UNDO1 INDEX 201
35 I_UNDO2 INDEX 209
36 I_OBJ1 INDEX 217
37 I_OBJ2 INDEX 225
38 I_OBJ3 INDEX 233
39 I_IND1 INDEX 241
40 I_ICOL1 INDEX 249
41 I_FILE1 INDEX 257
42 I_FILE2 INDEX 265
43 I_TS1 INDEX 273
44 I_USER1 INDEX 281
45 I_COL1 INDEX 289
46 I_COL2 INDEX 297
47 I_COL3 INDEX 305
48 I_CON1 INDEX 313
49 I_CON2 INDEX 321
50 I_CDEF1 INDEX 329
51 I_CDEF2 INDEX 337
52 I_CDEF3 INDEX 345
53 I_CDEF4 INDEX 353
OBJECT_ID SEGMENT_NAME SEGMENT_TYPE HEADER_BLOCK
---------- -------------------- ------------------ ------------
54 I_CCOL1 INDEX 361
55 I_CCOL2 INDEX 369
56 BOOTSTRAP$ TABLE 377
1.417 CACHE 417
45 rows selected |
一共有44个对象。我们再来看一下初始化过程中bootstrap$中的信息:
SQL> select * from bootstrap$ order by obj#;
LINE# OBJ# SQL_TEXT
------ -------- -----------------------
-1 -1 8.0.0.0.0
0 0 CREATE ROLLBACK SEGMENT SYSTEM STORAGE
(INITIAL 112K NEXT 1024K MINEXTENTS 1M
2 2 CREATE CLUSTER C_OBJ#("OBJ#" NUMBER)
PCTFREE 5 PCTUSED 40 INITRANS 2 MAXTRANS 25
3 3 CREATE INDEX I_OBJ# ON CLUSTER C_OBJ#
PCTFREE 10 INITRANS 2MAXTRANS 255 STORAGE
4 4 CREATE TABLE TAB$("OBJ#" NUMBER NOT NULL,
"DATAOBJ#" NUMBER,"TS#" NUMBER NOT NULL
5 5 CREATE TABLE CLU$("OBJ#" NUMBER NOT NULL,
"DATAOBJ#" NUMBER,"TS#" NUMBER NOT NULL
6 6 CREATE CLUSTER C_TS#("TS#" NUMBER)
PCTFREE 10 PCTUSED 40 INITRANS 2 MAXTRANS 255
7 7 CREATE INDEX I_TS# ON CLUSTER C_TS#
PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE (
8 8 CREATE CLUSTER C_FILE#_BLOCK#("TS#"
NUMBER,"SEGFILE#" NUMBER,"SEGBLOCK#" NUMBER)
9 9 CREATE INDEX I_FILE#_BLOCK# ON
CLUSTER C_FILE#_BLOCK# PCTFREE 10 INITRANS 2 MAXT
10 10 CREATE CLUSTER C_USER#("USER#" NUMBER)
PCTFREE 10 PCTUSED 40 INITRANS 2 MAXTRANS
11 11 CREATE INDEX I_USER# ON CLUSTER C_USER#
PCTFREE 10 INITRANS 2 MAXTRANS 255 STORA
12 12 CREATE TABLE FET$("TS#" NUMBER NOT NULL,
"FILE#" NUMBER NOT NULL,"BLOCK#" NUMBER
13 13 CREATE TABLE UET$("SEGFILE#" NUMBER NOT
NULL,"SEGBLOCK#" NUMBER NOT NULL,"EXT#"
14 14 CREATE TABLE SEG$("FILE#" NUMBER NOT NULL
,"BLOCK#" NUMBER NOT NULL,"TYPE#" NUMBE
15 15 CREATE TABLE UNDO$("US#" NUMBER NOT NULL,
"NAME" VARCHAR2(30) NOT NULL,"USER#" NU
16 16 CREATE TABLE TS$("TS#" NUMBER NOT NULL,
"NAME" VARCHAR2(30) NOT NULL,"OWNER#" NUM
17 17 CREATE TABLE FILE$("FILE#" NUMBER NOT NULL,
"STATUS$" NUMBER NOT NULL,"BLOCKS" NU
18 18 CREATE TABLE OBJ$("OBJ#" NUMBER NOT NULL,
"DATAOBJ#" NUMBER,"OWNER#" NUMBER NOT N
19 19 CREATE TABLE IND$("OBJ#" NUMBER NOT NULL,
"DATAOBJ#" NUMBER,"TS#" NUMBER NOT NULL
LINE# OBJ# SQL_TEXT
---------- ---------- ----------------------------------------
20 20 CREATE TABLE ICOL$("OBJ#" NUMBER NOT NULL,
"BO#" NUMBER NOT NULL,"COL#" NUMBER NO
21 21 CREATE TABLE COL$("OBJ#" NUMBER NOT NULL,
"COL#" NUMBER NOT NULL,"SEGCOL#" NUMBER
22 22 CREATE TABLE USER$("USER#" NUMBER NOT NULL,
"NAME" VARCHAR2(30) NOT NULL,"TYPE#"
23 23 CREATE TABLE PROXY_DATA$("CLIENT#" NUMBER NOT NULL,
"PROXY#" NUMBER NOT NULL,"CRE
24 24 CREATE UNIQUE INDEX I_PROXY_DATA$
ON PROXY_DATA$(CLIENT#,PROXY#) PCTFREE 10 INIT
25 25 CREATE TABLE PROXY_ROLE_DATA$("CLIENT#"
NUMBER NOT NULL,"PROXY#" NUMBER NOT NULL
26 26 CREATE INDEX I_PROXY_ROLE_DATA$_1 ON
PROXY_ROLE_DATA$(CLIENT#,PROXY#) PCTFREE 10
27 27 CREATE UNIQUE INDEX I_PROXY_ROLE_
DATA$_2ONPROXY_ROLE_DATA$(CLIENT#,
PROXY#,ROLE
28 28 CREATE TABLE CON$("OWNER#" NUMBER NOT NULL,
"NAME" VARCHAR2(30) NOT NULL,"CON#" N
29 29 CREATE CLUSTER C_COBJ#("OBJ#" NUMBER)
PCTFREE 0 PCTUSED 50 INITRANS 2 MAXTRANS 2
30 30 CREATE INDEX I_COBJ# ON CLUSTER C_COBJ#
PCTFREE 10 INITRANS 2 MAXTRANS 255 STORA
31 31 CREATE TABLE CDEF$("CON#" NUMBER NOT NULL,
"OBJ#" NUMBER NOT NULL,"COLS" NUMBER,"
32 32 CREATE TABLE CCOL$("CON#" NUMBER NOT NULL,
"OBJ#" NUMBER NOT NULL,"COL#" NUMBER N
33 33 CREATE INDEX I_TAB1 ON TAB$(BOBJ#)
PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE (
34 34 CREATE UNIQUE INDEX I_UNDO1 ON
UNDO$(US#) PCTFREE 10 INITRANS 2 MAXTRANS 255 STO
35 35 CREATE INDEX I_UNDO2 ON UNDO$(NAME)
PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE (
36 36 CREATE UNIQUE INDEX I_OBJ1 ON OBJ$(OBJ#)
PCTFREE 10 INITRANS 2 MAXTRANS 255 STOR
37 37 CREATE UNIQUE INDEXI_OBJ2ONOBJ$(OWNER#,
NAME,NAMESPACE,REMOTEOWNER,LINKNAME,SU
38 38 CREATE INDEX I_OBJ3 ON OBJ$(OID$)
PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE (
39 39 CREATE UNIQUE INDEX I_IND1 ON IND$(OBJ#)
PCTFREE 10 INITRANS 2 MAXTRANS 255 STOR
40 40 CREATE INDEX I_ICOL1 ON ICOL$(OBJ#)
PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE (
LINE# OBJ# SQL_TEXT
---------- ------- --------------------------------------------
41 41 CREATE UNIQUE INDEX I_FILE1
ON FILE$(FILE#) PCTFREE 10 INITRANS
2 MAXTRANS 255 S
42 42 CREATE UNIQUE INDEX I_FILE2 ON
FILE$(TS#,RELFILE#) PCTFREE 10
INITRANS 2 MAXTRAN
43 43 CREATE UNIQUE INDEX I_TS1 ON TS$(NAME)
PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAG
44 44 CREATE UNIQUE INDEX I_USER1 ON USER$(NAME)
PCTFREE 10 INITRANS 2 MAXTRANS 255 ST
45 45 CREATE UNIQUE INDEX I_COL1 ON COL$(OBJ#,NAME)
PCTFREE 10 INITRANS 2 MAXTRANS 255
46 46 CREATE INDEX I_COL2 ON COL$(OBJ#,COL#)
PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAG
47 47 CREATE UNIQUE INDEX I_COL3 ON COL$(OBJ#,
INTCOL#) PCTFREE 10 INITRANS 2 MAXTRANS
48 48 CREATE UNIQUE INDEX I_CON1 ON CON$(OWNER#,
NAME) PCTFREE 10 INITRANS 2 MAXTRANS 2
49 49 CREATE UNIQUE INDEX I_CON2 ON CON$(CON#)
PCTFREE 10 INITRANS 2 MAXTRANS 255 STOR
50 50 CREATE UNIQUE INDEX I_CDEF1 ON CDEF$(CON#)
PCTFREE 10 INITRANS 2 MAXTRANS 255 ST
51 51 CREATE INDEX I_CDEF2 ON CDEF$(OBJ#)
PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE (
52 52 CREATE INDEX I_CDEF3 ON CDEF$(ROBJ#)
PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE
53 53 CREATE INDEX I_CDEF4 ON CDEF$(ENABLED)
PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAG
54 54 CREATE INDEX I_CCOL1 ON CCOL$(CON#,COL#)
PCTFREE 10 INITRANS 2 MAXTRANS 255 STOR
55 55 CREATE UNIQUE INDEX I_CCOL2 ON CCOL$(CON#,
INTCOL#) PCTFREE 10 INITRANS 2 MAXTRAN
56 56 CREATE TABLE BOOTSTRAP$("LINE#" NUMBER
NOT NULL,"OBJ#" NUMBER NOT NULL,"SQL_TEXT
57 rows selected |
bootstarp的对象都是在1.417之前的,当然有部分对象是基于Cluster创建的。那么这个对象在启动之前有什么作用呢?
itpub上的jametong同学给出了一个重要的信息,在SYSTEM文件头,Oracle存储了一个root dba: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指向了1.417对象,而1.417对象的上一个对象正是bootstrap$,Oracle通过1.417找到了bootstrap$对象就可以启动了数据库。
我们可以从文件头的转储中找到这个root dba,以下是一个Oracle9i的数据文件头信息:
DATA FILE #1:
(name #9) /opt/oracle/oradata/eygle/system01.dbf
creation size=0 block size=8192 status=0xe
head=9 tail=9 dup=1
tablespace 0, index=1 krfil=1 prev_file=0
unrecoverable scn: 0x0004.6c4b5cba
04/10/2007 13:34:26
Checkpoint cnt:6933 scn: 0x0004.6c4dfc0c
04/16/2007 14:38:05
Stop scn: 0xffff.ffffffff 04/07/2007 21:03:02
Creation Checkpointed at scn:
0x0000.00000007 04/24/2006 11:34:39
thread:0 rba:(0x0.0.0)
enabled threads: 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000
Offline scn: 0x0004.6c432ebf prev_range: 0
Online Checkpointed at scn:
0x0004.6c432ec0 03/28/2007 11:22:37
thread:1 rba:(0x1.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=1407686520=0x53e79778, Db Name='EYGLE'
Activation ID=0=0x0
Control Seq=1299557=0x13d465,
File size=27017=0x6989
File Number=1, Blksiz=8192, File Type=3 DATA
Tablespace #0 - SYSTEM rel_fn:1
Creation at scn: 0x0000.00000007
04/24/2006 11:34:39
Backup taken at scn: 0x0004.6c2d657e
02/12/2007 15:54:52 thread:1
reset logs count:0x24dc1f7d scn: 0x0004.6c432ec0
recovered at 04/07/2007 21:04:11
status:0x4 root dba:0x004001a1 chkpt cnt:
6933 ctl cnt:6932
begin-hot-backup file size: 32000
Checkpointed at scn: 0x0004.6c4dfc0c
04/16/2007 14:38:05
thread:1 rba:(0x17.2.10)
enabled threads: 01000000 00000000 00000000
00000000 00000000 00000000
00000000 00000000
Backup Checkpointed at scn:
0x0004.6c2d657e 02/12/2007 15:54:52
thread:1 rba:(0x18e1.30.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
01/01/1988 00:00:00
Terminal Recovery Stamp scn: 0x0000.00000000
01/01/1988 00:00:00 | |