在看盖国强的《深入浅出——DBA入门、进阶与诊断案例》的时候发现了这个命令,觉得很好用,于是汇总如下。
一、基本用法
[oracle@root]oerr --help
Usage: oerr facility error

Facility is identified by the prefix string in the error message.
For example, if you get ORA-7300, "ora" is the facility and "7300"
is the error.    So you should type "oerr ora 7300".

If you get LCD-111, type "oerr lcd 111", and so on.
[oracle@root]oerr --info
Usage: oerr facility error

Facility is identified by the prefix string in the error message.
For example, if you get ORA-7300, "ora" is the facility and "7300"
is the error.    So you should type "oerr ora 7300".

If you get LCD-111, type "oerr lcd 111", and so on.
[oracle@root]man oerr
No manual entry for oerr.
[oracle@root]
由上面的公式就可以知道了,oerr使用方法大体如下:
[oracle@root]oerr ora 00600   ----查询ora-00600错误的描述信息
00600, 00000, "internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]"
// *Cause:    This is the generic internal error number for Oracle program
//                 exceptions.    This indicates that a process has encountered an
//                 exceptional condition.
// *Action: Report as a bug - the first argument is the internal error number
[oracle@root]oerr lcd 111       ----查询lcd-111错误的描述信息
111, 0, "value not in legal range [%.*s]"
// *Cause: The value of the parameter is outside bounds
// *Action: Refer to the manual for the bounds on the parameter
[oracle@root]
二、简单的看看oerr命令脚本
1.位置
[oracle@root]which oerr
/data/oracle/oracle/product/10.2.0/bin/oerr
[oracle@root]cd /data/oracle/oracle/product/10.2.0/bin
2.内容
[oracle@root]more oerr
#!/bin/sh
#
# $Id: oerr 28-aug-2001.15:35:03 mkrohan Exp $
# Copyright (c) 1994, 2001, Oracle Corporation.    All rights reserved.    
#
# Usage: oerr facility error
#
# This shell script is used to get the description and the cause and action
# of an error from a message text file when a list of error numbers are passed
# to it.    It supports different language environments and errors from different
# facilities.
#

#
# Turn on script tracing if, requested
[ "$ORACLE_TRACE" = "T" ] && set -x

#
# If ORACLE_HOME is not set, we will not be able to locate
# the message text file.
if [ ! "$ORACLE_HOME" ]
then
                echo "ORACLE_HOME not set.    Please set ORACLE_HOME and try again." 1>&2
                exit 1
fi

#
# Ignore user locale
LC_ALL=C
export LC_ALL

#
# Definition script "constants"
Facilities_File=$ORACLE_HOME/lib/facility.lis

#
# Check script usage
if [ "$#" != "2" ]
then
                exec 1>&2
                echo 'Usage: oerr facility error'
                echo
                echo 'Facility is identified by the prefix string in the error message.'
                echo 'For example, if you get ORA-7300, "ora" is the facility and "7300"'
                echo 'is the error.    So you should type "oerr ora 7300".'
                echo
                echo 'If you get LCD-111, type "oerr lcd 111", and so on.'
                exit 1
fi

#
# Pickup the command line arguments
Facility= "$1"
Code= "$2"

#
# Get the facility information from the oerr data file
Fac_Info=`grep -i "^${Facility}:" $Facilities_File 2> /dev/ null`
if [ $? -ne 0 ]
then
                echo "oerr: Unknown facility '$Facility'" 1>&2
                exit 1
fi

#
# Parse the components from the Fac_Info string into Shell variables
eval `echo "$Fac_Info" | awk -F: '{
                                 if (index ($3, "*") == 0)
                                                printf ( "Facility=%s\n", $3);
                                 else
                                                printf ( "Facility=%s\n", $1);
                                printf ( "Component=%s\n", $2);
                                }'`
if [ -z "$Facility" -o -z "$Component" ]
then
                echo "oerr: Invalid facilities entry '$Fac_Info'" 1>&2
                exit 1
fi

