收到一套生產庫的告警信息:
2021-03-20T10:07:49.857362+08:00
Errors in file /u01/app/oracle/diag/rdbms/orcl/orcl13/trace/orcl13_j000_28097.trc:
ORA-12012: 自動執行做業 "SYS"."ORA$AT_OS_OPT_SY_10947" 出錯
ORA-20001: Statistics Advisor: Invalid task name for the current user
ORA-06512: 在 "SYS.DBMS_STATS", line 47214
ORA-06512: 在 "SYS.DBMS_STATS_ADVISOR", line 882
ORA-06512: 在 "SYS.DBMS_STATS_INTERNAL", line 20059
ORA-06512: 在 "SYS.DBMS_STATS_INTERNAL", line 22201
ORA-06512: 在 "SYS.DBMS_STATS", line 47204
數據庫及補丁版本:
SQL> select * from v$version where rownum=1;
BANNER CON_ID
------------------------------------------------------------------------------------------ ----------
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 0
[oracle@rac3 ~]$ opatch lspatches
30138470;Database Oct 2019 Release Update : 12.2.0.1.191015 (30138470)
30122814;OCW OCT 2019 RELEASE UPDATE 12.2.0.1.191015 (30122814)
版本有些舊了,仍是一套3節點的rac,跑web應用。
Oracle Database 12.2 includes a new feature called the Optimizer Statistics Advisor. The goal of the advisor is to analyze how statistics are gathered, validate the quality of statistics already gathered and check the status of auto stats gathering (for example, checking for successful completion). To achieve this, it examines the data dictionary with respect to a set of rules. Where exceptions to the rules are found, findings may be generated and these, in turn, may lead to specific recommendations. The advisor will generate a report that lists findings (with the associated 「broken」 rule), and then list specific recommendations to remedy the situation. Finally, the recommendations can be implemented using a set of actions. Actions can be output in the form of a SQL script or they can be implemented automatically.
12.2中引入了統計信息顧問,用於提升統計信息收集的質量。
查看統計信息任務:
SQL> col owner_name for a15;
SQL> col name for a35;
SQL> select name, ctime, how_created, OWNER_NAME
from sys.wri$_adv_tasks
where name in ('AUTO_STATS_ADVISOR_TASK', 'INDIVIDUAL_STATS_ADVISOR_TASK');
no rows selected
建立任務:
$ sqlplus / as sysdba
SQL> EXEC DBMS_STATS.INIT_PACKAGE();
SQL> col owner_name for a15;
SQL> col name for a35;
SQL> select name, ctime, how_created, OWNER_NAME
from sys.wri$_adv_tasks
where name in ('AUTO_STATS_ADVISOR_TASK', 'INDIVIDUAL_STATS_ADVISOR_TASK');
NAME CTIME HOW_CREATED OWNER_NAME
------------------------------ ------------------- ------------- -----------------
AUTO_STATS_ADVISOR_TASK 2021-03-20 10:47:26 CMD SYS
INDIVIDUAL_STATS_ADVISOR_TASK 2021-03-20 10:47:26 CMD SYS
開啓該任務後可能會致使SYSAUX表空間增加過快,:
SQL> SET LINES 120
SQL> COL OCCUPANT_NAME FORMAT A30
SQL> SELECT OCCUPANT_NAME,SPACE_USAGE_KBYTES FROM V$SYSAUX_OCCUPANTS ORDER BY SPACE_USAGE_KBYTES DESC;
OCCUPANT_NAME SPACE_USAGE_KBYTES
------------------------------ ------------------
SM/ADVISOR 5901376
SM/OPTSTAT 574080
能夠經過如下三種方法處理:
1.修改任務結果過時時間
mos中描述在12.2.0.1中,EXECUTION_DAYS_TO_EXPIRE默認爲UNLIMITED,應用補丁後默認值爲30天。web
For 12.2.0.1, Download & Apply the Patch 30138470 12.2.0.1.191015 (Oct 2019) Database Release Update (DB RU) or above where the above two bug fixes are included. For 18c, Download & Apply the Patch 28822489 18.5.0.0.190115 (Jan 2019) Database Release Update (DB RU) or above where the above two bug fixes are included. For 19c, the bug fixes are included in 19.1.0 itself.sql
SQL> col TASK_NAME format a25
SQL> col parameter_name format a35
SQL> col parameter_value format a20
SQL> set lines 120
SQL> select TASK_NAME, parameter_name, parameter_value
FROM DBA_ADVISOR_PARAMETERS
WHERE task_name = 'AUTO_STATS_ADVISOR_TASK'
and PARAMETER_NAME = 'EXECUTION_DAYS_TO_EXPIRE';
TASK_NAME PARAMETER_NAME PARAMETER_VALUE
------------------------- ----------------------------------- --------------------
AUTO_STATS_ADVISOR_TASK EXECUTION_DAYS_TO_EXPIRE 30
修改成10天
SQL> EXEC DBMS_ADVISOR.SET_TASK_PARAMETER(task_name=> 'AUTO_STATS_ADVISOR_TASK', parameter=> 'EXECUTION_DAYS_TO_EXPIRE', value => 10);數據庫
可能不生效,參考AUTO_STATS_ADVISOR_TASK Not Purging Even Though Setting EXECUTION_DAYS_TO_EXPIRE (Doc ID 2615851.1)api
2.手動清理
sqlplus / as sysdba
exec prvt_advisor.delete_expired_tasks;oracle
3.禁用任務
DECLARE
v_tname VARCHAR2(32767);
BEGIN
v_tname := 'AUTO_STATS_ADVISOR_TASK';
DBMS_STATS.DROP_ADVISOR_TASK(v_tname); ---刪除任務
END;
/
app
exec dbms_stats.set_global_prefs('AUTO_STATS_ADVISOR_TASK','FALSE');
jsp
須要注意,cdb與pdb保留時間或清理任務須要單獨進行ide
相關文檔:ui
AUTO_STATS_ADVISOR_TASK Not Purging Even Though Setting EXECUTION_DAYS_TO_EXPIRE (Doc ID 2615851.1)Recurring ORA-12012, ORA-20001, ORA-06512 In Container Database (DocID 2420581.1)12.2.0.0.2 Automatic Statistics Advisor Job Errors with Statistics Fatal Error (Doc ID 2448436.1)How To Purge Optimizer Statistics Advisor Old Records From 12.2 Onwards (Doc ID 2660128.1)AUTO_STATS_ADVISOR_TASK Running Outside of Maintenance Window (Doc ID 2387110.1)ORA-12012 Error on auto execute of job "SYS"."ORA$AT_OS_OPT_SY_<NN> in 12.2.0 Database version or higher release (like 18c)(Doc ID 2127675.1)How To Set DAYS_TO_EXPIRE and EXECUTION_DAYS_TO_EXPIRE of Automatic Statistics Advisor Task (Doc ID 2544788.1)升級DB到12.2.0.1版本以後,因爲統計信息顧問致使SYSAUX 過快增加 (Doc ID 2440139.1)SYSAUX Tablespace Grows Rapidly After Upgrading Database to 12.2.0.1 Due To Statistics Advisor (Doc ID 2305512.1)How To Disable Optimizer Statistics Advisor From 12.2 Onwards (Doc ID 2686022.1)