【RMAN】重新將資料庫註冊到RMAN Catalog時偶遇ORA-02291錯誤之探查

secooler發表於2011-05-29
  使用“unregister database”命令可以取消資料庫例項到RMAN Catalog的註冊。但是,當需要重新完成註冊時需要注意,一定要先退出RMAN環境然後再重新登入完成註冊,否則將有可能遭遇“ORA-02291: integrity constraint (RMAN_CATALOG.RLH_F1) violated - parent key not found”這個報錯。將這個問題的現象及處理方法整理如下。

1.問題現象
1)將secgc例項註冊到secdb例項的RMAN Catalog
secgc@secdb1 /home/oracle$ rman target sys/oracle1@secgc catalog rman_catalog/rman_catalog@secdb

Recovery Manager: Release 10.2.0.1.0 - Production on Sun May 29 21:48:45 2011

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

connected to target database: SECGC (DBID=2970158546)
connected to recovery catalog database

RMAN> register database;

database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

2)確認RMAN Catalog資料庫中註冊的資訊
rman_catalog@secdb> col name for a6
rman_catalog@secdb> select * from rc_database;

    DB_KEY  DBINC_KEY       DBID NAME   RESETLOGS_CHANGE# RESETLOGS
---------- ---------- ---------- ------ ----------------- ---------
         1          2 2970158546 SECGC                  1 25-MAY-11

OK,測試secdb例項已經成功註冊到RMAN Catalog中。

3)使用“unregister database”命令取消註冊並重新註冊
(1)取消註冊
RMAN> unregister database;

database name is "SECGC" and DBID is 2970158546

Do you really want to unregister the database (enter YES or NO)? yes
database unregistered from the recovery catalog

(2)檢視rc_database資訊
rman_catalog@secdb> select * from rc_database;

no rows selected

此時顯示已經成功取消註冊。

(3)未退出RMAN環境情況下再次進行註冊
RMAN> register database;

database registered in recovery catalog
starting full resync of recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03008: error while performing automatic resync of recovery catalog
ORA-02291: integrity constraint (RMAN_CATALOG.RLH_F1) violated - parent key not found

問題出現了,此時報出了一個非常詭異的錯誤:“ORA-02291: integrity constraint (RMAN_CATALOG.RLH_F1) violated - parent key not found”。

如不退出RMAN環境再次執行註冊命令會收到如下錯誤。
RMAN> register database;

starting full resync of recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of register command at 05/29/2011 21:52:55
RMAN-03014: implicit resync of recovery catalog failed
RMAN-03009: failure of full resync command on default channel at 05/29/2011 21:52:55
ORA-02291: integrity constraint (RMAN_CATALOG.RLH_F1) violated - parent key not found

退出RMAN環境重新進入再次註冊,會收到如下報錯。
RMAN> exit


Recovery Manager complete.
secgc@secdb1 /home/oracle$ rman target sys/oracle1@secgc catalog rman_catalog/rman_catalog@secdb

Recovery Manager: Release 10.2.0.1.0 - Production on Sun May 29 21:53:19 2011

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

connected to target database: SECGC (DBID=2970158546)
connected to recovery catalog database

RMAN> register database;

starting full resync of recovery catalog
full resync complete
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of register command on default channel at 05/29/2011 21:53:25
RMAN-20002: target database already registered in recovery catalog

與此同時,rc_database檢視中再次出現secdb的註冊資訊。

rman_catalog@secdb> select * from rc_database;

    DB_KEY  DBINC_KEY       DBID NAME   RESETLOGS_CHANGE# RESETLOGS
---------- ---------- ---------- ------ ----------------- ---------
        55         56 2970158546 SECGC                  1 25-MAY-11

以上便是使用“unregister database”命令取消註冊後再次註冊時遇到的問題現象。

2.問題分析及探查過程
報錯涉及到的約束是一個外來鍵參照約束,RLH表的DBINC_KEY列參照引用DBINC表的DBINC列。該約束的建立指令碼如下。
ALTER TABLE RMAN_CATALOG.RLH ADD (
  CONSTRAINT RLH_F1
 FOREIGN KEY (DBINC_KEY)
 REFERENCES RMAN_CATALOG.DBINC (DBINC_KEY)
    ON DELETE CASCADE);

