ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 【RMAN】重新将数据库注册到RMAN Catalog时偶遇ORA-02291错误之探查

【RMAN】重新将数据库注册到RMAN Catalog时偶遇ORA-02291错误之探查

原创 Linux操作系统 作者:secooler 时间:2011-05-29 22:50:28 0 删除 编辑
  使用“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/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
Oracle ACE 总监,阿里云MVP,北京大学理学硕士,恩墨学院创始人,教育专家,中国区 Cloudera 首位官方授权大数据讲师,金牌培训专家,BDA大数据联盟创始人,OCM联盟创始人,ACCUG创始人、ACOUG核心专家,Blogger。

注册时间:2008-03-16

  • 博文量
    797
  • 访问量
    8105039