oracle的controlfile_header


SYS@hyyk> select table_name from dict where table_name like '%CONTROL%';

TABLE_NAME
------------------------------
DBA_HIST_WR_CONTROL
DBA_REPRESOL_STATS_CONTROL
USER_REPRESOL_STATS_CONTROL
ALL_REPRESOL_STATS_CONTROL
V$BACKUP_CONTROLFILE_DETAILS
V$BACKUP_CONTROLFILE_SUMMARY
V$CONTROLFILE
V$CONTROLFILE_RECORD_SECTION
V$SESSION_FIX_CONTROL
V$SYSTEM_FIX_CONTROL
V$DLM_TRAFFIC_CONTROLLER
GV$CONTROLFILE
GV$CONTROLFILE_RECORD_SECTION
GV$DLM_TRAFFIC_CONTROLLER
V$DIAG_ADR_CONTROL


SYS@hyyk> select * from V$CONTROLFILE_RECORD_SECTION;

TYPE                 RECORD_SIZE RECORDS_TOTAL RECORDS_USED FIRST_INDEX LAST_INDEX LAST_RECID
---------------------------- ----------- ------------- ------------ ----------- ---------- ----------
DATABASE                 316         1          1          0      0        0
CKPT PROGRESS            8180        11          0         0      0        0
REDO THREAD              256         8          1          0      0        0
REDO LOG                  72        16          3          0      0        3
DATAFILE                 520       100          8          0      0       72
FILENAME                 524      2298         12          0      0        0
TABLESPACE                68       100          9          0      0        5
TEMPORARY FILENAME        56       100          1          0      0        1
RMAN CONFIGURATION      1108        50          0          0      0        0
LOG HISTORY               56       292         62          1     62       62
OFFLINE RANGE            200       163          2          1      2        2
ARCHIVED LOG             584        56         40          1     40       40
BACKUP SET                40       409          3          1      3        3
BACKUP PIECE             736       200          3          1      3        3
BACKUP DATAFILE          200       245          7          1      7        7
BACKUP REDOLOG            76       215          0          0      0        0
DATAFILE COPY            736       200          1          1      1        1
BACKUP CORRUPTION         44       371          0          0      0        0
COPY CORRUPTION           40       409          0          0      0        0
DELETED OBJECT            20       818          1          1      1        1
PROXY COPY               928       246          0          0      0        0
BACKUP SPFILE            124       131          2          1      2        2
DATABASE INCARNATION      56       292          2          1      2        2
FLASHBACK LOG             84      2048          0          0      0        0
RECOVERY DESTINATION      80         1          1          0      0        0
INSTANCE SPACE RESERVATION 28      1055          1          0      0        0
REMOVABLE RECOVERY FILES   32      1000          1          0      0        0
RMAN STATUS               116       141          7          1      7        7
THREAD INSTANCE NAME MAPPING 0        8          8          0      0        0
MTTR                      100         8          1          0      0        0
DATAFILE HISTORY          568        57          0          0      0        0
STANDBY DATABASE MATRIX   400        31         31          0      0        0
GUARANTEED RESTORE POINT  212      2048          0          0      0        0
RESTORE POINT             212      2083          0          0      0        0
DATABASE BLOCK CORRUPTION  80      8384          0          0      0        0
ACM OPERATION             104        64          6          0      0        0
FOREIGN ARCHIVED LOG      604      1002          0          0      0        0

record size,则表示该部分内容在controlfile 中所占据的大小,其单位是byte.

那我们通过controlfile dump来进行观察,如下:

dump controlfile header

SQL> oradebug setmypid
Statement processed.
SQL> ALTER SESSION SET EVENTS 'immediate trace name controlf level 1';

Session altered.

SQL> oradebug close_trace
Statement processed.
SQL> oradebug tracefile_name
/home/ora10g/admin/roger/udump/roger_ora_8303.trc

说明:level 1  --dump controlfile header
          level 2  --level 1+datafile 文件头信息
          level 3  --level 2+可重用信息
          level 10 --level 3+其他全部信息

***************************************************************************
LOG FILE RECORDS
***************************************************************************
(size = 72, compat size = 72, section max = 16, section in-use = 3,
  last-recid= 3, old-recno = 0, last-recno = 0)
