[20170406]關於檔案頭轉儲.txt

lfree發表於2017-04-06

[20170406]關於檔案頭轉儲.txt

--//oracle 資料庫檔案頭轉儲使用如下命令alter session set events 'immediate trace name file_hdrs level 12' ;
--//實際上裡面有一部分資訊來自控制檔案,在分析時注意,透過例子來說明:

1.環境:

SYS@book> @ &r/ver
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SYS@book> @ &r/spid

       SID    SERIAL# SPID       PID  P_SERIAL# C50
---------- ---------- ------ ------- ---------- --------------------------------------------------
        56         49 16397       29         17 alter system kill session '56,49' immediate;


$ ls -l  /proc/16397/fd
total 0
lr-x------ 1 oracle oinstall 64 2017-04-06 15:28:32 0 -> /dev/null
l-wx------ 1 oracle oinstall 64 2017-04-06 15:28:32 1 -> /dev/null
l-wx------ 1 oracle oinstall 64 2017-04-06 15:28:32 12 -> pipe:[25896412]
l-wx------ 1 oracle oinstall 64 2017-04-06 15:28:32 2 -> /dev/null
lr-x------ 1 oracle oinstall 64 2017-04-06 15:28:32 3 -> /dev/null
lr-x------ 1 oracle oinstall 64 2017-04-06 15:28:32 4 -> /u01/app/oracle/product/11.2.0.4/dbhome_1/rdbms/mesg/oraus.msb
lr-x------ 1 oracle oinstall 64 2017-04-06 15:28:32 5 -> /proc/16397/fd
lr-x------ 1 oracle oinstall 64 2017-04-06 15:28:32 6 -> /dev/zero
lrwx------ 1 oracle oinstall 64 2017-04-06 15:28:32 7 -> /u01/app/oracle/admin/book/adump/book_ora_16397_20170406152806864944143795.aud
lr-x------ 1 oracle oinstall 64 2017-04-06 15:28:32 9 -> pipe:[25896411]

--//沒有控制檔案.開啟跟蹤:
$ strace -f -p 16397   -trace=pread  -o /tmp/aa.txt

2.轉儲:
SYS@book> alter session set events 'immediate trace name file_hdrs level 12' ;
Session altered.

$ ls -l  /proc/16397/fd
total 0
lr-x------ 1 oracle oinstall 64 2017-04-06 15:28:32 0 -> /dev/null
l-wx------ 1 oracle oinstall 64 2017-04-06 15:28:32 1 -> /dev/null
l-wx------ 1 oracle oinstall 64 2017-04-06 15:30:44 10 -> /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_16397.trc
l-wx------ 1 oracle oinstall 64 2017-04-06 15:30:44 11 -> /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_16397.trm
l-wx------ 1 oracle oinstall 64 2017-04-06 15:28:32 12 -> pipe:[25896412]
l-wx------ 1 oracle oinstall 64 2017-04-06 15:28:32 2 -> /dev/null
lrwx------ 1 oracle oinstall 64 2017-04-06 15:30:44 256 -> /mnt/ramdisk/book/control01.ctl
lrwx------ 1 oracle oinstall 64 2017-04-06 15:30:44 257 -> /mnt/ramdisk/book/control02.ctl
lrwx------ 1 oracle oinstall 64 2017-04-06 15:30:44 258 -> /mnt/ramdisk/book/system01.dbf
lrwx------ 1 oracle oinstall 64 2017-04-06 15:30:44 259 -> /mnt/ramdisk/book/sysaux01.dbf
lrwx------ 1 oracle oinstall 64 2017-04-06 15:30:44 260 -> /mnt/ramdisk/book/undotbs01.dbf
lrwx------ 1 oracle oinstall 64 2017-04-06 15:30:44 261 -> /mnt/ramdisk/book/users01.dbf
lrwx------ 1 oracle oinstall 64 2017-04-06 15:30:44 262 -> /mnt/ramdisk/book/example01.dbf
lrwx------ 1 oracle oinstall 64 2017-04-06 15:30:44 263 -> /mnt/ramdisk/book/tea01.dbf
lrwx------ 1 oracle oinstall 64 2017-04-06 15:30:44 264 -> /mnt/ramdisk/book/temp01.dbf
lr-x------ 1 oracle oinstall 64 2017-04-06 15:28:32 3 -> /dev/null
lr-x------ 1 oracle oinstall 64 2017-04-06 15:28:32 4 -> /u01/app/oracle/product/11.2.0.4/dbhome_1/rdbms/mesg/oraus.msb
lr-x------ 1 oracle oinstall 64 2017-04-06 15:28:32 5 -> /proc/16397/fd
lr-x------ 1 oracle oinstall 64 2017-04-06 15:28:32 6 -> /dev/zero
lrwx------ 1 oracle oinstall 64 2017-04-06 15:28:32 7 -> /u01/app/oracle/admin/book/adump/book_ora_16397_20170406152806864944143795.aud
lr-x------ 1 oracle oinstall 64 2017-04-06 15:28:32 9 -> pipe:[25896411]
--//你可以發現執行完成後開啟了控制檔案以及資料檔案.

