当前位置: 首页 > BACKUP & RESTORE > 正文

       在有些情况下可以通过替换bootstrap$来达到一些目的,如重建object_id小于58的对象。下面是测试常用的2种方式来切换bootstrap$表:1,使用DBMS_DDL_INTERNAL.SWAP_BOOTSTRAP2,直接修改system数据文件头的信息

1DBMS_DDL_INTERNAL方法

使用dbms_ddl_internal要求数据库必须启动了upgrade状态,并且版本要求11G以上。

www.cdhtz.com > startup upgrade;

ORACLE instance started.

 

Total System Global Area 2137886720 bytes

Fixed Size                  2230072 bytes

Variable Size            1493174472 bytes

Database Buffers          637534208 bytes

Redo Buffers                4947968 bytes

Database mounted.

Database opened.

www.cdhtz.com > create table htz as select * from bootstrap$;

Table created.

www.cdhtz.com > select * from htz where LINE#=59;

     LINE#       OBJ#

———- ———-

SQL_TEXT

——————————————————————————–

        59         59

CREATE TABLE BOOTSTRAP$(“LINE#” NUMBER NOT NULL,”OBJ#” NUMBER NOT NULL,”SQL_TEXT

” VARCHAR2(4000) NOT NULL) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 STORAGE

 (  INITIAL 56K NEXT 1024K MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 OBJN

O 59 EXTENTS (FILE 1 BLOCK 520))

这里删除59这行记录,不然在启动的时候会报重复对象的错误

www.cdhtz.com > delete htz where LINE#=59;

1 row deleted.

www.cdhtz.com > commit;

Commit complete.

www.cdhtz.com > exec DBMS_DDL_INTERNAL.SWAP_BOOTSTRAP(‘HTZ’);

PL/SQL procedure successfully completed.

www.cdhtz.com >  update obj$ set name=’BOOTSTRAP_BACK’ where name=’BOOTSTRAP$’;

1 row updated.

www.cdhtz.com > commit;

Commit complete.

www.cdhtz.com > shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

www.cdhtz.com > startup

ORACLE instance started.

 

Total System Global Area 2137886720 bytes

Fixed Size                  2230072 bytes

Variable Size            1493174472 bytes

Database Buffers          637534208 bytes

Redo Buffers                4947968 bytes

Database mounted.

Database opened.

2 跟踪数据库开机读bootstrap$

BBED> set block 1

        BLOCK#          1

BBED> map

 File: /oracle/app/oracle/oradata/orcl1123/system01.dbf (0)

 Block: 1                                     Dba:0x00000000

————————————————————

 Data File Header

 

 struct kcvfh, 860 bytes                    @0      

 

 ub4 tailchk                                @8188   

 

意思这里就是指定bootstrap$表存放的意思,我这里使用的htz表,事实的dba地址如下:方式二就是修改kcvfhrdb这个值。

BBED> p kcvfh

BBED> p kcvfh.kcvfhrdb

ub4 kcvfhrdb                                @96       0x00417648

www.cdhtz.com > @dba_to_fno_bno.sql

Enter value for dba: 00417648

 

      FILE      BLOCK

———- ———-

         1      95816

 

www.cdhtz.com > @segment.sql

Enter value for owner: sys

Enter value for segment_name: htz

Enter value for tablespace_name:

 

                         HEADER

OWNER:SEGMENT_NAME       FILE_BLOCK   

———————— ————–

SYS.HTZ                  1.95816      

******************************        

Total:                                

 

1 row selected.

www.cdhtz.com > alter system set db_file_multiblock_read_count=1;

System altered.

www.cdhtz.com > oradebug setmypid

Statement processed.

www.cdhtz.com > oradebug event 10046 trace name context forever,level 12;

Statement processed.

www.cdhtz.com > alter database open;

Database altered.

www.cdhtz.com > oradebug tracefile_name;

/oracle/app/oracle/diag/rdbms/orcl1123/orcl1123/trace/orcl1123_ora_16641.trc

 

 

trace文件中可以发现下面的内容

trace开头是读控制文件,读了控制文件后才读这个

WAIT #182936778744: nam=’control file sequential read’ ela= 5 file#=0 block#=1 blocks=1 obj#=-1 tim=1416412117362314

