ora-01207錯誤處理

ora-01207錯誤處理

一: ora-01207錯誤解釋


[oracle@oracle ~]$ oerr ora 01207
01207, 00000, "file is more recent than control file - old control file"
// *Cause:  The control file change sequence number in the data file is 
//         greater than the number in the control file. This implies that
//         the wrong control file is being used. Note that repeatedly causing
//         this error can make it stop happening without correcting the real
//         problem. Every attempt to open the database will advance the
//         control file change sequence number until it is great enough.
// *Action: Use the current control file or do backup control file recovery to 
//         make the control file current. Be sure to follow all restrictions 
//         on doing a backup control file recovery.

從上面的英文中不難看出,造成ora-01207錯誤的實質就是由於數據文件頭部記錄控制seq號比控制文件中記錄的該值大。


二:通過bbed修改數據文件頭部的seq號模擬該錯誤,過程如下:


 說明:數據文件頭部記錄的控制文件seq號位於,如下所示
 ub4 kccfhcsq                          @40       0x000003df 轉換爲10進製爲991
 和通過表x$kcvfh查詢到的值一樣(fhcsq爲控制文件seq號)


 SQL> select hxfil,fhcsq,fhscn,fhrba_seq from x$kcvfh;

     HXFIL      FHCSQ FHSCN             FHRBA_SEQ
---------- ---------- ---------------- ----------
         1        991 1077238                   1
         2        991 1077238                   1
         3        991 1077238                   1
         4        991 1077238                   1
         5        991 1077238                   1
 模擬過程如下:

[oracle@oracle ~]$ bbed parfile=bbed.par
Password: 

BBED: Release 2.0.0.0.0 - Limited Production on Wed Jul 31 14:38:26 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

************* !!! For Oracle Internal Use only !!! ***************

BBED> info
 File#  Name                                                        Size(blks)
 -----  ----                                                        ----------
     1  /oracle/CRM/ZBCRM/system01.dbf                                   89600
     2  /oracle/CRM/ZBCRM/sysaux01.dbf                                   65280
     3  /oracle/CRM/ZBCRM/undotbs01.dbf                                   8960
     4  /oracle/CRM/ZBCRM/users01.dbf                                      640
     5  /oracle/CRM/ZBCRM/sysaux02.dbf                                   12800

BBED> show all
        FILE#           1
        BLOCK#          1
        OFFSET          0
        DBA             0x00400001 (4194305 1,1)
        FILENAME        /oracle/CRM/ZBCRM/system01.dbf
        BIFILE          bifile.bbd
        LISTFILE        /oracle/file
        BLOCKSIZE       8192
        MODE            Edit
        EDIT            Unrecoverable
        IBASE           Dec
        OBASE           Dec
        WIDTH           80
        COUNT           512
        LOGFILE         log.bbd
        SPOOL           No

BBED> dump /v dba 5,1 offset 40 count 30
 File: /oracle/CRM/ZBCRM/sysaux02.dbf (5)
 Block: 1       Offsets:   40 to   69  Dba:0x01400001
-------------------------------------------------------
 df030000 00320000 00200000 05000300 l ?...2... ......
 00000000 00000000 00000000 0000     l ..............

 <16 bytes per line>

BBED> modify /x df04
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
 File: /oracle/CRM/ZBCRM/sysaux02.dbf (5)
 Block: 1                Offsets:   40 to   69           Dba:0x01400001
------------------------------------------------------------------------
 df040000 00320000 00200000 05000300 00000000 00000000 00000000 0000 

 <32 bytes per line>

BBED> sum apply
Check value for File 5, Block 1:
current = 0xe985, required = 0xe985

BBED> exit

