less12 proactive

32
12 Copyright © 2007, Oracle. All rights reserved. Database Maintenance

Upload: vivaankumar

Post on 06-May-2015

930 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Less12 Proactive

12Copyright © 2007, Oracle. All rights reserved.

Database Maintenance

Page 2: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 2

Objectives

After completing this lesson, you should be able to:

• Manage optimizer statistics

• Manage the Automatic Workload Repository (AWR)

• Use the Automatic Database Diagnostic Monitor (ADDM)

• Use advisors and checkers

• Set alert thresholds

• Use server-generated alerts

• Use automated tasks

Page 3: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 3

Database Maintenance

AutomaticWorkload

Repository

Advisoryframework

Automatedtasks

Server alerts

Data warehouseof the database

Automatic collection of important statistics

Direct memoryaccess

Automatic Proactive

Efficient

AutomaticDiagnostic Repository

Reactive

Critical errors

Page 4: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 4

Terminology

• Automatic Workload Repository (AWR): Infrastructure for data gathering, analysis, and solutions recommendations

• Baseline: A set of AWR snapshots for performance comparison

• Metric: Rate of change in a cumulative statistic

• Statistics: Data collections used for performance monitoring or SQL optimization

• Threshold: A boundary value againstwhich metric values are compared

Page 5: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 5

Oracle Optimizer: Overview

The Oracle optimizer determines the most efficient execution plan and is the most important step in the processing of any SQL statement.

The optimizer:

• Evaluates expressions and conditions

• Uses object and system statistics

• Decides how to access the data

• Decides how to join tables

• Determines the most efficient path

Page 6: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 6

Optimizer Statistics

Optimizer statistics are:

• A snapshot at a point in time

• Persistent across instance restarts

• Collected automaticallySQL> SELECT COUNT(*) FROM hr.employees;

COUNT(*)

----------

214

SQL> SELECT num_rows FROM dba_tables

2 WHERE owner='HR' AND table_name = 'EMPLOYEES';

NUM_ROWS

----------

107

Page 7: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 7

Using the Manage Optimizer Statistics Page

Page 8: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 8

Gathering Optimizer Statistics Manually

Page 9: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 10

Statistic Levels

STATISTICS_LEVEL

BASIC TYPICAL ALL

Recommendeddefault value

Additional statisticsfor manual

SQL diagnostics

Self-tuningcapabilities disabled

Page 10: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 11

Preferences for Gathering Statistics

CASCADE

DEGREE

ESTIMATE_PERCENT

NO_INVALIDATE

METHOD_OPT

GRANULARITY

INCREMENTAL

PUBLISH

STALE_PERCENT

DATABASE LEVEL

SCHEMA LEVEL

TABLE LEVEL

STATEMENT LEVEL

GLOBAL LEVEL

PREFERENCES

SCOPE

exec dbms_stats.set_table_prefs('SH','SALES','STALE_PERCENT','13');

DBADBMS_STATS

set | get | delete | export | import

Optimizerstatisticsgathering

task

Page 11: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 13

Automatic Workload Repository (AWR)

• Built-in repository of performance information

• Snapshots of database metrics taken every 60 minutes and retained for eight days

• Foundation for all self-management functions

MMONIn-memorystatistics

Snapshots

AWRSGA

60 minutes

Page 12: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 14

AWR Infrastructure

SGA

V$ DBA_*

ADDM Self-tuningcomponent

Self-tuningcomponent

…Internal clients

External clientsEM SQL*Plus …

Efficientin-memorystatisticscollection

AWRsnapshotsMMON

Page 13: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 15

Baselines

DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE ( - start_snap_id IN NUMBER, end_snap_id IN NUMBER, baseline_name IN VARCHAR2);

Relevant periodin the past

Page 14: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 16

Enterprise Manager and the AWR

Page 15: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 17

Managing the AWR

• Retention period– Default: Eight days– Consider storage needs

• Collection interval– Default: 60 minutes– Consider storage needs and performance impact

• Collection level– Basic (disables most ADDM functionality) – Typical (recommended)– All (adds additional SQL tuning information to

snapshots)

Page 16: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 18

Automatic Database Diagnostic Monitor (ADDM)

• Runs after each AWR snapshot

• Monitors the instance; detects bottlenecks

• Stores results in the AWR

Snapshots

ADDM

AWR

EMADDM results

Page 17: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 19

ADDM Findings

1

2

3

Page 18: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 20

ADDM Recommendations

Page 19: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 21

Advisory Framework

ADDMSQL Tuning

Advisor

SQL Access Advisor

Memory Advisor

Space

SGA

Advisor

Segment Advisor

Undo Advisor

Buffer Cache

Advisor

Shared Pool

Advisor

Backup MTTR Advisor

Java Pool

Advisor

Streams Pool

Advisor

PGA

Advisor

Page 20: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 23

Enterprise Manager and Advisors

Page 21: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 24

DBMS_ADVISOR Package

Creates a script of all the recommendations that are accepted

GET_TASK_SCRIPT

Marks one or more recommendations as accepted, rejected, or ignored

MARK_RECOMMENDATION

Modifies a task parameterSET_TASK_PARAMETER

Updates task attributesUPDATE_TASK_ATTRIBUTES

Causes a suspended task to resumeRESUME_TASK

Creates and returns a text report for the specified task

GET_TASK_REPORT

Suspends a task that is currently executing

INTERRUPT_TASK

Initiates execution of the taskEXECUTE_TASK

Deletes a task from the repositoryDELETE_TASK

Creates a new task in the repositoryCREATE_TASK

DescriptionProcedure

Page 22: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 25

Automated Maintenance Tasks

Autotask maintenance process:

1. Maintenance Window opens.

2. Autotask background process schedules jobs.

3. Scheduler initiates jobs.

4. Resource Manager limits impact of Autotask jobs.

Default Autotask maintenance jobs:

• Gathering optimizer statistics

• Automatic Segment Advisor

• Automatic SQL Advisor

Page 23: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 26

Automated Maintenance Tasks

Page 24: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 27

Automated Maintenance Tasks Configuration

Page 25: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 28

Server-Generated Alerts

Serveralerts

queue.

Metric exceeds

threshold.

AWR

Enterprise Manager

Oracle instance

Page 26: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 29

Setting Thresholds

Page 27: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 30

Creating and Testing an Alert

1. Specify a threshold.

2. Create a test case.

3. Check for an alert.

2

1

3

Page 28: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 31

Alerts Notification

Page 29: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 33

Reacting to Alerts

• If necessary, you should gather more input (for example, by running ADDM or another advisor).

• Investigate critical errors.

• Take corrective measures.

• Acknowledge alerts that are not automatically cleared.

Page 30: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 34

Alert Types and Clearing Alerts

MMON

85% Warning

97% Critical Cleared

Cleared

Alert

SnapshotToo Old

ResumableSession

Suspended

Recovery Area Low On

Free Space

Metric based

Event based

Threshold(stateful)

alerts

Nonthreshold (stateless)

alerts

DBA_OUTSTANDING_ALERTS DBA_ALERT_HISTORY

Page 31: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 35

Summary

In this lesson, you should have learned how to:

• Use statistics

• Manage the Automatic Workload Repository

• Use the Automatic Database Diagnostic Monitor

• Describe the advisory framework

• Set alert thresholds

• Use server-generated alerts

• Use automated tasks

Page 32: Less12 Proactive

Copyright © 2007, Oracle. All rights reserved.12 - 36

Practice 12 Overview: Proactive Maintenance

This practice covers proactively managing your database with ADDM, including:

• Setting up an issue for analysis

• Reviewing your database performance

• Implementing a solution