RAC環境下控制文件損壞重建過程

處理過程參考了:
https://blogs.oracle.com/Database4CN/entry/%E5%A6%82%E4%BD%95%E9%87%8D%E5%BB%BArac%E7%9A%84%E6%8E%A7%E5%88%B6%E6%96%87%E4%BB%B6
 
 
問題現象:
 
現場有學校提報 登陸PL/SQL鏈接數據庫是報錯「ORA-12541: TNS:無監聽程序 」;排查日誌,發現
 
Tue Nov 25 14:46:58 2014
Thread 2 advanced to log sequence 18098 (LGWR switch)
  Current log# 4 seq# 18098 mem# 0: +DATADG/urpdb/onlinelog/group_4.266.821439273
Tue Nov 25 14:46:58 2014
Archived Log entry 50394 added for thread 2 sequence 18097 ID 0xb0471722 dest 1:
Tue Nov 25 14:54:49 2014
Read from controlfile member '+DATADG/urpdb/controlfile/current.260.821439141' has found a corrupted block (blk# 35, cf seq# 0)
Hex dump of (file 0, block 35) in trace file /u01/app/oracle/diag/rdbms/urpdb/urpdb2/trace/urpdb2_lmon_10377.trc
Corrupt block relative dba: 0x00000023 (file 0, block 35)
Completely zero block found during control file block read
Hex dump of (file 0, block 35) in trace file /u01/app/oracle/diag/rdbms/urpdb/urpdb2/trace/urpdb2_lmon_10377.trc
Corrupt block relative dba: 0x00000023 (file 0, block 35)
Completely zero block found during control file block read
Errors in file /u01/app/oracle/diag/rdbms/urpdb/urpdb2/trace/urpdb2_lmon_10377.trc:
ORA-00202: control file: '+DATADG/urpdb/controlfile/current.260.821439141'
Errors in file /u01/app/oracle/diag/rdbms/urpdb/urpdb2/trace/urpdb2_lmon_10377.trc  (incident=15289):
ORA-00227: corrupt block detected in control file: (block 35, # blocks 1)
ORA-00202: control file: '+DATADG/urpdb/controlfile/current.260.821439141'

Incident details in: /u01/app/oracle/diag/rdbms/urpdb/urpdb2/incident/incdir_15289/urpdb2_lmon_10377_i15289.trc
Tue Nov 25 14:54:51 2014
Dumping diagnostic data in directory=[cdmp_20141125145451], requested by (instance=2, osid=10377 (LMON)), summary=[incident=15289].
Errors in file /u01/app/oracle/diag/rdbms/urpdb/urpdb2/trace/urpdb2_lmon_10377.trc:
ORA-00227: corrupt block detected in control file: (block 35, # blocks 1)
ORA-00202: control file: '+DATADG/urpdb/controlfile/current.260.821439141'
LMON (ospid: 10377): terminating the instance due to error 227
System state dump requested by (instance=2, osid=10377 (LMON)), summary=[abnormal instance termination].
System State dumped to trace file /u01/app/oracle/diag/rdbms/urpdb/urpdb2/trace/urpdb2_diag_10357.trc
Instance terminated by LMON, pid = 10377
 
從日誌能夠看出,控制文件損壞了,致使數據庫實例終止。
 
 
 
解決辦法:
 
由於日誌文件、數據文件都是好的,只是惟一的一份控制文件損壞了,只能經過重建控制文件方法解決;
 
在RAC上重建控制文件與單實例有一些小區別:
 在重建控制文件前必須設置cluster_database=false,並且只啓動一個實例來執行操做,不然會報錯
ORA-01503: CREATE CONTROLFILE failed
ORA-12720: operation requires database is in EXCLUSIVE mode

重建完控制文件後,須要再將cluster_database設爲true.
 
 
處理步驟:
 
1.首先生成重建控制文件的腳本:
SQL> alter database backup controlfile to trace;
 
2.數據庫的Alert log中會詳細輸出這個文件的路徑和名字:

Tue Nov 25 22:32:04 2014
alter database backup controlfile to trace
Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/urpdb/urpdb1/trace/urpdb1_ora_6233.trc
Completed: alter database backup controlfile to trace數據庫

 
 
3.啓動一個實例

SQL> startup nomount;    服務器

 

4.修改cluster_database屬性
SQL> alter system set cluster_database=false scope=spfile;

SQL> shutdown immediate

SQL> startup nomount;
 
 
5.從urpdb1_ora_6233.trc 中獲取建立控制文件腳本(noresetlogs的)執行
 
SQL> CREATE CONTROLFILE REUSE DATABASE "URPDB" NORESETLOGS  ARCHIVELOG
    MAXLOGFILES 192
    MAXLOGMEMBERS 3
    MAXDATAFILES 1024
    MAXINSTANCES 32
    MAXLOGHISTORY 18688
LOGFILE
  GROUP 1 '+DATADG/urpdb/onlinelog/group_1.261.821439143'  SIZE 50M BLOCKSIZE 512,
  GROUP 2 '+DATADG/urpdb/onlinelog/group_2.262.821439143'  SIZE 50M BLOCKSIZE 512,
  GROUP 3 '+DATADG/urpdb/onlinelog/group_3.265.821439273'  SIZE 50M BLOCKSIZE 512,
  GROUP 4 '+DATADG/urpdb/onlinelog/group_4.266.821439273'  SIZE 50M BLOCKSIZE 512
DATAFILE
  '+DATADG/urpdb/datafile/system.256.821439061',
  '+DATADG/urpdb/datafile/sysaux.257.821439061',
  '+DATADG/urpdb/datafile/undotbs1.258.821439061',
  '+DATADG/urpdb/datafile/users.259.821439061',
  '+DATADG/urpdb/datafile/undotbs2.264.821439205',
  '+DATADG/urpdb/datafile/tsp_imp_d.dbf',
  '+DATADG/urpdb/datafile/tsp_dpstar.dbf',
  '+DATADG/urpdb/datafile/ts_portal_d.dbf',
  '+DATADG/urpdb/datafile/ts_w5_d.dbf',
  '+DATADG/urpdb/datafile/ts_wap_d.dbf',
  '+DATADG/urpdb/datafile/ts_oa_d.dbf',
  '+DATADG/urpdb/datafile/tsp_sastar.dbf',
  '+DATADG/urpdb/datafile/tsp_portal.dbf'
CHARACTER SET AL32UTF8
;
 
 
6.確認redo log,thread#是正確的
SQL> select * from v$log; 
 
 
7.恢復數據庫、啓動數據庫、恢復臨時文件( 這些步驟,在urpdb1_ora_6233.trc 寫的很清楚
SQL> recover database;

Media recovery complete.

SQL> alter system  archive log all;

SQL> alter database open;oracle


SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '+DATADG/urpdb/tempfile/temp.263.821439145' REUSE;app

SQL> ALTER TABLESPACE TSP_IMP_TEMP ADD TEMPFILE '+DATADG/urpdb/tempfile/tsp_imp_temp.dbf' REUSE;
SQL> ALTER TABLESPACE TSP_DPSTAR_TEMP ADD TEMPFILE '+DATADG/urpdb/tempfile/tsp_dpstar_temp.dbf' REUSE;
SQL> ALTER TABLESPACE TS_PORTAL_TEMP ADD TEMPFILE '+DATADG/urpdb/datafile/ts_portal_temp.dbf' REUSE;
SQL> ALTER TABLESPACE TS_W5_TEMP ADD TEMPFILE '+DATADG/urpdb/datafile/ts_w5_temp.dbf' REUSE;
SQL> ALTER TABLESPACE TS_WAP_TEMP ADD TEMPFILE '+DATADG/urpdb/datafile/ts_wap_temp.dbf' REUSE;
 
 
8.還原cluster_database屬性
 
SQL> alter system set cluster_database=true scope=spfile;


SQL> shutdown immediateide

 
 
9.重啓集羣服務
./crsctl start cluser   問題解決。
 
 
10.登陸另一臺服務器查看數據庫狀態,若有問題進行相應處理。
 
 
總結:
 
  1.開啓數據庫控制文件自動備份很重要:
         本數據庫因爲沒有打開控制文件自動備份功能,只能採用重建方法。若是開啓了,採用該控制文件,進行recover database using backup controlfile會更簡單一些(有待測試驗證)
相關文章
相關標籤/搜索