#
# The message file searched is always the US English file
Msg_File=$ORACLE_HOME/$Component/mesg/${Facility}us.msg
if [ ! -r $Msg_File ]
then
                echo "oerr: Cannot access the message file $Msg_File" 1>&2
                exit 1
fi

#
# Search the message file for the error code, printing the message text
# and any following comments which should give the cause and action for
# the error.
awk "BEGIN { found = 0; }
                /^[0]*$Code/        { found = 1; print ; next;}
                /^\/\ //                 { if (found) { print; } next; }
                                                { if (found) { exit; } }" $Msg_File

exit 0
[oracle@root]
3.入口
Msg_File=$ORACLE_HOME/$Component/mesg/${Facility}us.ms
4.在$ORACLE_HOME/rdbms/mesg下有很多.msg文件、.msb文件
在$ORACLE_HOME/mesg下有几个.msb文件,可以发现
1)在$ORACLE_HOME/rdbms/mesg下的文件均为commands test,可以编辑但有部分乱码情况。
[oracle@root]file bbedus.msb
bbedus.msb:         commands text
[oracle@root]file bbedus.msg
bbedus.msg:         commands text
[oracle@root]
2)在$ORACLE_HOME/mesg下的文件为data类型
[oracle@root]file kfodus.msb
kfodus.msb:         data
[oracle@root]
为类似二进制文件,部分字符可以识别,但很多乱码。

5.发现
在$ORACLE_HOME/rdbms/mesg下有很多.msg文件中,可以找到ora-600的错误描述和命令oerr ora 00600一样的结果
[oracle@root]grep 00600 *.msg
kgpus.msg:00600, 00000, "internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]"
ocius.msg:/     Use ORA-00600 messages for internal messages not to be seen by the user.
ocius.msg:/         BETTER    : ORA-00600, internal error, arguments: [ttcxxx], [], [], [], []
ocius.msg:/     Use ORA-00600 messages for internal messages not to be seen by the user.
oraus.msg:/     Use ORA-00600 messages for internal messages not to be seen by the user.
oraus.msg:/         BETTER    : ORA-00600, internal error, arguments: [ttcxxx], [], [], [], []
oraus.msg:/     Use ORA-00600 messages for internal messages not to be seen by the user.
oraus.msg:00600, 00000, "internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]"
oraus.msg:16099, 00000, "internal error ORA-00600 occurred at standby database"
[oracle@root]
6.脚本执行路径
[oracle@root]sh -x oerr ora 00600
+ [    = T ]
+ [ ! /data/oracle/oracle/product/10.2.0 ]
LC_ALL=C
+ export LC_ALL
Facilities_File=/data/oracle/oracle/product/10.2.0/lib/facility.lis    ----调用facility.lis
+ [ 2 != 2 ]
Facility=ora
Code=00600
+ grep -i ^ora: /data/oracle/oracle/product/10.2.0/lib/facility.lis
Fac_Info=ora:rdbms:*:
+ [ 0 -ne 0 ]
+ + awk echo ora:rdbms:*:
-F: {
                                 if (index ($3, "*") == 0)
                                                printf ( "Facility=%s\n", $3);
                                 else
                                                printf ( "Facility=%s\n", $1);
                                printf ( "Component=%s\n", $2);
                                }
+ eval Facility=ora Component=rdbms
Component=rdbms Facility=ora
+ [ -z ora -o -z rdbms ]
Msg_File=/data/oracle/oracle/product/10.2.0/rdbms/mesg/oraus.msg  --定位在oraus.msg内,与上面查相符合
+ [ ! -r /data/oracle/oracle/product/10.2.0/rdbms/mesg/oraus.msg ]
+ awk BEGIN { found = 0; }
                /^[0]*00600/        { found = 1; print ; next;}
                /^\/\ //                 { if (found) { print; } next; }
                                                { if (found) { exit; } } /data/oracle/oracle/product/10.2.0/rdbms/mesg/oraus.msg
00600, 00000, "internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]"
// *Cause:    This is the generic internal error number for Oracle program
//                 exceptions.    This indicates that a process has encountered an
//                 exceptional condition.
// *Action: Report as a bug - the first argument is the internal error number
+ exit 0
[oracle@root]