alter session set events 'immediate trace name controlf level 1';中level n的意义如下:

1 控制文件中的文件头信息


2 level 1 + 文件头信息


3 level 2 + 数据文件头信息


10 level 3


更详细的alter session set events--oracle -Oracle跟踪事件简介见 第2小节。


个人见解:

在需要DBID进行数据恢复时,alter system dump logfile 'filename';明显适合更复杂的场景。

ALTER SYSTEM DUMP LOGFILE 'filename'  DBA MIN fileno  blockno    DBA MAX fileno  blockno; 


本实验命令如下:

SYS@ bys3>

alter session set events 'immediate trace name controlf level 1';   --同样要求数据库是MOUNT/OPEN状态可执行语句


Session altered.


SYS@ bys3>

oradebug setmypid;   --此语句要用SYSDBA权限执行,普通DBA用户会报错:ORA-01031: insufficient privileges


Statement processed.


SYS@ bys3>

oradebug tracefile_name  --找出产生的TRACE文件名


/u01/app/oracle/product/11.2.0/dbhome_1/log/diag/rdbms/bys3/bys3/trace/bys3_ora_1788.trc


################################################################


查看产生的TRACE文件信息 --因只DUMP了控制文件头的信息,所以内容并不多。

Trace file /u01/app/oracle/product/11.2.0/dbhome_1/log/diag/rdbms/bys3/bys3/trace/bys3_ora_1788.trc


Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production


With the Partitioning, OLAP, Data Mining and Real Application Testing options


ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1


System name:    Linux


Node name:    bys3.bys.com


Release:    2.6.32-200.13.1.el5uek


Version:    #1 SMP Wed Jul 27 20:21:26 EDT 2011


Machine:    i686


Instance name: bys3


Redo thread mounted by this instance: 1


Oracle process number: 17


Unix process pid: 1788, image: oracle@bys3.bys.com (TNS V1-V3)



*** 2013-11-17 15:08:09.573


*** SESSION ID:(43.881) 2013-11-17 15:08:09.573


*** CLIENT ID:() 2013-11-17 15:08:09.573


*** SERVICE NAME:(SYS$USERS) 2013-11-17 15:08:09.573


*** MODULE NAME:(sqlplus@bys3.bys.com (TNS V1-V3)) 2013-11-17 15:08:09.573


*** ACTION NAME:() 2013-11-17 15:08:09.573


 


DUMP OF CONTROL FILES, Seq # 1596 = 0x63c       DUMP的控制文件


 V10 STYLE FILE HEADER:


    Compatibility Vsn = 186646528=0xb200000


  

 Db ID=3358363031=0xc82c8d97, Db Name='BYS3'  ---数据库的DBID和DB_NAME信息

    Activation ID=0=0x0


    Control Seq=1596=0x63c, File size=604=0x25c


 

   File Number=0, Blksiz=16384, File Type=1 CONTROL

*** END OF DUMP ***



*** 2013-11-17 15:08:13.584


Processing Oradebug command 'setmypid'


*** 2013-11-17 15:08:13.585


Oradebug command 'setmypid' console output: <none>


*** 2013-11-17 15:08:16.701


Processing Oradebug command 'tracefile_name'


*** 2013-11-17 15:08:16.701


Oradebug command 'tracefile_name' console output:


/u01/app/oracle/product/11.2.0/dbhome_1/log/diag/rdbms/bys3/bys3/trace/bys3_ora_1788.trc