公司一台測試環境的基於linux 平台下 oracle 11.2.0.3 的資料庫,為開歸檔,未備份。 21號晚上,因/目錄下 空間使用%100,oracle HOME目錄在系統 / 目錄下:
因硬碟資源佔盡,不能串連操作,oracle 資料庫掛起。
某人的操作,查看undotbs1 佔用最大,通過mv 移動到 另一目錄,同時系統被重啟,使得undotbs1 資料檔案損壞,不能使用,最後又做了一個rm 操作, 重啟庫,導致故障出現!
報錯一:
Wed Jan 22 09:42:50 2014ALTER DATABASE OPENErrors in file /u01/app/oracle/diag/rdbms/gtadata13/gtadata13/trace/gtadata13_dbw0_4245.trc:ORA-01157: cannot identify/lock data file 3 - see DBWR trace fileORA-01110: data file 3: '/u01/app/oracle/oradata/gtadata13/undotbs01.dbf'ORA-27047: unable to read the header block of fileLinux-x86_64 Error: 25: Inappropriate ioctl for deviceAdditional information: 1Wed Jan 22 09:42:52 2014Checker run found 1 new persistent data failuresErrors in file /u01/app/oracle/diag/rdbms/gtadata13/gtadata13/trace/gtadata13_ora_4361.trc:ORA-01157: cannot identify/lock data file 3 - see DBWR trace fileORA-01110: data file 3: '/u01/app/oracle/oradata/gtadata13/undotbs01.dbf'ORA-1157 signalled during: ALTER DATABASE OPEN...
--- 就是oracle 在mount後,不能載入到open 狀態。
2 接下來操作: 因為undo tablespace 資料檔案undotbs1 沒有了,想通過重建一個undo 資料表空間 undotbs2 把資料庫啟動到open 狀態
操作:
SQL> show parameter undoNAME TYPE VALUE------------------------------------ ----------- ------------------------------undo_management string AUTOundo_retention integer 900undo_tablespace string UNDOTBS1
SQL > CREATE UNDO TABLESPACE UNDOTBS2 DATAFILE '/XXXX.DBF' SIZE 32M AUTOEXTEND ON NEXT 32M MAXSIZE 10G; --重建立資料表空間SQL > SELECT * FROM V$TABLESAPCE SELECT NAME,STATUS FROM V$DATAFILE -- 查詢其狀態值SQL > ALTER SYSTEM SET UNDO_TABLESPACE=UNDOTBS2 SCOPE=BOTH -- 通過show parameter undo 查看是否使用。
3 此時,資料庫可以open起來, 但是通過client ,或者其他使用者串連時,報錯:
報錯二SQL> conn input/INPUTERROR:ORA-00604: error occurred at recursive SQL level 1ORA-00376: file 3 cannot be read at this timeORA-01110: data file 3: '/u01/app/oracle/oradata/gtadata13/undotbs01.dbf'ORA-02002: error while writing to audit trailORA-00604: error occurred at recursive SQL level 1ORA-00376: file 3 cannot be read at this timeORA-01110: data file 3: '/u01/app/oracle/oradata/gtadata13/undotbs01.dbf'
4 根據報錯,發現不僅僅是 undotbs1資料檔案有問題,還有開啟了審計 audit: 如是
先關閉審計SQL > SHOW PARAMETER AUDITNAME TYPE VALUE------------------------------------ ----------- ------------------------------audit_file_dest string /u01/app/oracle/admin/gtadata1 3/adumpaudit_sys_operations boolean FALSEaudit_syslog_level stringaudit_trail string DB
SQL > alter system set audit_trail=none scope=spfile -- 設定後需要重啟庫。 --具體見審計
5 再通過對undotbs1資料檔案操作,使其offline 處理(看行否)
SQL > alter database datafile 3 offline drop ;
6 通過 v$logfile,dba_tablespaces, dba_data_files 查看資料資料表空間,資料檔案的狀態:
SQL> select tablespace_name,file_id,file_name from dba_data_files; TABLESPACE_NAME FILE_ID FILE_NAME------- ---------- -------------------------------------------------------------USERS 4 /u01/app/oracle/oradata/gtadata13/users01.dbfUNDOTBS1 3 /u01/app/oracle/oradata/gtadata13/undotbs01.dbfSQL> select status,tablespace_name from dba_tablespaces; STATUS TABLESPACE_NAME--------- ------------------------------ONLINE SYSTEMONLINE SYSAUXONLINE UNDOTBS1
7 此時發現undotbs1 資料檔案還在,同時undotbs1 表空online
如是操作:
報錯三 SQL> alter tablespace UNDOTBS1 offline; alter tablespace UNDOTBS1 offline * ERROR at line 1: ORA-01191: file 3 is already offline - cannot do a normal offline ORA-01110: data file 3: '/u01/app/oracle/oradata/gtadata13/undotbs01.dbf' --- 此時心想,怎麼不能offline了,看能否風能 temporary offline 查詢資料檔案頭,select FILE#,checkpoint_change#,recover, fuzzy from v$datafile_header;
最後通過 SQL> alter system checkpoint; --做一個檢查點,再試試:System altered.SQL> alter tablespace undotbs1 offline temporary;Tablespace altered.
再次通過 dba_tablespaces 查看 undotbs1 的狀態,發現 是否offline。 offline 狀態。
8 測試再看看能否通過其他使用者串連或client 串連: -- 發現ok,可以通過其他使用者串連了,但是一些程式 涉及到報錯:
報錯四:
執行預存程序失敗 ORA-00376: 此時無法讀取檔案 3ORA-01110: 資料檔案 3: '/u01/app/oracle/oradata/gtadata13/undotbs01.dbf'ORA-06512: 在 "GTA_DATA.SP_QA_TIMELINESS", line 54ORA-06512: 在 line 1
如是想了想 ,確實,因為undotbs1 是通過物理刪除的,那麼oracle 一致性 會是這些需要recovery恢複:
9 既然offline,可否刪除掉,(估計比較麻煩,這回退給幹掉了,怎麼回退了?)
通過dba_rollback_segs 發現 還有很多 recovery 的undotbs1 段需要復原恢複,是資料一致性。
SQL> select segment_name,tablespace_name,status from dba_rollback_segs;SEGMENT_NAME TABLESPACE_NAME STATUS------------------------------ ------------------------------ ----------------SYSTEM SYSTEM ONLINE_SYSSMU122_928896348$ UNDOTBS1 OFFLINE_SYSSMU121_4101333926$ UNDOTBS1 OFFLINE_SYSSMU120_471964226$ UNDOTBS1 OFFLINE_SYSSMU119_3645569891$ UNDOTBS1 OFFLINE_SYSSMU118_1816999230$ UNDOTBS1 OFFLINE_SYSSMU117_3513527861$ UNDOTBS1 OFFLINE_SYSSMU116_2167311593$ UNDOTBS1 OFFLINE_SYSSMU90_1969094056$ UNDOTBS1 NEEDS RECOVERY_SYSSMU89_2804401042$ UNDOTBS1 NEEDS RECOVERY_SYSSMU88_3446396459$ UNDOTBS1 NEEDS RECOVERY_SYSSMU87_268667266$ UNDOTBS1 NEEDS RECOVERY_SYSSMU86_1912503840$ UNDOTBS1 NEEDS RECOVERY_SYSSMU85_2732352333$ UNDOTBS1 NEEDS RECOVERY_SYSSMU84_1805825668$ UNDOTBS1 NEEDS RECOVERY_SYSSMU83_1984855352$ UNDOTBS1 NEEDS RECOVERY_SYSSMU212_1777710046$ UNDOTBS2 ONLINE_SYSSMU211_3260590093$ UNDOTBS2 ONLINE_SYSSMU210_1915944113$ UNDOTBS2 ONLINE_SYSSMU209_2868303011$ UNDOTBS2 ONLINE_SYSSMU208_3687438092$ UNDOTBS2 ONLINE_SYSSMU207_752508113$ UNDOTBS2 ONLINE
此時,百度,及詢問了一些高手,說最好做個備份: 如是想通過expdp 匯入匯出:
報錯五:
[oracle@gtadata13 dump_dir]$ impdp dcsys/DCSYS directory=dump_dir dumpfile=TBL_CHN_FN_ForecFin.dmpImport: Release 11.2.0.3.0 - Production on Wed Jan 22 14:40:30 2014Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsORA-31626: job does not existORA-06512: at "SYS.DBMS_SYS_ERROR", line 79ORA-06512: at "SYS.KUPV$FT", line 1042ORA-31637: cannot create job SYS_IMPORT_FULL_01 for user DCSYSORA-31632: master table "DCSYS.SYS_IMPORT_FULL_01" not found, invalid, or inaccessibleORA-31635: unable to establish job resource synchronizationORA-06512: at "SYS.DBMS_SYS_ERROR", line 79ORA-06512: at "SYS.KUPV$FT_INT", line 2401ORA-00376: file 3 cannot be read at this timeORA-01110: data file 3: '/u01/app/oracle/oradata/gtadata13/undotbs01.dbf' -- 這也不行,看來,只能老實的弄了
10 ,打算刪除 這offline undotbs1資料表空間,看是否跳過:
報錯六:
SQL> drop tablespace undotbs1;drop tablespace undotbs1*ERROR at line 1:ORA-01548: active rollback segment '_SYSSMU1_1240252155$' found, terminate dropping tablespaceSQL> DROP ROLLBACK SEGMENT "_SYSSMU1_1240252155$";DROP ROLLBACK SEGMENT "_SYSSMU1_1240252155$"*ERROR at line 1:ORA-30025: DROP segment '_SYSSMU1_1240252155$' (in undo tablespace) not allowed
再次通過百度,高手請教: 發現需要在pfile 上 添加隱藏參數檔案_offline_rollback_segments (‘xx’)和 _corrupted_rollback_segments ('xx') 後再刪除,看否跳過
在pfile中加入參數_offline_rollback_segments=(‘’)_corrupted_rollback_segments=(‘’) ---括弧參數為dba_rollback_segs中 undotbs1 status 為need recovery 狀態的這種值“_SYSSMU122_928896348$”
10 : 於是通過 pfile添加影藏參數 或者 alter system set _offline_rollback_segments = " 值 " socpe=spfile
alter system set _corrupted_rollback_segments = " 值 " socpe=spfile 進行操作。
當時我通過重建pfile參數檔案 *._offline_rollback_segments=('_SYSSMU90_1969094056$',。。。。) *._corrupted_rollback_segments=('_SYSSMU90_1969094056$', 來操作
然後 通過刪除所有 dba_rollback_segs 下的所有值後,在drop undotbs1 資料表空間:
SQL> drop rollback segment "_SYSSMU1_1240252155$"; ---注意雙引號不能有空格Rollback segment dropped. ---對應的值,一個一個刪除。
11 : 最後刪除 undotbs1 資料表空間 ---ok,可以刪除了,再通過dba_rollback_segs發現,沒有了undtotbs1 的資料表空間了。
SQL> select segment_name,tablespace_name,status from dba_rollback_segs;SEGMENT_NAME TABLESPACE_NAME STATUS------------------------------ ------------------------------ ----------------SYSTEM SYSTEM ONLINE_SYSSMU212_1777710046$ UNDOTBS2 ONLINE_SYSSMU211_3260590093$ UNDOTBS2 ONLINE_SYSSMU210_1915944113$ UNDOTBS2 ONLINE_SYSSMU209_2868303011$ UNDOTBS2 ONLINE_SYSSMU208_3687438092$ UNDOTBS2 ONLINE_SYSSMU207_752508113$ UNDOTBS2 ONLINE_SYSSMU206_883733676$ UNDOTBS2 ONLINE_SYSSMU205_725465268$ UNDOTBS2 ONLINE_SYSSMU204_1401227473$ UNDOTBS2 ONLINE_SYSSMU203_3100642042$ UNDOTBS2 ONLINE
12 : 掃尾: a: 恢複原來好審計功能設定, b: 多切換幾次,查看業務資料 c: 這樣操作,雖然 可以了,但是有部分業務資料丟失 d: 做好備份 e: 就像大師說的,遇事,莫急躁