[oracle@oracle ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Wed Jul 31 14:39:48 2013

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select hxfil,fhcsq,fhscn,fhrba_seq from x$kcvfh;

     HXFIL      FHCSQ FHSCN             FHRBA_SEQ
---------- ---------- ---------------- ----------
         1        991 1077238                   1
         2        991 1077238                   1
         3        991 1077238                   1
         4        991 1077238                   1
         5       1247 1077238                   1                                                             SQL> select controlfile_type,controlfile_sequence#,controlfile_change#,checkpoint_change# from v$database;

CONTROL CONTROLFILE_SEQUENCE# CONTROLFILE_CHANGE# CHECKPOINT_CHANGE#
------- --------------------- ------------------- ------------------
CURRENT                  1074             1086625            1077238

 

上面模擬了數據文件頭部記錄的控制文件seq號大於控制文件記錄的seq號,下面重啓數據庫觸發報錯

SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 1152450560 bytes
Fixed Size                  2225832 bytes
Variable Size             704645464 bytes
Database Buffers          436207616 bytes
Redo Buffers                9371648 bytes
Database mounted.
ORA-01122: database file 5 failed verification check
ORA-01110: data file 5: '/oracle/CRM/ZBCRM/sysaux02.dbf'
ORA-01207: file is more recent than control file - old control file

 

三 對於ora-01207錯誤的處理


 既然已經知道ora-01207的錯誤是由於數據文件頭部的記錄的控制文件seq號比控制文件的seq號大,那麼針對這個錯誤提供如下兩種處理方法
方法一:
 1 利用歸檔和聯機日誌推進控制文件中的相關信息,即通過執行命令recover database using backup controlfile來實現。不過這個命令能順利執行的前提
 是controlfile_change#值所在的歸檔及其之後所需歸檔能夠利用進行恢復。
 2 恢復過程如下:
 SQL> startup
ORACLE instance started.

Total System Global Area 1152450560 bytes
Fixed Size                  2225832 bytes
Variable Size             704645464 bytes
Database Buffers          436207616 bytes
Redo Buffers                9371648 bytes
Database mounted.
ORA-01122: database file 5 failed verification check
ORA-01110: data file 5: '/oracle/CRM/ZBCRM/sysaux02.dbf'
ORA-01207: file is more recent than control file - old control file


SQL> select open_mode from v$database;

OPEN_MODE
--------------------
MOUNTED

SQL> recover database using backup controlfile;
ORA-00279: change 1077238 generated at 07/26/2013 17:02:10 needed for thread 1
ORA-00289: suggestion : /oracle/CRM/archlog/1_1_821811716.dbf
ORA-00280: change 1077238 for thread 1 is in sequence #1


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
ORA-00308: cannot open archived log '/oracle/CRM/archlog/1_1_821811716.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3


ORA-00308: cannot open archived log '/oracle/CRM/archlog/1_1_821811716.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3


SQL> select group#,archived,sequence#,status from v$Log;

    GROUP# ARC  SEQUENCE# STATUS
---------- --- ---------- ----------------
         2 YES          0 UNUSED
         1 NO           1 CURRENT

SQL> col member for a60    

SQL> select group#,member from v$logfile;

    GROUP# MEMBER
---------- ------------------------------------------------------------
         2 /oracle/CRM/ZBCRM/log1/ZBCRM/onlinelog/o1_mf_2_8z4grccs_.log
         2 /oracle/CRM/ZBCRM/log2/ZBCRM/onlinelog/o1_mf_2_8z4grd0x_.log
         1 /oracle/CRM/ZBCRM/log1/ZBCRM/onlinelog/o1_mf_1_8z4gr4yz_.log
         1 /oracle/CRM/ZBCRM/log2/ZBCRM/onlinelog/o1_mf_1_8z4gr5p0_.log

SQL> recover database using backup controlfile;
ORA-00279: change 1077238 generated at 07/26/2013 17:02:10 needed for thread 1
ORA-00289: suggestion : /oracle/CRM/archlog/1_1_821811716.dbf
ORA-00280: change 1077238 for thread 1 is in sequence #1


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/oracle/CRM/ZBCRM/log1/ZBCRM/onlinelog/o1_mf_1_8z4gr4yz_.log
Log applied.
Media recovery complete.

SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> alter database open resetlogs;

Database altered.

SQL> select controlfile_type,controlfile_sequence#,controlfile_change#,checkpoint_change# from v$database;

CONTROL CONTROLFILE_SEQUENCE# CONTROLFILE_CHANGE# CHECKPOINT_CHANGE#
------- --------------------- ------------------- ------------------
CURRENT                  1112             1086859            1086663

SQL> select hxfil,fhcsq,fhscn,fhrba_seq from x$kcvfh;

     HXFIL      FHCSQ FHSCN             FHRBA_SEQ
---------- ---------- ---------------- ----------
         1       1102 1086663                   1
         2       1102 1086663                   1
         3       1102 1086663                   1
         4       1102 1086663                   1
         5       1102 1086663                   1

方法二:重建控制文件。因爲在重建控制文件的過程中,控制文件中記錄的seq號的基值會取自於數據文件頭部,從而達到一致性。其次通過重建控制文件還可以規避recover database using backup controlfile 過程中遭遇歸檔丟失問題。
SQL> startup
ORACLE instance started.

Total System Global Area 1152450560 bytes
Fixed Size                  2225832 bytes
Variable Size             704645464 bytes
Database Buffers          436207616 bytes
Redo Buffers                9371648 bytes
Database mounted.
ORA-01122: database file 5 failed verification check
ORA-01110: data file 5: '/oracle/CRM/ZBCRM/sysaux02.dbf'
ORA-01207: file is more recent than control file - old control file


SQL> shutdown abort;
ORACLE instance shut down.
SQL> @/oracle/noresetlogs.sql
ORACLE instance started.

Total System Global Area 1152450560 bytes
Fixed Size                  2225832 bytes
Variable Size             704645464 bytes
Database Buffers          436207616 bytes
Redo Buffers                9371648 bytes

Control file created.

SQL> select controlfile_type,controlfile_sequence#,controlfile_change#,checkpoint_change# from v$database;

CONTROL CONTROLFILE_SEQUENCE# CONTROLFILE_CHANGE# CHECKPOINT_CHANGE#
------- --------------------- ------------------- ------------------
CREATED                  1379                   0            1109137

SQL> select hxfil,fhcsq,fhscn,fhrba_seq from x$kcvfh;

     HXFIL      FHCSQ FHSCN             FHRBA_SEQ
---------- ---------- ---------------- ----------
         1       1135 1109138                   2
         2       1135 1109138                   2
         3       1135 1109138                   2
         4       1135 1109138                   2
         5       1375 1109138                   2

SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '/oracle/CRM/ZBCRM/system01.dbf'


SQL> recover database;
Media recovery complete.
SQL> alter database open;

Database altered.

關於更多利用舊控制文件恢復問題見於:http://jiujian.blog.51cto.com/444665/1119600

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章