用errorstack解决exp导出时使用direct=y参数报错问题

一、问题提出:

在一台数据库主机上做exp,一样的语句,用exp导出,加上direct=y参数就报错:

oracle@gd_rdb01:/rpt_bak$exp report/pwd@gdreport tables=hjm_jfbb_close direct=y log=111.log

Export: Release9.2.0.6.0 - Production on Tue Jan 16 11:31:07 2007

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Connected to: Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
Export done in ZHS16GBK character set and UTF8 NCHAR character set

About to export specified tables via Direct Path ...
EXP-00056: ORACLE error 942 encountered
ORA-00942: table or view does not exist
EXP-00000: Export terminated unsuccessfully

但是这个表是存在的,如果不加direct的参数可以正常导出:

oracle@gd_rdb01:/rpt_bak$exp report/pwd@gdreport tables=hjm_jfbb_close log=222.log

Export: Release9.2.0.6.0 - Production on Tue Jan 16 11:31:37 2007

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.


Connected to: Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
Export done in ZHS16GBK character set and UTF8 NCHAR character set

About to export specified tables via Conventional Path ...
. . exporting table HJM_JFBB_CLOSE 70 rows exported
Export terminated successfully without warnings.
oracle@gd_rdb01:/rpt_bak$

以下是数据库的相关信息:
数据库版本:

SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release9.2.0.6.0- 64bit Production
PL/SQL Release 9.2.0.6.0 - Production
CORE 9.2.0.6.0 Production
TNS for HPUX: Version 9.2.0.6.0 - Production
NLSRTL Version 9.2.0.6.0 - Production


环境变量:
SQL> SELECT NAME,VALUE FROM v$parameter
2 WHERE NAME LIKE '%nls_language%';

NAME VALUE
-------------------- --------------------
nls_language AMERICAN

SQL>

系统环境变量:
oracle@gd_rdb01:/rpt_bak$ env
_=/usr/bin/env
MANPATH=/usr/share/man/%L:/usr/share/man:/usr/contrib/man/%L:/usr/contrib/man:/usr/local/man/%L:/usr/local/man:/opt/upgrade/share/man/%L:/opt/upgrade/share/man:/opt/pd/share/man/%L:/opt/pd/share/man:/opt/pd/share/man/%L:/opt/pd/share/man:/opt/pd/share/man/%L:/opt/pd/share/man:/opt/ignite/share/man/%L:/opt/ignite/share/man:/opt/mx/share/man:/opt/resmon/share/man:/usr/dt/share/man:/opt/samba/man:/opt/gnome/man:/opt/perf/man/%L:/opt/perf/man:/opt/perl/man:/opt/wbem/share/man:/opt/openssl/man:/opt/openssl/prngd/man:/opt/hparray/share/man/%L:/opt/hparray/share/man:/opt/graphics/common/man:/opt/EMCpower/share:/opt/omni/lib/man:/opt/ssh/share/man
SHLIB_PATH=/oracle/app/oracle/product/920/lib32:/oracle/app/oracle/product/920/rdbms/lib32
PATH=/oracle/app/oracle/product/920/bin:/usr/sbin:/usr/ccs/bin:/opt/perl5/bin:/usr/bin:/usr/ccs/bin:/usr/contrib/bin:/opt/hparray/bin:/opt/nettladm/bin:/opt/upgrade/bin:/opt/fcms/bin:/opt/pd/bin:/usr/bin/X11:/usr/contrib/bin/X11:/opt/resmon/bin:/opt/mx/bin:/opt/gnome/bin:/opt/perf/bin:/opt/mozilla:/opt/perl/bin:/opt/wbem/bin:/opt/wbem/sbin:/usr/sbin/diag/contrib:/opt/graphics/common/bin:/opt/ignite/bin:/opt/omni/bin:/opt/ssh/bin:.:/oracle/OPatch:.
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
COLUMNS=132
ORACLE_BASE=/oracle/app/oracle
EDITOR=vi
LOGNAME=oracle
ERASE=^H
ORACLE_SID=gdreport
PS1=oracle@gd_rdb01:$PWD$
SHELL=/usr/bin/sh
TNS_ADM=/oracle/app/oracle/product/920/network/admin
ORA_NLS33=/oracle/app/oracle/product/920/ocommon/nls/admin/data
HOME=/home/oracle
TERM=vt100
LD_LIBRARY_PATH=/oracle/app/oracle/product/920/lib:/lib:/usr/lib:/oracle/app/oracle/product/920/rdbms/lib
ORACLE_HOME=/oracle/app/oracle/product/920
PWD=/rpt_bak
TZ=EAT-8
LINES=49