(extent = 1, blkno = 10, numrecs = 16)
可知redo log该部分内容在controlfile 中所占据72 byte.

*** 2018-02-22 13:21:25.972
DUMP OF CONTROL FILES, Seq # 4293 = 0x10c5
V10 STYLE FILE HEADER:
        Compatibility Vsn = 186646528=0xb200000
        Db ID=2117284640=0x7e333320, Db Name='HYYK'
        Activation ID=0=0x0
        Control Seq=4293=0x10c5, File size=596=0x254
        File Number=0, Blksiz=16384, File Type=1 CONTROL

Compatibility Vsn:     表示具体的版本号  0xb200000   转换后及表示100205
DB ID:                 表示数据库的db id号
Db Name:              表示数据库的数据库名
Activation:           这里没有什么实际意义
Control Seq:          表示control的sequence号。
File size:            表示文件大小,这里但是是block(conrolfile block)
File Number:           在oracle内部,定义controlfile的文件号为0.
Blksize:               表示controlfile block的大小.
File Type:             表示文件类型.

既然知道controlfile header的各个部分的含义后,那么在有些针对controlfile损坏的情况下,甚至可以手工修复controlfile来
解决问题。 除了dump controlfile之外,我们还可以利用操作系统命令dd+od来观察,如下:

[oracle@pc6 ~]$ dd if=/u01/app/oracle/oradata/hyyk/control01.ctl bs=16384 count=1 | od -x |head -20
记录了1+0 的读入
记录了1+0 的写出
16384字节(16 kB)已复制0000000 c200 0000 0000 ffc0 0000 0000 0000 0000
0000020 f832 0000 4000 0000 0254 0000 7c7d 7a7b
0000040 81a0 0000 0000 0000 0000 0000 0000 0000
0000060 0000 0000 0000 0000 0000 0000 0000 0000
*
0040000
,0.0256473 秒,639 kB/秒

这个dump是os block 的信息

[oracle@pc6 ~]$  dd if=/u01/app/oracle/oradata/hyyk/control01.ctl bs=16384 count=2 | od -x |head -500
0000000 c200 0000 0000 ffc0 0000 0000 0000 0000
0000020 fba4 0000 4000 0000 01c2 0000 7c7d 7a7b      --33184
0000040 81a0 0000 0000 0000 0000 0000 0000 0000
0000060 0000 0000 0000 0000 0000 0000 0000 0000
*
0040000 c215 0000 0001 0000 0000 0000 0000 0401
0040020 ee77 0000 0000 0000 0500 0a20 4d29 930a
0040040 4f52 4547 0052 0000 26f4 0000 01c2 0000
0040060 4000 0000 0000 0001 0000 0000 0000 0000
0040100 4154 3247 3130 3033 3032 5437 3230 3033
0040120 3835 0000 0000 0000 0000 0000 0000 0000
0040140 fb8d 95ed d25b 3008 733f 0069 0000 0000
0040160 6204 305b 0000 0000 0000 0000 0000 0000
0040200 0000 0000 0000 0000 0000 0000 0000 0000
*
0040400 0000 0000 0000 0000 0008 0000 0008 0000
0040420 0008 0000 0000 0000 0000 0000 0000 0000
0040440 0001 0000 0000 0000 0000 0000 0000 0000
0040460 0000 0000 0000 0000 0000 0000 0000 0000
*
0077760 0000 0000 0000 0000 0000 0000 1501 0000
0100000
下面针对上面dump 内容进行解析:
c2         表示type类型,转换后为194
4000       表示controlfile block size.(转换为10进制后为16384)
01c2       表示文件大小,单位是block,转换为10进制后为450.
7c7d 7a7b  表示操作系统平台的magic number号,每个操作系统对应的号码可能都不一样.

c215       是头部信息,这个不用关注
0001       表示file type.
0500 0a20  表示数据库版本号
4d29 930a  表示DB ID号
4f52 4547 0052  表示DB Name,如下:


文章名称:oracle的controlfile_header
URL分享:http://cdiso.cn/article/ghdscj.html

其他资讯