可以跟蹤一下這個報錯過程:
1)當使用“unregister database”命令取消註冊時,可以觀察到DBINC表和RLH表的內容都會被清空。
  若對這個過程進行trace跟蹤,可以觀察到在註冊的過程中是按照如下順序進行初始化表資料的。
    INSERT INTO DB(DB_KEY, DB_ID)
    INSERT INTO DBINC (DBINC_KEY, DB_KEY, DB_NAME, RESET_SCN, RESET_TIME)
    INSERT INTO CKP (CKP_KEY, CKP_SCN, CKP_CF_SEQ, CF_CREATE_TIME, CKP_TIME,
    INSERT INTO NODE(DB_UNIQUE_NAME, DB_KEY, HIGH_CONF_RECID, FORCE_RESYNC2CF,
    INSERT INTO TS (DBINC_KEY, TS#, TS_NAME, CREATE_SCN, CREATE_TIME,
    INSERT INTO TSATT(DBINC_KEY, TS#, CREATE_SCN, START_CKP_KEY, RBS_COUNT)
    INSERT INTO DF(DBINC_KEY, FILE#, CREATE_SCN, CREATE_TIME, TS#, TS_CREATE_SCN,
    INSERT INTO DFATT(DBINC_KEY, FILE#, CREATE_SCN, START_CKP_KEY, FNAME, BLOCKS)
    INSERT INTO TF(DBINC_KEY, FILE#, CREATE_SCN, CREATE_TIME, TS#, TS_CREATE_SCN,
    INSERT INTO TFATT(DBINC_KEY, FILE#, CREATE_SCN, START_CKP_KEY, FNAME, BLOCKS,
    INSERT INTO RT (DBINC_KEY, THREAD#, SEQUENCE#, ENABLE_SCN, ENABLE_TIME,
    INSERT INTO ORL (DBINC_KEY, THREAD#, GROUP#, FNAME)
    INSERT INTO RSR (RSR_KEY, DBINC_KEY, RSR_RECID, RSR_STAMP, RSR_PKEY,
    INSERT INTO ROUT (DB_KEY, RSR_KEY, ROUT_SKEY, ROUT_RECID, ROUT_STAMP,
    INSERT INTO RLH( RLH_KEY, DBINC_KEY, RLH_RECID, RLH_STAMP, THREAD#, SEQUENCE#,

2)未退出RMAN環境操作再次註冊時,可以觀察到此時子表RLH內容為空,原因是找不到父表中的記錄,但此時父表DBINC中已經成功寫入資料。
3)此時若不退出RMAN環境重新登入,反覆進行註冊都不會成功
4)在未退出RMAN環境時如果操作取消註冊可以成功,對應DBINC表中的記錄也會被清空。
5)退出RMAN環境重新登入後再次嘗試註冊,成功!
6)可以解決問題的重新註冊過程如下。
RMAN> unregister database;

database name is "SECGC" and DBID is 2970158546

Do you really want to unregister the database (enter YES or NO)? yes
database unregistered from the recovery catalog

RMAN> exit


Recovery Manager complete.
secgc@secdb1 /home/oracle$ rman target sys/oracle1@secgc catalog rman_catalog/rman_catalog@secdb

Recovery Manager: Release 10.2.0.1.0 - Production on Sun May 29 21:54:20 2011

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

connected to target database: SECGC (DBID=2970158546)
connected to recovery catalog database

RMAN> register database;

database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

  按照這個跟蹤過程,大家是不是已經有了問題的答案。沒錯,這是一起由於操作不規範導致的報錯。我們應該在每次完成取消註冊後退出RMAN環境,重新登入後進行註冊!

4.小結
  本文給出了一起因操作不規範導致資料庫無法重新註冊到RMAN Catalog問題的探查過程。

Good luck.

secooler
11.05.29

-- The End --

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

相關文章