11g: Scheduler Maintenance Tasks or Autotasks [ID 756734.1]

This document provides information about the Automated Maintenance Tasks or AUTOTASK jobs in Oracle 11g, focusing on their introduction, implementation, and key differences compared to Oracle 10g. It also discusses the new setup for system-generated maintenance jobs and the changes in visibility and execution of these tasks.
11g: Scheduler Maintenance Tasks or Autotasks [ID 756734.1]

修改时间 14-SEP-2011     类型 BULLETIN     状态 PUBLISHED

In this Document
  Purpose
  Scope and Application
  11g: Scheduler Maintenance Tasks or Autotasks
     Introduction
     Implementation
     Summary of changes between 10g and 11g :
     Related views :
  References


Applies to:

Oracle Server - Enterprise Edition - Version: 11.1.0.6 to 11.2.0.2 - Release: 11.1 to 11.2
Information in this document applies to any platform.
Oracle Server Enterprise Edition - Version: 11.1.0.6

Purpose

This bulletin gives more information about the Automated Maintenance Tasks or AUTOTASK jobs which are a new setup in 11g for certain System generated maintenance jobs.

It indentifies some key differences between 10g and 11g related to the Maintenance Tasks.

Scope and Application

This is relevant for Oracle 11g and intended for Oracle DBAs and support analysts.

11g: Scheduler Maintenance Tasks or Autotasks

Introduction


Oracle 11g Database has three predefined automated maintenance tasks:

â–  Automatic Optimizer Statistics Collection
Collects optimizer statistics for all schema objects in the database for which there
are no statistics or only stale statistics. The statistics gathered by this task are used
by the SQL query optimizer to improve the performance of SQL execution.
â–  Automatic Segment Advisor
Identifies segments that have space available for reclamation, and makes recommendations
on how to defragment those segments. You can also run the Segment Advisor manually
to obtain more up-to-the-minute recommendations or to obtain recommendations on
segments that the Automatic Segment Advisor did not examine for possible space reclamation.
â–  Automatic SQL Tuning Advisor
Examines the performance of high-load SQL statements, and makes recommendations
on how to tune those statements. You can configure this advisor to automatically
implement SQL profile recommendations.
Note 466920.1 - 11g New Feature: Health Monitor

Note 755838.1 - New 11g Default Jobs

Implementation


In Oracle10g they were created as separate jobs and visible in DBA_SCHEDULER_JOBS.JOB_NAME.

This has changed in Oracle 11g. The related view is DBA_AUTOTASK_WINDOW_CLIENTS.
The jobs are now only visible in DBA_SCHEDULER_JOBS with their system generated name once they are really executed.

SQL> desc DBA_AUTOTASK_WINDOW_CLIENTS
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 WINDOW_NAME                               NOT NULL VARCHAR2(30)
 WINDOW_NEXT_TIME                                   TIMESTAMP(6) WITH TIME ZONE
 WINDOW_ACTIVE                                      VARCHAR2(5)
 AUTOTASK_STATUS                                    VARCHAR2(8)
 OPTIMIZER_STATS                                    VARCHAR2(8)
 SEGMENT_ADVISOR                                    VARCHAR2(8)
 SQL_TUNE_ADVISOR                                   VARCHAR2(8)
 HEALTH_MONITOR                                     VARCHAR2(8)

 select * from DBA_AUTOTASK_WINDOW_CLIENTS;

WINDOW_NAME
------------------------------
WINDOW_NEXT_TIME
---------------------------------------------------------------------------
WINDO AUTOTASK OPTIMIZE SEGMENT_ SQL_TUNE HEALTH_M
----- -------- -------- -------- -------- --------
MONDAY_WINDOW
08-DEC-08 10.00.00.000000 PM EUROPE/VIENNA
FALSE ENABLED ENABLED ENABLED ENABLED DISABLED

...

SUNDAY_WINDOW
07-DEC-08 06.00.00.000000 AM EUROPE/VIENNA
FALSE ENABLED ENABLED ENABLED ENABLED DISABLED
7 rows selected.


To enable or disable ALL automated maintenance tasks for all windows, call the ENABLE or DISABLE procedure with no arguments.
SQL> execute DBMS_AUTO_TASK_ADMIN.DISABLE;

To disable a specific maintenance task, use the DISABLE procedure, as follows:
SQL> BEGIN
       dbms_auto_task_admin.disable(
       client_name => 'sql tuning advisor',
       operation => NULL,
       window_name => NULL);
     END; 
    /

To enable this specific maintenance task again, use the ENABLE procedure, as follows:

SQL> BEGIN
       dbms_auto_task_admin.enable(
       client_name => 'sql tuning advisor',
       operation => NULL,
       window_name => NULL);
     END;
     /