$ grep "pread" /tmp/aa.txt
16397      0.000133 pread(256, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4$\346\0\0\0\0\0\0\0\4 \vn!\267O"..., 16384, 16384) = 16384
16397      0.000166 pread(257, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4$\346\0\0\0\0\0\0\0\4 \vn!\267O"..., 16384, 16384) = 16384
16397      0.000117 pread(256, "\25\302\0\0\17\0\0\0\302\222\0\0\377\377\1\4(!\0\0\0C\0\0\0\0\0\0\0\0\0\4"..., 16384, 245760) = 16384
16397      0.000107 pread(256, "\25\302\0\0\21\0\0\0\302\222\0\0\377\377\1\4\311n\0\0\0\0\0\0\0\0\0\0\256\36q5"..., 16384, 278528) = 16384
16397      0.000106 pread(256, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4$\346\0\0\0\0\0\0\0\4 \vn!\267O"..., 16384, 16384) = 16384
16397      0.000108 pread(257, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4$\346\0\0\0\0\0\0\0\4 \vn!\267O"..., 16384, 16384) = 16384
16397      0.000115 pread(256, "\25\302\0\0\17\0\0\0\302\222\0\0\377\377\1\4(!\0\0\0C\0\0\0\0\0\0\0\0\0\4"..., 16384, 245760) = 16384
16397      0.000104 pread(256, "\25\302\0\0\21\0\0\0\302\222\0\0\377\377\1\4\311n\0\0\0\0\0\0\0\0\0\0\256\36q5"..., 16384, 278528) = 16384
16397      0.000102 pread(256, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4$\346\0\0\0\0\0\0\0\4 \vn!\267O"..., 16384, 16384) = 16384
16397      0.000107 pread(257, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4$\346\0\0\0\0\0\0\0\4 \vn!\267O"..., 16384, 16384) = 16384
16397      0.000101 pread(256, "\25\302\0\0\17\0\0\0\302\222\0\0\377\377\1\4(!\0\0\0C\0\0\0\0\0\0\0\0\0\4"..., 16384, 245760) = 16384
16397      0.000104 pread(256, "\25\302\0\0\21\0\0\0\302\222\0\0\377\377\1\4\311n\0\0\0\0\0\0\0\0\0\0\256\36q5"..., 16384, 278528) = 16384
16397      0.000110 pread(256, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4$\346\0\0\0\0\0\0\0\4 \vn!\267O"..., 16384, 16384) = 16384
16397      0.000107 pread(257, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4$\346\0\0\0\0\0\0\0\4 \vn!\267O"..., 16384, 16384) = 16384
16397      0.000101 pread(256, "\25\302\0\0\17\0\0\0\302\222\0\0\377\377\1\4(!\0\0\0C\0\0\0\0\0\0\0\0\0\4"..., 16384, 245760) = 16384
16397      0.000105 pread(256, "\25\302\0\0\21\0\0\0\302\222\0\0\377\377\1\4\311n\0\0\0\0\0\0\0\0\0\0\256\36q5"..., 16384, 278528) = 16384
16397      0.000146 pread(256, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4$\346\0\0\0\0\0\0\0\4 \vn!\267O"..., 16384, 16384) = 16384
16397      0.000109 pread(257, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4$\346\0\0\0\0\0\0\0\4 \vn!\267O"..., 16384, 16384) = 16384
16397      0.000102 pread(256, "\25\302\0\0\17\0\0\0\302\222\0\0\377\377\1\4(!\0\0\0C\0\0\0\0\0\0\0\0\0\4"..., 16384, 245760) = 16384
16397      0.000110 pread(256, "\25\302\0\0\21\0\0\0\302\222\0\0\377\377\1\4\311n\0\0\0\0\0\0\0\0\0\0\256\36q5"..., 16384, 278528) = 16384
16397      0.000098 pread(256, "\25\302\0\0\27\0\0\0:\222\0\0\377\377\1\4w'\0\0\0\0\0\0\0 \0\0\16\0\0\0"..., 16384, 376832) = 16384
16397      0.000113 pread(256, "\25\302\0\0 \0\0\0/\222\0\0\377\377\1\4\267\7\0\0\3\0\3\0\0\0\0\0\0\0/m"..., 16384, 524288) = 16384
16397      0.000111 pread(258, "\v\242\0\0\1\0@\0\0\0\0\0\0\0\1\4=\r\0\0\0\0\0\0\0\4 \vn!\267O"..., 8192, 8192) = 8192
16397      0.000103 pread(259, "\v\242\0\0\1\0\200\0\0\0\0\0\0\0\1\4\364\342\0\0\0\0\0\0\0\4 \vn!\267O"..., 8192, 8192) = 8192
16397      0.000105 pread(260, "\v\242\0\0\1\0\300\0\0\0\0\0\0\0\1\4\325\240\0\0\0\0\0\0\0\4 \vn!\267O"..., 8192, 8192) = 8192
16397      0.000103 pread(261, "\v\242\0\0\1\0\0\1\0\0\0\0\0\0\1\0043\23\0\0\0\0\0\0\0\4 \vn!\267O"..., 8192, 8192) = 8192
16397      0.000128 pread(262, "\v\242\0\0\1\0@\1\0\0\0\0\0\0\1\4\273N\0\0\0\0\0\0\0\4 \vn!\267O"..., 8192, 8192) = 8192
16397      0.000103 pread(263, "\v\242\0\0\1\0\200\1\0\0\0\0\0\0\1\4\32\215\0\0\0\0\0\0\0\4 \vn!\267O"..., 8192, 8192) = 8192
16397      0.000089 pread(256, "\25\302\0\0\265\0\0\0|\2\0\0\377\377\1\4z\362\0\0\0\n\0\0\0 \0\0\36\0\10\0"..., 16384, 2965504) = 16384
16397      0.000102 pread(264, "\v\242\0\0\1\0@\0\0\0\0\0\0\0\1\4\312\6\0\0\0\0\0\0\0\4 \vn!\267O"..., 8192, 8192) = 8192

--//可以發現轉儲時也讀取了控制檔案後,在依次讀取資料檔案控制程式碼258,259,.... ,然後在讀取控制檔案,在讀取臨時檔案.控制程式碼264.

3.透過bbed改寫檔案頭確認裡面的資訊:
SYS@book> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.

SYS@book> startup mount
ORACLE instance started.
Total System Global Area    634732544 bytes
Fixed Size                    2255792 bytes
Variable Size               197133392 bytes
Database Buffers            427819008 bytes
Redo Buffers                  7524352 bytes
Database mounted.

SYS@book> SELECT file#, CHECKPOINT_CHANGE#, CHECKPOINT_TIME,CREATION_CHANGE#  , RESETLOGS_CHANGE#,status, CHECKPOINT_COUNT,fuzzy,name,tablespace_name  FROM v$datafile_header;
FILE# CHECKPOINT_CHANGE# CHECKPOINT_TIME     CREATION_CHANGE# RESETLOGS_CHANGE# STATUS  CHECKPOINT_COUNT FUZ NAME                             TABLESPACE_NAME
----- ------------------ ------------------- ---------------- ----------------- ------- ---------------- --- -------------------------------- ----------------
    1        13277116630 2017-04-06 15:40:05                7            925702 ONLINE               937 NO  /mnt/ramdisk/book/system01.dbf   SYSTEM
    2        13277116630 2017-04-06 15:40:05             1834            925702 ONLINE               926 NO  /mnt/ramdisk/book/sysaux01.dbf   SYSAUX
    3        13277116630 2017-04-06 15:40:05           923328            925702 ONLINE               847 NO  /mnt/ramdisk/book/undotbs01.dbf  UNDOTBS1
    4        13277116630 2017-04-06 15:40:05            16143            925702 ONLINE               932 NO  /mnt/ramdisk/book/users01.dbf    USERS
    5        13277116630 2017-04-06 15:40:05           952916            925702 ONLINE               843 NO  /mnt/ramdisk/book/example01.dbf  EXAMPLE
    6        13277116630 2017-04-06 15:40:05      13276257767            925702 ONLINE               316 NO  /mnt/ramdisk/book/tea01.dbf      TEA
6 rows selected.

--//資料檔案6 CHECKPOINT_COUNT=316,我增加到416看看.

BBED> p /d dba 6,1 kcvfh.kcvfhcpc
ub4 kcvfhcpc                                @140      316

BBED> p /d dba 6,1 kcvfh.kcvfhccc
ub4 kcvfhccc                                @148      315

--//我這兩個數值增加100看看.
BBED> assign dba 6,1 kcvfh.kcvfhcpc=416
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
ub4 kcvfhcpc                                @140      0x000001a0

BBED> assign dba 6,1 kcvfh.kcvfhccc=415
ub4 kcvfhccc                                @148      0x0000019f

BBED> sum apply dba 6,1
Check value for File 6, Block 1:
current = 0x3d1b, required = 0x3d1b

SYS@book> SELECT file#, CHECKPOINT_CHANGE#, CHECKPOINT_TIME,CREATION_CHANGE#  , RESETLOGS_CHANGE#,status, CHECKPOINT_COUNT,fuzzy,name,tablespace_name  FROM v$datafile_header;
FILE# CHECKPOINT_CHANGE# CHECKPOINT_TIME     CREATION_CHANGE# RESETLOGS_CHANGE# STATUS  CHECKPOINT_COUNT FUZ NAME                                               TABLESPACE_NAME
----- ------------------ ------------------- ---------------- ----------------- ------- ---------------- --- -------------------------------------------------- ------------------------------
    1        13277116630 2017-04-06 15:40:05                7            925702 ONLINE               937 NO  /mnt/ramdisk/book/system01.dbf                     SYSTEM
    2        13277116630 2017-04-06 15:40:05             1834            925702 ONLINE               926 NO  /mnt/ramdisk/book/sysaux01.dbf                     SYSAUX
    3        13277116630 2017-04-06 15:40:05           923328            925702 ONLINE               847 NO  /mnt/ramdisk/book/undotbs01.dbf                    UNDOTBS1
    4        13277116630 2017-04-06 15:40:05            16143            925702 ONLINE               932 NO  /mnt/ramdisk/book/users01.dbf                      USERS
    5        13277116630 2017-04-06 15:40:05           952916            925702 ONLINE               843 NO  /mnt/ramdisk/book/example01.dbf                    EXAMPLE
    6        13277116630 2017-04-06 15:40:05      13276257767            925702 ONLINE               416 NO  /mnt/ramdisk/book/tea01.dbf                        TEA
6 rows selected.
--//資料檔案6的CHECKPOINT_COUNT=416.

4.再繼續執行轉儲看看:
SYS@book> alter session set events 'immediate trace name file_hdrs level 12' ;
Session altered.

--//檢查轉儲內容:
DATA FILE #6:
  name #10: /mnt/ramdisk/book/tea01.dbf
creation size=5120 block size=8192 status=0xe head=10 tail=10 dup=1
tablespace 7, index=7 krfil=6 prev_file=0
unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
Checkpoint cnt:316 scn: 0x0003.1760b8d6 04/06/2017 15:40:05
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Stop scn: 0x0003.1760b8d6 04/06/2017 15:40:05
Creation Checkpointed at scn:  0x0003.17539de7 02/13/2017 15:09:58
thread:1 rba:(0x1d6.48.10)
enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000
Offline scn: 0x0003.175f8300 prev_range: 0
Online Checkpointed at scn:  0x0003.175f8324 04/05/2017 11:10:42
thread:1 rba:(0x2f9.195e.10)
enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000
Hot Backup end marker scn: 0x0000.00000000
aux_file is NOT DEFINED
Plugged readony: NO
Plugin scnscn: 0x0000.00000000
Plugin resetlogs scn/timescn: 0x0000.00000000 01/01/1988 00:00:00
Foreign creation scn/timescn: 0x0000.00000000 01/01/1988 00:00:00
Foreign checkpoint scn/timescn: 0x0000.00000000 01/01/1988 00:00:00
Online move state: 0

V10 STYLE FILE HEADER:
    Compatibility Vsn = 186647552=0xb200400
    Db ID=1337401710=0x4fb7216e, Db Name='BOOK'
    Activation ID=0=0x0
    Control Seq=37574=0x92c6, File size=5120=0x1400
    File Number=6, Blksiz=8192, File Type=3 DATA
Tablespace #7 - TEA  rel_fn:6
Creation   at   scn: 0x0003.17539de7 02/13/2017 15:09:58
Backup taken at scn: 0x0003.175f8350 04/05/2017 11:11:14 thread:1
reset logs count:0x35711eb0 scn: 0x0000.000e2006
prev reset logs count:0x3121c97a scn: 0x0000.00000001
recovered at 04/05/2017 11:15:13
status:0x0 root dba:0x00000000 chkpt cnt: 416 ctl cnt:415
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
begin-hot-backup file size: 5120
Checkpointed at scn:  0x0003.1760b8d6 04/06/2017 15:40:05
thread:1 rba:(0x30f.f5fb.10)
enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000
Backup Checkpointed at scn:  0x0003.175f8350 04/05/2017 11:11:14
thread:1 rba:(0x2f9.1987.10)
enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000 00000000 00000000 00000000 00000000 00000000 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  01/01/1988 00:00:00
Platform Information:    Creation Platform ID: 13
Current Platform ID: 13 Last Platform ID: 13
DUMP OF TEMP FILES: 1 files in database

--//注意看下劃線部分
Checkpoint cnt:316 scn: 0x0003.1760b8d6 04/06/2017 15:40:05
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
status:0x0 root dba:0x00000000 chkpt cnt: 416 ctl cnt:415
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--//很明顯前面部分來自控制檔案.

DATA FILE #6:來自控制檔案.
V10 STYLE FILE HEADER:的內容才來自資料檔案頭.

--//在工作中分析注意,實際上我覺得oracle應該在轉儲時說明 僅僅加入一段資訊DATA FILE #6 from controlfile就ok了.

5.看看這樣能open嗎?

SYS@book> alter database open ;
alter database open
*
ERROR at line 1:
ORA-01122: database file 6 failed verification check
ORA-01110: data file 6: '/mnt/ramdisk/book/tea01.dbf'
ORA-01207: file is more recent than control file - old control file

--//改小看看是否可行.
BBED> assign dba 6,1 kcvfh.kcvfhcpc=306
ub4 kcvfhcpc                                @140      0x00000132

BBED> assign dba 6,1 kcvfh.kcvfhccc=305
ub4 kcvfhccc                                @148      0x00000131

BBED> sum apply dba 6,1
Check value for File 6, Block 1:
current = 0x3d27, required = 0x3d27

SYS@book> alter database open ;
alter database open
*
ERROR at line 1:
ORA-01113: file 6 needs media recovery
ORA-01110: data file 6: '/mnt/ramdisk/book/tea01.dbf'

SYS@book> recover datafile 6
Media recovery complete.

SYS@book> alter database open ;
Database altered.

SYS@book> SELECT file#, CHECKPOINT_CHANGE#, CHECKPOINT_TIME,CREATION_CHANGE#  , RESETLOGS_CHANGE#,status, CHECKPOINT_COUNT,fuzzy,name,tablespace_name  FROM v$datafile_header;
FILE# CHECKPOINT_CHANGE# CHECKPOINT_TIME     CREATION_CHANGE# RESETLOGS_CHANGE# STATUS  CHECKPOINT_COUNT FUZ NAME                             TABLESPACE_NAME
----- ------------------ ------------------- ---------------- ----------------- ------- ---------------- --- -------------------------------- ----------------
    1        13277116634 2017-04-06 15:54:45                7            925702 ONLINE               938 YES /mnt/ramdisk/book/system01.dbf   SYSTEM
    2        13277116634 2017-04-06 15:54:45             1834            925702 ONLINE               927 YES /mnt/ramdisk/book/sysaux01.dbf   SYSAUX
    3        13277116634 2017-04-06 15:54:45           923328            925702 ONLINE               848 YES /mnt/ramdisk/book/undotbs01.dbf  UNDOTBS1
    4        13277116634 2017-04-06 15:54:45            16143            925702 ONLINE               933 YES /mnt/ramdisk/book/users01.dbf    USERS
    5        13277116634 2017-04-06 15:54:45           952916            925702 ONLINE               844 YES /mnt/ramdisk/book/example01.dbf  EXAMPLE
    6        13277116634 2017-04-06 15:54:45      13276257767            925702 ONLINE               318 YES /mnt/ramdisk/book/tea01.dbf      TEA
6 rows selected.

--//open後CHECKPOINT_COUNT增加2.
--//實際上我自己有補充測試1次,recover datafile 6後在控制檔案的基礎上+1.open後有增加1.

總之一點注意轉儲資料檔案頭時,有部分資訊來自控制檔案,切記!!

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2136766/,如需轉載,請註明出處,否則將追究法律責任。

相關文章