WAIT #182936778744: nam=’control file sequential read’ ela= 4 file#=0 block#=16 blocks=1 obj#=-1 tim=1416412117362330

WAIT #182936778744: nam=’control file sequential read’ ela= 3 file#=0 block#=18 blocks=1 obj#=-1 tim=1416412117362341

WAIT #182936778744: nam=’control file sequential read’ ela= 4 file#=0 block#=302 blocks=1 obj#=-1 tim=1416412117362354

WAIT #182936778744: nam=’instance state change’ ela= 796 layer=2 value=1 waited=1 obj#=-1 tim=1416412117363178

WAIT #182936778744: nam=’db file sequential read’ ela= 10 file#=1 block#=95816 blocks=1 obj#=-1 tim=1416412117363386

=====================

PARSING IN CURSOR #182937207776 len=193 dep=1 uid=0 oct=1 lid=0 tim=1416412117364049 hv=2050547241 ad=’de8496c0′ sqlid=’a6hh009x3jrj9′

由于htz中已经删除了59这行的内容,不知道这条命令从那里来的,从oracle二进制文件中也没有找到。

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

END OF STMT

PARSE #182937207776:c=0,e=573,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,plh=0,tim=1416412117364048

EXEC #182937207776:c=999,e=229,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=4,plh=0,tim=1416412117364312

CLOSE #182937207776:c=0,e=4,dep=1,type=0,tim=1416412117364370

=====================

PARSING IN CURSOR #182937207776 len=55 dep=1 uid=0 oct=3 lid=0 tim=1416412117364662 hv=2111436465 ad=’de8481d0′ sqlid=’6apq2rjyxmxpj’

select line#, sql_text from bootstrap$ where obj# != :1

END OF STMT

PARSE #182937207776:c=0,e=279,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,plh=0,tim=1416412117364661

BINDS #182937207776:

 Bind#0

  oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00

  oacflg=08 fl2=0001 frm=00 csi=00 siz=24 off=0

  kxsbbbfp=2a97e83f98  bln=22  avl=04  flg=05

  value=82697

EXEC #182937207776:c=1000,e=48132,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,plh=867914364,tim=1416412117412850

WAIT #182937207776: nam=’db file sequential read’ ela= 14 file#=1 block#=95816 blocks=1 obj#=82697 tim=1416412117412929

WAIT #182937207776: nam=’db file sequential read’ ela= 15 file#=1 block#=95817 blocks=1 obj#=82697 tim=1416412117413061

FETCH #182937207776:c=1000,e=300,p=2,cr=3,cu=0,mis=0,r=1,dep=1,og=4,plh=867914364,tim=1416412117413185

FETCH #182937207776:c=0,e=12,p=0,cr=1,cu=0,mis=0,r=1,dep=1,og=4,plh=867914364,tim=1416412117413231

FETCH #182937207776:c=0,e=5,p=0,cr=1,cu=0,mis=0,r=1,dep=1,og=4,plh=867914364,tim=1416412117413250

3 bbed修改

下面是bbed修改system文件头来实现切换bootstrap$

www.htz.pw > select open_mode from v$database;

OPEN_MODE

——————–

READ WRITE

www.htz.pw > create table htz as select * from bootstrap$;

Table created.

这里记得删除obj#59不然会报错的,如下:

www.htz.pw > startup

ORACLE instance started.

 

Total System Global Area  592920576 bytes

Fixed Size                  2230632 bytes

Variable Size             176162456 bytes

Database Buffers          411041792 bytes

Redo Buffers                3485696 bytes

Database mounted.

ORA-01092: ORACLE instance terminated. Disconnection forced

ORA-00704: bootstrap process failure

ORA-00955: name is already used by an existing object

Process ID: 19265

Session ID: 1 Serial number: 5

www.htz.pw > delete htz where obj#=59;

1 row deleted.

www.htz.pw > commit;

Commit complete.

www.htz.pw > @extent.sql

Enter value for owner: sys

Enter value for segment_name: htz

Enter value for tablespace_name:

                    

                      FILE                  BLOCK

OWNER:SEGMENT_NAME      ID   FNO  EXTENT_ID BEGIN_END  

——————– —– —– ———- ————

SYS.HTZ                  1     1          0 86088~86095

******************************                         

Total:                                                 

1 row selected.

转成DBA地址为00415048