The task names to use for the client_name argument are listed in the DBA_AUTOTASK_CLIENT database dictionary view.

Examples :
auto optimizer stats collection
auto space advisor
sql tuning advisor


Another difference is the predefined Scheduler Windows :
  •   Oracle10g : WEEKNIGHT_WINDOW and WEEKEND_WINDOW
  •   Oracle11g : MONDAY_WINDOW .... SUNDAY_WINDOW. 

The WEEKNIGHT_WINDOW and WEEKEND_WINDOW are still there for backwards compatibility.

The duration times when the windows are open have changed in 11g. The Monday-Friday are from 10:00PM till 02:00AM and Saturday-Sunday are from 06:00AM  till 02:00AM.

You can adjust the predefined maintenance windows to a time suitable to your database environment using the DBMS_SCHEDULER.SET_ATTRIBUTE procedure.

Example: The following script moves the WEEKNIGHT_WINDOW to midnight to 8 a.m. every weekday morning (duration of the window is unchanged at 8 hours):
  
EXECUTE DBMS_SCHEDULER.SET_ATTRIBUTE( 'WEEKNIGHT_WINDOW', 'repeat_interval', 'freq=daily;byday=MON, TUE, WED, THU, FRI;byhour=0;byminute=0;bysecond=0');

Each weekday window also has a pre-defined Resource Plan called DEFAULT_MAINTENANCE_PLAN, which will become active once the related window opens. This is another difference between 10g and 11g.


SQL> select window_name, resource_plan from dba_scheduler_windows;

WINDOW_NAME                    RESOURCE_PLAN
------------------------------ ------------------------------
MONDAY_WINDOW                  DEFAULT_MAINTENANCE_PLAN
TUESDAY_WINDOW                 DEFAULT_MAINTENANCE_PLAN
WEDNESDAY_WINDOW               DEFAULT_MAINTENANCE_PLAN
THURSDAY_WINDOW                DEFAULT_MAINTENANCE_PLAN
FRIDAY_WINDOW                  DEFAULT_MAINTENANCE_PLAN
SATURDAY_WINDOW                DEFAULT_MAINTENANCE_PLAN
SUNDAY_WINDOW                  DEFAULT_MAINTENANCE_PLAN
WEEKNIGHT_WINDOW
WEEKEND_WINDOW

9 rows selected.


SQL> select * from dba_rsrc_plans where plan='DEFAULT_MAINTENANCE_PLAN'
PLAN_ID PLAN NUM_PLAN_DIRECTIVES
---------- ------------------------------ -------------------
CPU_METHOD MGMT_METHOD
------------------------------ ------------------------------
ACTIVE_SESS_POOL_MTH PARALLEL_DEGREE_LIMIT_MTH
------------------------------ ------------------------------
QUEUEING_MTH SUB
------------------------------ ---
COMMENTS
--------------------------------------------------------------------------------
STATUS MAN
------------------------------ ---
11187 DEFAULT_MAINTENANCE_PLAN 4
EMPHASIS EMPHASIS
ACTIVE_SESS_POOL_ABSOLUTE PARALLEL_DEGREE_LIMIT_ABSOLUTE
FIFO_TIMEOUT NO
Default plan for maintenance windows that prioritizes SYS_GROUP operations and a
llocates the remaining 5% to diagnostic operations and 25% to automated maintena
nce operations.
YES


SQL> select * from DBA_RSRC_PLAN_DIRECTIVES where plan='DEFAULT_MAINTENANCE_PLAN';

PLAN GROUP_OR_SUBPLAN TYPE
------------------------------ ------------------------------ --------------
CPU_P1 CPU_P2 CPU_P3 CPU_P4 CPU_P5 CPU_P6 CPU_P7
---------- ---------- ---------- ---------- ---------- ---------- ----------
CPU_P8 MGMT_P1 MGMT_P2 MGMT_P3 MGMT_P4 MGMT_P5 MGMT_P6
---------- ---------- ---------- ---------- ---------- ---------- ----------
MGMT_P7 MGMT_P8 ACTIVE_SESS_POOL_P1 QUEUEING_P1 PARALLEL_DEGREE_LIMIT_P1
---------- ---------- ------------------- ----------- ------------------------
SWITCH_GROUP SWITC SWITCH_TIME SWITCH_IO_MEGABYTES
------------------------------ ----- ----------- -------------------
SWITCH_IO_REQS SWITC MAX_EST_EXEC_TIME UNDO_POOL MAX_IDLE_TIME
-------------- ----- ----------------- ---------- -------------
MAX_IDLE_BLOCKER_TIME SWITCH_TIME_IN_CALL
--------------------- -------------------
COMMENTS
--------------------------------------------------------------------------------
STATUS MAN
------------------------------ ---
DEFAULT_MAINTENANCE_PLAN SYS_GROUP CONSUMER_GROUP
100 0 0 0 0 0 0
0 100 0 0 0 0 0
0 0
FALSE
FALSE

