`

Oracle 11g Automated Maintenance Tasks(原创)

 
阅读更多

Overview
You’re familiar with the concept of automated maintenance tasks from the Oracle Database 10g release. These are jobs that are run automatically by the database to perform maintenance operations. In Oracle Database 10g, you had two automatic maintenance tasks: the Automatic Optimizer Statistics collection and the Automatic Segment Advisor. In Oracle Database 11g, there is a third automatic  maintenance task named Automatic SQL Tuning Advisor. The Automatic SQL Tuning Advisor reviews all high resource consuming SQL statements in the database and provides recommendations to tune them. If you want, you can configure the database so it automatically implements some types of recommendations, such as SQL profiles.This artical will revolve around Automatic Sql Tuning Task to introduce the Automated Maintenance Task.

The Automatic SQL Tuning Advisor runs during the default system maintenance window on a nightly basis, just as the other two automated maintenance tasks do. A maintenance window is an Oracle Scheduler window that’s part of the MAINTENANCE_WINDOW_GROUP. You choose low system load time interval periods for the maintenance windows. A Scheduler resource plan specifies how the database will allocate resources during the duration of a window. When a Scheduler window opens, the database automatically enables the resource plan associated with that window. 

Predefi ned Maintenance Windows

In Oracle Database 10g, you had two maintenance windows: weeknight_window and weekend_window. In Oracle Database 11g, there are seven predefined daily maintenance windows, one for each day of the week. Here are the predefined maintenance windows and their descriptions: 

 

  • MONDAY_WINDOW               Starts 10 P.M. on Monday ends at 2 A.M.
  • TUESDAY_WINDOW              Starts 10 P.M. on Tuesday ends at 2 A.M.
  • WEDNESDAY_WINDOW        Starts 10 P.M. on Wednesday ends at 2 A.M.
  • THURSDAY_WINDOW            Starts 10 P.M. on Thursday ends at 2 A.M.
  • FRIDAY_WINDOW                  Starts 10 P.M. on Friday ends at 2 A.M.
  • SATURDAY_WINDOW            Starts 6 A.M on Saturday ends at 2.A.M
  • SUNDAY_WINDOW                Starts 6 A.M. on Sunday ends at 2 A.M.

Note that the first five windows that run during the weekdays are open for 4 hours and the two weekend maintenance windows are open for 20 hours. By default, all seven daily windows belong to the MAINTENANCE_WINDOW_GROUP group. You can change the time and duration of the daily maintenance windows, create new maintenance windows, or disable or remove the default maintenance windows. 

Managing the Automatic Maintenance Tasks

In Oracle Database 10g, you had to use the DBMS_SCHEDULER package to enable and disable the automatic maintenance tasks. The ENABLE procedure lets you enable an automatic maintenance job such as the automatic statistics collection job, and the DISABLE procedure lets you disable it, if you wanted to manually collect the optimizer statistics. In Oracle Database 11g, use the new DBMS_AUTO_TASK_ ADMIN package to manage the automatic maintenance tasks. You can also use the Enterprise Manager to access the controls for the automatic maintenance tasks. The DBMS_AUTO_TASK_ADMIN package provides a more fine-grained management capability to control the operation of the automatic maintenance tasks. For example, the DBMS_SCHEDULER package only lets you enable or disable an automatic task. With the new DBMS_AUTO_TASK_ADMIN package, you can now disable a task only in selected maintenance windows instead of completely disabling the entire task. Before you start looking into the management of the automatic maintenance tasks, it’s a good idea to get familiar with two new views that provide information you might need to manage the tasks: the DBA_AUTOTASK_CLIENT view and the DBA_AUTOTASK_OPERATION view. The two views contain several identical columns. The DBA_AUTOTASK_CLIENT view shows data for all three automated tasks over a 1-day and a 30-day period. The following query shows details about the automatic maintenance tasks: 

SQL> select client_name, status,
  2  attributes, window_group,service_name
  3  from dba_autotask_client;
CLIENT_NAME            STATUS     ATTRIBUTES
--------------------  --------    ------------------------------
auto optimizer        ENABLED     ON BY DEFAULT, VOLATILE,
statistics collection             SAFE TO KILL
auto space advisor    ENABLED     ON BY DEFAULT, VOLATILE,
                                  SAFE TO KILL
sql tuning advisor    ENABLED     ONCE PER WINDOW,ON BY DEFAULT,
                                  VOLATILE, SAFE TO KILL
You can see that all three of the automatic maintenance tasks are enabled. When the maintenance window opens, Oracle Scheduler automatically creates the automatic maintenance jobs and runs them. If the maintenance window is long, Oracle restarts the automatic optimizer statistics collection and the automatic segment advisor jobs every four hours. However, the automatic SQL advisor job runs only once per maintenance window, as evidenced by the ONCE PER WINDOW attribute for that job. The attributes column shows only ON BY DEFAULT as the value for the other two automated maintenance tasks. Each of the automatic maintenance tasks is called a client and is given a client name. The actual Scheduler job associated with each of the three clients is called an operation and is given an operation name. The following query on the DBA_AUTO_TASK_OPERATION view shows the operation names:

SQL> select client_name, operation_name from
dba_autotask_operation;
CLIENT_NAME                OPERATION_NAME
----------------------     -------------------------
auto optimizer             auto optimizer stats job
stats collection
auto space advisor         auto space advisor job
sql tuning advisor         automatic sql tuning task
Enabling a Maintenance task

Use the DBMS_AUTO_ADMIN.ENABLE procedure to enable a client, operation, target type, or individual target that you previously disabled. Before you can do this, you must first query the DBA_AUTOTASK_CLIENT and the DBA_AUTOTASK_ OPERATION views to find the values for the client_name and operation_ name attributes of the procedure.

SQL> begin
  2  dbms_auto_task_admin.enable
  3  (client_name  => 'sql tuning advisor',
  4  operation     => 'automatic sql tuning task',
  5  window_name   => 'monday_window');
  6* end;
PL/SQL procedure successfully completed.

Disabling a Maintenance Task

By default, all three maintenance jobs will run in every maintenance window. You can use the DBMS_AUTO_ADMIN.DISABLE procedure to disable a client or operation for a specific window, as shown here:

SQL> begin
  2     dbms_auto_task_admin.disable(
  3          client_name => 'sql tuning advisor',
  4          operation   => 'automatic sql tuning task',
  5          window_name => 'monday_window');
  6  end;
  7  /
PL/SQL procedure successfully completed.

Maintenance Window Configuration

Before you configure the window attributes,you need to get the current window attributes by querying DBA_SCHEDULER_WINDOWS view.

SQL> SELECT WINDOW_NAME, DURATION
  2  FROM DBA_SCHEDULER_WINDOWS
  3  WHERE WINDOW_NAME = 'TUESDAY_WINDOW';
WINDOW_NAME      DURATION
---------------- --------------------
TUESDAY_WINDOW   +000 03:00:00

To configure window attributes,you can use following command:

SQL> BEGIN
  2      DBMS_SCHEDULER.set_attribute(
  3      name    =>  'TUESDAY_WINDOW',
  4  attribute => 'DURATION',
  5  value   => numtodsinterval(120,'minute'));
  6  END;
  7  /
PL/SQL procedure successfully completed.

SQL> SELECT WINDOW_NAME, DURATION
  2   FROM DBA_SCHEDULER_WINDOWS
  3   WHERE WINDOW_NAME = 'TUESDAY_WINDOW';
WINDOW_NAME      DURATION
---------------- --------------------
TUESDAY_WINDOW   +000 02:00:00

The other window attributes you can find from following diagram.

Name Description

comments

An optional comment about the window.

duration

The duration of the window.

end_date

The date after which the window will no longer open. If this is set, schedule_name must be NULL.

repeat_interval

A string using the calendaring syntax. PL/SQL date functions are not allowed. If this is set, schedule_name must be NULL. See "Calendaring Syntax" for more information.

resource_plan

The resource plan to be associated with a window. When the window opens, the system will switch to this resource plan. When the window closes, the original resource plan will be restored. If a resource plan has been made active with the force option, no resource plan switch will occur.

Only one resource plan can be associated with a window. It may be NULL or the empty string (""). When it is NULL, the resource plan that is in effect when the window opens stays in effect for the duration of the window. When it is the empty string, the resource manager is disabled for the duration of the window.

schedule_name

The name of a schedule to use with this window. If this is set, start_date, end_date, and repeat_interval must all be NULL.

start_date

The next date and time on which this window is scheduled to open. If this is set, schedule_name must be NULL.

window_priority

The priority of the window. Must be one of 'LOW' (default) or 'HIGH'.

 

Implementing Automatic Maintenance Task

The database doesn’t assign any permanent Scheduler jobs to the three automated maintenance tasks. You therefore can’t manage the jobs with the usual DBMS_ SCHEDULER package. Use the new DBMS_AUTO_TASK_ADMIN package instead to manage the automated maintenance tasks. The new background process, Autotask Background Process (ABP), implements the automated maintenance tasks. The ABP maintains a history of all automated maintenance task executions in the repository that it maintains in the SYSAUX tablespace. Another background process, MMON, spawns (usually when a maintenance window opens), monitors, and restarts the ABP process. The ABP is in charge of converting tasks into Scheduler jobs. The ABP creates a task list for each maintenance job and assigns them a priority. There are three levels of job priorities: urgent, high, and medium. The ABP creates the urgent priority jobs first, after which it creates the high priority and the medium priority jobs. Various Scheduler job classes are also created, in order to map a task’s priority consumer group to the corresponding job class. The ABP is in charge of assigning the jobs to the job classes. The job classes map the individual jobs to a consumer group, based on the job priority. The ABP stores its data in the SYSAUX tablespace. You can view the ABP repository by querying the DBA_AUTOTASK_TASK view.  

Configuring Resource Allocation for Automatic Tasks

You can control the percentage of resources allocated to the maintenance tasks during a given maintenance window. The default resource plan for each predefined maintenance window is the DEFAULT_MAINTENANCE_PLAN. When a maintenance window opens, the DEFAULT_MAINTENANCE_PLAN is activated to control the amount of CPU used by the various automatic maintenance tasks. The three default maintenance tasks run under the ORA$AUTOTASK_SUB_PLAN, which is a subplan of the DEFAULT_MAINTENANCE_PLAN, with all three plans sharing the resources equally. ORA$AUTOTASK_SUB_PLAN gets 25 percent of the resources at the priority level 2. The consumer group SYS_GROUP takes priority in the DEFAULT_MAINTENANCE_PLAN resource plan, getting 100 percent of the level 1 resources in the DEFAULT_MAINTENANCE_PLAN. If you want to change the resource allocation for the automatic tasks in a specific window, you must change the resource allocation to the subplan ORA$AUTOTASK_SUB_PLAN in the resource plan for that window.

Priorities for the various tasks that run during the maintenance window (three tasks altogether) are determined by assigning different consumer groups to the DEFAULT_ MAINTENANCE_PLAN. For example, the new Automatic SQL Tuning task is assigned to the ORA$AUTOTASK_SQL_GROUP consumer group. The Optimizer Statistics Gathering task is part of the ORA$AUTOTASK_STATS_GROUP, and the Segment Advisor task belongs to the ORA$AUTOTASK_SPACE_GROUP.

 

参考至:《McGraw.Hill.OCP.Oracle.Database.11g.New.Features.for.Administrators.Exam.Guide.Apr.2008》

                http://www.oracle-base.com/articles/11g/awr-baseline-enhancements-11gr1.php

                http://www.oracle-base.com/articles/11g/automated-database-maintenance-task-management-11gr1.php

                http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_sched.htm#CIHDAIIH

本文原创,转载请注明出处、作者

如有错误,欢迎指正

邮箱:czmcj@163.com

 

 

0
2
分享到:
评论

相关推荐

    Oracle Solaris 11 Oracle Solaris Administration:Common Tasks-348

    Oracle Solaris 11的“Oracle Solaris Administration: Common Tasks-348”是针对系统管理员的一份指南,旨在教授如何执行日常管理和维护任务。这份文档详细介绍了在Oracle Solaris 11环境下进行系统管理的基础知识...

    Oracle11g 自动维护任务配置与调优

    Oracle 11g引入了一个新的特性——自动维护任务(Automatic Maintenance Tasks),其目的是为了简化数据库管理员(DBA)的工作,并确保数据库能够高效运行。这些任务通常在预定的时间内执行,比如在业务低峰时段进行...

    [Oracle] Oracle Goldengate 11g 开发技巧大全 (英文版)

    [Packt Publishing] Oracle Goldengate 11g 开发技巧大全 (英文版) [Packt Publishing] Oracle Goldengate 11g Complete Cookbook (E-Book) ☆ 图书概要:☆ Over 60 simple and easy-to-follow recipes to ...

    (完整版)Oracle11G日常维护手册.doc

    Oracle 11g 是一款广泛使用的数据库管理系统,其日常维护对于确保系统...此外,使用Oracle的自动维护任务(Automatic Maintenance Tasks),如DBMS_JOB和DBMS_SCHEDULER,可以自动化许多维护过程,减轻管理员的工作负担。

    windows_2008+Oracle_11g_R2_配置完整版_oracle_oracle11_

    在本教程中,我们将深入探讨如何在Windows Server 2008 R2操作系统上配置Oracle Database 11g Release 2(11.2),并使用Data Guard功能来实现数据同步。Oracle数据库是世界上最广泛使用的数据库系统之一,尤其在...

    Oracle® Database Concepts 11r2

    - **Automated Maintenance Tasks**:自动执行常规维护工作,如备份、恢复和优化操作。 - **Automatic SQL Tuning Advisor**:自动分析SQL语句性能,并提出优化建议。 ##### 5. **其他新特性** - **Advanced ...

    Linux_环境下_将oracle10g_升级至10[1].2.0.4

    ### Linux环境下将Oracle 10g升级至10.2.0.4的详细步骤 在Linux环境下将Oracle 10g升级至10.2.0.4是一项较为复杂的技术工作,涉及到多个步骤和注意事项。以下是根据提供的部分文档内容整理出来的详细升级指南。 ##...

    Oracle DBA

    - **Oracle 11G**:Oracle公司发布的一个重要的数据库版本,具有高度的可靠性和安全性,支持高可用性解决方案,并引入了自动诊断资源库等新特性。 #### 二、Oracle 11G 的主要特点与优势 1. **高可用性**:通过...

    oracle10g安装教程.rar

    Oracle 10g是一款经典的关系型数据库管理系统,广泛应用于企业级的数据存储和管理。本教程将详细介绍Oracle 10g的安装步骤,帮助你成功在你的计算机上搭建Oracle数据库环境。 首先,安装前的准备工作至关重要。确保...

    Oracle Database 10g: The Top 20 Features for DBAs

    ### Oracle Database 10g: The Top 20 Features for DBAs #### 1. Flashback Versions Query **Description:** This feature allows database administrators (DBAs) to query the history of data changes within ...

    Oracle Real Application Clusters Installation Guide 11g Release

    在Oracle 11g Release 2 (11.2)中,RAC支持Microsoft Windows x64 (64-Bit)平台,这为Windows环境下的企业级应用提供了强大的集群解决方案。 本指南《Oracle Real Application Clusters Installation Guide 11g ...

    maintenance_tasks:一个用于排队和管理维护任务的Rails引擎

    $ bundle add maintenance_tasks $ rails generate maintenance_tasks:install 生成器创建并运行迁移,以将必要的表添加到数据库中。 它还config/routes.rb维护任务安装在config/routes.rb 。 默认情况下,可以在新...

    Oracle Grid Infrastructure Installation Guide 11g Release 2

    《Oracle Grid Infrastructure Installation Guide 11g Release 2 for Win x64》是Oracle公司为在Windows 64位平台上安装Oracle Grid Infrastructure 11.2版本提供的一份详细指南。Oracle Grid Infrastructure是...

    Oracle Warehouse Builder 11g 教程 Part 2

    Oracle Warehouse Builder 11g 是一个强大的数据仓库构建工具,用于设计、构建和管理数据仓库。本教程的第二部分主要涵盖了如何设置和使用这个工具的基础知识。以下是对教程内容的详细解析: 1. **建立 Oracle ...

    Oracle10g开闭脚本_v1.0.0

    Oracle 10g 开闭脚本是一套用于管理Oracle数据库实例的自动化脚本,主要针对Windows操作系统。在数据库管理员(DBA)的日常工作中,启动、关闭数据库是常见操作,而这些脚本则能极大地提高效率,减少手动操作的错误...

    Oracle® Database New Features Guide

    3. **Automated Maintenance Tasks**: 该版本通过自动化维护任务进一步简化了数据库管理,例如自动备份、在线重做日志归档等。 ### 三、数据整合与分区功能 1. **Partitioning Enhancements**: Oracle 10g引入了...

    ansible-oracle-master

    - **角色(Roles)**:在Ansible中,我们可以创建一个名为“oracle”的角色,包含所有安装Oracle所需的任务(tasks)、变量(variables)、模板(templates)和文件(files)。 - **任务(Tasks)**:在tasks/main...

    2010年10月最新ORACLE OCP培训教程

    Oracle Database 10g: “g” Stands for Grid 1-6 Oracle Database Architecture 1-8 Database Structures 1-9 Oracle Memory Structures 1-10 Process Structures 1-12 Oracle Instance Management 1-13 Server ...

    10g_ASM_新特征.pdf

    相比9i,10g的管理组件更加全面,包括AWR(Automatic Workload Repository)、AMT(Automatic Maintenance Tasks)、ADDM(Automatic Database Diagnostic Monitor)等,这些工具大大提升了数据库的自我监控和自我...

Global site tag (gtag.js) - Google Analytics