Oracle运维笔记之EXPDP报错ORA-39077和ORA-31638

客户的生产库在做日常数据expdp导出时报错:

ORA-31626: job does not exist
ORA-31638: cannot attach to job SYS_EXPORT_TABLE_01 for user SYS
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.KUPV$FT_INT", line 428
ORA-39077: unable to subscribe agent KUPC$A_1_191136568928000 to queue "KUPC$C_1_20140807191136"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.KUPC$QUE_INT", line 250
ORA-06502: PL/SQL: numeric or value error: character string buffer too small

MOS上的文档16928674.8和2383405.1,指出了该错误是一个BUG,其原因是每次datapump命令执行后,序列SYS.AQ$_KUPC$DATAPUMP_QUETAB_1_N都会增加,如果多次执行后,SYS.AQ$_KUPC$DATAPUMP_QUETAB_1_N的值超过6位数,那么expdp就会报错ORA-39077和ORA-31638。
Oracle运维笔记之EXPDP报错ORA-39077和ORA-31638

同时文档中也给出了解决方案,那就是打补丁,该补丁的作用是在SYS.AQ$_KUPC$DATAPUMP_QUETAB_1_N的值增长到6位数时,重建该序列,expdp或者impdp可能会报出同样的错误,再次执行命令即可。
Oracle运维笔记之EXPDP报错ORA-39077和ORA-31638

根据补丁的描述,官方的方法是重建序列SYS.AQ$_KUPC$DATAPUMP_QUETAB_1_N,那么我们也可以通过手工重建的方式来规避错误,以下是重建语句,重建后的sequence的参数和原来保持一致。

drop sequence AQ$_KUPC$DATAPUMP_QUETAB_1_N;
create sequence AQ$_KUPC$DATAPUMP_QUETAB_1_N minvalue 1 maxvalue 9999999999999999999999999999 start with 1 increment by 1 cache 20 nocycle;

接下来做个测试,来验证手工重建序列是否有效。
1.查看当前的序列值,当前值是175

select AQ$_KUPC$DATAPUMP_QUETAB_1_N.nextval from dual;

nextval

  175

2.做一个简单的expdp导出

expdp "'" / as sysdba"'" directory=dump schemas=scott dumpfile=scott.dmp logfile=scott.log

3.再次查看序列值,发现是增加了,现在是182

select AQ$_KUPC$DATAPUMP_QUETAB_1_N.nextval from dual;

nextval

  182

4.修改序列值,让大小接近999999

alter sequence AQ$_KUPC$DATAPUMP_QUETAB_1_N increment by 999816;
select AQ$_KUPC$DATAPUMP_QUETAB_1_N.nextval from dual;

nextval

999998

5.再次执行expdp命令,发现的确是报错了,ORA-39077和ORA-31638

expdp "'" / as sysdba"'" directory=dump schemas=scott dumpfile=scott.dmp logfile=scott.log
ORA-31626: job does not exist
ORA-31638: cannot attach to job SYS_EXPORT_SCHEMA_01 for user SYS
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.KUPV$FT_INT", line 428
ORA-39077: unable to subscribe agent KUPC$A_1_174305386572000 to queue "KUPC$C_1_20201103174305"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.KUPC$QUE_INT", line 254
ORA-06502: PL/SQL: numeric or value error: character string buffer too small

6.接下来重建序列

drop sequence AQ$_KUPC$DATAPUMP_QUETAB_1_N;
create sequence AQ$_KUPC$DATAPUMP_QUETAB_1_N minvalue 1 maxvalue 9999999999999999999999999999 start with 1 increment by 1 cache 20 nocycle;

再次执行expdp导出,这次导出成功,说明重建也是可以解决ORA-39077和ORA-31638报错的,但是还是推荐采用官方方法,也就是打补丁来解决这个问题,而且补丁不大,可以回退。

上一篇:Android ant自动打包脚本:自动替换友盟渠道、版本号、包名


下一篇:Android--ActivityLiving生命周期