www.htz.pw > @dba_to_fno_bno.sql

Enter value for dba: 00415048

      FILE      BLOCK

———- ———-

         1      86088

1 row selected

www.htz.pw > select name from v$dbfile where file#=1;

NAME

——————————————————————————–

/oracle/app/oracle/oradata/orcl1123/system01.dbf

 

www.htz.pw > shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

使用bbed修改kcvfhrdb的值

BBED> set filename ‘/oracle/app/oracle/oradata/orcl1123/system01.dbf’;

        FILENAME        /oracle/app/oracle/oradata/orcl1123/system01.dbf

 

BBED> set block 1

        BLOCK#          1

 

BBED> p kcvfh.kcvfhrdb

ub4 kcvfhrdb                                @96       0x00400208

 

BBED> dump offset 96 count 20

 File: /oracle/app/oracle/oradata/orcl1123/system01.dbf (0)

 Block: 1                Offsets:   96 to  115           Dba:0x00000000

————————————————————————

 08024000 07000000 00000000 60776c2d 25f68233

 

 <32 bytes per line>

 

BBED> set mode edit

        MODE            Edit

 

BBED> set count 20

        COUNT           20

       

BBED> modify /x 48504100 offset 96

Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y

 File: /oracle/app/oracle/oradata/orcl1123/system01.dbf (0)

 Block: 1                Offsets:   96 to  115           Dba:0x00000000

————————————————————————

 48504100 07000000 00000000 60776c2d 25f68233

 

 <32 bytes per line>

 

 

BBED> sum apply

Check value for File 0, Block 1:

current = 0xcebf, required = 0xcebf

 

BBED> verify

DBVERIFY – Verification starting

FILE = /oracle/app/oracle/oradata/orcl1123/system01.dbf

BLOCK = 1

 

 

DBVERIFY – Verification complete

 

Total Blocks Examined         : 1

Total Blocks Processed (Data) : 0

Total Blocks Failing   (Data) : 0

Total Blocks Processed (Index): 0

Total Blocks Failing   (Index): 0

Total Blocks Empty            : 0

Total Blocks Marked Corrupt   : 0

Total Blocks Influx           : 0

Message 531 not found;  product=RDBMS; facility=BBED

 

 

 

www.htz.pw > startup

ORACLE instance started.

 

Total System Global Area  592920576 bytes

Fixed Size                  2230632 bytes

Variable Size             176162456 bytes

Database Buffers          411041792 bytes

Redo Buffers                3485696 bytes

Database mounted.

Database opened.

数据库正常启动

www.htz.pw > oradebug setmypid

Statement processed.

www.htz.pw > oradebug event 10046 trace name context forever,level 12;

Statement processed.

www.htz.pw > show parameter db_file

 

NAME                                 TYPE        VALUE

———————————— ———– ——————————

db_file_multiblock_read_count        integer     128

db_file_name_convert                 string

db_files                             integer     200

www.htz.pw > alter session set db_file_multiblock_read_count=1;

 

Session altered.

 

www.htz.pw > oradebug tracefile_name;

/oracle/app/oracle/diag/rdbms/orcl1123/orcl1123/trace/orcl1123_ora_20077.trc

www.htz.pw > alter database open;

 

Database altered.

 

trace文件中可以看到下面的信息

WAIT #182936774688: nam=’db file sequential read’ ela= 10 file#=1 block#=86088 blocks=1 obj#=-1 tim=1416570843425508

=====================

PARSING IN CURSOR #182937313288 len=193 dep=1 uid=0 oct=1 lid=0 tim=1416570843426130 hv=819885117 ad=’830e4b60′ sqlid=’g63vpahsdwx1x’

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

END OF STMT

PARSE #182937313288:c=999,e=544,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,plh=0,tim=1416570843426129

EXEC #182937313288:c=0,e=153,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=4,plh=0,tim=1416570843426318

CLOSE #182937313288:c=0,e=5,dep=1,type=0,tim=1416570843426373

再次申明:只能在测试环境玩玩,生产环境千万不要玩这些,也没有实际的作用。

substituter bootstrap$ using other table:等您坐沙发呢!

发表评论

gravatar

? razz sad evil ! smile oops grin eek shock ??? cool lol mad twisted roll wink idea arrow neutral cry mrgreen

快捷键:Ctrl+Enter