關於兩個簡單問題的分析

dbhelper發表於2016-05-26
工作中碰到問題當然是見怪不怪了,而處理這些問題也是我們的價值所在。
今天處理了幾個看起來比較有意思的小問題,當然究其原因,要不是不規範,要不就是基本功不夠紮實。
問題1:奇怪的ORA-00600報錯,常規的原因
對於ORA-00600的錯誤,其實自己也碰到過很多次了,絕大多數的情況下,這個錯誤還是能夠反映出來一些不規範的現象。
比如今天得到了一個DDL語句,執行的時候有卡頓,然後直接丟擲了ORA-00600的錯誤。
SQL>    CREATE USER "KA_SYS" IDENTIFIED BY VALUES 'S:C4EA100810C8DE6923BCF6F2E2E
    C8C0FA1BCE0CCB11EA7A6E8234845C424;5FEFDBD83ED3C188'
          DEFAULT TABLESPACE "MIN_DATA"
          TEMPORARY TABLESPACE "TEMP";
   CREATE USER "KA_SYS" IDENTIFIED BY VALUES 'S:C4EA100810C8DE6923BCF6F2E2E
*
ERROR at line 1:
ORA-00600: internal error code, arguments: [kzsviver:4], [], [], [], [], [],
[], [], [], [], [], []  
對於這個錯誤,自己頓時來了興趣,不過自己一看,問題其實還是常規的問題,密碼怎麼串成兩行了。這種情況下Oracle應該不知道該怎麼處理了。
而進一步來分析,為什麼DDL中的密碼會序列,還是在生成語句的時候不夠規範,我們完全可以格式化一下。
問題2:Switchover中跨儲存的相容問題
在之前分析Switchover的時候,有一個地方簡單提了一句,就是備庫的臨時資料檔案是可選的,在備庫中如果不存在會嘗試重建,如果因為配置原因,沒有路徑對映,則臨時檔案無法建立,這個也是一個潛在的問題。
今天在檢查一個備庫的時候,在open狀態
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY WITH APPLY
但是檢視資料庫日誌,卻發現了下面的一段錯誤日誌:
alert
File 1003 not verified due to error ORA-01157
Errors in file /U01/app/oracle/diag/rdbms/statdb29/statdb2/trace/statdb2_dbw0_57554.trc:
ORA-01186: file 1004 failed verification tests
ORA-01157: cannot identify/lock data file 1004 - see DBWR trace file
ORA-01110: data file 1004: '+DATA'
File 1004 not verified due to error ORA-01157
Errors in file /U01/app/oracle/diag/rdbms/statdb29/statdb2/trace/statdb2_dbw0_57554.trc:
ORA-01186: file 1005 failed verification tests
ORA-01157: cannot identify/lock data file 1005 - see DBWR trace file
ORA-01110: data file 1005: '+DATA'
可以根據錯誤資訊得出,建立檔案的時候,無法識別磁碟組而建立失敗。根據更清晰的資訊發現是在建立臨時資料檔案時拋錯。
SQL> select file#,ts#,status,name from v$tempfile
     FILE#        TS# STATUS  NAME
---------- ---------- ------- ------------------------------
         1          3 ONLINE  +DATA
         2          3 ONLINE  +DATA
         3          3 ONLINE  +DATA
         4          3 ONLINE  +DATA
檢視資料字典發現臨時檔案指向了ASM磁碟組DATA,但是這個備庫是檔案系統,所以查詢dba_temp_files會失敗,因為檔案壓根不存在。
SQL> select file_name,bytes from dba_temp_files;
select file_name,bytes from dba_temp_files
                            *
ERROR at line 1:
ORA-01157: cannot identify/lock data file 1003 - see DBWR trace file
ORA-01110: data file 1003: '+DATA'
當然要在備庫刪除臨時資料檔案,下面的幾種失敗方式供參考:
SQL> drop tablespace temp including contents and datafiles;
drop tablespace temp including contents and datafiles
*
ERROR at line 1:
ORA-16000: database open for read-only access

SQL> drop tablespace temp;
drop tablespace temp
*
ERROR at line 1:
ORA-16000: database open for read-only access
重新建立一個臨時表空間來。
SQL> create temporary tablespace TEMP2 TEMPFILE '/U01/app/oracle/oradata/statdb29/temp01.dbf' SIZE 30G;
create temporary tablespace TEMP2 TEMPFILE '/U01/app/oracle/oradata/statdb29/temp01.dbf' SIZE 30G
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-16000: database open for read-only access

當然重啟到mount嘗試肯定是不對的。為什麼,姿勢不對,正確的姿勢為:
SQL> alter tablespace temp drop tempfile 3;
Tablespace altered.
繼續刪除其它的臨時資料檔案,直到最後一個會報錯。
SQL> alter tablespace temp drop tempfile 7;
alter tablespace temp drop tempfile 7
*
ERROR at line 1:
ORA-03261: the tablespace TEMP has only one file
我們可以新增一個,繼續刪除錯誤的資訊。
SQL> select file#,ts#,status,name from v$tempfile;
     FILE#        TS# STATUS  NAME
---------- ---------- ------- ------------------------------
         7          3 ONLINE  +DATA

SQL> alter tablespace temp add tempfile '/U01/app/oracle/oradata/statdb29/temp01.dbf' size 30G;
Tablespace altered.

SQL> alter tablespace temp drop tempfile 7;
Tablespace altered.
如果仔細分析一下alert日誌就會發現,其實前臺雖然現實命令執行成功,但是後臺的檢查卻丟擲了ORA錯誤,當然我們需要了解這個分析的過程。
alter tablespace temp drop tempfile 5
Errors in file /U01/app/oracle/diag/rdbms/statdb29/statdb2/trace/statdb2_ora_58092.trc:
ORA-01122: database file 1005 failed verification check
ORA-01110: data file 1005: '+DATA'
ORA-01565: error in identifying file '+DATA'
ORA-17503: ksfdopn:2 Failed to open file +DATA
ORA-15045: ASM file name '+DATA' is not in reference form
Errors in file /U01/app/oracle/diag/rdbms/statdb29/statdb2/trace/statdb2_ora_58092.trc:
ORA-01258: unable to delete temporary file +DATA
Completed: alter tablespace temp drop tempfile 5
Wed May 25 18:15:11 2016
明白了這些,很多問題其實還是開始所說的,不夠規範,基本功不夠紮實。

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

相關文章