ITPub博客

首页 > 数据库 > Oracle > bootstrap$浅谈

bootstrap$浅谈

原创 Oracle 作者:bestpaydata 时间:2015-10-17 20:54:28 0 删除 编辑
1.什么是bootstrap$

我们看一下官方解释:
In general, Bootstrap is a technique for loading the first few instructions of a computer program into active memory and then using them to bring in the rest of the program.
What is bootstrap in Oracle ?
In Oracle, Bootstrap refers to loading of metadata (data dictionary) before we OPEN the database.
Bootstrap objects are classified as the objects (tables / indexes / clusters) with the object_id below 56 as bootstrap objects.
These objects are mandatory to bring up an instance, as this contains the most important metadata of the database.
What happens on database startup?
This shall be explained by setting the SQL_TRACE while opening the database.

总结:oracle启动时,加载原数据(数据字典)。可以理解为oracle 启动时初始化过程。在这个过程中,加载一些核心的元数据。

2.  Bootstrap的内容是什么?
SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE    11.2.0.4.0      Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

SQL> select owner,object_name,object_type,object_id from dba_objects where object_name='BOOTSTRAP$';

OWNER                OBJECT_NAME          OBJECT_TYPE          OBJECT_ID
-------------------- -------------------- ------------------- ----------
SYS                  BOOTSTRAP$           TABLE                       59

SQL> select dbms_metadata.get_ddl('TABLE','BOOTSTRAP$') from dual;
  CREATE TABLE "SYS"."BOOTSTRAP$"
   (    "LINE#" NUMBER NOT NULL ENABLE,
         "OBJ#" NUMBER NOT NULL ENABLE,
         "SQL_TEXT" VARCHAR2(4000) NOT NULL ENABLE
   ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
        NOCOMPRESS LOGGING
        STORAGE(INITIAL 57344 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
         PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
         BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
         TABLESPACE "SYSTEM"

SQL> select * from bootstrap$ order by 2;

     LINE#       OBJ# SQL_TEXT                                                  
---------- ---------- ----------------------------------------                  
        -1         -1 8.0.0.0.0                                                 
         0          0 CREATE ROLLBACK SEGMENT SYSTEM STORAGE (                  
                        INITIAL 112K NEXT 56K MINEXTENTS 1 MAX                  
                      EXTENTS 32765 OBJNO 0 EXTENTS (FILE 1 BL                  
                      OCK 128))                                                 
                                                                                
         2          2 CREATE CLUSTER C_OBJ#("OBJ#" NUMBER) PCT                  
                      FREE 5 PCTUSED 40 INITRANS 2 MAXTRANS 25                  
                      5 STORAGE (  INITIAL 136K NEXT 200K MINE                  
                      XTENTS 1 MAXEXTENTS 2147483645 PCTINCREA                  
                      SE 0 OBJNO 2 EXTENTS (FILE 1 BLOCK 144))                  
                   
         3          3 CREATE INDEX I_OBJ# ON CLUSTER C_OBJ# PC                  
                      TFREE 10 INITRANS 2 MAXTRANS 255 STORAGE                  
                       (  INITIAL 64K NEXT 1024K MINEXTENTS 1                   
                      MAXEXTENTS 2147483645 PCTINCREASE 0 OBJN                  
                      O 3 EXTENTS (FILE 1 BLOCK 168))                           
                                                                                
         4          4 CREATE TABLE TAB$("OBJ#" NUMBER NOT NULL                  
                      ,"DATAOBJ#" NUMBER,"TS#" NUMBER NOT NULL                  
                      ,"FILE#" NUMBER NOT NULL,"BLOCK#" NUMBER    

                  。。。。。。。。。。。。。

  
        57         57 CREATE INDEX I_CCOL1 ON CCOL$(CON#,COL#) PCTFREE 10 INITRANS
                       2 MAXTRANS 255 STORAGE (  INITIAL 64K NEXT 1024K MINEXTENTS
                       1 MAXEXTENTS 2147483645 PCTINCREASE 0 OBJNO 57 EXTENTS (FIL
                      E 1 BLOCK 504))

     LINE#       OBJ# SQL_TEXT
---------- ---------- ------------------------------------------------------------

        58         58 CREATE UNIQUE INDEX I_CCOL2 ON CCOL$(CON#,INTCOL#) PCTFREE 1
                      0 INITRANS 2 MAXTRANS 255 STORAGE (  INITIAL 64K NEXT 1024K
                      MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 OBJNO 58 EX
                      TENTS (FILE 1 BLOCK 512))

        59         59 CREATE TABLE BOOTSTRAP$("LINE#" NUMBER NOT NULL,"OBJ#" NUMBE
                      R NOT NULL,"SQL_TEXT" VARCHAR2(4000) NOT NULL) PCTFREE 10 PC
                      TUSED 40 INITRANS 1 MAXTRANS 255 STORAGE (  INITIAL 56K NEXT
                       1024K MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 OBJN
                      O 59 EXTENTS (FILE 1 BLOCK 520))

60 rows selected.

我们可以看到, 
1.bootstrap$ 表里面的内容就是创建一些基表对象。
2. 核心的基本数据块位置是固定的,比如系统回滚段在  FILE 1 BLOCK 128。
可以推测,如果这些基表块有问题,数据库肯定无法打开。
3.
可以看数据库启动时是按编号依次执行。
In Oracle, Bootstrap refers to loading of metadata (data dictionary) before we OPEN the database.

继续往下看:
SQL> select count(*) from bootstrap$;

  COUNT(*)
----------
        60

SQL> select header_file,header_block from dba_segments
  2  where segment_name='BOOTSTRAP$';

HEADER_FILE HEADER_BLOCK
----------- ------------
          1          520


bootstrap$ 一共有60行数据。
file 1 block 520 是BOOTSTRAP$ 的段头。

我们可以看到,bootstrap$表是oracle在open之前首先需要创建的表,然后会向里面插入数据,
插入的这些数据其实就是创建核心数据字典表的DDL 语句。问题是这些DDL语句是在什么地方 ?

SQL> select fhrdb,FHFNO from x$kcvfh order by 2;

     FHRDB      FHFNO
---------- ----------
   4194824          1
         0          2
         0          3
         0          4
         0          5
         0          6
         0          7
         0          8
         0          9
         0         10

10 rows selected.

SQL>  select to_char(4194824,'xxxxxxxxx') from dual;

TO_CHAR(41
----------
    400208

SQL> select dbms_utility.data_block_address_file(TO_NUMBER('400208', 'XXXXXXXX')) file_id, dbms_utility.data_block_address_block(TO_NUMBER('400208', 'XXXXXXXX')) block_id from dual;

   FILE_ID   BLOCK_ID
---------- ----------
         1        520

通过BBED 可以看到,bootstrap$ 的DDL 语句,在 520 块的段头。















来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30109892/viewspace-1814704/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2015-01-19

  • 博文量
    126
  • 访问量
    992040