12 Copyright © 2007, Oracle. All rights reserved. Database Maintenance.
-
Upload
miles-cobb -
Category
Documents
-
view
223 -
download
4
Transcript of 12 Copyright © 2007, Oracle. All rights reserved. Database Maintenance.
12Copyright © 2007, Oracle. All rights reserved.
Database Maintenance
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
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
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
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
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
Copyright © 2007, Oracle. All rights reserved.12 - 7
Using the Manage Optimizer Statistics Page
Copyright © 2007, Oracle. All rights reserved.12 - 8
Gathering Optimizer Statistics Manually
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
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
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
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
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
Copyright © 2007, Oracle. All rights reserved.12 - 16
Enterprise Manager and the AWR
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)
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
Copyright © 2007, Oracle. All rights reserved.12 - 19
ADDM Findings
1
2
3
Copyright © 2007, Oracle. All rights reserved.12 - 20
ADDM Recommendations
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
Copyright © 2007, Oracle. All rights reserved.12 - 23
Enterprise Manager and Advisors
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
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
Copyright © 2007, Oracle. All rights reserved.12 - 26
Automated Maintenance Tasks
Copyright © 2007, Oracle. All rights reserved.12 - 27
Automated Maintenance Tasks Configuration
Copyright © 2007, Oracle. All rights reserved.12 - 28
Server-Generated Alerts
Serveralerts
queue.
Metric exceeds
threshold.
AWR
Enterprise Manager
Oracle instance
Copyright © 2007, Oracle. All rights reserved.12 - 29
Setting Thresholds
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
Copyright © 2007, Oracle. All rights reserved.12 - 31
Alerts Notification
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.
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
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
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