生産庫備份遇到ORA-01400 錯誤~當rman 不使用 catalog時,RMAN 指令可以正常實施~!當rman 備份使用catalog資料庫時,執行rman 指令總是報錯:<b>ORA-01400:cannot insert NULL into ("RMAN_</b><b>YANGDB"."RLH"."LOW_TIME")</b>
RMAN> resync catalog;
starting full resync of recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-03009: failure of resync command on default channel at 01/06/2012 10:39:11
ORA-01400: cannot insert NULL into ("RMAN_YANGDB"."RLH"."LOW_TIME")
報錯的原因是因為:<b>不能向恢複目錄資料庫的表RLH插入空值“the issue caused by unable to insert NULL value in RSR table of the recovery catalog.”(至于為什麼會産生 thread# 為0的記錄,這個待查!)</b>
執行如下查詢,檢視v$log_history的記錄中thread#為0的記錄!
<b>select thread#, sequence#, first_change#, next_change#, first_time from v$log_history where thread#=0;</b>
THREAD# SEQUENCE# FIRST_CHANGE# NEXT_CHANGE# FIRST_TIME
------- -------- ------------- ------------ ------------------
0 0 0 0
<b>解決方法!</b>
<b>因為v$log_history 記錄中含有空值,v$log_history是有系統自己管理的動态性能視圖,是以使用oracle提供的</b><b>dbms_backup_restore.resetCfileSection()包來清除控制檔案中關于log_history 的記錄,讓系統重新生成新的日志記錄!</b>
<b>1 使用如下指令查詢LOG HISTORY在控制檔案中的編号為 9 !</b>v$controlfile_record_section 視圖記錄了控制檔案裡包含的資訊,以及各個項目的目前使用情況
17:31:18 yang(40)@yangdb> select rownum-1 session_id, type from v$controlfile_record_section;
SESSION_ID TYPE
---------- ----------------------------
0 DATABASE
1 CKPT PROGRESS
2 REDO THREAD
3 REDO LOG
4 DATAFILE
5 FILENAME
6 TABLESPACE
7 TEMPORARY FILENAME
8 RMAN CONFIGURATION
<b>9 LOG HISTORY</b>
10 OFFLINE RANGE
11 ARCHIVED LOG
12 BACKUP SET
13 BACKUP PIECE
14 BACKUP DATAFILE
15 BACKUP REDOLOG
16 DATAFILE COPY
17 BACKUP CORRUPTION
18 COPY CORRUPTION
19 DELETED OBJECT
20 PROXY COPY
21 BACKUP SPFILE
22 DATABASE INCARNATION
23 FLASHBACK LOG
24 RECOVERY DESTINATION
25 INSTANCE SPACE RESERVATION
26 REMOVABLE RECOVERY FILES
27 RMAN STATUS
28 THREAD INSTANCE NAME MAPPING
29 MTTR
30 DATAFILE HISTORY
31 STANDBY DATABASE MATRIX
32 GUARANTEED RESTORE POINT
33 RESTORE POINT
34 DATABASE BLOCK CORRUPTION
35 ACM OPERATION
36 FOREIGN ARCHIVED LOG
37 rows selected.
<b>2. 使用上面查詢出來的 "LOG HISTORY" 的session_id ,使用dbms_backup_restore.resetCfileSection(section_id);:</b>
SQL> execute dbms_backup_restore.resetCfileSection(9);
在清理控制檔案中 "LOG HISTORY"部分之後後,使用rman 連接配接catalog 進行同步catalog~
$ rman target sys/password@alias_target catalog rman_user/password@alias_catalog
<b>RMAN> resync catalog;</b>
<b>關于v$CONTROLFILE_RECORD_SECTION 是v_$CONTROLFILE_RECORD_SECTION的同義詞。該表中記錄了資料庫中的各種資訊,備份的資訊,redo資訊,歸檔資訊,資料檔案資訊~</b>
17:31:19 yang(40)@yangdb> set pages 50000
21:10:19 yang(40)@yangdb> col type for a30
21:10:19 yang(40)@yangdb> col PCT_USED format 990.09
21:10:19 yang(40)@yangdb> -- Controlfile creation parameters:
21:10:19 yang(40)@yangdb> -- Type DATAFILE is for MAXDATAFILES
21:10:19 yang(40)@yangdb> -- Type REDO LOG is for MAXLOGFILES
21:10:19 yang(40)@yangdb> -- Type LOG HISTORY is for MAXLOGHISTORY
21:10:19 yang(40)@yangdb> -- Type REDO THREAD is for MAXINSTANCES
21:10:19 yang(40)@yangdb> -- No entry for MAXLOGMEMBERS here, use: select dimlm max_log_members from X$KCCDI;
21:10:19 yang(40)@yangdb> <b>select type,records_used,records_total,records_used/records_total*100 "PCT_USED" from sys.v_$CONTROLFILE_RECORD_SECTION order by 1;</b>
TYPE RECORDS_USED RECORDS_TOTAL PCT_USED
------------------------------ ------------ ------------- --------
ACM OPERATION 6 64 9.38
ARCHIVED LOG 179 224 79.91
BACKUP CORRUPTION 0 371 0.00
BACKUP DATAFILE 245 245 100.00
BACKUP PIECE 200 200 100.00
BACKUP REDOLOG 199 215 92.56
BACKUP SET 304 409 74.33
BACKUP SPFILE 46 131 35.11
CKPT PROGRESS 0 11 0.00
COPY CORRUPTION 0 409 0.00
DATABASE 1 1 100.00
DATABASE BLOCK CORRUPTION 0 8384 0.00
DATABASE INCARNATION 2 292 0.68
DATAFILE 7 100 7.00
DATAFILE COPY 3 200 1.50
DATAFILE HISTORY 0 57 0.00
DELETED OBJECT 818 818 100.00
FILENAME 12 2298 0.52
FLASHBACK LOG 0 2048 0.00
FOREIGN ARCHIVED LOG 0 1002 0.00
GUARANTEED RESTORE POINT 0 2048 0.00
INSTANCE SPACE RESERVATION 1 1055 0.09
LOG HISTORY 292 292 100.00
MTTR 1 8 12.50
OFFLINE RANGE 0 163 0.00
PROXY COPY 0 246 0.00
RECOVERY DESTINATION 1 1 100.00
REDO LOG 3 16 18.75
REDO THREAD 1 8 12.50
REMOVABLE RECOVERY FILES 6 1000 0.60
RESTORE POINT 0 2083 0.00
RMAN CONFIGURATION 2 50 4.00
RMAN STATUS 451 451 100.00
STANDBY DATABASE MATRIX 31 31 100.00
TABLESPACE 7 100 7.00
TEMPORARY FILENAME 2 100 2.00
THREAD INSTANCE NAME MAPPING 8 8 100.00
<b>2 關于dbms_backup_restore.resetCfileSection的作用是将控制檔案相關區域中的内容清空:(注意,此操作為測試環境,在無oracle技術支援建議或允許的情況下,請勿在生産環境測試,以下操作是在資料庫open狀态下執行)</b>
17:04:26 SYS@yangdb> <b>execute dbms_backup_restore.resetCfileSection(9);</b>
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.05
17:04:37 SYS@yangdb> <b>select count(1) from v$log_history;</b>
COUNT(1)
----------
17:26:55 YANG@yangdb> update bigtab set object_id=id where rownum
9999 rows updated.
Elapsed: 00:00:00.44
17:26:57 YANG@yangdb> commit;
Commit complete.
Elapsed: 00:00:00.01
17:27:04 YANG@yangdb>
17:27:04 YANG@yangdb> conn /as sysdba
Connected.
17:27:10 SYS@yangdb>
17:27:10 SYS@yangdb> <b>select count(1) from v$log_history;</b>
62
1 row selected.
Elapsed: 00:00:00.03
17:27:15 SYS@yangdb> <b>execute dbms_backup_restore.resetCfileSection(9);</b>
17:27:21 SYS@yangdb> select count(1) from v$log_history;
17:27:23 SYS@yangdb>