在網上查了幾天的資料,嘗試綜合清除告警日志內容及建外部表的方式來解決這一問題。
一:備份並清除告警日志內容
將每天的告警日志備份好,然後進行清除。
1:備份報警日志
在$ORACLE_HOME/SID/bdump/ 目錄下,
按日期備份alert_ORACLE_你的實例名.LOG這個文件,如:alert_ORACLE_orcl_201408111639_bak.LOG。
2:清除日志內容
打開報警日志文件,用true > 文件名 可清除掉裡面的內容
具體示例:
假如,我現在第一次進行該設置,我先把現有的告警日志進行備份,如:
--備份文件名稱:今天16點24分前的告警日志信息
[oracle@rac2 bdump]$ cp alert_orcl2.log alert_orcl2_before_201408111624_bak.log
-清空報警日志
[oracle@rac2 bdump]$ true > alert_orcl2.log
現在告警日志是空的。
切換下歸檔日志,檢查報警日志裡是否出現了新內容:
SQL> alter system switch logfile; System altered.
則現在alert_orcl2.log記錄的是2014年8月11日16點24分後至你下次對報警日志進行備份,截取前的信息。
二:建外部表查看報警日志錯誤
如果已建立了一個用戶,並賦相應的權限,所以直接建立目錄對象並建立外部表就可以了。
1.建立目錄對象
SQL> conn test / 123
Connected. SQL> create directory bdump as '/oracle/u01/app/oracle/admin/db2/bdump'; Directory created.
2.建立外部表
SQL> create table alert_log( text varchar2(400) )organization external (type oracle_loader default directory bdump access parameters (records delimited by newline )location('alert_db2.log') );
3.測試首先查看能否查到alert_db2.log的內容
SQL> select * from alert_log where rownum < 10; TEXT -------------------------------------------------------------------------------- Thu Jun 11 00:51:46 2009 Starting ORACLE instance (normal) Cannot determine all dependent dynamic libraries for /proc/self/exe Unable to find dynamic library libocr10.so in search paths RPATH = /ade/aime1_build2101/oracle/has/lib/:/ade/aime1_build2101/oracle/lib/:/a de/aime1_build2101/oracle/has/lib/: LD_LIBRARY_PATH is not set! The default library directories are /lib and /usr/lib Unable to find dynamic library libocrb10.so in search paths Unable to find dynamic library libocrutl10.so in search paths 9 rows selected.
測試成功
然後我們測試查報警信息'ORA-%'
SQL> select * from alert_log where text like 'ORA-%'; TEXT -------------------------------------------------------------------------------- ORA-00202: control file: '/oracle/u01/app/oracle/product/10.2.0/db2/dbs/cntrldb2 .dbf' ORA-27037: unable to obtain file status ORA-205 signalled during: ALTER DATABASE MOUNT... ORA-00301: error in adding log file '/home/oracle/oracle/oradata/testdb/redo01.l og' - file cannot be created ORA-27040: file create error ORA-1501 signalled during: CREATE DATABASE db2 ORA-00200: control file could not be created TEXT -------------------------------------------------------------------------------- ORA-00202: control file: '/oracle/u01/app/oracle/product/10.2.0/db2/dbs/cntrldb2 .dbf' ORA-27038: created file already exists ORA-1501 signalled during: CREATE DATABASE db2 ORA-00200: control file could not be created ORA-00202: control file: '/oracle/u01/app/oracle/product/10.2.0/db2/dbs/cntrldb2 .dbf' ORA-27038: created file already exists ORA-1501 signalled during: CREATE DATABASE db2
--假如,你的報警日志文件只包含今天的信息(可以通過備份並清除告警日志內容實現),則通過外部表可以查到當天產生了哪些錯誤。
alert_orcl.log
sqlplus / as sysdba
show parameter background
查到告警日志所在目錄
然後cd到該目錄, 並vi alert*.log
即可查看
askmaclean