教你怎样用Oracle方便地查看报警日志错误

前端之家收集整理的这篇文章主要介绍了教你怎样用Oracle方便地查看报警日志错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

在网上查了几天的资料,尝试综合清除告警日志内容及建外部表的方式来解决这一问题。

一:备份并清除告警日志内容

将每天的告警日志备份好,然后进行清除。

1:备份报警日志

在$ORACLE_HOME/SID/bdump/ 目录下,
按日期备份alert_ORACLE_你的实例名.LOG这个文件,如:alert_ORACLE_orcl_201408111639_bak.LOG。

2:清除日志内容

打开报警日志文件,用true > 文件名 可清除掉里面的内容

具体示例:
假如,我现在第一次进行该设置,我先把现有的告警日志进行备份,如:

--备份文件名称:今天16点24分前的告警日志信息

-清空报警日志

alert_orcl2.log

现在告警日志是空的。
切换下归档日志,检查报警日志里是否出现了新内容

alter system switch logfile; System altered.

则现在alert_orcl2.log记录的是2014年8月11日16点24分后至你下次对报警日志进行备份,截取前的信息。

二:建外部表查看报警日志错误

如果已建立了一个用户,并赋相应的权限,所以直接建立目录对象并建立外部表就可以了。

1.建立目录对象

conn test / 123
Connected. sql> create directory bdump as '/oracle/u01/app/oracle/admin/db2/bdump'; Directory created.

2.建立外部表

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的内容

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-%'

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

--假如,你的报警日志文件只包含今天的信息(可以通过备份并清除告警日志内容实现),则通过外部表可以查到当天产生了哪些错误

原文链接:https://www.f2er.com/oracle/65265.html

猜你在找的Oracle相关文章