關於兩個簡單問題的分析(r9筆記第10天)
阿新 • • 發佈:2022-05-04
工作中碰到問題當然是見怪不怪了,而處理這些問題也是我們的價值所在。
今天處理了幾個看起來比較有意思的小問題,當然究其原因,要不是不規範,要不就是基本功不夠紮實。
問題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], [], [], [], [], [],
[], [], [], [], [], []
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
明白了這些,很多問題其實還是開始所說的,不夠規範,基本功不夠紮實。