Directive for system operations
NO

DEFAULT_MAINTENANCE_PLAN OTHER_GROUPS CONSUMER_GROUP
0 70 0 0 0 0 0
0 0 70 0 0 0 0
0 0
FALSE
FALSE

Directive for all other operations
NO

DEFAULT_MAINTENANCE_PLAN ORA$AUTOTASK_SUB_PLAN PLAN
0 25 0 0 0 0 0
0 0 25 0 0 0 0
0 0
FALSE
FALSE

Directive for automated maintenance tasks
NO

DEFAULT_MAINTENANCE_PLAN ORA$DIAGNOSTICS CONSUMER_GROUP
0 5 0 0 0 0 0
0 0 5 0 0 0 0
0 0
FALSE
FALSE

Directive for automated diagnostic tasks
NO

Summary of changes between 10g and 11g :

Subject
10g
11g
Jobs
Separate jobs in DBA_SCHEDULER_JOBSAUTOTASKS has a naming prefix 'ORA$AT' and are only visible as a job once executed
Maintenance Window
2 windows, WEEKNIGHT and WEEKEND
Each day has its own window
Resource manager
Not enabled per default
Pre-defined Resource Plan for every weekday window





Related views :

DBA_AUTOTASK_CLIENT
DBA_AUTOTASK_CLIENT_HISTORY
DBA_AUTOTASK_CLIENT_JOB
DBA_AUTOTASK_JOB_HISTORY
DBA_AUTOTASK_OPERATION
DBA_AUTOTASK_SCHEDULE
DBA_AUTOTASK_TASK
DBA_AUTOTASK_WINDOW_CLIENTS
DBA_AUTOTASK_WINDOW_HISTORY

References

NOTE:466920.1 - 11g New Feature: Health monitor
NOTE:755838.1 - New 11g Default Jobs
11g Database Administrator's Guide : Chapter 24
NOTE:858852.1 - DBA_AUTOTASK_TASK and DBA_AUTOTASK_CLIENT Shows Different Status For Auto Optimizer Stats Collection

显示相关信息 相关内容


产品
  • Oracle Database Products > Oracle Database > Oracle Database > Oracle Server - Enterprise Edition
