Transcript Lesson 11
Managing Storage
Copyright © 2006, Oracle. All rights reserved.
11-2
Objectives
• • • • •
Space Management Proactive Monitoring Seg. Advisor & Seg.Shrink
Resumable Allocation Transportable TBS and DB After completing this lesson, you should be able to:
•
Describe how the Oracle database automatically manages space
•
Proactively monitor and manage tablespace space usage
• •
Use the Segment Advisor Reclaim wasted space from tables and indexes by using the segment shrink functionality
• •
Manage resumable space allocation Describe the concepts of transportable tablespaces and databases
Copyright © 2006, Oracle. All rights reserved.
Space Management: Overview
11-3
Space is automatically managed by the Oracle database. It generates alerts about potential problems and recommends possible solutions. Features include:
• •
Oracle Managed Files (OMF) Free space management with bitmaps (“locally managed”) and automatic data file extension
•
Proactive space management (default thresholds and server-generated alerts)
•
Space reclamation (shrinking segments, online table redefinition)
•
Capacity planning (growth reports)
Copyright © 2006, Oracle. All rights reserved.
Free Space Management
11-4
BMB BMB BMB BMB BMB … … BMB … BMB … … … … … … Data block … … Extent
• • •
Automatic Enabled by the use of locally managed tablespaces Tracked by bitmaps in segments
• • •
Benefits: More flexible space utilization Run-time adjustment Multiple process search of BMBs Segment
Copyright © 2006, Oracle. All rights reserved.
Types of Segments
A segment is a set of extents allocated for a certain logical structure. The different types of segments are:
•
Data segment
• •
Index segment Temporary segment Segments are dynamically allocated by the database.
11-5 Copyright © 2006, Oracle. All rights reserved.
11-6
Allocating Extents
• • • •
Searching the data file’s bitmap for the required number of adjacent free blocks Sizing extents with storage clauses:
–
UNIFORM
–
AUTOALLOCATE Viewing extent map Obtaining deallocation advice
Copyright © 2006, Oracle. All rights reserved.
Block Space Management
11-7
PCTFREE = 10 FS2 FS3 Inserts, updates FS1
FS1 FS2 FS3 FS4
Full block Deletes Full block Deletes
Copyright © 2006, Oracle. All rights reserved.
Row Chaining and Migration
11-8 • • • • •
Example: On update: Row length increases, exceeding the available free space in the block.
Data needs to be stored in a new block.
Original physical identifier of row ( ROWID ) is preserved.
The Oracle database needs to read two blocks to retrieve data.
The Segment Advisor finds segments containing the migrated rows.
Old Original block with pointer to migrated row New data Copyright © 2006, Oracle. All rights reserved.
Space Management
Proactive Tablespace Monitoring .
.
Monitoring Seg. Advisor & Seg.Shrink
Resumable Allocation Transportable TBS and DB
11-9 Copyright © 2006, Oracle. All rights reserved.
Thresholds and Resolving Space Problems
97% full or 5 MB left critical 85% full or 100 MB left warning Locally managed tablespace Alert DBA Resolve space problem Resolve space problem by:
• •
Adding or resizing data file Setting AUTOEXTEND ON
• •
Shrinking objects Reducing UNDO_RETENTION
•
Checking for long-running queries in temporary tablespaces
11-10 Copyright © 2006, Oracle. All rights reserved.
Monitoring Tablespace Space Usage
11-11
Alert Check every 10 min.
97% Critical 85% Warning Cleared Cleared Alert MMON
• • • •
Read-only and offline tablespaces: Do not set up alerts.
Temporary tablespace: Threshold corresponds to space currently used by sessions.
Undo tablespace: Threshold corresponds to space used by active and unexpired extents.
Autoextensible files: Threshold is based on the maximum file size.
Copyright © 2006, Oracle. All rights reserved.
1
Shrinking Segments
Space Management Proactive Monitoring > Seg. Advisor & Seg.Shrink
Resumable Allocation Transportable TBS and DB HWM ALTER TABLE employees SHRINK SPACE COMPACT; HWM DML operations and queries can be issued during compaction.
2 ALTER TABLE employees SHRINK SPACE;
11-12
HWM DML operations are blocked when the HWM is adjusted.
Copyright © 2006, Oracle. All rights reserved.
Results of Shrink Operation
11-13 • • • • •
Improved performance and space utilization Indexes maintained Triggers not executed Number of migrated rows may be reduced Rebuilding secondary indexes on IOTs recommended Index Table Shrink Triggers not executed
Copyright © 2006, Oracle. All rights reserved.
DBA
11-14
Space Reclamation with ASSM
• • •
Online and in-place operation Applicable only to segments residing in ASSM tablespaces Candidate segment types:
– – – –
Heap-organized tables and index-organized tables Indexes Partitions and subpartitions Materialized views and materialized view logs
Copyright © 2006, Oracle. All rights reserved.
Segment Advisor: Overview
11-15 Copyright © 2006, Oracle. All rights reserved.
Segment Advisor
11-16 Copyright © 2006, Oracle. All rights reserved.
Implementing Recommendations
11-18 Copyright © 2006, Oracle. All rights reserved.
Database Control and Segment Shrink
11-19 Copyright © 2006, Oracle. All rights reserved.
Shrinking Segments by Using SQL
ALTER … SHRINK SPACE [CASCADE] TABLE [OVERFLOW] INDEX MATERIALIZED VIEW MATERIALIZED VIEW LOG MODIFY PARTITION MODIFY SUBPARTITION MODIFY LOB
11-20
ALTER TABLE employees ENABLE ROW MOVEMENT; ALTER TABLE employees SHRINK SPACE CASCADE; ALTER TABLE employees MODIFY LOB(resume) (SHRINK SPACE); 3 ALTER TABLE employees OVERFLOW SHRINK SPACE; 4 1 2
Copyright © 2006, Oracle. All rights reserved.
11-21
Managing Resumable Space Allocation
Space Management Proactive Monitoring Seg. Advisor & Seg.Shrink
> Resumable Allocation Transportable TBS and DB A resumable statement:
•
Enables you to suspend large operations instead of receiving an error
•
Gives you a chance to fix the problem while the operation is suspended, rather than starting over
•
Is suspended for the following conditions:
– – –
Out of space Maximum extents reached Space quota exceeded
Copyright © 2006, Oracle. All rights reserved.
Using Resumable Space Allocation
11-22 • • •
Queries, DML operations, and certain DDL operations can be resumed if they encounter an out-of-space error.
A resumable statement can be issued through SQL, PL/SQL, SQL*Loader, or the Oracle Call Interface (OCI).
To run a resumable statement, you must first enable resumable statements for your session.
ALTER SESSION ENABLE RESUMABLE; INSERT INTO sales_new SELECT * FROM sh.sales; ALTER SESSION DISABLE RESUMABLE;
Copyright © 2006, Oracle. All rights reserved.
Resuming Suspended Statements
11-24
1 SQL statement Full table 2 Suspended Continue SQL operation 5 3 Table with free space AFTER SUSPEND trigger
Optionally
4 Abort
Copyright © 2006, Oracle. All rights reserved.
…
Transporting Tablespaces
.
Resumable Allocation > Transportable TBS Transportable DB
• • •
Concept: Cross-platform transportable tablespaces: Simplify data distribution between data warehouse and data marts Allow database migration from one platform to another Supported platforms: Solaris[tm] OE (32-bit) Solaris[tm] OE (64-bit) Microsoft Windows IA (32-bit) Linux IA (32-bit) AIX-Based Systems (64-bit) HP-UX (64-bit) HP Tru64 UNIX HP-UX IA (64-bit) Linux IA (64-bit) HP Open VMS Microsoft Windows IA (64-bit) IBM zSeries Based Linux Linux 64-bit for AMD Apple Mac OS Microsoft Windows 64-bit for AMD Solaris Operating System (x86)
11-26 Copyright © 2006, Oracle. All rights reserved.
Concept: Minimum Compatibility Level
• • •
Both source and target databases must have COMPATIBLE set to 10.0.0
or higher.
Data file headers are platform-aware.
Before transporting, make sure that all read-only and offline files are platform-aware.
Read/ write Read/ write
11-27
Read only COMPATIBLE=9.2.0
Read only Read/ write COMPATIBLE=10.0.0
Read only
Copyright © 2006, Oracle. All rights reserved.
Transportable Tablespace Procedure
Source Make tablespaces read-only.
Use Data Pump to extract metadata.
Target uses the same endian format?
Yes No Convert data files by using RMAN.
11-28
Target Ship data files and dump file to target.
Use Data Pump to import metadata.
Make tablespaces read/write.
Copyright © 2006, Oracle. All rights reserved.
11-29
Determining the Endian Format of a Platform
SELECT tp.endian_format
FROM v$transportable_platform tp, v$database d WHERE tp.platform_name = d.platform_name; Source Target
Copyright © 2006, Oracle. All rights reserved.
Transporting Databases
… Resumable Allocation Transportable TBS > Transportable DB
• • •
Generalize the transportable tablespace feature.
Data can easily be distributed from a data warehousing environment to data marts, which are usually on smaller platforms.
A database can be migrated from one platform to another very quickly.
Platform X Same “endianness” Platform Y
11-30
Existing database Database files transfer New database
Copyright © 2006, Oracle. All rights reserved.
11-31
Database Transportation Procedure: Source System Conversion
Open database in READ ONLY and COMPATIBLE=10.0.0
mode Read only Source system CONVERT DATABASE TO PLATFORM Read only Ship files Read only Read only Target system
Copyright © 2006, Oracle. All rights reserved.
11-32
Database Transportation Procedure: Target System Conversion
Open database in READ ONLY and COMPATIBLE=10.0.0
mode CONVERT DATABASE ON TARGET Source system Read only Ship files Read only Read only Read only Target system
Copyright © 2006, Oracle. All rights reserved.
Database Transportation: Considerations
• • • •
Create the password file on the target platform.
Transport the BFILE s used in the source database.
The generated pfile and transport script use OMF.
Use DBNEWID to change the DBID .
11-33 Copyright © 2006, Oracle. All rights reserved.
Summary
11-34
In this lesson, you should have learned how to:
•
Use the Oracle database to automatically manage space
•
Proactively monitor and manage tablespace space usage
• •
Use the Segment Advisor Reclaim wasted space from tables and indexes by using the segment shrink functionality
• •
Manage resumable space allocation Describe the concepts of transportable tablespaces and databases
Copyright © 2006, Oracle. All rights reserved.
Practice Overview: Managing Storage
This practice covers the following topics:
•
Using threshold alerts to proactively manage tablespaces
• •
Using the Segment Advisor to shrink space Viewing alerts and alert history in SQL*Plus and Enterprise Manager
11-35 Copyright © 2006, Oracle. All rights reserved.