一个测试环境的Oracle 12.2.0.1数据库后台alert不断报出以下错误信息:
Errors in file /d12/app/oracle/diag/rdbms/test/test/trace/test_j001_4981.trc:
ORA-12012: error on auto execute of job "SYS"."ORA$AT_OS_OPT_SY_21"
ORA-20001: Statistics Advisor: Invalid task name for the current user
ORA-06512: at "SYS.DBMS_STATS", line 47207
ORA-06512: at "SYS.DBMS_STATS_ADVISOR", line 882
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 20059
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 22201
ORA-06512: at "SYS.DBMS_STATS", line 47197
看了一下报错频率,大概是每隔10分钟报一次。该库是12.2.0.1的CDB,其中还有两个pdb。
从MOS找到一篇对应的文章:ORA-12012 Error on auto execute of job "SYS"."ORA$AT_OS_OPT_SY_<NN> in 12.2 Database (Doc ID 2127675.1)
分析可能是在建库的时候没有执行dbms_stats.init_package()
$ sqlplus / as sysdba
SQL> EXEC dbms_stats.init_package();
PL/SQL procedure successfully completed.
SQL> column name format A35
SQL> set linesize 120
SQL>
SQL> select name, ctime, how_created
2 from sys.wri$_adv_tasks
3 where owner_name = 'SYS'
4 and name in ('AUTO_STATS_ADVISOR_TASK','INDIVIDUAL_STATS_ADVISOR_TASK');
NAME CTIME HOW_CREATED
----------------------------------- --------- ------------------------------
AUTO_STATS_ADVISOR_TASK 17-JUN-17 CMD
INDIVIDUAL_STATS_ADVISOR_TASK 17-JUN-17 CMD
执行结束后,观察日志,不再继续报错!