关键字
DBA_SCHEDULER_JOBS; DBA_SCHEDULER_WINDOWS; SCHEDULER; SQL TUNING ADVISOR; STATISTICS GATHERING
soft kill task:1468277_17691070, process id:240547, cmd:sudo -u root kill 240547 [ERROR] 2025-03-14 05:39:01.462 +0800 - kill attempt failed java.io.IOException: Cannot run program "pstree": error=2, No such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at org.apache.dolphinscheduler.plugin.task.api.AbstractShell.runCommand(AbstractShell.java:144) at org.apache.dolphinscheduler.plugin.task.api.AbstractShell.run(AbstractShell.java:124) at org.apache.dolphinscheduler.plugin.task.api.ShellExecutor.execute(ShellExecutor.java:130) at org.apache.dolphinscheduler.plugin.task.api.ShellExecutor.execCommand(ShellExecutor.java:105) at org.apache.dolphinscheduler.plugin.task.api.ShellExecutor.execCommand(ShellExecutor.java:87) at org.apache.dolphinscheduler.plugin.task.api.utils.OSUtils.exeShell(OSUtils.java:78) at org.apache.dolphinscheduler.plugin.task.api.utils.OSUtils.exeCmd(OSUtils.java:67) at org.apache.dolphinscheduler.plugin.task.api.ProcessUtils.getPidsStr(ProcessUtils.java:92) at org.apache.dolphinscheduler.plugin.task.api.AbstractCommandExecutor.hardKill(AbstractCommandExecutor.java:310) at org.apache.dolphinscheduler.plugin.task.api.AbstractCommandExecutor.cancelApplication(AbstractCommandExecutor.java:274) at org.apache.dolphinscheduler.plugin.task.python.PythonTask.cancel(PythonTask.java:129) at org.apache.dolphinscheduler.server.worker.runner.WorkerTaskExecuteRunnable.cancelTask(WorkerTaskExecuteRunnable.java:133) at org.apache.dolphinscheduler.server.worker.runner.WorkerTaskExecuteRunnable.afterThrowing(WorkerTaskExecuteRunnable.java:119) at org.apache.dolphinscheduler.server.worker.runner.DefaultWorkerDelayTaskExecuteRunnable.afterThrowing(DefaultWorkerDelayTaskExecuteRunnable.java:59) at org.apache.dolphinscheduler.server.worker.runner.WorkerTaskExecuteRunnable.run(WorkerTaskExecuteRunnable.java:180) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131) at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:74) at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750) Caused by: java.io.IOException: error=2, No such file or directory at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.<init>(UNIXProcess.java:247) at java.lang.ProcessImpl.start(ProcessImpl.java:134) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 22 common frames omitted
03-15
<think>好的,我现在要解决用户提供的错误信息。首先,我需要理解问题所在。用户尝试执行一个软终止任务(soft kill task),但失败了。错误信息显示无法运行程序"pstree",系统找不到该文件或目录。这看起来像是系统缺少了某个必要的工具。 首先,我需要确认pstree命令的作用。pstree通常用于显示进程树,以树状图的形式展示进程之间的关系。在终止进程时,可能需要使用pstree来找到所有相关的子进程,以确保彻底终止目标进程及其子进程。如果系统中没有安装pstree,那么执行相关命令时就会报错。 接下来,查看错误日志中的Java异常堆栈。错误发生在尝试启动进程执行pstree时,抛出IOException,指出没有这样的文件或目录。这说明执行环境中的系统路径里没有pstree这个可执行文件,或者该命令没有安装。 然后,我需要考虑pstree属于哪个软件包。在基于Debian的系统(如Ubuntu)中,pstree通常包含在psmisc包中。而在Red Hat系列的系统(如CentOS)中,可能也是同样的包。用户需要安装这个包才能使用pstree命令。 此外,用户执行的命令是“sudo -u root kill 240547”,也就是以root身份终止进程240547。但可能由于权限问题,或者进程本身的状态(如僵尸进程),导致kill命令未能成功。不过主要的错误还是pstree缺失,所以先解决这个问题。 解决方案步骤应该是: 1. 安装psmisc包,以获取pstree命令。 2. 确保安装后pstree在系统的PATH环境变量中,可以通过which pstree来验证。 3. 重新执行原来的终止任务,看是否问题解决。 另外,用户可能是在Apache DolphinScheduler的任务中遇到这个问题,因为堆栈跟踪中提到了org.apache.dolphinscheduler的类。DolphinScheduler在执行任务时可能需要调用系统命令,所以确保所有依赖的命令都已安装。 还需要检查用户是否有权限安装软件包,可能需要使用sudo权限来安装psmisc。安装命令例如: - Ubuntu/Debian: sudo apt-get install psmisc - CentOS/RHEL: sudo yum install psmisc 安装完成后,再次运行任务,应该就不会出现找不到pstree的错误了。如果问题仍然存在,可能需要检查环境变量或路径设置,或者查看DolphinScheduler的配置是否正确。 总结来说,主要问题是缺少pstree命令,安装对应的软件包即可解决。同时,检查权限和进程状态,确保kill命令能够正确执行。</think>### 问题分析: 您遇到的错误源于执行`pstree`命令时系统提示**文件或目录不存在**,具体表现为: ```java java.io.IOException: Cannot run program "pstree": error=2, No such file or directory ``` 该错误表明系统中未安装`pstree`工具,而任务执行流程依赖此命令来终止进程。 --- ### 分步解决方案: 1. **确认缺失的依赖工具** - `pstree` 是一个用于显示进程树关系的命令行工具,属于`psmisc`软件包的一部分。 - 若系统未安装`psmisc`,则无法调用`pstree`,导致任务终止失败。 2. **安装 psmisc 软件包** - **Debian/Ubuntu 系统**: ```bash sudo apt-get update && sudo apt-get install -y psmisc ``` - **RHEL/CentOS 系统**: ```bash sudo yum install -y psmisc ``` 3. **验证安装结果** - 执行命令检查`pstree`是否可用: ```bash which pstree # 应输出路径,如 /usr/bin/pstree ``` 4. **检查权限问题** - 确保执行任务的用户(如DolphinScheduler Worker)拥有调用`pstree`的权限。 - 若使用容器化部署,需在容器内安装`psmisc`。 5. **重试任务终止操作** - 安装完成后,重新触发任务终止流程,观察是否仍报错。 --- ### 附加建议: - **进程终止逻辑优化**: - 若`pstree`不可用,可改用`pgrep -P <PID>`递归查找子进程。 - 示例脚本: ```bash kill_children() { local parent_pid=$1 for child_pid in $(pgrep -P $parent_pid); do kill_children $child_pid kill -9 $child_pid done } kill_children 240547 kill -9 240547 ``` - **检查环境变量**: - 确保`/usr/bin`或`/bin`等目录在`$PATH`环境变量中。 --- ### 错误根本原因: DolphinScheduler 的 `ProcessUtils.getPidsStr()` 方法依赖`pstree`来定位进程树,缺少此工具会导致**软终止(soft kill)**流程中断。建议在部署DolphinScheduler时预装必要依赖。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值