二、问题分析:

下面用errorstack event来定位问题

alter session set events ‘942 trace name errorstack level 1’;
exp report/pwd@gdreport tables=hjm_jfbb_close log=222.log

同时另看窗口观察alertlog

OS Pid: 10948 executed alter session set events '942 trace name errorstack level 1'
Wed Jan 17 09:44:17 2007
Errors in file /oracle/app/oracle/admin/gdreport/udump/gdreport_ora_11024.trc:
ORA-00942: table or view does not exist
Wed Jan 17 09:46:17 2007
OS Pid: 10948 executed alter session set events '942 trace name errorstack off'

alter session set events ‘942 trace name errorstack off’;

查看trace文件:

/oracle/app/oracle/admin/gdreport/udump/gdreport_ora_11024.trc

Oracle9i Enterprise Edition Release9.2.0.6.0 – 64bit Production

With the Partitioning, OLAP and Oracle Data Mining options

JServer Release9.2.0.6.0 – Production

ORACLE_HOME = /oracle/app/oracle/product/920

System name:HP-UX

Node name: gd_rdb01

Release: B.11.11

Version: U

Machine:9000/800

Instance name: gdreport

Redo thread mounted by this instance: 1

Oracle process number: 11

Unix process pid: 11024, image: oracle@gd_rdb01 (TNS V1-V3)

*** SESSION ID:(100.42947) 2007-01-17 09:44:17.397

*** 2007-01-17 09:44:17.397

ksedmp: internal or fatal error

ORA-00942: table or view does not exist

Current SQL statement for this session:

SELECT COUNT(*) FROM SYS.EXPCOMPRESSEDTAB WHERE TOBJ$ = :1

—– Call Stack Trace —–

calling call entry argument values in hex

location type point (? means dubious value)

——————– ——– ——————– —————————-

ksedmp()+184 ? ksedst() 800003FFBFFFC250 ?

800000010000C18C?

800000010000C18C?

81BC2D681E93E ?

ksddoa()+304 ? ksedmp() 000000000 ? 000000000 ?

……

从trace文件上看可能是SYS.EXPCOMPRESSEDTAB这个表发生了问题,登陆sqlplus查询,发现该视图不存在:

SQL> select * from EXPCOMPRESSEDTAB;

select * from EXPCOMPRESSEDTAB

             *

ERROR at line 1:

ORA-00942: table or view does not exist

三、问题解决:

找到$ORACLE_HOME/rdbms/admin/catexp.sql,查找其中关于EXPCOMPRESSEDTAB的语句,并且执行:

CREATE OR REPLACE VIEW sys.expcompressedtab

   (SPARE1, TOBJ$) AS

       SELECT s.spare1, t.obj#

       FROM  sys.tab$ t, sys.seg$ s

       WHERE t.ts#   = s.ts#

       AND   t.file# = s.file#

       AND   t.block# = s.block#

       AND   s.type# = 5

       AND   (bitand(s.spare1,4096) = 4096 OR bitand(s.spare1,2048) = 2048)

/

GRANT SELECT ON sys.expcompressedtab TO PUBLIC;

 

SQL> host
oracle@gd_rdb01:/oracle/app/oracle/admin/gdreport/bdump$ hjm_jfbb_close file=kkk.dmp log=nnn.log direct=y <

Export: Release9.2.0.6.0 - Production on Wed Jan 17 12:06:00 2007

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.


Connected to: Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
Export done in ZHS16GBK character set and UTF8 NCHAR character set

About to export specified tables via Direct Path ...
. . exporting table HJM_JFBB_CLOSE 70 rows exported
Export terminated successfully without warnings.

=====================================================================
四、alter system set events相关知识:

格式:alter system|session set events '[eventnumber|immediate] trace name eventname [forever] [, level levelnumber] : .......'

通过:符号,可以连续设置多个事件,也可以通过连续使用alter session set events来设置多个事件。

格式说明:eventnumber指触发dump的事件号,事件号可以是Oracle错误号(出现相应错误时跟踪指定的事件)或oralce内部事件号,内部事件号在10000到10999之间,不能与immediate关键字同用。

immediate关键字表示命令发出后,立即将指定的结构dump到跟踪文件中,这个关键字只用在alter session语句中,并且不能与eventnumber、forever关键字同用。

trace name是关键字。

eventname指事件名称(见后面),即要进行dump的实际结构名。若eventname为context,则指根据内部事件号进行跟踪。

forever关键字表示事件在实例或会话的周期内保持有效状态,不能与immediate同用。

level为事件级别关键字。但在dump错误栈(errorstack)时不存在级别。

levelnumber表示事件级别号,一般从1到10,1表示只dump结构头部信息,10表示dump结构的所有信息。

1、buffers事件:dump SGA缓冲区中的db buffer结构

alter session set events 'immediate trace name buffers level 1'; --表示dump缓冲区的头部。

2、blockdump事件:dump数据文件、索引文件、回滚段文件结构

alter session set events 'immediate trace name blockdump level 66666'; --表示dump块地址为6666的数据块。

在Oracle 8以后该命令已改为:

alter system dump datafile 11 block 9; --表示dump数据文件号为11中的第9个数据块。

3、controlf事件:dump控制文件结构

alter session set events 'immediate trace name controlf level 10'; --表示dump控制文件的所有内容。

4、locks事件:dump LCK进程的锁信息

alter session set events 'immediate trace name locks level 5';

5、redohdr事件:dump redo日志的头部信息

alter session set events 'immediate trace name redohdr level 1'; --表示dump redo日志头部的控制文件项。

alter session set events 'immediate trace name redohdr level 2'; --表示dump redo日志的通用文件头。

alter session set events 'immediate trace name redohdr level 10'; --表示dump redo日志的完整文件头。

注意:redo日志的内容dump可以采用下面的语句:

alter system dump logfile 'logfilename';

6、loghist事件:dump控制文件中的日志历史项

alter session set events 'immediate trace name loghist level 1'; --表示只dump最早和最迟的日志历史项。

levelnumber大于等于2时,表示2的levelnumber次方个日志历史项。

alter session set events 'immediate trace name loghist level 4'; --表示dump 16个日志历史项。

7、file_hdrs事件:dump所有数据文件的头部信息

alter session set events 'immediate trace name file_hdrs level 1'; --表示dump所有数据文件头部的控制文件项。

alter session set events 'immediate trace name file_hdrs level 2'; --表示dump所有数据文件的通用文件头。

alter session set events 'immediate trace name file_hdrs level 10'; --表示dump所有数据文件的完整文件头。

8、errorstack事件:dump错误栈信息,通常Oracle发生错误时前台进程将得到一条错误信息,但某些情况下得不到错误信息,可以采用这种方式得到Oracle错误。

alter session set events '604 trace name errorstack forever'; --表示当出现604错误时,dump错误栈和进程栈。

9、systemstate事件:dump所有系统状态和进程状态

alter session set events 'immediate trace name systemstate level 10'; --表示dump所有系统状态和进程状态。

10、coalesec事件:dump指定表空间中的自由区间

levelnumber以十六进制表示时,两个高位字节表示自由区间数目,两个低位字节表示表空间号,如0x00050000表示dump系统表空间中的5个自由区间,转换成十进制就是327680,即:

alter session set events 'immediate trace name coalesec level 327680';

11、processsate事件:dump进程状态

alter session set events 'immediate trace name processsate level 10';

12、library_cache事件:dump library cache信息

alter session set events 'immediate trace name library_cache level 10';

13、heapdump事件:dump PGA、SGA、UGA中的信息

alter session set events 'immediate trace name heapdump level 1';

14、row_cache事件:dump数据字典缓冲区中的信息

alter session set events 'immediate trace name row_cache level 1';

相关文章

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据