D78846GC10sg2

.pdf
School
Anadolu University**We aren't endorsed by this school
Course
COMPUTER E STORAGE101
Subject
Information Systems
Date
Jan 14, 2025
Pages
374
Uploaded by guleryuz17
Oracle Database 12c: Administration Workshop Student Guide Volume II D78846GC10 Edition 1.0 July 2013 D82567
Background image
Copyright © 2013,Oracle and/or its affiliates. All rights reserved.DisclaimerThis document contains proprietary information and is protected by copyright and other intellectual property laws. You may copy and print this document solely for your own use in an Oracle training course. The document may not be modified or altered in any way. Except where your use constitutes "fair use" under copyright law, you may not use, share, download, upload, copy, print, display, perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part without the express authorization of Oracle.The information contained in this document is subject to change without notice. If you find any problems in the document, please report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not warranted to be error-free.Restricted Rights NoticeIf this documentation is delivered to the United States Government or anyone using the documentation on behalf of the United States Government, the following notice is applicable: U.S. GOVERNMENT RIGHTSThe U.S. Government’s rights to use, modify, reproduce, release, perform, display, or disclose these training materials are restricted by the terms of the applicable Oracle license agreement and/or the applicable U.S. Government contract. Trademark NoticeOracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.AuthorsDonna K. KeeslingJames L. SpillerTechnical Contributors and ReviewersDarryl BalaskiRainer BienMaria BillingsAndy FortunakJoel GoodmanDaniela HansellPat HueyDominique JeunotGwen LazenbyIra SingerLori TritzBranislav ValnyHarald Van BreederodeEditorsSmita KomminiRashmi RajagopalGraphic DesignerSeema BopaiahPublishersGiri VenugopalJoseph FernandezVeena Narasimhan
Background image
iiiContents 1 Introduction Objectives 1-2 Course Objectives 1-3 Suggested Schedule 1-4 Oracle Database Innovation 1-5 Enterprise Cloud Computing 1-6 Course Examples: HR Sample Schema 1-7 Summary 1-8 2 Exploring Oracle Database Architecture Objectives 2-2 Oracle Database Server Architecture: Overview 2-3 Oracle Database Instance Configurations 2-4 Connecting to the Database Instance 2-5 Oracle Database Memory Structures 2-6 Shared Pool 2-8 Database Buffer Cache 2-10 Redo Log Buffer 2-11 Large Pool 2-12 Java Pool 2-13 Streams Pool 2-14 Program Global Area (PGA) 2-15 Quiz 2-16 Process Architecture 2-18 Process Structures 2-20 Database Writer Process (DBWn) 2-22 Log Writer Process (LGWR) 2-24 Checkpoint Process (CKPT) 2-26 System Monitor Process (SMON) 2-27 Process Monitor Process (PMON) 2-28 Recoverer Process (RECO) 2-29 Listener Registration Process (LREG) 2-30 Archiver Processes (ARCn) 2-31 Database Storage Architecture 2-32 Logical and Physical Database Structures 2-34
Background image
ivSegments, Extents, and Blocks 2-36 Tablespaces and Data Files 2-37 SYSTEM and SYSAUX Tablespaces 2-38 Oracle Container Database: Introduction 2-39 Multitenant Architecture 2-40 Automatic Storage Management 2-41 ASM Storage Components 2-42 Interacting with an Oracle Database: Memory, Processes, and Storage 2-43 Quiz 2-45 Summary 2-47 Practice Overview 2-48 3 Oracle Database Management Tools Objectives 3-2 Oracle Database Management Tools: Introduction 3-3 Using SQL*Plus 3-4 Calling SQL*Plus from a Shell Script 3-5 Calling a SQL Script from SQL*Plus 3-6 Oracle SQL Developer: Connections 3-7 Oracle SQL Developer: DBA Actions 3-8 Oracle Enterprise Manager Database Express Architecture 3-9 Configuring Enterprise Manager Database Express 3-10 Logging In to Oracle Enterprise Manager Database Express 3-11 Using the Database Home Page 3-12 Using Enterprise Manager Database Express Menus 3-13 Oracle Enterprise Manager Cloud Control Components 3-14 Controlling the Enterprise Manager Cloud Control Framework 3-15 Starting the Enterprise Manager Cloud Control Framework 3-16 Stopping the Enterprise Manager Cloud Control Framework 3-17 Types of Enterprise Manager Cloud Control Targets 3-18 Enterprise Manager Cloud Control 3-19 Using Enterprise Manager Cloud Control 3-20 Quiz 3-21 Summary 3-22 Practice Overview 3-23 4 Managing the Database Instance Objectives 4-2 Initialization Parameter Files 4-3 Types of Initialization Parameters 4-5 Initialization Parameters: Examples 4-6
Background image
v Using SQL*Plus to View Parameters 4-10 Changing Initialization Parameter Values 4-13 Changing Parameter Values: Examples 4-15 Quiz 4-16 Starting Up an Oracle Database Instance: NOMOUNT 4-17 Starting Up an Oracle Database Instance: MOUNT 4-18 Starting Up an Oracle Database Instance: OPEN 4-19 Startup Options: Examples 4-20 Shutdown Modes 4-21 Shutdown Options 4-22 Shutdown Options: Examples 4-25 Viewing the Alert Log 4-26 Using Trace Files 4-28 Administering the DDL Log File 4-30 Understanding the Debug Log File 4-31 Using Dynamic Performance Views 4-32 Dynamic Performance Views: Usage Examples 4-33 Dynamic Performance Views: Considerations 4-34 Data Dictionary: Overview 4-35 Data Dictionary Views 4-36 Data Dictionary: Usage Examples 4-39 Quiz 4-40 Summary 4-41 Practice Overview 4-42 5 Configuring the Oracle Network Environment Objectives 5-2 Oracle Net Services: Overview 5-3 Oracle Net Listener: Overview 5-4 Establishing Oracle Network Connections 5-5 Connecting to an Oracle Database 5-6 Name Resolution 5-7 Establishing a Connection 5-8 User Sessions 5-9 Naming Methods 5-11 Easy Connect 5-12 Local Naming 5-13 Directory Naming 5-14 External Naming Method 5-15 Tools for Configuring and Managing Oracle Net Services 5-16 Defining Oracle Net Services Components 5-17
Background image
viUsing Enterprise Manager Cloud Control 5-18 Using Oracle Net Manager 5-19 Using Oracle Net Configuration Assistant 5-20 Using the Listener Control Utility 5-21 Listener Control Utility Syntax 5-22 Advanced Connection Options 5-24 Testing Oracle Net Connectivity 5-26 Comparing Dedicated Server and Shared Server Configurations 5-27 User Sessions: Dedicated Server Process 5-28 User Sessions: Shared Server Processes 5-29 SGA and PGA Usage 5-30 Shared Server Configuration Considerations 5-31 Configuring Communication Between Databases 5-32 Connecting to Another Database 5-33 Quiz 5-34 Summary 5-36 Practice Overview 5-37 6 Administering User Security Objectives 6-2 Database User Accounts 6-3 Predefined Administrative Accounts 6-5 Administrative Privileges 6-6 Protecting Privileged Accounts 6-7 Authenticating Users 6-8 Administrator Authentication 6-10 OS Authentication and OS Groups 6-11 Managing Users 6-13 Creating a User 6-14 Unlocking a User Account and Resetting the Password 6-15 Privileges 6-16 System Privileges 6-17 Revoking System Privileges with ADMIN OPTION 6-19 Granting Object Privileges 6-20 Object Privileges 6-21 Revoking Object Privileges with GRANT OPTION 6-22 Using Roles to Manage Privileges 6-23 Assigning Privileges to Roles and Assigning Roles to Users 6-24 Predefined Roles 6-25 Creating a Role 6-26 Secure Roles 6-27
Background image
vii Assigning Roles to Users 6-28 Privilege Analysis 6-29 Privilege Analysis Flow 6-30 Profiles and Users 6-31 Implementing Password Security Features 6-33 Creating a Password Profile 6-35 Supplied Password Verification Functions 6-36 Modifications to the Default Profile 6-37 Assigning Quotas to Users 6-38 Applying the Principle of Least Privilege 6-40 Quiz 6-42 Summary 6-46 Practice Overview 6-47 7 Managing Database Storage Structures Objectives 7-2 How Table Data Is Stored 7-3 Database Block: Contents 7-4 Exploring the Storage Structure 7-5 Creating a New Tablespace 7-6 Overview of Tablespaces Created by Default 7-12 Altering a Tablespace 7-14 Adding a Data File to a Tablespace 7-16 Making Changes to a Data File 7-17 Dropping Tablespaces 7-18 Viewing Tablespace Information 7-19 Oracle Managed Files (OMF) 7-20 Quiz 7-22 Enlarging the Database 7-23 Moving or Renaming an Online Data File 7-24 Summary 7-26 Practice Overview 7-27 8 Managing Space Objectives 8-2 Space Management: Overview 8-3 Block Space Management 8-4 Row Chaining and Migration 8-5 Quiz 8-7 Free Space Management Within Segments 8-8 Types of Segments 8-9
Background image
viii Allocating Extents 8-10 Understanding Deferred Segment Creation 8-11 Viewing Deferred Segment Information 8-12 Controlling Deferred Segment Creation 8-13 Restrictions and Exceptions 8-14 Additional Automatic Functionality 8-15 Quiz 8-16 Table Compression: Overview 8-17 Compression for Direct-Path Insert Operations 8-18 Advanced Row Compression for DML Operations 8-20 Specifying Table Compression 8-21 Using the Compression Advisor 8-22 Using the DBMS_COMPRESSION Package 8-23 Proactive Tablespace Monitoring 8-24 Thresholds and Resolving Space Problems 8-25 Monitoring Tablespace Space Usage 8-26 Shrinking Segments 8-27 Results of Shrink Operation 8-28 Reclaiming Space Within ASSM Segments 8-29 Using the Segment Advisor 8-30 Automatic Segment Advisor 8-31 Shrinking Segments by Using SQL 8-32 Shrinking Segments by Using Enterprise Manager 8-33 Managing Resumable Space Allocation 8-34 Using Resumable Space Allocation 8-35 Resuming Suspended Statements 8-37 What Operations Are Resumable? 8-39 Quiz 8-40 Summary 8-41 Practice Overview 8-42 9 Managing Undo Data Objectives 9-2 Undo Data: Overview 9-3 Transactions and Undo Data 9-5 Storing Undo Information 9-6 Comparing Undo Data and Redo Data 9-7 Managing Undo 9-8 Configuring Undo Retention 9-9 Categories of Undo 9-10 Guaranteeing Undo Retention 9-11
Background image
ixChanging an Undo Tablespace to a Fixed Size 9-12 Temporary Undo: Overview 9-13 Temporary Undo: Benefits 9-14 Enabling Temporary Undo 9-15 Monitoring Temporary Undo 9-16 Viewing Undo Information 9-17 Viewing Undo Activity 9-18 Using the Undo Advisor 9-19 Quiz 9-20 Summary 9-21 Practice Overview 9-22 10 Managing Data Concurrency Objectives 10-2 Locks 10-3 Locking Mechanism 10-4 Data Concurrency 10-5 DML Locks 10-7 Enqueue Mechanism 10-8 Lock Conflicts 10-9 Possible Causes of Lock Conflicts 10-10 Detecting Lock Conflicts 10-11 Resolving Lock Conflicts 10-12 Resolving Lock Conflicts by Using SQL 10-13 Deadlocks 10-14 Quiz 10-15 Summary 10-17 Practice Overview 10-18 11 Implementing Oracle Database Auditing Objectives 11-2 Database Security 11-3 Monitoring for Compliance 11-5 Types of Activities to be Audited 11-6 Mandatorily Audited Activities 11-7 Understanding Auditing Implementation 11-8 Administering the Roles Required for Auditing 11-9 Database Auditing: Overview 11-10 Understanding the Audit Architecture 11-11 Enabling Unified Auditing 11-12 Configuring Auditing 11-13
Background image
x Using Enterprise Manager Cloud Control 11-14 Creating a Unified Audit Policy 11-15 Creating an Audit Policy: System-Wide Audit Options 11-16 Creating an Audit Policy: Object-Specific Actions 11-17 Creating an Audit Policy: Specifying Conditions 11-18 Enabling and Disabling Audit Policies 11-19 Altering a Unified Audit Policy 11-20 Viewing Audit Policy Information 11-21 Setting the Write Mode for Audit Trail Records 11-22 Value-Based Auditing 11-23 Fine-Grained Auditing 11-25 FGA Policy 11-26 Audited DML Statement: Considerations 11-28 FGA Guidelines 11-29 Archiving and Purging the Audit Trail 11-30 Purging Audit Trail Records 11-31 Quiz 11-32 Summary 11-33 Practice Overview 11-34 12 Backup and Recovery: Concepts Objectives 12-2 DBA Responsibilities 12-3 Categories of Failure 12-5 Statement Failure 12-6 User Process Failure 12-7 Network Failure 12-8 User Error 12-9 Flashback Technology 12-10 Instance Failure 12-12 Understanding Instance Recovery: Checkpoint (CKPT) Process 12-13 Understanding Instance Recovery: Redo Log Files and Log Writer 12-14 Understanding Instance Recovery 12-15 Phases of Instance Recovery 12-16 Tuning Instance Recovery 12-17 Using the MTTR Advisor 12-18 Media Failure 12-19 Comparing Complete and Incomplete Recovery 12-20 Complete Recovery Process 12-21 Point-in-Time Recovery Process 12-22 Oracle Data Protection Solutions 12-24
Background image
xiQuiz 12-25 Summary 12-26 13 Backup and Recovery: Configuration Objectives 13-2 Configuring for Recoverability 13-3 Configuring the Fast Recovery Area 13-4 Monitoring the Fast Recovery Area 13-5 Multiplexing Control Files 13-6 Redo Log Files 13-8 Multiplexing the Redo Log 13-9 Creating Archived Redo Log Files 13-10 Archiver (ARCn) Process 13-11 Archived Redo Log Files: Naming and Destinations 13-12 Configuring ARCHIVELOG Mode 13-14 Quiz 13-15 Summary 13-16 Practice Overview 13-17 14 Performing Database Backups Objectives 14-2 Backup Solutions: Overview 14-3 Oracle Secure Backup 14-4 User-Managed Backup 14-5 Understanding Backup Terminology 14-6 Understanding Types of Backups 14-7 RMAN Backup Types 14-8 Using Recovery Manager (RMAN) 14-10 Configuring Backup Settings 14-11 Oracle-Suggested Backup 14-13 Selecting a Backup Strategy 14-14 Backing Up the Control File to a Trace File 14-15 Managing Backups 14-16 Using RMAN Commands to Create Backups 14-17 Quiz 14-18 Summary 14-19 Practice Overview 14-20 15 Performing Database Recovery Objectives 15-2 Opening a Database 15-3
Background image
xii Keeping a Database Open 15-5 Data Recovery Advisor 15-6 Loss of a Control File 15-8 Loss of a Redo Log File 15-9 Loss of a Data File in NOARCHIVELOG Mode 15-11 Loss of a Noncritical Data File in ARCHIVELOG Mode 15-12 Loss of a System-Critical Data File in ARCHIVELOG Mode 15-13 Quiz 15-14 Summary 15-15 Practice Overview 15-16 16 Moving Data Objectives 16-2 Moving Data: General Architecture 16-3 Oracle Data Pump: Overview 16-4 Oracle Data Pump: Benefits 16-5 Directory Objects for Data Pump 16-7 Creating Directory Objects 16-8 Data Pump Export and Import Clients: Overview 16-9 Data Pump Utility: Interfaces and Modes 16-10 Performing a Data Pump Export by Using Enterprise Manager Cloud Control 16-11 Performing a Data Pump Import 16-12 Data Pump Import: Transformations 16-13 Using Enterprise Manager Cloud Control to Monitor Data Pump Jobs 16-14 SQL*Loader: Overview 16-15 SQL*Loader Control File 16-17 Loading Methods 16-19 Loading Data by Using Enterprise Manager Cloud Control 16-20 SQL*Loader Express Mode 16-21 External Tables 16-23 External Table: Benefits 16-24 Defining an External Tables with ORACLE_LOADER 16-25 External Table Population with ORACLE_DATAPUMP 16-26 Using External Tables 16-27 Data Dictionary 16-28 Quiz 16-29 Summary 16-31 Practice Overview 16-32 17 Database Maintenance Objectives 17-2
Background image
xiii Database Maintenance 17-3 Viewing the Alert History 17-4 Terminology 17-5 Automatic Workload Repository (AWR): Overview 17-6 AWR Infrastructure 17-7 Automatic Workload Repository 17-8 AWR Baselines 17-10 Accessing the AWR Page 17-11 Managing the AWR 17-12 Statistic Levels 17-13 Automatic Database Diagnostic Monitor (ADDM) 17-14 ADDM Findings in Enterprise Manager Cloud Control 17-15 ADDM Findings in Enterprise Manager Database Express 17-16 Advisory Framework 17-17 Viewing the Advisor Central Page in Enterprise Manager Cloud Control 17-19 Using Packages to Invoke the Advisors 17-20 Automated Maintenance Tasks 17-21 Automated Maintenance Tasks Configuration 17-23 Server-Generated Alerts 17-24 Setting Metrics Thresholds 17-25 Reacting to Alerts 17-26 Alert Types and Clearing Alerts 17-27 Quiz 17-28 Summary 17-29 Practice: Overview 17-30 18 Managing Performance Objectives 18-2 Performance Monitoring 18-3 Tuning Activities 18-5 Performance Planning 18-6 Instance Tuning 18-8 Performance Tuning Methodology 18-9 Performance Tuning Data 18-10 Using the Enterprise Manager Database Express Performance Hub Page 18-11 Using the Enterprise Manager Cloud Control Performance Home Page 18-13 Monitoring Session Performance 18-14 Performance Monitoring: Top Sessions 18-15 Displaying Session-Related Statistics 18-16 Performance Monitoring: Top Services 18-17 Displaying Service-Related Statistics 18-18
Background image
xiv Viewing Wait Events 18-19 Oracle Wait Events 18-20 Memory Management: Overview 18-21 Managing Memory Components 18-22 Efficient Memory Usage: Guidelines 18-23 Automatic Memory Management: Overview 18-25 Oracle Database Memory Parameters 18-26 Enabling Automatic Memory Management (AMM) by Using Enterprise Manager Cloud Control 18-27 Monitoring Automatic Memory Management 18-28 Automatic Shared Memory Management: Overview 18-30 Enabling Automatic Shared Memory Management (ASMM) 18-31 Understanding Automatic Shared Memory Management 18-32 Automatic Shared Memory Advisor 18-33 Enabling Automatic Shared Memory Management 18-34 Disabling Automatic Shared Memory Management 18-35 Using V$PARAMETER to View Memory Component Sizes 18-36 Managing the Program Global Area (PGA) 18-37 Dynamic Performance Statistics 18-39 Troubleshooting and Tuning Views 18-41 Quiz 18-42 Summary 18-44 Practice: Overview 18-45 19 Managing Performance: SQL Tuning Objectives 19-2 SQL Tuning 19-3 Oracle Optimizer: Overview 19-4 Optimizer Statistics 19-5 Optimizer Statistics Collection 19-6 Using the Manage Optimizer Statistics Page 19-8 Setting Global Preferences by Using Enterprise Manager Cloud Control 19-9 Gathering Optimizer Statistics Manually 19-10 Setting Optimizer Statistics Preferences 19-12 Concurrent Statistics Gathering 19-14 Viewing Statistics Information 19-15 SQL Plan Directives 19-17 Adaptive Execution Plans 19-18 Using the SQL Advisors 19-19 Automatic SQL Tuning Results 19-20 Implementing Automatic Tuning Recommendations 19-21
Background image
xv SQL Tuning Advisor: Overview 19-22 Using the SQL Tuning Advisor 19-23 SQL Tuning Advisor Recommendations 19-25 Duplicate SQL 19-26 SQL Access Advisor: Overview 19-27 Using the SQL Access Advisor 19-28 Workload Source 19-29 Recommendation Options 19-30 Reviewing Recommendations 19-32 SQL Performance Analyzer: Overview 19-33 SQL Performance Analyzer: Use Cases 19-34 Using SQL Performance Analyzer 19-35 Quiz 19-36 Summary 19-40 Practice: Overview 19-41 20 Using Database Resource Manager Objectives 20-2 Database Resource Manager: Overview 20-3 Database Resource Manager: Concepts 20-4 Using the Resource Manager 20-5 Default Plan for Maintenance Windows 20-7 Default Plan 20-8 Creating a Simple Resource Plan 20-9 Creating a Complex Resource Plan 20-10 Specifying Resource Plan Directives 20-12 Resource Allocation Methods for Resource Plans 20-13 Comparison of EMPHASIS and RATIO 20-14 Active Session Pool Mechanism 20-16 Specifying Thresholds 20-17 Setting Idle Timeouts 20-19 Limiting CPU Utilization at the Database Level 20-20 Limiting CPU Utilization at the Server Level: Instance Caging 20-22 Instance Caging Examples 20-23 Monitoring Instance Caging 20-24 Runaway Queries and Resource Manager 20-25 Resource Consumer Group Mapping 20-27 Activating a Resource Plan 20-29 Database Resource Manager Information 20-30 Viewing Resource Manager Statistics 20-31 Monitoring the Resource Manager 20-32
Background image
xvi Quiz 20-34 Summary 20-35 Practice: Overview 20-36 21 Using Oracle Scheduler to Automate Tasks Objectives 21-2 Simplifying Management Tasks 21-3 Understanding a Simple Job 21-4 Oracle Scheduler Core Components 21-5 Using Oracle Scheduler 21-6 Quiz 21-8 Persistent Lightweight Jobs 21-9 Using a Time-Based or Event-Based Schedule 21-10 Creating a Time-Based Job 21-11 Creating an Event-Based Schedule 21-13 Creating Event-Based Schedules by Using Enterprise Manager Cloud Control 21-14 Creating an Event-Based Job 21-15 Event-Based Scheduling 21-16 Creating Complex Schedules 21-18 Quiz 21-19 Using Email Notification 21-20 Adding and Removing Email Notifications 21-21 Creating Job Chains 21-22 Example of a Chain 21-24 Using Advanced Scheduler Features 21-25 Job Classes 21-26 Windows 21-28 Prioritizing Jobs Within a Window 21-29 Creating a Job Array 21-30 Quiz 21-32 Creating a File Watcher and an Event-Based Job 21-33 Enabling File Arrival Events from Remote Systems 21-35 Scheduling Remote Database Jobs 21-36 Creating Remote Database Jobs 21-37 Scheduling Multiple Destination Jobs 21-38 Viewing Scheduler Meta Data 21-39 Quiz 21-41 Summary 21-42 Practice: Overview 21-43
Background image
xvii A Working with Oracle Support Objectives A-2 Working with Oracle Support A-3 Using My Oracle Support A-4 Researching an Issue A-6 Logging Service Requests A-8 Accessing My Oracle Support Community A-10 Managing Patches A-11 Applying a Patch Release A-12 Enterprise Manager Cloud Control: My Oracle Support Integration A-13 Using the Patch Advisor A-14 Online Patching: Overview A-15 Installing an Online Patch A-16 Benefits of Online Patching A-17 Conventional Patching and Online Patching A-18 Online Patching Considerations A-19 Quiz A-20 Using the Support Workbench A-21 Accessing the Support Workbench A-22 Viewing Problem Details A-23 Viewing Incident Details A-24 Packaging and Uploading Diagnostic Data to Oracle Support A-25 Tracking the Service Request and Implementing Repairs A-26 Summary A-27 B Basic Linux and vi Commands
Background image
Background image
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Backup and Recovery: Concepts
Background image
Oracle Database 12c: Administration Workshop 12 - 2Copyright © 2013, Oracle and/or its affiliates. All rights reserved.ObjectivesAfter completing this lesson, you should be able to:Identify the types of failure that can occur in an Oracle databaseDescribe instance recoveryDescribe complete and incomplete recovery
Background image
Oracle Database 12c: Administration Workshop 12 - 3The database administrator (DBA) is typically responsible for ensuring that the database is open and available when users need it. To achieve that goal, the DBA (working with the system administrator):Anticipates and works to avoid common causes of failureWorks to increase the mean time between failures (MTBF) that negatively affect availability Ensures that hardware is as reliable as possible, that critical components are protected by redundancy, and that operating system maintenance is performed in a timely manner. Oracle Database provides advanced configuration options to increase MTBF, including:-Real Application Clusters-Oracle Data GuardDecreases the mean time to recover (MTTR) by practicing recovery procedures in advance and configuring backups so that they are readily available when neededCopyright © 2013, Oracle and/or its affiliates. All rights reserved.DBA ResponsibilitiesProtect the database from failure wherever possibleIncrease the mean time between failures (MTBF)Protect critical components by using redundancyDecrease the mean time to recover (MTTR)Minimize the loss of data
Background image
Oracle Database 12c: Administration Workshop 12 - 4Minimizes the loss of data. DBAs who follow accepted best practices can configure their databases so that no committed transaction is ever lost. Entities that assist in guaranteeing this include:-Archive log files (discussed later in this lesson)-Flashback technology-Standby databases and Oracle Data Guard (discussed in the Oracle Database 12c: Data Guard Administrationcourse)
Background image
Oracle Database 12c: Administration Workshop 12 - 5Statement failure:A single database operation (select, insert, update, or delete) fails.User process failure:A single database session fails.Network failure:Connectivity to the database is lost.User error:A user successfully completes an operation, but the operation (dropping a table or entering bad data) is incorrect.Instance failure:The database instance shuts down unexpectedly.Media failure:A loss of any file that is needed for database operation (that is, the files have been deleted or the disk has failed).Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Categories of FailureFailures can generally be divided into the following categories:Statement failureUser process failureNetwork failureUser errorInstance failureMedia failure
Background image
Oracle Database 12c: Administration Workshop 12 - 6When a single database operation fails, DBA involvement may be necessary to correct errors with user privileges or database space allocation. DBAs may also need to assist in troubleshooting, even for problems that are not directly in their task area. This can vary greatly from one organization to another. For example, in organizations that use off-the-shelf applications (that is, organizations that have no software developers), the DBA is the only point of contact and must examine logic errors in applications.To understand logic errors in applications, you should work with developers to understand the scope of the problem. Oracle Database tools may provide assistance by helping to examine audit trails or previous transactions.Note:In many cases, statement failures are by design and desired. For example, security policies and quota rules are often decided upon in advance. If a user gets an error while trying to exceed his or her limits, it may be desired for the operation to fail and no resolution may be necessary.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Statement FailureTypical ProblemsPossible SolutionsAttempts to enter invalid data into a tableWork with users to validate and correct data.Attempts to perform operations with insufficient privilegesProvide appropriate object or system privileges.Attempts to allocate space that failEnable resumable spaceallocation.Increase owner quota.Add space to tablespace.Logic errors in applicationsWork with developers to correct program errors.
Background image
Oracle Database 12c: Administration Workshop 12 - 7User processes that abnormally disconnect from the instance may have uncommitted work in progress that needs to be rolled back. The Process Monitor (PMON) background process periodically polls server processes to ensure that their sessions are still connected. If PMONfinds a server process whose user is no longer connected, PMONrecovers from any ongoing transactions; it also rolls back uncommitted changes and releases any locks that are held by the failed session.A DBA’s intervention should not be required to recover from user process failure, but the administrator must watch for trends. One or two users disconnecting abnormally is not a cause for concern. A small percentage of user process failures may occur from time to time. But consistent and systemic failures indicate other problems. A large percentage of abnormal disconnects may indicate a need for user training (which includes teaching users to log out rather than just terminate their programs). It may also be indicative of network or application problems.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.User Process FailureTypical ProblemsPossible SolutionsA user performs an abnormal disconnect.A user’s session is abnormally terminated.A user experiences a program error that terminates the session.A DBA’s action is not usually needed to resolve user process failures. Instance background processes roll back uncommitted changes and release locks.Watch for trends.
Background image
Oracle Database 12c: Administration Workshop 12 - 8The best solution to network failure is to provide redundant paths for network connections. Backup listeners, network connections, and network interface cards reduce the chance that network failures will affect system availability.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Network FailureTypical ProblemsPossible SolutionsListener fails.Configure a backup listener and connect-time failover.Network Interface Card (NIC) fails.Configure multiple network cards.Network connection fails.Configure a backup network connection.
Background image
Oracle Database 12c: Administration Workshop 12 - 9Users may inadvertently delete or modify data. If they have not yet committed or exited their program, they can simply roll back. You can use Oracle LogMiner to query your online redo logs and archived redo logs through an Enterprise Manager or SQL interface. Transaction data may persist in online redo logs longer than it persists in undo segments; if you have configured archiving of redo information, redo persists until you delete the archived files. Oracle LogMiner is discussed in the Oracle Database Utilitiesreference.Users who drop a table can recover it from the recycle bin by flashing back the table to before the drop.If the recycle bin has already been purged, or if the user dropped the table with the PURGEoption, the dropped table can still be recovered by using point-in-time recovery (PITR) if the database has been properly configured. In Oracle Database 12c, RMAN enables you to recover one or more tables or table partitions to a specified point in time without affecting the remaining database objects. Note:Flashback technologies, PITR, and table recovery are discussed in the Oracle Database 12c: Backup and Recovery Workshopcourse and in the Oracle Database Backup and Recovery User’s Guide. Copyright © 2013, Oracle and/or its affiliates. All rights reserved.User ErrorTypical CausesPossible SolutionsUser inadvertently deletes or modifies data.Roll back transaction and dependent transactions or rewind table.User drops a table.Recover table from recycle bin.Recover table from a backup.Oracle LogMiner
Background image
Oracle Database 12c: Administration Workshop 12 - 10Oracle Database includes Oracle Flashback technology: a group of features that support viewing past states of data—and winding data back and forth in time—without requiring restoring the database from backup. With this technology, you help users analyze and recover from errors. For users who have committed erroneous changes, use the following to analyze the errors:Flashback Query:View committed data as it existed at some point in the past. The SELECTcommand with the ASOFclause references a time in the past through a time stamp or system change number (SCN).Flashback Version Query:View committed historical data for a specific time interval. Use the VERSIONSBETWEENclause of the SELECTcommand (for performance reasons with existing indexes).Flashback Transaction Query:View all database changes made at the transaction level.Possible solutions to recover from user error:Flashback Transaction Backout:Rolls back a specific transaction and dependent transactionsFlashback Table:Rewinds one or more tables to their contents at a previous time without affecting other database objectsCopyright © 2013, Oracle and/or its affiliates. All rights reserved.Flashback TechnologyUse Flashback technology for:Viewing past states of dataWinding data back and forth in timeAssisting users in error analysis and recoveryFor error analysis:Oracle Flashback QueryOracle Flashback Versions Query Oracle Flashback Transaction QueryFor error recovery:Oracle Flashback Transaction Backout Oracle Flashback Table Oracle Flashback Drop Oracle Flashback Database
Background image
Oracle Database 12c: Administration Workshop 12 - 11Flashback Drop:Reverses the effects of dropping a table by returning the dropped table from the recycle bin to the database along with dependent objects such as indexes and triggersFlashback Database:Returns the database to a past time or SCN
Background image
Oracle Database 12c: Administration Workshop 12 - 12Instance failure occurs when the database instance is shut down before synchronizing all database files. An instance failure can occur because of hardware or software failure or through the use of the emergency SHUTDOWNABORTand STARTUPFORCEshutdown commands.Administrator involvement in recovering from instance failure is rarely required if Oracle Restart is enabled and is monitoring your database. Oracle Restart attempts to restart your database instance as soon as it fails. If manual intervention is required, then there may be a more serious problem that prevents the instance from restarting, such as a memory CPU failure.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Instance FailureTypical CausesPossible SolutionsPower outageRestart the instance by using the STARTUPcommand. Recovering from instance failure is automatic, including rolling forward changes in the redo logs and then rolling back any uncommitted transactions.Investigate the causes of failure by using the alert log, trace files, and Enterprise Manager.Hardware failureFailure of one of the critical background processesEmergency shutdown procedures
Background image
Oracle Database 12c: Administration Workshop 12 - 13To understand instance recovery, you need to understand the functioning of certain background processes.Every three seconds (or more frequently), the CKPT process stores data in a control file to document the modified data blocks that DBWn has written from the SGA to disk. This is called an “incremental checkpoint.” The purpose of a checkpoint is to identify that place in the online redo log file where instance recovery is to begin (which is called the “checkpoint position”).In the event of a log switch, the CKPT process also writes this checkpoint information to the headers of data files.Checkpoints exist for the following reasons:To ensure that modified data blocks in memory are written to the disk regularly so that data is not lost in case of a system or database failureTo reduce the time required for instance recovery (Only the online redo log file entries following the last checkpoint need to be processed for recovery.)To ensure that all committed data has been written to data files during shutdownThe checkpoint information written by the CKPT process includes checkpoint position, system change number (SCN), location in the online redo log file to begin recovery, information about logs, and so on. Note:The CKPT process does not write data blocks to the disk or redo blocks to the online redo log files.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Understanding Instance Recovery: Checkpoint (CKPT) ProcessCKPT is responsible for:Updating data file headers withcheckpoint informationUpdating control files withcheckpoint informationSignaling DBWn at full checkpointsSGADatabasebuffer cacheCheckpoint processCKPTData filesControl filesDatabase WriterprocessDBWn
Background image
Oracle Database 12c: Administration Workshop 12 - 14Redo log files record changes to the database as a result of transactions and internal Oracle server actions. (A transaction is a logical unit of work consisting of one or more SQL statements run by a user.) Redo log files protect the database from loss of integrity because of system failures caused by power outages, disk failures, and so on. Redo log files should be multiplexed to ensure that the information stored in them is not lost in the event of a disk failure.The redo log consists of groups of redo log files. A group consists of a redo log file and its multiplexed copies. Each identical copy is said to be a member of that group, and each group is identified by a number. The Log Writer (LGWR) process writes redo records from the redo log buffer to all members of a redo log group until the files are filled or a log switch operation is requested.It then switches and writes to the files in the next group. Redo log groups are used in a circular fashion.Best practice tip:If possible, multiplexed redo log files should reside on different disks.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Understanding Instance Recovery: Redo Log Files and Log WriterRedo log files:Record changes to the databaseShould be multiplexed to protect against lossLog Writer (LGWR) writes:At commitWhen one-third fullEvery three secondsBefore DBWnwritesBefore clean shutdownsRedo loggroup 1Redo loggroup 3Redo loggroup 2SGARedo log bufferLog WriterLGWR
Background image
Oracle Database 12c: Administration Workshop 12 - 15The Oracle database automatically recovers from instance failure. All that needs to happen is for the instance to be started normally. If Oracle Restart is enabled and configured to monitor this database, then this happens automatically. The instance mounts the control files and then attempts to open the data files. When it discovers that the data files have not been synchronized during shutdown, the instance uses information contained in the redo log groups to roll the data files forward to the time of shutdown. Then the database is opened and any uncommitted transactions are rolled back.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Understanding Instance RecoveryAutomatic instance or crash recovery:Is caused by attempts to open a database whose files are not synchronized on shutdownUses information stored in redo log groups to synchronize filesInvolves two distinct operations:Rolling forward: Redo log changes (both committed and uncommitted) are applied to data files.Rolling back: Changes that are made but not committed are returned to their original state.
Background image
Oracle Database 12c: Administration Workshop 12 - 16For an instance to open a data file, the system change number (SCN) contained in the data file’s header must match the current SCN that is stored in the database’s control files.If the numbers do not match, the instance applies redo data from the online redo logs, sequentially “redoing” transactions until the data files are up-to-date. After all data files have been synchronized with the control files, the database is opened and users can log in.When redo logs are applied, alltransactions are applied to bring the database up to the state as of the time of failure. This usually includes transactions that are in progress but have not yet been committed. After the database has been opened, those uncommitted transactions are rolled back.At the end of the rollback phase of instance recovery, the data files contain only committed data.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Phases of Instance Recovery1.Instance startup (data filesare out of sync)2.Roll forward (redo)3.Committed and uncommitted data in files4.Database opened5.Roll back (undo)6.Committed data in filesUndoInstanceBackgroundprocessesSGADatabaseData filesRedo log groupControl filesSCN: 99SCN:129SCN:140SCN:143SCN:102-143SCN:143SCN:74-101
Background image
Oracle Database 12c: Administration Workshop 12 - 17Transaction information is recorded in the redo log groups before the instance returns commitcompletefor a transaction. The information in the redo log groups guarantees that the transaction can be recovered in case of a failure. The transaction information must also be written to the data file. The data file write usually happens at some time after the information is recorded in redo log groups because the data file write process is much slower than the redo writes. (Random writes for data files are slower than serial writes for redo log files.)Every three seconds, the checkpoint process records information in the control file about the checkpoint position in the redo log. Therefore, the Oracle Database server knows that all redo log entries recorded before this point are not necessary for database recovery. In the graphic in the slide, the striped blocks have not yet been written to the disk.The time required for instance recovery is the time required to bring data files from their last checkpoint to the latest SCN recorded in the control file. The administrator controls that time by setting an MTTR target (in seconds) and through the sizing of redo log groups. For example, for two redo groups, the distance between the checkpoint position and the end of the redo log group cannot be more than 90% of the smallest redo log group.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Tuning Instance RecoveryDuring instance recovery, the transactions between the checkpoint position and the end of redo log must be applied to data files.You tune instance recovery by controlling the difference between the checkpoint position and the end of redo log.End of redo logCheckpoint positionTransactionsInstance recovery
Background image
Oracle Database 12c: Administration Workshop 12 - 18The FAST_START_MTTR_TARGETinitialization parameter simplifies the configuration of recovery time from instance or system failure. The MTTR Advisor converts the FAST_START_MTTR_TARGETvalue into several parameters to enable instance recovery in the desired time (or as close to it as possible). Please note, explicitly setting the FAST_START_MTTR_TARGETparameter to 0disables the MTTR Advisor.The FAST_START_MTTR_TARGETparameter must be set to a value that supports the service level agreement for your system. A small value for the MTTR target increases I/O overhead because of additional data file writes (affecting the performance). However, if you set the MTTR target too large, the instance takes longer to recover after a crash.For assistance in setting the MTTR target by using Enterprise Manager Cloud Control, navigate as follows:Performance > Advisors Home > MTTR AdvisorAvailability > Backup & Recovery > Recovery SettingsCopyright © 2013, Oracle and/or its affiliates. All rights reserved.Using the MTTR AdvisorSpecify the desired time in seconds or minutes.The default value is 0 (disabled).The maximum value is 3,600 seconds (one hour).
Background image
Oracle Database 12c: Administration Workshop 12 - 19Oracle Corporation defines media failure as any failure that results in the loss or corruption of one or more database files (data, control, or redo log file).Recovering from media failure requires that you restore and recover the missing files.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Media FailureTypical CausesPossible SolutionsFailure of disk drive1.Restore the affected file from backup.2.Inform the database about a new file location (if necessary).3.Recover the file by applying redo information (if necessary).Failure of disk controllerDeletion or corruption of a file needed for database operation
Background image
When you perform complete recovery, you bring the database to the state where it is fully up-to-date, including all committed data modifications to the present time. Incomplete recovery, however, brings the database or tablespace to some point of time in the past. This is also known as “point-in-time recovery (PITR).” It means there are missing transactions; any data modifications done between the recovery destination time and the present are lost. In many cases, this is the desirable goal because there may have been some changes made to the database that need to be undone. Recovering to a point in the past is a way to remove the unwanted changes.Oracle Database 12c: Administration Workshop 12 - 20Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Comparing Complete and Incomplete RecoveryRecovery can have two kinds of scope:Complete recovery: Brings the database or tablespace up to the present, including all committed data changes made to the point in time when the recovery was requestedIncomplete or point-in-time recovery (PITR): Brings the database or tablespace up to a specified point in time in the past, before the recovery operation was requestedRecoverytask startedat this timeCompleterecoveryPoint-in-timerecoveryMissing transactionsafter point-in-time recoveryRestore fromthis backupTime ofcrash
Background image
The following steps describe what takes place during complete recovery:1. Damaged or missing files are restored from a backup.2. Changes from incremental backups, archived redo log files, and online redo log files are applied as necessary. The redo log changes are applied to the data files until the current online log is reached and the most recent transactions have been re-entered. Undo blocks are generated during this entire process. This is referred to as rolling forward or cache recovery.3. The restored data files may now contain committed and uncommitted changes. 4. The undo blocks are used to roll back any uncommitted changes. This is sometimes referred to as transaction recovery.5. The data files are now in a recovered state and are consistent with the other data files in the database.Oracle Database 12c: Administration Workshop 12 - 21Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Complete Recovery ProcessRestoreddata filesData files containingcommitted and uncommittedtransactionsRecovereddata filesChanges appliedUndo applied54321ArchivedlogArchivedlogOnlineRedo log
Background image
Incomplete recovery, or database point-in-time recovery (DBPITR), uses a backup to produce a noncurrent version of the database. That is, you do not apply all of the redo records generated after the most recent backup. Perform this type of recovery only when absolutely necessary. To perform point-in-time recovery, you need:A valid offline or online backup of all the data files made before the recovery pointAll archived logs from the time of the backup until the specified time of recoveryThe steps to perform a point-in-time recovery are as follows:1.Restore the data files from backup: The backup that is used must be from before your target recovery point. This entails either copying files using OS commands or using the RMAN RESTOREcommand.2.Use the RECOVERcommand:Apply redo from the archived redo log files, including as many as necessary to reach the restore point destination.3.State of over-recovery:Now the data files contain some committed and some uncommitted transactions because the redo can contain uncommitted data.4.Use the ALTER DATABASE OPENcommand:The database is opened before undo is applied. This is to provide higher availability.Oracle Database 12c: Administration Workshop 12 - 22Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Point-in-Time Recovery ProcessData files containingcommitted anduncommittedtransactions up to PITPIT-recovereddata filesArchivedlogArchivedlogOnlineRedo logXXChanges applied to point in time (PIT)Restored datafiles from as farback as necessaryUndo applied653124Databaseopened
Background image
5.Apply undo data:While the redo was being applied, redo supporting the undo data files was also applied. So the undo is available to be applied to the data files in order to undo any uncommitted transactions. That is done next.6.Process complete:The data files are now recovered to the point in time that you chose.Oracle Flashback Database is the most efficient alternative to DBPITR. Unlike the other flashback features, it operates at a physical level and reverts the current data files to their contents at a past time. The result is like the result of a DBPITR, including the OPEN RESETLOGS, but Flashback Database is typically faster because it does not require you to restore data files and requires only limited application of redo compared to media recovery.Oracle Database 12c: Administration Workshop 12 - 23
Background image
Oracle provides an appropriate data protection solution depending on your backup and recovery objective and RTO:Oracle Recovery Manager (RMAN) is the core Oracle Database software component that manages database backup, restore, and recovery processes.Oracle Secure Backup (OSB) is Oracle’s enterprise-grade tape backup management solution for both database and file system data.Oracle Database Flashback technologies are a set of data recovery solutions that enable human errors to be reversed by selectively and efficiently undoing the effects of a mistake.The Data Recovery Advisor provides intelligent database problem identification and recovery capabilities.Data Guard and Active Data Guard enable physical standby databases to be open for read access while being kept synchronized with the production database through media recovery.Oracle Database 12c: Administration Workshop 12 - 24Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Oracle Data Protection SolutionsBackup and Recovery ObjectiveRecovery Time Objective (RTO)Oracle SolutionPhysical data protectionHours/DaysRecovery ManagerOracle Secure BackupLogical data protectionMinutes/HoursFlashback TechnologiesRecovery analysisMinimize time for problem identification and recovery planningData Recovery AdvisorDisaster Recovery ObjectiveRecovery Time Objective (RTO)Oracle SolutionPhysical data protectionSeconds/MinutesData GuardActive Data Guard
Background image
Oracle Database 12c: Administration Workshop 12 - 25Answer: bCopyright © 2013, Oracle and/or its affiliates. All rights reserved.QuizStatement failure is never by design and always requires the DBA to address the issue.a.Trueb.False
Background image
Oracle Database 12c: Administration Workshop 12 - 26Copyright © 2013, Oracle and/or its affiliates. All rights reserved.SummaryIn this lesson, you should have learned how to:Identify the types of failure that can occur in an Oracle databaseDescribe instance recoveryDescribe complete and incomplete recovery
Background image
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Backup and Recovery: Configuration
Background image
Oracle Database 12c: Administration Workshop 13 - 2Copyright © 2013, Oracle and/or its affiliates. All rights reserved.ObjectivesAfter completing this lesson, you should be able to:Configure the fast recovery areaMultiplex the control fileMultiplex redo log filesConfigure ARCHIVELOGmode
Background image
Oracle Database 12c: Administration Workshop 13 - 3To provide the best protection for your data, you must:Schedule regular backups: Most media failures require that you restore the lost or damaged file from backup.Multiplex control files: All control files associated with a database are identical. Recovering from the loss of a single control file is not difficult; recovering from the loss of allcontrol files is much more challenging. Guard against losing all control files by having at least two copies.Multiplex redo log groups: To recover from instance or media failure, redo log information is used to roll data files forward to the last committed transaction. If your redo log groups rely on a single redo log file, the loss of that file means that data is likely to be lost. Ensure that there are at least two copies of each redo log group; if possible, each copy should be under different disk controllers.Retain archived copies of redo logs: If a file is lost and restored from backup, the instance must apply redo information to bring that file up to the latest SCN contained in the control file. With the default setting, the database can overwrite redo information after it has been written to the data files. Your database can be configured to retain redo information in archived copies of the redo logs. This is known as placing the database in ARCHIVELOGmode.You can perform configuration tasks in Enterprise Manager Cloud Control or by using the SQL command line.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Configuring for RecoverabilityTo configure your database for maximum recoverability, you must:Schedule regular backupsMultiplex control filesMultiplex redo log groupsRetain archived copies of redo logs
Background image
Oracle Database 12c: Administration Workshop 13 - 4The fast recovery area is a space that is set aside on disk to contain archived logs, backups, flashback logs, multiplexed control files, and multiplexed redo logs. A fast recovery area simplifies backup storage management and is strongly recommended. You should place the fast recovery area on storage space that is separate from the location of your database data files and primary online log files and control file.The amount of disk space to allocate for the fast recovery area depends on the size and activity levels of your database. As a general rule, the larger the fast recovery area, the more useful it is. Ideally, the fast recovery area should be large enough for copies of your data and control files and for flashback, online redo, and archived logs needed to recover the database with the backups kept based on the retention policy. (In short, the fast recovery area should be at least twice the size of the database so that it can hold one backup and several archived logs.)Space management in the fast recovery area is governed by a backup retention policy. A retention policy determines when files are obsolete, which means that they are no longer needed to meet your data recovery objectives. The Oracle Database server automatically manages this storage by deleting files that are no longer needed.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Configuring the Fast Recovery AreaFast recovery area:Strongly recommended for simplified backup storage managementStorage space (separate from working database files)Location specified by the DB_RECOVERY_FILE_DESTparameterSize specified by the DB_RECOVERY_FILE_DEST_SIZEparameterLarge enough for backups, archived logs, flashback logs, multiplexed control files, and multiplexed redo logsAutomatically managed according to your retention policyConfiguration of the fast recovery area includes specifying the location, size, and retention policy.
Background image
Oracle Database 12c: Administration Workshop 13 - 5If you have configured your archived logs to be written to this location, it is important to monitor this space to ensure that it does not reach its capacity. If the instance is unable to create an archived log because of lack of space, it pauses until the administrator corrects the situation.In Enterprise Manager Cloud Control, select Availability > Backup & Recovery > Recovery Settings. On this page, you can:Verify how much of the fast recovery area has been consumedSpecify the location of the fast recovery areaSpecify the size of the fast recovery areaConfigure Flashback DatabaseSpecify the retention timeThe retention time determines when files are obsolete (that is, when they are no longer needed to meet your data recovery objectives). The Oracle Database server automatically manages this storage, deleting files that are no longer needed. You can back up the recovery area so that Oracle Recovery Manager (RMAN) can fail over to other archived redo log destinations if the archived redo log in the fast recovery area is inaccessible or corrupted. Periodically copying backups to tape frees space in the fast recovery area for other files, but retrieving files from tape causes longer database restoration and recovery times.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Monitoring the Fast Recovery Area
Background image
Oracle Database 12c: Administration Workshop 13 - 6A control file is a small binary file that describes the structure of the database. It must be available for writing by the Oracle server whenever the database is mounted or opened. Without this file, the database cannot be mounted, and recovery or re-creation of the control file is required. Your database should have a minimum of two control files on different storage devices to minimize the impact of a loss of one control file.The loss of a single control file causes the instance to fail because all control files must be available at all times. However, recovery can be a simple matter of copying one of the other control files. The loss of all control files is slightly more difficult to recover from but is not usually catastrophic.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Multiplexing Control FilesTo protect against database failure, your database should have multiple copies of the control file.ASM StorageFile System StorageBest PracticeOne copy on each disk group (such as +DATA and +FRA)At least two copies, each on separate disk (at least one on separate disk controller)Steps to create additional control filesNo additional control file copies required1.Alter the SPFILE with the ALTER SYSTEM SETcontrol_filescommand.2.Shut down the database.3.Copy control file to a new location.4.Open the database and verify the addition of the new control file.
Background image
Oracle Database 12c: Administration Workshop 13 - 7Adding a Control FileIf you are using ASM as your storage technique, then as long as you have two control files, one in each disk group (such as +DATA and +FRA), then you should not require further multiplexing. In a database using Oracle Managed Files (OMF)—such as a database using ASM storage—all additional control files must be created as part of a recovery process using RMAN (or through Enterprise Manager). In a database using regular file system storage, adding a control file is a manual operation: 1.Alter the SPFILE with the following command specifying the appropriate location of your files: ALTER SYSTEM SET control_files = '/u01/app/oracle/oradata/orcl/control01.ctl' , '/u02/app/oracle/oradata/orcl/control02.ctl' , '/u03/app/oracle/oradata/orcl/control03.ctl' SCOPE=SPFILE; 2.Shut down the database instance.3.Use an operating system command to copy an existing control file to the location you select for your new file.4.Open the database.Note:More information about using RMAN is provided in the Oracle Database 12c: Backup and Recovery Workshop and in product documentation.
Background image
Oracle Database 12c: Administration Workshop 13 - 8Redo log groups are made up of one or more redo log files. Each log file in a group is a duplicate of the others. Oracle Corporation recommends that redo log groups have at least two files per group. If using file system storage, then each member should be distributed on separate disks or controllers so that no single equipment failure impacts an entire log group. If you are using ASM storage, then each member should be in a separate disk group, such as +DATA and +FRA.The loss of an entire current log group is one of the most serious media failures because it can result in loss of data. The loss of a single member of a multiple-member log group is trivial and does not affect database operation (other than causing an alert to be published in the alert log). Recovery from the loss of an entire log group requires advanced recovery techniques and is discussed in the course titled Oracle Database 12c: Backup and Recovery Workshop.Remember that multiplexing redo logs may heavily influence database performance because a commit cannot complete until the transaction information has been written to the logs. You must place your redo log files on your fastest disks served by your fastest controllers. If possible, do not place any other database files on the same disks as your redo log files (unless you are using ASM). Because only one group is written to at a given time, there is no performance impact in having members from several groups on the same disk.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Redo Log FilesMultiplex redo log groups to protect against media failure and loss of data. This increases database I/O. It is suggested that redo log groups have:At least two members (files) per groupEach member:On a separate disk or controller if using file system storageIn a separate disk group (such as +DATA and +FRA) if using ASMGroup 1Group 2Group 3+DATA+FRAMember aMember aMember aMember bMember bMember bNote: Multiplexing redo logs may impact overall database performance.
Background image
Oracle Database 12c: Administration Workshop 13 - 9You can multiplex your redo log by adding a member to an existing log group. To add a member to a redo log group (with open database and no impact on user performance), perform the following steps in Enterprise Manager Database Express:1. Select Storage > Redo Log Groups.2. Select a group and click Add Member.3. The Add Redo Log Member page appears.4. For File System storage, enter the file name and the file directory. Click OK. Repeat these steps for every existing group that you want to multiplex. An example showing the SQL syntax of adding a redo log member to redo log group 1 (using ASM) is shown here:SQL> ALTER DATABASE ADD LOGFILE MEMBER '+DATA' TO GROUP 1;When you add the redo log member to a group, the member’s status is marked as INVALID (as can be seen in the V$LOGFILEview). This is the expected state because the new member of the group has not yet been written to. When a log switch occurs and the group containing the new member becomes CURRENT, the member’s status changes to null.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Multiplexing the Redo Log
Background image
The Oracle Database server treats the online redo log groups as a circular buffer in which to store transaction information, filling one group and then moving on to the next. After all groups have been written to, the Oracle Database server begins overwriting information in the first log group.To configure your database for maximum recoverability, you must instruct the Oracle Database server to make a copy of the online redo log group before allowing it to be overwritten. These copies are known as archived redo log files. To facilitate the creation of archived redo log files:1.Specify a naming convention for your archived redo log files.2.Specify a destination or destinations for storing your archived redo log files.3.Place the database in ARCHIVELOGmode.Note:Steps 1 and 2 are not necessary if you are using a fast recovery area.The destination should exist before placing the database in ARCHIVELOGmode. When a directory is specified as a destination, there should be a slash at the end of the directory name.Oracle Database 12c: Administration Workshop 13 - 10Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Creating Archived Redo Log FilesTo preserve redo information, create archived copies of redo log files by performing the following steps:1.Specify archived redo log file-naming convention.2.Specify one or more archived redo log file locations. 3.Place the database in ARCHIVELOGmode.Archiver(ARCn)Archivedredo log filesOnline redo log files
Background image
Oracle Database 12c: Administration Workshop 13 - 11ARCnis an optional background process. However, it is crucial to the recovery of a database after the loss of a disk. When an online redo log group gets filled, the Oracle Database server begins writing to the next online redo log group. The process of switching from one online redo log group to another is called a log switch. The ARCnprocess initiates archiving of the filled log group at every log switch. It automatically archives the online redo log group before the log group can be reused so that all the changes made to the database are preserved. This enables recovery of the database to the point of failure even if a disk drive is damaged.One of the important decisions that a DBA must make is whether to configure the database to operate in ARCHIVELOGmode or in NOARCHIVELOGmode.In NOARCHIVELOGmode, the online redo log files are overwritten each time a log switch occurs. In ARCHIVELOGmode, inactive groups of filled online redo log files must be archived before they can be used again.NoteARCHIVELOGmode is essential for most backup strategies.If the archived redo log file destination fills up or cannot be written to, the database will eventually come to a halt. Remove archived redo log files from the archived redo log file destination and the database will resume operations.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Archiver (ARCn) ProcessArchiver (ARCn): Is an optional background processAutomatically archives online redo log files when the database is in ARCHIVELOGmodePreserves a record of all changes made to the databaseRedo logfilesSGARedo log bufferLog WriterLGWRArchiver processARCnCopies of Redo logfiles
Background image
Oracle Database 12c: Administration Workshop 13 - 12To configure archived redo log file names and destinations by using Enterprise Manager Cloud Control, select Availability > Backup & Recovery > Recovery Settings.Each archived redo log file must have a unique name to avoid overwriting older log files. Specify the naming format as shown in the slide. To help create unique file names, Oracle Database allows several wildcard characters in the name format:%s:Includes the log sequence number as part of the file name%t:Includes the thread number as part of the file name %r:Includes the resetlogs ID to ensure that the archive log file name remains unique (even after certain advanced recovery techniques that reset log sequence numbers)%d:Includes the database ID as part of the file nameThe format should include %s, %t, and %ras best practice (%dcan also be included if multiple databases share the same archive log destination).By default, if the fast recovery area is enabled, then USE_DB_RECOVERY_FILE_DESTis specified as an archived redo log file destination. Archived redo log files can be written to as many as ten different destinations. Destinations may be local (a directory) or remote (an Oracle Net alias for a standby database). Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Archived Redo Log Files:Naming and DestinationsSpecify naming and archive destination information on the Recovery Settings page. If using file system storage, then it is recommended that you add multiple locations across different disks.
Background image
Click Add Another Row to add further destinations. To change recovery settings, you must be connected as SYSDBA, SYSOPER, or SYSBACKUP.Note: If you do not want archives sent to this location, delete USE_DB_RECOVERY_FILE_DEST.Oracle Database 12c: Administration Workshop 13 - 13
Background image
Placing the database in ARCHIVELOGmode prevents redo logs from being overwritten until they have been archived.In Enterprise Manager Cloud Control, select Availability > Backup & Recovery > Recovery Settings. Select “ARCHIVELOG Mode” and click Apply. The database instance must be restarted after making this change.To issue the SQL command to put the database in ARCHIVELOGmode, the database must be in MOUNTmode. If the database is currently open, you must shut it down cleanly (not abort), and then mount it as shown in the following example:shutdown immediatestartup mountalter database archivelog;alter database open;With the database in NOARCHIVELOGmode (the default), recovery is possible only until the time of the last backup. All transactions made after that backup are lost.In ARCHIVELOGmode, recovery is possible until the time of the last commit. Most production databases are operated in ARCHIVELOGmode.Note:Back up your database after switching to ARCHIVELOGmode because your database is recoverable only from the first backup taken in that mode.Oracle Database 12c: Administration Workshop 13 - 14Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Configuring ARCHIVELOGModeTo place the database in ARCHIVELOGmode, perform the following steps:Using Enterprise Manager Cloud Control:1.On the Recovery Settings page, select “ARCHIVELOG Mode” and click Apply. The database can be set to ARCHIVELOGmode only from the MOUNTstate.2.Restart the database instance by clicking “Yes” when prompted.Using SQL commands:Mount the database.Issue the ALTER DATABASE ARCHIVELOGcommand.Open the database.
Background image
Oracle Database 12c: Administration Workshop 13 - 15Answer: b, dCopyright © 2013, Oracle and/or its affiliates. All rights reserved.QuizWhich parameters configure the fast recovery area?a.FLASH_RECOVERY_AREA_SIZEb.DB_RECOVERY_FILE_DESTc.FLASH_RECOVERY_AREA_LOCd.DB_RECOVERY_FILE_DEST_SIZE
Background image
Oracle Database 12c: Administration Workshop 13 - 16Copyright © 2013, Oracle and/or its affiliates. All rights reserved.SummaryIn this lesson, you should have learned how to:Configure the fast recovery areaMultiplex the control fileMultiplex redo log filesConfigure ARCHIVELOGmode
Background image
Oracle Database 12c: Administration Workshop 13 - 17Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Practice OverviewThis practice covers the following topics:Verifying control filesConfiguring a default fast recovery areaMultiplexing redo log groupsPlacing your database in ARCHIVELOGmodeEnsuring that redundant archive logs are created
Background image
Background image
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Performing Database Backups
Background image
Oracle Database 12c: Administration Workshop 14 - 2Copyright © 2013, Oracle and/or its affiliates. All rights reserved.ObjectivesAfter completing this lesson, you should be able to:Create consistent database backupsBack up your database without shutting it downCreate incremental backupsAutomate database backupsManage backups
Background image
Recovery Manager (RMAN) is the recommended method of backing up your Oracle database. You can use it to back up to disk or to a system backup to tape (SBT) channel. Oracle recommends that disk backups be stored in the fast recovery area (FRA).Oracle Secure Backup complements existing functionality by adding backup to tape and backup of file system data. It interacts transparently with RMAN. Third-party media managers can also be used to back up to tape.User-managed backups are non-RMAN backups, for example, using an OS utility. They are often based on scripts that a DBA must write. This option is being phased out because it is more labor intensive.Oracle Database 12c: Administration Workshop 14 - 3Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Backup Solutions: OverviewImage copiesBackup piecesBackup dataData filesFast recovery areaor other disk areasTarget databaseArchive log filesControlfileRMANRMANBackup to diskMedia Management(Example: Oracle Secure Backup)Backup to TapeBackup to SBT channelNon database filesOracleSecureBackupBackup with third-party media managerUser-managed OS backup
Background image
Oracle Database 12c: Administration Workshop 14 - 4Oracle’s current backup and recovery product for the database is Recovery Manager. Oracle Secure Backup complements existing functionality in the following ways:Complete backup solution:Oracle Secure Backup provides data protection for the database and nondatabase data to protect the entire Oracle environment. Media management:Oracle Secure Backup provides the media management layer for RMAN database backups to tape. Before Oracle Secure Backup, customers had to purchase expensive third-party media management products offering integration with RMAN tape backups.Backup anywhere on the network:Oracle Secure Backup backs up data from multiple network-attached computer systems to tertiary storage resources on the network. Oracle Secure Backup supports diverse configurations of servers, clients, Network Attached Storage (NAS) servers, and tertiary storage devices and protects network storage environments.The combination of RMAN and Oracle Secure Backup provides an end-to-end backup solution that is entirely within the Oracle product stack. This solution makes better customer support possible because Oracle Corporation is responsible for the entire backup solution.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Oracle Secure BackupOracle Secure Backup and RMAN provide an end-to-end backup solution for Oracle environments:Centralized tape backup management for file system data and the Oracle databaseMost well-integrated media management layer for RMAN backupsBackup of any data anywhere on the networkA single technical support resource for the entire backup solution expedites problem resolution.This ensures reliable data protection at lower cost and complexity.
Background image
Oracle Database 12c: Administration Workshop 14 - 5A user-managed backup can be performed interactively. However, most often it entails the writing of scripts to perform the backup. There are several scenarios that can be run, and scripts must be written to handle them. Some of the actions that scripts must take:Querying V$DATAFILEto determine the data files that need to be backed up and their current stateQuerying V$LOGFILEto identify the online redo log filesQuerying V$CONTROLFILEto identify the control file to back upPlacing each tablespace in online backup modeQuerying V$BACKUPto see what data files are part of a tablespace that has been placed in online backup modeIssuing operating system copy commands to copy the data files to the backup locationBringing each tablespace out of online backup modeCopyright © 2013, Oracle and/or its affiliates. All rights reserved.User-Managed BackupA user-managed scenario:Is a manual process of tracking backup needs and statusTypically uses your own written scriptsRequires that database files be put in the correct mode for backupRelies on operating system commands to make backups of files
Background image
Oracle Database 12c: Administration Workshop 14 - 6Whole database backup:Includes all data files and at least one control file (Remember that all control files in a database are identical.)Partial database backup:May include zero or more tablespaces and zero or more data files; may or may not include a control fileFull backup:Makes a copy of each data block that contains data and that is within the files being backed upIncremental backup:Makes a copy of all data blocks that have changed since a previous backup. Oracle Database supports two levels of incremental backup (0 and 1). A level 1 incremental backup can be one of two types: cumulativeor differential. A cumulative backup backs up all changes since the last level 0 backup. A differential backup backs up all changes since the last incremental backup (which could be either a level 0 or level 1 backup). Change Tracking with RMAN supports incremental backups.Offline backups(also known as “cold” or consistent backup):Are taken while the database is not open. They are consistent because, at the time of the backup, the system change number (SCN) in data file headers matches the SCN in the control files.Online backups(also known as “hot” or inconsistent backup):Are taken while the database is open. They are inconsistent because, with the database open, there is no guarantee that the data files are synchronized with the control files. Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Understanding Backup TerminologyBackup strategy may include:Entire database (whole)Portion of the database (partial)Backup type may indicate inclusion of:All data blocks within your chosen files (full)Only information that has changed since a previous backup (incremental)Cumulative (changes since last level 0)Differential (changes since last incremental)Backup mode may be:Offline (consistent, cold)Online (inconsistent, hot)DatabaseData filesOnline redo log filesControl files
Background image
Oracle Database 12c: Administration Workshop 14 - 7Image copies:Are duplicates of data or archived log files (similar to simply copying the files by using operating system commands)Backup sets:Are collections of one or more binary files that contain one or more data files, control files, server parameter files, or archived log files. With backup sets, empty data blocks are not stored, thereby causing backup sets to use less space on the disk or tape. Backup sets can be compressed to further reduce the space requirements of the backup.Image copies must be backed up to the disk. Backup sets can be sent to the disk or directly to the tape.The advantage of creating a backup as an image copy is improved granularity of the restore operation. With an image copy, only the file or files need to be retrieved from your backup location. With backup sets, the entire backup set must be retrieved from your backup location before you extract the file or files that are needed.The advantage of creating backups as backup sets is better space usage. In most databases, 20% or more of the data blocks are empty blocks. Image copies back up every data block, even if the data block is empty. Backup sets significantly reduce the space required by the backup. In most systems, the advantages of backup sets outweigh the advantages of image copies.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Understanding Types of BackupsBackups may be stored as:Image copiesBackup setsData file #2Data file #3Data file #4Data file #5Data file #1Data file #6Image copies(Duplicate data and log files in OS format)Backup set(Binary, compressed files in Oracle proprietary format)Data file #1Data file #2Data file #3Data file #4Data file #5Data file #6
Background image
Full BackupsA full backup is different from a whole database backup. A full data file backup is a backup that includes every used data block in the file. RMAN copies all blocks into the backup set or image copy, skipping only those data file blocks that are not part of an existing segment. For a full image copy, the entire file contents are reproduced exactly. A full backup cannot be part of an incremental backup strategy; it cannot be the parent for a subsequent incremental backup.Incremental BackupsAn incremental backup is either a level 0 backup, which includes every block in the data files except blocks that have never been used, or a level 1 backup, which includes only those blocks that have been changed since a previous backup was taken. A level 0 incremental backup is physically identical to a full backup. The only difference is that the level 0 backup (as well as an image copy) can be used as the base for a level 1 backup, but a full backup can never be used as the base for a level 1 backup.Incremental backups are specified using the INCREMENTALkeyword of the BACKUPcommand. You specify INCREMENTALLEVEL[0 | 1].Oracle Database 12c: Administration Workshop 14 - 8Copyright © 2013, Oracle and/or its affiliates. All rights reserved.RMAN Backup TypesA full backup contains all used data file blocks.A level 0 incremental backup is equivalent to a full backup that has been marked as level 0.A cumulative level 1 incremental backupcontains only blocks modified since thelast level 0 incremental backup.A differential level 1 incremental backup contains only blocks modified since the last incremental backup.Differentialincremental backup Cumulativeincremental backup Full, or “level 0incremental backup”
Background image
RMAN can create multilevel incremental backups as follows:Differential:Is the default type of incremental backup that backs up all blocks changed after the most recent incremental backup at either level 1 or level 0Cumulative:Backs up all blocks changed after the most recent backup at level 0Examples To perform an incremental backup at level 0, use the following command:RMAN> BACKUP INCREMENTAL LEVEL 0 DATABASE;To perform a differential incremental backup, use the following command:RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE;To perform a cumulative incremental backup, use the following command: RMAN> BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;RMAN makes full backups by default if neither FULLnor INCREMENTALis specified. Unused block compression causes never-written blocks to be skipped when backing up data files to backup sets, even for full backups. A full backup has no effect on subsequent incremental backups, and is not considered part of any incremental backup strategy, although a full image copy backup can be incrementally updated by applying incremental backups with the RECOVERcommand.Note:It is possible to perform any type of backup (full or incremental) of a database that is in NOARCHIVELOGmode—if, of course, the database is not open. Note also that recovery is limited to the time of the last backup. The database can be recovered to the last committed transaction only when the database is in ARCHIVELOGmode. Oracle Database 12c: Administration Workshop 14 - 9
Background image
Oracle Database 12c: Administration Workshop 14 - 10RMAN is the component of the Oracle Database server that is used to perform backup and recovery operations. It can be used to make consistent and inconsistent backups, perform incremental and full backups, and back up either the whole database or a portion of it.RMAN uses its own powerful job control and scripting language, as well as a published API that interfaces RMAN with many popular backup software solutions.RMAN can store backups on the disk for quick recovery or place them on the tape for long-term storage. For RMAN to store backups on the tape, you must either use Oracle Secure Backup or configure an interface to the tape device known as a media management library (MML).Enterprise Manager Cloud Control provides a graphical interface to the most commonly used RMAN functionality. Advanced backup and recovery operations are accessible through RMAN’s command-line client. For more information about advanced RMAN capabilities, see the course titled Oracle Database 12c: Backup and Recovery Workshopor consult the Oracle Backup and Recovery User’s Guide.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using Recovery Manager (RMAN)Provides a powerful control and scripting languageIncludes a published API that enables interface with most popular backup softwareBacks up data, control, archived redo log, and server parameter filesBacks up files to disk or tapeIs integrated with Enterprise Manager Cloud Control
Background image
Oracle Database 12c: Administration Workshop 14 - 11By using RMAN commands or the Enterprise Manager Cloud Control interface, you can manage the persistent backup settings that are used for creating backups. In Enterprise Manager Cloud Control, select Availability > Backup & Recovery > Backup Settings. There are separate settings for disk and tape. Tape settings depend on the media management library capabilities. Disk settings include:Parallelism:How many separate streams of backup information do you want to create? The best setting for parallelism depends on your hardware. As hardware resources increase, the appropriate degree of parallelism also increases. Generally, you want to set your parallelism to the number of disks that your disk backup location is striped over. For tape backup, you want to set your parallelism to the same number of tape drives that you have. Disk backup location:Where should backups be stored? The default is the fast recovery area. If you change this, click Test Disk Backup to verify that RMAN can write to the new location.Disk backup type:Select Backup Set, Compressed Backup Set, or Image Copy.Click the Backup Set tab to set the maximum file size of backup pieces, specify the compression algorithm to be used for compressed backup sets, and specify redundancy for tape backups. Host credentials are required to save changes to the backup settings.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Configuring Backup Settings
Background image
Oracle Database 12c: Administration Workshop 14 - 12Click the Policy tab to:Automatically back up the control file and server parameter file (SPFILE) with each backup. You can also specify a location for these backups if you do not want them to go to the fast recovery area.Optimize backups by not backing up files that exactly match a file that is already part of the retained backups. This setting enables you to skip read-only and offline data files.Enable block change tracking and specify a location for the tracking file. If you intend to create incremental backups, this setting can decrease the time required to choose which blocks to include in the incremental backup.Exclude tablespaces from a whole database backup. Some administrators choose not to back up tablespaces containing data or objects that can be easily re-created (such as indexes or data that is batch-loaded frequently). Specify a retention policy: How long should RMAN keep your backups? If you are using the fast recovery area to store backups, RMAN automatically deletes old backups to make room for new ones (if the retention policy allows it). By default, only the last backup is retained. The retention policy can be specified as a number of backups or a number of days.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Configuring Backup SettingsChangetracking fileData filesBackup piecesRecovery areaBest practice
Background image
Enterprise Manager Cloud Control makes it easy for you to set up an Oracle-suggested backup strategy that protects your data and provides efficient recoverability to any point in the preceding 24 hours, and possibly as far back as 48 hours, depending on when the last backup was created. The Oracle-suggested strategy uses the incremental backup and incrementally updated backup features, providing faster recoverability than is possible when applying database changes from the archived redo log files. Because these backups on disk are retained, you can always perform a full database recovery or a point-in-time recovery to any time within the past 24 hours, at the minimum. The recovery time could reach back as far as 48 hours. This is because just before a backup is taken on a given day, the backup from the beginning of day n–1 still exists.Oracle Database 12c: Administration Workshop 14 - 13Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Oracle-Suggested BackupProvides an out-of-the-box backup strategy based on the backup destinationSets up a recovery window for backup managementSchedules recurring and immediate backups:Full backup+ daily incremental= new “full” backup+ daily archived logs for recovery
Background image
Oracle Database 12c: Administration Workshop 14 - 14To establish an Oracle-suggested strategy, navigate to the database home page > Availability > Backup & Recovery > Schedule Backup. The Backup Strategies section enables you to select from the Oracle-suggested backup and Customized backup strategies. The Oracle-suggested strategy takes a full database copy as the first backup. Because it is a whole database backup, you might want to consider taking this at the period of least activity. After that, an incremental backup to disk is taken every day. Optionally, a weekly tape backup can be made, which backs up all recovery-related files.By clicking Schedule Customized Backup, you gain access to a wider range of configuration options. Select the objects that you want to back up—the whole database (the default) or individual tablespaces, data files, archived logs, or any Oracle backups currently residing on the disk (to move them to the tape).Both strategies enable you to set up encrypted backups.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Selecting a Backup Strategy
Background image
Oracle Database 12c: Administration Workshop 14 - 15In Enterprise Manager Database Express, select Storage > Control Files to manage your database’s control files. Control files have an additional backup option; they may be backed up to a trace file. A control file trace backup contains the SQL statement required to re-create the control files in the event that all control files are lost. Although it is very unlikely that a properly configured database (with multiple copies of the control file placed on separate disks and separate controllers) would lose all control files at the same time, it is possible. Therefore, you should back up the control file to a trace file after each change to the physical structure of the database (adding tablespaces or data files, or adding additional redo log groups).Trace copies of the control file can be created by using Enterprise Manager Database Express, Enterprise Manager Cloud Control, or by using the following SQL command:ALTER DATABASE BACKUP CONTROLFILE TO TRACEThe trace backup is created in the location specified by the DIAGNOSTIC_DESTinitialization parameter. For example, in this course the trace file for the orcldatabase is found in the /u01/app/oracle/diag/rdbms/orcl/orcl/tracedirectory and will have a file name such as orcl_ora_924.trc.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Backing Up the Control File to a Trace FileControl files can be backed up to a trace file, generating a SQL command to re-create the control file.Control file trace backups may be used to recover from loss of all control files.
Background image
Oracle Database 12c: Administration Workshop 14 - 16In Enterprise Manager Cloud Control, select Availability > Backup & Recovery > Manage Current Backups to manage your existing backups. On this page, you can see when a backup was completed, where it was created (disk or tape), and whether it is still available.At the top of the Manage Current Backups page, four buttons enable you to work with existing backups:Catalog Additional Files:Although RMAN (working through Enterprise Manager) is the recommended way to create backups, you might have image copies or backup sets that were created by some other means or in some other environment with the result that RMAN is not aware of them. This task identifies those files and adds them to the catalog.Crosscheck All:RMAN can automatically delete obsolete backups, but you can also delete them by using operating system commands. If you delete a backup without using RMAN, the catalog does not know whether the backup is missing until you perform a cross-check between the catalog and what is really there.Delete All Obsolete:This deletes backups older than the retention policy.Delete All Expired:This deletes the catalog listing for any backups that are not found when the cross-check is performed as described previously.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Managing Backups
Background image
Oracle Database 12c: Administration Workshop 14 - 171.In a terminal session, start RMAN and connect to the target database.2.Execute configuration commands:-CONFIGUREDEFAULTDEVICETYPETOdisk;-CONFIGUREDEVICETYPEDISKBACKUPTYPETOCOPY;-CONFIGURECONTROLFILEAUTOBACKUPON;3.A whole database backup is a copy of all data files and the control file. You can optionally include the server parameter file (SPFILE) and archived redo log files. Using RMAN to make an image copy of all the database files simply requires mounting or opening the database, starting RMAN, and entering the BACKUPcommand shown in the slide. Optionally, you can supply the DELETE INPUToption when backing up archive log files. That causes RMAN to remove the archive log files after backing them up. This is useful especially if you are not using a fast recovery area, which would perform space management for you, deleting files when space pressure grows. In that case, the command in the slide would look like the following:RMAN> BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;You can also create a backup (either a backup set or image copies) of previous image copies of all data files and control files in the database by using the following command:RMAN> BACKUP COPY OF DATABASE;Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using RMAN Commands to Create Backups$ rman target / RMAN> CONFIGURE …RMAN> BACKUP DATABASE PLUS ARCHIVELOG;SPFILEArchived redo log fileData filesControl files123
Background image
Oracle Database 12c: Administration Workshop 14 - 18Answer: bCopyright © 2013, Oracle and/or its affiliates. All rights reserved.QuizUsing the change-tracking feature, an image copy backup performed by RMAN can skip blocks that have not changed since the last backup.a.Trueb.False
Background image
Oracle Database 12c: Administration Workshop 14 - 19Copyright © 2013, Oracle and/or its affiliates. All rights reserved.SummaryIn this lesson, you should have learned how to:Create consistent database backupsBack up your database without shutting it downCreate incremental backupsAutomate database backupsManage backups and view backup reports
Background image
Oracle Database 12c: Administration Workshop 14 - 20Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Practice OverviewThis practice covers the following topics:Backing up your database while the database is open for user activityScheduling automatic nightly incremental backups for your database
Background image
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Performing Database Recovery
Background image
Oracle Database 12c: Administration Workshop 15 - 2Copyright © 2013, Oracle and/or its affiliates. All rights reserved.ObjectivesAfter completing this lesson, you should be able to:Determine the need for performing recoveryDescribe and use available options, such as Recovery Manager (RMAN) and the Data Recovery AdvisorPerform recovery:Control fileRedo log fileData file
Background image
Oracle Database 12c: Administration Workshop 15 - 3As a database moves from the shutdown stage to being fully open, it performs internal consistency checks with the following stages:NOMOUNT:For an instance to reach the NOMOUNT(also known as STARTED) status, the instance must read the initialization parameter file. No database files are checked while the instance enters the NOMOUNTstate.MOUNT:As the instance moves to the MOUNTstatus, it checks whether all control files listed in the initialization parameter file are present and synchronized. If even one control file is missing or corrupt, the instance returns an error (noting the missing control file) to the administrator and remains in the NOMOUNTstate.OPEN:When the instance moves from the MOUNTstate to the OPENstate, it does the following:-Checks whether all redo log groups known to the control file have at least one member present. Any missing members are noted in the alert log.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Opening a DatabaseTo open a database:All control files must be present and synchronizedAll online data files must be present and synchronizedAt least one member of each redo log group must be presentSHUTDOWNNOMOUNTMOUNTOPENSTARTUP
Background image
Oracle Database 12c: Administration Workshop 15 - 4-Verifies that all data files known to the control file are present unless they have been taken offline. Offline files are not checked until the administrator tries to bring them online. The administrator may take a data file offline and open the instance if the data file does not belong to the SYSTEMor UNDOtablespaces. If any files are missing, an error noting the first missing file is returned to the administrator and the instance remains in the MOUNTstate. When the instance finds files that are missing, only the first file causing a problem appears in the error message. To find all files that need recovery, the administrator can check the v$recover_filedynamic performance view to get a complete list of the files that need attention:SQL> startupORACLE instance started.Total System Global Area 171966464 bytesFixed Size 775608 bytesVariable Size 145762888 bytesDatabase Buffers 25165824 bytesRedo Buffers 262144 bytesDatabase mounted.ORA-01157: cannot identify/lock data file 4 - see DBWR trace fileORA-01110: data file 4: '/oracle/oradata/orcl/users01.dbf'SQL> SELECT name, error2 FROM v$datafile3 JOIN v$recover_file4 USING (file#);NAME ERROR----------------------------------- ------------------/oracle/oradata/orcl/users01.dbf FILE NOT FOUND/oracle/oradata/orcl/example01.dbf FILE NOT FOUND-Verifies that all data files that are not offline or read-only are synchronized with the control file. If necessary, instance recovery is automatically performed. However, if a file is out of synchronization to the extent that it cannot be recovered by using the online redo log groups, then the administrator must perform media recovery. If any files require media recovery, an error message noting the first file requiring recovery is returned to the administrator and the instance remains in the MOUNTstate:ORA-01113: file 4 needs media recoveryORA-01110: data file 4: '/oracle/oradata/orcl/users01.dbf'Again, v$recover_filegives a complete list of files that need attention. Files that are present and require media recovery are listed, but no error message is displayed.
Background image
Oracle Database 12c: Administration Workshop 15 - 5After a database is open, instance failure can be caused by media failure: for example, by the loss of a control file, the loss of an entire redo log group, or the loss of a data file belonging to the SYSTEMor UNDOtablespaces. Even if an inactive redo log group is lost, the database would eventually fail due to log switches.In many cases, the failed instance does not completely shut down but is unable to continue to perform work. Recovering from these types of media failure must be done with the database down. As a result, the administrator must use the SHUTDOWNABORTcommand before beginning recovery efforts.The loss of data files belonging to other tablespaces does not cause instance failure, and the database can be recovered while open, with work continuing in other tablespaces.These errors can be detected by inspecting the alert log file or by using the Data Recovery Advisor.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Keeping a Database OpenAfter the database is open, it fails in case of the loss of:Any control fileA data file belonging to the system or undo tablespacesAn entire redo log group (As long as at least one member of the group is available, the instance remains open.)
Background image
Oracle Database 12c: Administration Workshop 15 - 6The Data Recovery Advisor automatically gathers data failure information when an error is encountered. In addition, it can proactively check for failures. In this mode, it can potentially detect and analyze data failures before a database process discovers the corruption and signals an error. (Note that repairs are always under human control.) Data failures can be very serious. For example, if your current log files are missing, you cannot open your database. Some data failures (like block corruptions in data files) are not catastrophic because they do not take the database down or prevent you from opening the Oracle database. The Data Recovery Advisor handles both cases: the one when you cannot start up the database (because required database files are missing, inconsistent, or corrupted) and the one when file corruptions are discovered during run time. The preferred way to address serious data failures is as follows:1.Fail over to a standby database if you are in a Data Guard configuration. This allows users to come back online as soon as possible.2.Repair the primary cause of the data failure.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Data Recovery AdvisorFast detection, analysis, and repair of failuresHandling of down-time and runtime failuresMinimizing disruptions for usersUser interfaces:Enterprise Manager Cloud ControlRMAN command line
Background image
Oracle Database 12c: Administration Workshop 15 - 7User InterfacesThe Data Recovery Advisor is available in Enterprise Manager Cloud Control. When failures exist, there are several ways to access the Data Recovery Advisor. You can also use the Data Recovery Advisor by using the RMAN command line: rman target / rman> list failure all;Supported Database ConfigurationsIn the current release, the Data Recovery Advisor supports single-instance databases. Oracle Real Application Clusters databases are not supported.The Data Recovery Advisor cannot use blocks or files transferred from a standby database to repair failures on a primary database. Furthermore, you cannot use the Data Recovery Advisor to diagnose and repair failures on a standby database. However, the Data Recovery Advisor does support failover to a standby database as a repair option (as mentioned previously).
Background image
Oracle Database 12c: Administration Workshop 15 - 8The options for recovery from the loss of a control file depend on the storage configuration of the control files and on whether at least one control file remains or have all been lost. If using ASM storage, and at least one control file copy remains, you can perform guided recovery using Enterprise Manager or perform manual recovery using RMAN as follows:1.Put the database in NOMOUNTmode.2.Connect to RMAN and issue the RESTORE CONTROLFILEcommand to restore the control file from an existing control file, for example:restore controlfile from '+DATA/orcl/controlfile/current.260.695209463';3.After the control file is successfully restored, open the database.If your control files are stored as regular file system files and at least one control file copy remains, then, while the database is down, you can just copy one of the remaining control files to the missing file’s location. If the media failure is due to the loss of a disk drive or controller, copy one of the remaining control files to some other location and update the instance’s parameter file to point to the new location. Alternatively, you can delete the reference to the missing control file from the initialization parameter file. Remember that Oracle recommends having at least two control files at all times.Note:Recovering from the loss of all control files is covered in the course titled Oracle Database 12c: Backup and Recovery Workshop.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Loss of a Control File If a control file is lost or corrupted, the instance normally aborts. If control files are stored in ASM disk groups, recovery options are as follows:Perform guided recovery using Enterprise Manager.Put database in NOMOUNTmode and use an RMAN command to restore control file from existing control file.If control files are stored as regular file system files, then:Shut down the databaseCopy existing control file to replace lost control fileAfter control file is successfully restored, open the database.RMAN> restore controlfile from '+DATA/orcl/controlfile/current.260.695209463';
Background image
Oracle Database 12c: Administration Workshop 15 - 9Recovering from the loss of a single redo log group member should not affect the running instance.To perform this recovery by using SQL commands:1.Determine whether there is a missing log file by examining the alert log.2.Restore the missing file by first dropping the lost redo log member:ALTER DATABASE DROP LOGFILE MEMBER '<filename>'Then add a new member to replace the lost redo log member:ALTER DATABASE ADD LOGFILE MEMBER '<filename>TO GROUP <integer>Note: If you are using Oracle Managed Files (OMF) for your redo log files and you use the preceding syntax to add a new redo log member to an existing group, that new redo log member file will not be an OMF file. If you want to ensure that the new redo log member is an OMF file, then the easiest recovery option would be to create a new redo log group and then drop the redo log group that had the missing redo log member. 3.If the media failure is due to the loss of a disk drive or controller, rename the missing file.4.If the group has already been archived, or if you are in NOARCHIVELOGmode, you may choose to solve the problem by clearing the log group to re-create the missing file or files. You can clear the affected group manually with the following command:ALTER DATABASE CLEAR LOGFILE GROUP <integer>;Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Loss of a Redo Log FileIf a member of a redo log file group is lost and if the group still has at least one member, note the following results:Normal operation of the instance is not affected.You receive a message in the alert log notifying you that a member cannot be found.You can restore the missing log file by dropping the lost redo log member and adding a new member.If the group with the missing log file has been archived, you can clear the log group to re-create the missing file.
Background image
Oracle Database 12c: Administration Workshop 15 - 10Note:Enterprise Manager does not allow you to clear a log group that has not been archived. Doing so breaks the chain of redo information. If you must clear an unarchived log group, you should immediatelytake a full backup of the whole database. Failure to do so may result in a loss of data if another failure occurs. To clear an unarchived log group, use the following command:ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP <integer>
Background image
Oracle Database 12c: Administration Workshop 15 - 11The loss of anydata file from a database in NOARCHIVELOGmode requires complete restoration of the database, including control files and all data files.With the database in NOARCHIVELOGmode, recovery is possible only up to the time of the last backup. So users must re-enter all changes made since that backup. To perform this type of recovery by using Enterprise Manager Cloud Control:1.Shut down the instance if it is not already down.2.Select Availability > Backup & Recovery > Perform Recovery. 3.Select Whole Database as the type of recovery.If you have a database in NOARCHIVELOGmode that has an incremental backup strategy, RMAN first restores the most recent level 0 and then RMAN recovery applies the incremental backups.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Loss of a Data File in NOARCHIVELOGModeIf the database is in NOARCHIVELOGmode and if any data file is lost, perform the following tasks:1.Shut down the instance if it is not already down.2.Restore the entire database—including all data and control files—from the backup.3.Open the database.4.Have users re-enter all changes that were madesince the last backup.UserUserUserUserUser
Background image
Oracle Database 12c: Administration Workshop 15 - 12With the database in ARCHIVELOGmode, the loss of any data file not belonging to the SYSTEMor UNDOtablespaces affects only the objects that are in the missing file. The rest of the database remains available for users to continue work. To restore and recover the missing data file by using Enterprise Manager Cloud Control, use the Data Recovery Advisor or perform the following steps:1.Select Availability > Backup & Recovery > Perform Recovery.2.In the User Directed Recovery section, select Datafiles in the Recovery Scope menu and then select “Recover to current time.”3.Click Recover to begin the guided restore and recovery process.4.Click Add to select the data files to restore and recover.5.Specify whether you want to restore the files to the default location or (if a disk or controller is missing) to a new location.6.Submit the RMAN job to restore and recover the missing files.Because the database is in ARCHIVELOGmode, recovery is possible up to the time of the last commit and users are not required to re-enter any data.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Loss of a Noncritical Data File in ARCHIVELOGModeIf a data file is lost or corrupted, and if that file does not belong to the SYSTEMor UNDOtablespace, you restore and recover the missing data file.
Background image
Oracle Database 12c: Administration Workshop 15 - 13Data files belonging to the SYSTEMtablespace or containing UNDOdata are considered system critical. A loss of one of these files requires the database to be restored from the MOUNTstate (unlike other data files that may be restored with the database open). To perform this recovery by using Enterprise Manager Cloud Control:1.If the instance is not already shut down, shut it down.2.Mount the database.3.Select Availability > Backup & Recovery > Perform Recovery.4.In the User Directed Recovery Section, select Datafiles in the Recovery Scope menu and then select “Recover to current time.”5.Click Add to select all data files that need recovery.6.Specify whether you want to restore the files to the default location or (if a disk or controller is missing) to a new location.7.Submit the RMAN job to restore and recover the missing files. 8.Open the database. Users are not required to re-enter data because the recovery is up to the time of the last commit.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Loss of a System-Critical Data File in ARCHIVELOGModeIf a data file is lost or corrupted, and if that file belongs to the SYSTEMor UNDOtablespace, perform the following tasks:1.The instance may or may not shut down automatically. If it does not, use SHUTDOWN ABORTto bring the instance down.2.Mount the database.3.Restore and recover the missing data file.4.Open the database.
Background image
Oracle Database 12c: Administration Workshop 15 - 14Answer: cCopyright © 2013, Oracle and/or its affiliates. All rights reserved.QuizAn Oracle Database instance will not fail if the following event occurs: a.Loss of a control file if there is a remaining multiplexed control fileb.Loss of the SYSTEMtablespace c.Loss of one redo log member if there is a remaining multiplexed redo log member from the same group of the lost member d.Loss of the active undo tablespace
Background image
Oracle Database 12c: Administration Workshop 15 - 15Copyright © 2013, Oracle and/or its affiliates. All rights reserved.SummaryIn this lesson, you should have learned how to:Determine the need for performing recoveryDescribe and use available options, such as Recovery Manager (RMAN) and the Data Recovery AdvisorPerform recovery:Control fileRedo log fileData file
Background image
Oracle Database 12c: Administration Workshop 15 - 16Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Practice OverviewThis practice covers recovering from the loss of a:Control fileNoncritical data fileSystem-critical data file
Background image
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Moving Data
Background image
Oracle Database 12c: Administration Workshop 16 - 2Copyright © 2013, Oracle and/or its affiliates. All rights reserved.ObjectivesAfter completing this lesson, you should be able to:Describe ways to move dataExplain the general architecture of Oracle Data PumpCreate and use directory objectsUse Data Pump Export and Import to move data between Oracle databasesUse SQL*Loader to load data from a non-Oracle database (or user files)Use external tables to move data via platform-independent files
Background image
Oracle Database 12c: Administration Workshop 16 - 3Major functional components:DBMS_DATAPUMP:Contains the API for high-speed export and import utilities for bulk data and metadata movementDirect Path API (DPAPI):Oracle Database supports a Direct Path API interface that minimizes data conversion and parsing at both unload and load time.DBMS_METADATA:Used by worker processes for all metadata unloading and loading. Database object definitions are stored using XML rather than SQL.External Table API:With the ORACLE_DATAPUMPand ORACLE_LOADERaccess drivers, you can store data in external tables (that is, in platform-independent files). The SELECTstatement reads external tables as though they were stored in an Oracle database.SQL*Loader:Has been integrated with external tables, providing automatic migration of loader control files to external table access parametersexpdpand impdp:Thin layers that make calls to the DBMS_DATAPUMPpackage to initiate and monitor Data Pump operationsOther clients:Applications (such as replication, transportable tablespaces, and user applications) that benefit from this infrastructure. SQL*Plus may also be used as a client of DBMS_DATAPUMPfor simple status queries against ongoing operations.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Moving Data: General ArchitectureExternal Table APIOracleLoaderOracleDataPumpDirect Path APIDBMS_METADATAMetadata APIexpdpimpdpOther clientsData PumpDBMS_DATAPUMPData/Metadata Movement EngineSQL*Loader(sqlldr)
Background image
Oracle Database 12c: Administration Workshop 16 - 4Oracle Data Pump enables very high-speed data and metadata loading and unloading of Oracle databases. The Data Pump infrastructure is callable via the DBMS_DATAPUMPPL/SQL package. Thus, custom data movement utilities can be built by using Data Pump. Oracle Database provides the following tools: Command-line export and import clients called expdpand impdp, respectively Export and import interface in Enterprise Manager Cloud Control Data Pump automatically decides the data access methods to use; these can be either direct path or external tables. Data Pump uses direct path load and unload when a table’s structure allows it and when maximum single-stream performance is desired. However, if there are clustered tables, referential integrity constraints, encrypted columns, or several other items, Data Pump uses external tables rather than direct path to move the data.The ability to detach from and re-attach to long-running jobs without affecting the job itself enables you to monitor jobs from multiple locations while they are running. All stopped Data Pump jobs can be restarted without loss of data as long as the metainformation remains undisturbed. It does not matter whether the job is stopped voluntarily or involuntarily due to a crash.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Oracle Data Pump: OverviewAs a server-based facility for high-speed data and metadata movement, Oracle Data Pump:Is callable via DBMS_DATAPUMPProvides the following tools:expdpimpdpGUI interface in Enterprise Manager Cloud ControlProvides four data movement methods:Data file copyingDirect pathExternal tablesNetwork link supportDetaches from and re-attaches to long-running jobsRestarts Data Pump jobs
Background image
Oracle Database 12c: Administration Workshop 16 - 5The EXCLUDE, INCLUDE, and CONTENTparameters are used for fine-grained object and data selection.You can specify the database version for objects to be moved (using the VERSIONparameter) to create a dump file set that is compatible with a previous release of Oracle Database that supports Data Pump. You can use the PARALLELparameter to specify the maximum number of threads of active execution servers operating on behalf of the export job.You can estimate how much space an export job would consume (without actually performing the export) by using the ESTIMATE_ONLYparameter.Network mode enables you to export from a remote database directly to a dump file set. This can be done by using a database link to the source system.During import, you can change the target data file names, schemas, and tablespaces.In addition you can specify a percentage of data to be sampled and unloaded from the source database when performing a Data Pump export. This can be done by specifying the SAMPLEparameter.You can use the COMPRESSIONparameter to indicate whether the metadata should be compressed in the export dump file so that it consumes less disk space. If you compress the metadata, it is automatically uncompressed during import.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Oracle Data Pump: BenefitsData Pump offers many benefits and many features, such as:Fine-grained object and data selectionExplicit specification of database versionParallel execution Estimation of export job space consumptionNetwork mode in a distributed environmentRemapping capabilitiesData sampling and metadata compressionCompression of data during a Data Pump export Security through encryptionAbility to export XMLType data as CLOBsLegacy mode to support old import and export files
Background image
Oracle Database 12c: Administration Workshop 16 - 6Features of Data Pump enable you to:Compress both data and metadata, only data, only metadata, or no data during an export Specify additional encryption options in the following areas:-You can choose to encrypt both data and metadata, only data, only metadata, no data, or only encrypted columns during an export.-You can specify a particular encryption algorithm to use during an export. -You can specify the type of security to use for performing encryption and decryption during an export. For example, perhaps the dump file set will be imported into a different or remote database and it must remain secure in transit. Or perhaps the dump file set will be imported on-site using the Oracle Encryption Wallet but it may also need to be imported off-site where the Oracle Encryption Wallet is not available. Perform table mode exports and imports using the transportable method; specify how partitioned tables should be handled during import operations Overwrite existing dump files during an export operationRename tables during an import operation Specify that a data load should proceed even if nondeferred constraint violations are encountered (This is valid only for import operations that use the external tables access method.) Specify that XMLType columns are to be exported in uncompressed CLOB format regardless of the XMLType storage format that was defined for themDuring an export, specify a remap function that takes as a source the original value of the designated column and returns a remapped value that will replace the original value in the dump file Remap data as it is being imported into a new database Use legacy mode to support the use of original Export (exp) and Import (imp) scripts
Background image
Oracle Database 12c: Administration Workshop 16 - 7Directory objects are logical structures that represent a physical directory on the server’s file system. They contain the location of a specific operating system directory. This directory object name can be used in Enterprise Manager so that you do not need to hard-code directory path specifications. This provides greater flexibility for file management. Directory objects are owned by the SYSuser. Directory names are unique across the database because all the directories are located in a single name space (that is, SYS).Directory objects are required when you specify file locations for Data Pump because it accesses files on the server rather than on the client.In Enterprise Manager Cloud Control, select Schema > Database Objects > Directory Objects.To edit or delete a directory object, select the object and click the appropriate button.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Directory Objects for Data Pump
Background image
Oracle Database 12c: Administration Workshop 16 - 81.On the Directory Objects page, click Create. 2.Enter the name of the directory object and the OS path to which it maps. OS directories should be created before they are used. You can test this by clicking Test File System. For the test, provide the host login credentials (the OS user who has privileges on this OS directory).3.Permissions for directory objects are not the same as OS permissions on the physical directory on the server file system. You can manage user privileges on individual directory objects. This increases the level of security and gives you granular control over these objects. On the Privileges page, click Add to select the user to which you give read or write privileges (or both).4.Click Show SQL to view the underlying statements. Click Return when finished.5.Click OK to create the object.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Creating Directory Objects
Background image
Oracle Database 12c: Administration Workshop 16 - 9Data Pump Export is a utility for unloading data and metadata into a set of operating system files called dump file sets. Data Pump Import is used to load metadata and data stored in an export dump file set into a target system.The Data Pump API accesses its files on the server rather than on the client.These utilities can also be used to export from a remote database directly to a dump file set, or to load the target database directly from a source database with no intervening files. This is known as network mode. This mode is particularly useful to export data from a read-only source database.At the center of every Data Pump operation is the master table (MT), which is a table created in the schema of the user running the Data Pump job. The MT maintains all aspects of the job. The MT is built during a file-based export job and is written to the dump file set as the last step. Conversely, loading the MT into the current user’s schema is the first step of a file-based import operation and is used to sequence the creation of all objects imported.Note:The MT is the key to Data Pump’s restart capability in the event of a planned or unplanned stopping of the job. The MT is dropped when the Data Pump job finishes normally.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Data Pump Export and Import Clients: OverviewexpdpclientDumpfile setDatabaseData PumpjobSourceMastertableServerprocessDumpfile setServerprocessTargetData PumpjobimpdpclientDatabaseMastertableDatabaselink“Network mode”
Background image
Oracle Database 12c: Administration Workshop 16 - 10You can interact with Data Pump Export and Import by using one of the following interfaces:Command-line interface:Enables you to specify most of the export parameters directly on the command lineParameter file interface:Enables you to specify all command-line parameters in a parameter file. The only exception is the PARFILEparameter.Interactive-command interface:Stops logging to the terminal and displays the export or import prompts, where you can enter various commands. This mode is enabled by pressing Ctrl + C during an export operation that is started with the command-line interface or the parameter file interface. Interactive-command mode is also enabled when you attach to an executing or stopped job.GUI interface:Select Schema > Database Export/Import. In the menu select the export or import operation you want to execute.Data Pump Export and Import provide different modes for unloading and loading different portions of the database. The mode is specified on the command line by using the appropriate parameter. The available modes are listed in the slide and are the same as in the original export and import utilities.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Data Pump Utility: Interfaces and ModesData Pump Export and Import interfaces:Command lineParameter fileInteractive command lineEnterprise Manager Cloud ControlData Pump Export and Import modes:FullSchemaTableTablespaceTransportable tablespaceTransportable database
Background image
Oracle Database 12c: Administration Workshop 16 - 11Enterprise Manager Cloud Control provides a wizard to guide you through the process of performing a Data Pump export and import procedure. The example in the slide shows a Data Pump export. From the Database home page, expand the Schema menu, select Database Export/Import, and then select Export to Export Files to begin a Data Pump export session.The next window that appears is the selection of export type. If a privileged user is connected to the database instance, then the export types include the following:DatabaseSchemasTablesTablespaceIf a non-administrative account is used, then the export type list is limited to the following:SchemasTablesClick Continue to proceed with the export.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Performing a Data Pump Export by Using Enterprise Manager Cloud Control
Background image
Oracle Database 12c: Administration Workshop 16 - 12Oracle Database also includes Data Pump command-line clients for import and export operations. The example in the slide illustrates a Data Pump import using the impdputility. There are some parameters that are available only by using the command-line interface. For a complete list of options, refer to Oracle Database Utilities.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Performing a Data Pump ImportData Pump can be invoked on the command line:$ impdp hr DIRECTORY=DATA_PUMP_DIR \DUMPFILE=HR_SCHEMA.DMP \PARALLEL=1 \CONTENT=ALL \TABLES="EMPLOYEES" \LOGFILE=DATA_PUMP_DIR:import_hr_employees.log \JOB_NAME=importHR \TRANSFORM=STORAGE:n
Background image
Oracle Database 12c: Administration Workshop 16 - 13Because object metadata is stored as XML in the dump file set, it is easy to apply transformations when DDL is being formed during import. Data Pump Import supports several transformations:REMAP_DATAFILEis useful when moving databases across platforms that have different file-system semantics.REMAP_TABLESPACEenables objects to be moved from one tablespace to another.REMAP_SCHEMAprovides the old FROMUSER/TOUSERcapability to change object ownership.REMAP_TABLEprovides the ability to rename entire tables.REMAP_DATAprovides the ability to remap data as it is being inserted.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Data Pump Import: TransformationsYou can remap:Data files by using REMAP_DATAFILETablespaces by using REMAP_TABLESPACESchemas by using REMAP_SCHEMATables by using REMAP_TABLEData by using REMAP_DATAREMAP_TABLE= 'EMPLOYEES':'EMP'
Background image
Oracle Database 12c: Administration Workshop 16 - 14You can use the Enterprise Manager graphical user interface (GUI) to monitor all Data Pump jobs, including those created by using the expdpor impdpcommand-line interfaces or by using the DBMS_DATAPUMPpackage.You can view the current status of the job and change the status to EXECUTE, STOP, or SUSPEND.To access the “Export and Import Jobs” page, select View Export and Import Jobs in the Database Export/Import menu.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using Enterprise Manager Cloud Control to Monitor Data Pump Jobs
Background image
Oracle Database 12c: Administration Workshop 16 - 15SQL*Loader loads data from external files into tables of an Oracle database. It has a powerful data parsing engine that puts little limitation on the format of the data in the data file. SQL*Loader uses the following files:Input data files:SQL*Loader reads data from one or more files (or operating systemequivalents of files) that are specified in the control file. From SQL*Loader’s perspective, the data in the data file is organized as records. A particular data file can be in fixed record format, variable record format, or stream record format. The record format can be specified in the control file with the INFILEparameter. If no record format is specified, the default is stream record format.Control file:The control file is a text file that is written in a language that SQL*Loader understands. The control file indicates to SQL*Loader where to find the data, how to parse and interpret the data, where to insert the data, and so on. Although not precisely defined, a control file can be said to have three sections.The first section contains such session-wide information as the following: -Global options, such as the input data file name and records to be skipped-INFILEclauses to specify where the input data is located-Data to be loadedCopyright © 2013, Oracle and/or its affiliates. All rights reserved.SQL*Loader: OverviewInput data filesControl fileSQL*LoaderLog fileInsertedSelectedRejectedBad fileRejectedRecord selectionAcceptedDiscard file(optional)DiscardedField processingOracle server
Background image
Oracle Database 12c: Administration Workshop 16 - 16The second section consists of one or more INTOTABLEblocks. Each of these blocks contains information about the table (such as the table name and the columns of the table) into which the data is to be loaded.The third section is optional and, if present, contains input data.Log file:When SQL*Loader begins execution, it creates a log file. If it cannot create a log file, execution terminates. The log file contains a detailed summary of the load, including a description of any errors that occurred during the load.Bad file:The bad file contains records that are rejected, either by SQL*Loader or by the Oracle database. Data file records are rejected by SQL*Loader when the input format is invalid. After a data file record is accepted for processing by SQL*Loader, it is sent to the Oracle database for insertion into a table as a row. If the Oracle database determines that the row is valid, the row is inserted into the table. If the row is determined to be invalid, the record is rejected and SQL*Loader puts it in the bad file.Discard file:This file is created only when it is needed and only if you have specified that a discard file should be enabled. The discard file contains records that are filtered out of the load because they do not match any record-selection criteria specified in the control file.For more information about SQL*Loader, see the Oracle Database Utilities guide.
Background image
Oracle Database 12c: Administration Workshop 16 - 17The SQL*Loader control file is a text file that contains data definition language (DDL) instructions. DDL is used to control the following aspects of a SQL*Loader session:Where SQL*Loader finds the data to loadHow SQL*Loader expects that data to be formattedHow SQL*Loader is being configured (including memory management, selection and rejection criteria, interrupted load handling, and so on) as it loads the dataHow SQL*Loader manipulates the data being loadedCopyright © 2013, Oracle and/or its affiliates. All rights reserved.SQL*Loader Control FileThe SQL*Loader control file instructs SQL*Loader about:Location of the data to be loadedData formatConfiguration details:Memory managementRecord rejectionInterrupted load handling detailsData manipulation details
Background image
Oracle Database 12c: Administration Workshop 16 - 181-- This is a sample control file2LOAD DATA3INFILE SAMPLE.DAT4BADFILE sample.bad5DISCARDFILE sample.dsc6APPEND7INTO TABLE emp8WHEN (57) = ’.’9TRAILING NULLCOLS10(hiredate SYSDATE,deptno POSITION(1:2) INTEGER EXTERNAL(3)NULLIF deptno=BLANKS,job POSITION(7:14) CHAR TERMINATED BY WHITESPACENULLIF job=BLANKS "UPPER(:job)",mgr POSITION(28:31) INTEGER EXTERNALTERMINATED BY WHITESPACE, NULLIF mgr=BLANKS,ename POSITION(34:41) CHARTERMINATED BY WHITESPACE "UPPER(:ename)",empno POSITION(45) INTEGER EXTERNALTERMINATED BY WHITESPACE,sal POSITION(51) CHAR TERMINATED BY WHITESPACE"TO_NUMBER(:sal,$99,999.99)",comm INTEGER EXTERNAL ENCLOSED BY (AND %":comm * 100")The explanation of this sample control file (by line numbers) is as follows:1.Comments can appear anywhere in the command section of the file, but they must not appear in the data. Precede any comment with two hyphens. All text to the right of the double hyphen is ignored until the end of the line.2.The LOADDATAstatement indicates to SQL*Loader that this is the beginning of a new data load. If you are continuing a load that has been interrupted in progress, use the CONTINUELOADDATAstatement.3.The INFILEkeyword specifies the name of a data file containing data that you want to load.4.The BADFILEkeyword specifies the name of a file into which rejected records are placed.5.The DISCARDFILEkeyword specifies the name of a file into which discarded records are placed.6.The APPENDkeyword is one of the options that you can use when loading data into a table that is not empty. To load data into a table that is empty, use the INSERTkeyword.7.The INTOTABLEkeyword enables you to identify tables, fields, and data types. It defines the relationship between records in the data file and tables in the database.8.The WHENclause specifies one or more field conditions that each record must match before SQL*Loader loads the data. In this example, SQL*Loader loads the record only if the 57th character is a decimal point. That decimal point delimits dollars and cents in the field and causes records to be rejected if SALhas no value.9.The TRAILINGNULLCOLSclause prompts SQL*Loader to treat any relatively positioned columns that are not present in the record as null columns.10. The remainder of the control file contains the field list, which provides information about column formats in the table that is being loaded.
Background image
Oracle Database 12c: Administration Workshop 16 - 19Method of Saving DataA conventional path load executes SQL INSERTstatements to populate tables in an Oracle database. A direct path load eliminates much of the Oracle database overhead by formatting Oracle data blocks and writing the data blocks directly to the database files. A direct load does not compete with other users for database resources, so it can usually load data at close to disk speed. Conventional path loads use SQL processing and a database COMMIToperation for saving data. The insertion of an array of records is followed by a COMMIToperation. Each data load may involve several transactions.Direct path loads use data saves to write blocks of data to Oracle data files. This is why the direct path loads are faster than the conventional ones. The following features differentiate a data save from COMMIT:During a data save, only full database blocks are written to the database.The blocks are written after the high-water mark (HWM) of the table.After a data save, the HWM is moved.Internal resources are not released after a data save.A data save does not end the transaction.Indexes are not updated at each data save.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Loading MethodsConventional LoadDirect Path LoadUses COMMITUses data saves (faster operation)Always generates redo entries Generates redo only under specific conditionsEnforces all constraintsEnforces only PRIMARY KEY, UNIQUE, and NOT NULLFires INSERTtriggersDoes not fire INSERTtriggersCan load into clustered tablesDoes not load into clustersAllows other users to modify tables during load operationPrevents other users from making changes to tables during load operationMaintains index entries on each insertMerges new index entries at the end of the loadTableBlockwritesHWMData insert
Background image
Oracle Database 12c: Administration Workshop 16 - 20You can load data by using Enterprise Manager Cloud Control. In the Schema menu, select Database Export/Import. Then select Load Data From User Files.On the first page you indicate whether you are using an existing control file or want a new control file to be generated. Click Continue on this page to invoke the wizard.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Loading Data by UsingEnterprise Manager Cloud Control
Background image
If you activate SQL*Loader Express Mode, specifying only the username and the TABLEparameter, it uses default settings for several other parameters. You can override most of the defaults by specifying additional parameters on the command line.SQL*Loader Express Mode generates two files. The names of the log files come from the name of the table (by default).A log file that includes:The control file outputA SQL script for creating the external table and performing the load using a SQL INSERT AS SELECTstatementNeither the control file nor the SQL script are used by SQL*Loader Express Mode. They are made available to you in case you want to use them as a starting point to perform operations using regular SQL*Loader or stand-alone external tables.A log file similar to a SQL*Loader log file that describes the result of the operation The “%p” represents the process ID of the SQL*Loader process.Oracle Database 12c: Administration Workshop 16 - 21Copyright © 2013, Oracle and/or its affiliates. All rights reserved.SQL*Loader Express ModeSpecify a table name to initiate an Express Mode load.Table columns must be scalar data types (character, number, or datetime).A data file can contain only delimited character data.SQL*Loader uses table column definitions to determine input data types.There is no need to create a control file.$ sqlldr hr TABLE=testtest.datfilehr.test tabletest.logfileSQL*Loader control file options Create external table statement test_%p.log_xtfileLoad result
Background image
The following is an example of the input data file named test.datcontaining two records to load and excerpts of the two log files generated after the load completed. The table HR.TESTwas created with three columns, C1NUMBER, C2VARCHAR2(10), and C3VARCHAR2(10).$ more test.dat3 C WWW4 D UUU$ sqlldr hr TABLE=test$ more test.logExpress Mode Load, Table: TESTData File: test.datBad File: test_%p.bad Table TEST, loaded from every logical record.Insert option in effect for this table: APPENDColumn Name Position Len Term Encl Datatype-------------------- ---------- ----- ---- ---- ---------C1 FIRST * , CHARACTER C2 NEXT * , CHARACTER C3 NEXT * , CHARACTER Generated control file for possible reuse:OPTIONS(EXTERNAL_TABLE=EXECUTE, TRIM=LRTRIM)LOAD DATA INFILE 'test' APPEND INTO TABLE TESTFIELDS TERMINATED BY "," ( C1, C2, C3)End of generated control file for possible reuse.creating external table "SYS_SQLLDR_X_EXT_TEST"CREATE TABLE "SYS_SQLLDR_X_EXT_TEST" ("C1" NUMBER,"C2" CHAR(1),"C3" VARCHAR2(20)) ORGANIZATION external(TYPE oracle_loader DEFAULT DIRECTORY SYS_SQLLDR_XT_TMPDIR_00000ACCESS PARAMETERS ( RECORDS DELIMITED BY NEWLINE CHARACTERSET US7ASCIIBADFILE 'SYS_SQLLDR_XT_TMPDIR_00000':'test_%p.bad'LOGFILE 'test_%p.log_xt'READSIZE 1048576FIELDS TERMINATED BY "," LRTRIM REJECT ROWS WITH ALL NULL FIELDS ("C1" CHAR(255),"C2" CHAR(255),"C3" CHAR(255)))location ('test.dat')) REJECT LIMIT UNLIMITEDexecuting INSERT statement to load database table TESTINSERT /*+ append parallel(auto) */ INTO TEST (C1, C2, C3) SELECT "C1", "C2", "C3" FROM "SYS_SQLLDR_X_EXT_TEST" Table TEST: 2 Rows successfully loaded.Oracle Database 12c: Administration Workshop 16 - 22
Background image
Oracle Database 12c: Administration Workshop 16 - 23External tables access data in external sources as if it were in a table in the database. You can connect to the database and create metadata for the external table using DDL. The DDL for an external table consist of two parts: one part that describes the Oracle Database column types, and another part that describes the mapping of the external data to the Oracle Database data columns.An external table does not describe any data that is stored in the database. Nor does it describe how data is stored in the external source. Instead, it describes how the external table layer must present the data to the server. It is the responsibility of the access driver and the external table layer to do the necessary transformations required on the data in the external file so that it matches the external table definition. External tables are read only; therefore, no DML operations are possible, and no index can be created on them.There are two access drivers used with external tables. The ORACLE_LOADERaccess driver can be used only to read table data from an external table and load it into the database. It uses text files as the data source. The ORACLE_DATAPUMPaccess driver can both load table data from an external file into the database and also unload data from the database into an external file. It uses binary files as the external files. The binary files have the same format as the files used by the Data Pump Import and Export utilities and can be interchanged with them.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.External TablesExternal tables are read-only tables stored as files on the operating system outside of the Oracle database.DatabaseORACLE_DATAPUMPdriverORACLE_LOADERdriver(Text)(Binary)ServerprocessPGAext_table(Metadata Only)
Background image
Oracle Database 12c: Administration Workshop 16 - 24The data files created for the external table can be moved and used as the data files for another external table in the same database or different database. External data can be queried and joined directly in parallel to tables residing in the database, without requiring the data to be loaded first. You can choose to have your applications directly access external tables with the SELECTcommand, or you can choose to have data loaded first into a target database. The results of a complex query can be unloaded to an external file using the ORACLE_DATAPUMPaccess driver.Data files that are populated by different external tables can all be specified in the LOCATIONclause of another external table. This provides an easy way of aggregating data from multiple sources. The only restriction is that the metadata for all the external tables must be exactly the same.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.External Table: BenefitsData can be used directly from the external file or loaded into another database.External data can be queried and joined directly in parallel with tables residing in the database, without requiring it to be loaded first.The results of a complex query can be unloaded to an external file.You can combine generated files from different sources for loading purposes.From Oracle DatabaseFrom external file
Background image
Oracle Database 12c: Administration Workshop 16 - 25The metadata for an external table is created using the SQL language in the database. The ORACLE_LOADERaccess driver uses the SQL*Loader syntax to define the external table. This command does not create the external text files.The example in the slide shows three directory objects (EXTAB_DAT_DIR,EXTAB_BAD_DIR, and EXTAB_LOG_DIR) that are created and mapped to existing OS directories to which the user is granted access.When the EXTAB_EMPLOYEEStable is accessed, SQL*Loader functionality is used to load the table, and at that instance the log file and bad file are created.Best-practice tip:If you have a lot of data to load, enable PARALLELfor the load operation:ALTER SESSION ENABLE PARALLEL DML;Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Defining an External Tables with ORACLE_LOADERCREATE TABLEextab_employees(employee_id NUMBER(4), first_name VARCHAR2(20),last_name VARCHAR2(25),hire_date DATE)ORGANIZATION EXTERNAL( TYPE ORACLE_LOADERDEFAULT DIRECTORY extab_dat_dir ACCESS PARAMETERS ( records delimited by newline badfile extab_bad_dir:'empxt%a_%p.bad' logfile extab_log_dir:'empxt%a_%p.log' fields terminated by ',' missing field values are null ( employee_id, first_name, last_name, hire_date char date_format date mask "dd-mon-yyyy“)) LOCATION('empxt1.dat', 'empxt2.dat') ) PARALLEL REJECT LIMIT UNLIMITED;
Background image
Oracle Database 12c: Administration Workshop 16 - 26This example shows you how the external table population operation can help to export a selective set of records resulting from the join of the EMPLOYEESand DEPARTMENTStables. Because the external table can be large, you can use a parallel populate operation to unload your data to an external table. As opposed to a parallel query from an external table, the degree of parallelism of a parallel populate operation is constrained by the number of concurrent files that can be written to by the access driver. There is never more than one parallel execution server writing into one file at a particular point in time.The number of files in the LOCATIONclause must match the specified degree of parallelism because each input/output (I/O) server process requires its own file. Any extra files that are specified are ignored. If there are not enough files for the specified degree of parallelism, the degree of parallelization is lowered to match the number of files in the LOCATIONclause. The external table is read-only after is has been populated. The SELECTcommand can be very complex, allowing specific information to be populated in the external table. The external table, having the same file structure as binary Data Pump files, can then be migrated to another system, and imported with the impdputility or read as an external table.Note:For more information about the ORACLE_DATAPUMPaccess driver parameters, see the Oracle Database Utilitiesguide.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.External Table Population with ORACLE_DATAPUMPCREATE TABLEext_emp_query_results(first_name, last_name, department_name)ORGANIZATION EXTERNAL(TYPE ORACLE_DATAPUMPDEFAULT DIRECTORY ext_dirLOCATION ('emp1.exp','emp2.exp','emp3.exp'))PARALLELASSELECTe.first_name,e.last_name,d.department_nameFROM employees e, departments dWHERE e.department_id = d.department_id ANDd.department_name in('Marketing', 'Purchasing');
Background image
Oracle Database 12c: Administration Workshop 16 - 27External tables are queried just like internal database tables. The first example illustrates querying an external table named EXTAB_EMPLOYEESand only displaying the results. The results are not stored in the database.The second example shows the joining of an internal table named DEPARTMENTSwith an external table named EXTAB_EMPLOYEESand only displaying the results. The third example in the slide illustrates the direct appending of an internal table data with the query and load of data from an external table.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using External TablesQuerying an external table:Querying and joining an external table with an internal table:Appending data to an internal table from an external table:SQL> SELECT * FROM extab_employees;SQL> SELECT e.employee_id, e.first_name, e.last_name, d.department_name FROM departments d, extab_employees eWHERE d.department_id = e.department_id;SQL> INSERT /*+ APPEND */ INTO hr.employees SELECT * FROM extab_employees;
Background image
Oracle Database 12c: Administration Workshop 16 - 28The data dictionary views in the slide provide information about external tables:[DBA|ALL|USER]_EXTERNAL_TABLES:Specific attributes of external tables in the database [DBA|ALL|USER]_EXTERNAL_LOCATIONS:Data sources for external tables [DBA|ALL|USER]_TABLES:Descriptions of the relational tables in the database [DBA|ALL|USER]_TAB_COLUMNS:Descriptions of the columns of tables, views, and clusters in the database[DBA|ALL]_DIRECTORIES:Descriptions of the directory objects in the databaseCopyright © 2013, Oracle and/or its affiliates. All rights reserved.Data DictionaryView information about external tables in:[DBA| ALL| USER]_EXTERNAL_TABLES[DBA| ALL| USER]_EXTERNAL_LOCATIONS[DBA| ALL| USER]_TABLES[DBA| ALL| USER]_TAB_COLUMNS[DBA| ALL]_DIRECTORIES
Background image
Oracle Database 12c: Administration Workshop 16 - 29Answer: bCopyright © 2013, Oracle and/or its affiliates. All rights reserved.QuizLike other database objects, directory objects are owned by the user that creates them unless another schema is specified during creation.a.Trueb.False
Background image
Oracle Database 12c: Administration Workshop 16 - 30Answer: bCopyright © 2013, Oracle and/or its affiliates. All rights reserved.QuizAn index can be created on an external table.a.Trueb.False
Background image
Oracle Database 12c: Administration Workshop 16 - 31Copyright © 2013, Oracle and/or its affiliates. All rights reserved.SummaryIn this lesson, you should have learned how to:Describe ways to move dataExplain the general architecture of Oracle Data PumpCreate and use directory objectsUse Data Pump Export and Import to move data between Oracle databasesUse SQL*Loader to load data from a non-Oracle database (or user files)Use external tables to move data via platform-independent files
Background image
Oracle Database 12c: Administration Workshop 16 - 32Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Practice OverviewThis practice covers the following topics:Using the Data Pump Export wizard to select database objects to be exportedMonitoring a Data Pump Export jobUsing the Data Pump Import wizard to import tables to your databaseUsing the Load Data wizard to load data into your databaseLoading data by using the command line
Background image
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Database Maintenance
Background image
Oracle Database 12c: Administration Workshop 17 - 2Copyright © 2013, Oracle and/or its affiliates. All rights reserved.ObjectivesAfter completing this lesson, you should be able to:Manage the Automatic Workload Repository (AWR)Use the Automatic Database Diagnostic Monitor (ADDM)Describe and use the advisory frameworkSet alert thresholds Use server-generated alertsUse automated tasks
Background image
Oracle Database 12c: Administration Workshop 17 - 3Proactive database maintenance is made easy by the sophisticated infrastructure of the Oracle database, including the following main elements:The Automatic Workload Repository (AWR) is a built-in repository in each Oracle database. At regular intervals, the Oracle database server makes a snapshot of all its vital statistics and workload information and stores this data in the AWR. The captured data can be analyzed by you, by the database server itself, or by both.Using automated tasks, the database server performs routine maintenance operations, such as regular backups, refreshing optimizer statistics, and database health checks.Reactive database maintenance includes critical errors and conditions discovered by database health checkers:For problems that cannot be resolved automatically and require administrators to be notified (such as running out of space), the Oracle database server provides server-generated alerts. The Oracle database server, by default, monitors itself and sends out alerts to notify you of problems. The alerts notify you and often also provide recommendations on how to resolve the reported problem.Recommendations are generated from several advisors, each of which is responsible for a subsystem. For example, there are memory, segment, and SQL advisors.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Database MaintenanceAutomaticWorkload RepositoryAdvisoryframeworkAutomatedtasksServer alertsData warehouseof the databaseAutomatic collection of important statisticsDirect memoryaccessAutomaticProactiveEfficientAutomaticDiagnostic RepositoryReactiveCritical errors
Background image
Oracle Database 12c: Administration Workshop 17 - 4The Alert History page displays a chart that shows the alert history of the current database in segments of time that you designate. An alert indicates a potential problem: either a warning or critical threshold for a monitored metric, or an indication that a target is no longer available. Click the metric name listed on the Alert History page to get detailed statistics, graphs, and actual time stamps for each alert.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Viewing the Alert History
Background image
Oracle Database 12c: Administration Workshop 17 - 5Statisticsare collections of data that provide more details about the database and the objects in it. Optimizer statistics are used by the query optimizer to choose the best execution plan for each SQL statement. Database statistics provide information for performance monitoring.The Automatic Workload Repository(AWR) provides services to internal Oracle server components to collect, process, maintain, and use performance statistics for problem detection and self-tuning purposes. Active Session History(ASH) is the history of recent session activity stored in the AWR.AWR snapshotsinclude database statistics and metrics, application statistics (transaction volumes, response time), operating system statistics, and other measures. An AWR baselineis a set of AWR snapshots collected over a period of time. The baseline is used for performance comparison, either current performance versus the baseline or one baseline compared to another. The System Moving Windowbaseline is collected by default. The System Moving Window baseline is a changing set of snapshots that include the last eight days of snapshots by default. This baseline becomes valid after sufficient data has been collected and the statistics calculation occurs. The statistics calculation is scheduled for every Saturday at midnight by default.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.TerminologyStatistics: Data collections providing database and object detailOptimizer statistics: Used by query optimizerDatabase statistics: Used for performanceMetric: Rate of change in a cumulative statisticThreshold: A boundary value against which metric values are comparedAutomatic Workload Repository (AWR): Infrastructure for data gathering, analysis, and solutions recommendationsAWR Baseline: A set of AWR snapshots for performance comparison
Background image
Oracle Database 12c: Administration Workshop 17 - 6The AWR is the infrastructure that provides services to Oracle Database components to collect, maintain, and use statistics for problem detection and self-tuning purposes. You can view it as a data warehouse for database statistics, metrics, and so on.Every 60 minutes (by default), the database automatically captures statistical information from the SGA and stores it in the AWR in the form of snapshots. These snapshots are stored on disk by a background process called Manageability Monitor (MMON). By default, snapshots are retained for eight days. You can modify both the snapshot interval and the retention intervals.The AWR contains hundreds of tables, all belonging to the SYSschema and stored in the SYSAUXtablespace. Oracle recommends that the repository be accessed only through Enterprise Manager or the DBMS_WORKLOAD_REPOSITORYpackage to work with the AWR. Direct data manipulation language (DML) commands against the repository tables are not supported.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Automatic Workload Repository (AWR): OverviewBuilt-in repository of performance informationSnapshots of database metrics taken every 60 minutes and retained for eight daysFoundation for all self-management functionsMMONIn-memorystatisticsSnapshotsAWRSGA60 minutes
Background image
Oracle Database 12c: Administration Workshop 17 - 7The AWR infrastructure has two major parts:An in-memory statistics collection facility that is used by Oracle Database components to collect statistics. These statistics are stored in memory for performance reasons. Statistics stored in memory are accessible through dynamic performance (V$) views.The AWR snapshots that represent the persistent portion of the facility. AWR snapshots are accessible through data dictionary views and Enterprise Manager.Statistics are stored in persistent storage for several reasons:The statistics need to survive instance crashes.Some analyses need historical data for baseline comparisons.A memory overflow can occur. When old statistics are replaced by new ones because of memory shortage, the replaced data can be stored for later use.The memory version of the statistics is transferred to disk on a regular basis by the MMONbackground process. With the AWR, the Oracle database server provides a way to capture historical statistics data automatically without DBA intervention.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.AWR InfrastructureSGAV$DBA_*ADDMSelf-tuningcomponentSelf-tuningcomponentInternal clientsExternal clientsEMSQL*PlusEfficientin-memorystatisticscollectionAWRsnapshotsMMON
Background image
The Automatic Workload Repository (AWR) is a collection of persistent system performance statistics owned by SYS. The AWR resides in the SYSAUXtablespace.A snapshotis a set of performance statistics captured at a certain time and stored in the AWR. Each snapshot is identified by a snapshot sequence number (SNAP_ID) that is unique in the AWR. By default, snapshots are generated every 60 minutes. You can adjust this frequency by changing the snapshot INTERVALparameter. Because the database advisors rely on these snapshots, be aware that adjustment of the interval setting can affect diagnostic precision. For example, if the INTERVALis set to four hours, you may miss transient events that would be noticeable in 60-minute intervals. You can use the DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGSstored procedure or Enterprise Manager to change the settings that control snapshot collection.You can take manual snapshots by using Enterprise Manager or the DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOTstored procedure. Taking manual snapshots is supported in conjunction with the automatic snapshots that the system generates. Manual snapshots are expected to be used when you want to capture the system behavior at two specific points in time that do not coincide with the automatic schedule.Oracle Database 12c: Administration Workshop 17 - 8Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Automatic Workload RepositorySYSAUXSGAIn-memorystatistics6:00 AM7:00 AM8:00 AMSnapshot 1Snapshot 2Snapshot 3Snapshot 49:00 AM9:30 AMADDM finds top problems.MMON
Background image
Statspack is a bundled utility that provides a subset of the collection and reporting capability of the AWR. However, there is no supported path to migrate Statspack data into the workload repository. Also, the workload repository is not compatible with the Statspack schema. Statspack is not accessible through Enterprise Manager; it requires setup, and does not have automatic retention settings, or automatic purge. The Statspack utility does provide scripts for setup, automatic snapshot collection, and reporting. Statspack snapshots can be marked for retention, as part of a Statspack baseline, or purged with provided scripts.Statspack is documented in the $ORACLE_HOME/rdbms/admin/spdoc.txtfile. Oracle Database 12c: Administration Workshop 17 - 9
Background image
Oracle Database 12c: Administration Workshop 17 - 10An AWR baseline is a set of AWR snapshots. This is usually a set of snapshot data for an important period that you tag and retain in the AWR. A baseline is defined on a pair of snapshots; the snapshots are identified by their snapshot sequence numbers (SNAP_IDs) or a start and end time. Each snapshot set has starting and ending snapshots and includes all the snapshots in between. Snapshot sets are used to retain snapshot data. Therefore, by default, snapshots belonging to snapshot sets are retained until the snapshot sets are dropped. You can specify an expiration value to indicate the number of days that the snapshot will be retained.A baseline is identified by a user-supplied name. Execute the CREATE_BASELINEprocedure to create a baseline from a set of snapshots, and specify a name and a pair of snapshot identifiers. A baseline identifier that is unique for the life of a database is assigned to the newly created baseline. Usually, you set up baselines from representative periods in the past, to be used for comparisons with current system behavior. You can also set up threshold-based alerts by using baselines from Enterprise Manager. You can set the expiration time (in number of days) with the expiration parameter of this procedure. The default is NULL, meaning “never expire.”You can get the SNAP_IDs directly from DBA_HIST_SNAPSHOT, or from Enterprise Manager.Note:For more information about the DBMS_WORKLOAD_REPOSITORYpackage, see the Oracle Database PL/SQL Packages and Types Referenceguide.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.AWR BaselinesDBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE( -start_snap_idIN NUMBER,end_snap_idIN NUMBER,baseline_name IN VARCHAR2);Relevant periodin the past
Background image
Oracle Database 12c: Administration Workshop 17 - 11In Enterprise Manager Cloud Control, navigate to the Automatic Workload Repository page by expanding the Performance menu, selecting AWR and then selecting AWR Administration. On the Automatic Workload Repository page, click Edit to change the settings.On the Automatic Workload Repository page, you can:Edit the workload repository settingsLook at detailed information about created snapshots and manually create new onesCreate AWR baselinesGenerate an AWR reportCopyright © 2013, Oracle and/or its affiliates. All rights reserved.Accessing the AWR Page
Background image
Oracle Database 12c: Administration Workshop 17 - 12AWR settings include retention period, collection interval, and collection level. Remember that decreasing any of these settings affects the functionality of components that depend on the AWR, including the advisors.Increasing the settings can provide improved advisor recommendations—but at the cost of the space that is required to store the snapshots and the performance expended in collecting the snapshot information. Consider setting collection level to ALLwhen tuning a new application. The ALLsetting collects SQL execution plans and timing statistics that enhance the recommendations of the SQL advisors. When tuning is complete, this setting should be returned to the TYPICALsetting.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Managing the AWRRetention periodDefault: Eight daysConsider storage needsCollection intervalDefault: 60 minutesConsider storage needs and performance impactCollection levelBasic (disables most ADDM functionality) Typical (recommended)All (adds additional SQL tuning information to snapshots)
Background image
Oracle Database 12c: Administration Workshop 17 - 13The STATISTICS_LEVELinitialization parameter controls the capture of a variety of statistics and various advisors, including the automatic maintenance tasks. The automatic maintenance tasks include gathering optimizer statistics. The STATISTICS_LEVELparameter can be set to the following levels:BASIC:The computation of AWR statistics and metrics is turned off. The automatic optimizer statistics task is disabled, as are all advisors and server-generated alerts.TYPICAL:Major statistics that are required for database self-management are collected. They represent what is typically needed to monitor Oracle database behavior. This includes automatic gathering of statistics to reduce the likelihood of poorly performing SQL statements due to stale or invalid statistics. ALL:All possible statistics are captured. This level of capture adds timed OS statistics and plan execution statistics. These statistics are not needed in most cases and should not be enabled for best performance; they are sometimes needed for specific diagnostics tests.Oracle recommends that the default value of TYPICALbe set for the STATISTICS_LEVELinitialization parameter. Setting the value to BASICdisables the automatic gathering of optimizer statistics.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Statistic LevelsSTATISTICS_LEVELBASICTYPICALALLRecommendeddefault valueAdditional statisticsfor manualSQL diagnosticsSelf-tuningcapabilities disabled
Background image
Oracle Database 12c: Administration Workshop 17 - 14Unlike the other advisors, the ADDM runs automatically after each AWR snapshot. Each time a snapshot is taken, the ADDM performs an analysis of the period corresponding to the last two snapshots. The ADDM proactively monitors the instance and detects most bottlenecks before they become a significant problem.In many cases, the ADDM recommends solutions for detected problems and even quantifies the benefits for the recommendations. Some common problems that are detected by the ADDM:CPU bottlenecksPoor Oracle Net connection managementLock contention Input/output (I/O) capacityUndersizing of database instance memory structuresHigh-load SQL statementsHigh PL/SQL and Java timeHigh checkpoint load and cause (for example, small log files)The results of each ADDM analysis are stored in the AWR and are also accessible through Enterprise Manager.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Automatic Database Diagnostic Monitor (ADDM)Runs after each AWR snapshotMonitors the instance; detects bottlenecksStores results in the AWRSnapshotsADDMAWREMADDM results
Background image
Oracle Database 12c: Administration Workshop 17 - 15You can use Enterprise Manager Cloud Control to view ADDM findings. Select Advisors Home in the Performance menu. Select an ADDM autorun on the Advisors Central page.On the Automatic Database Diagnostic Monitor (ADDM) page, you see the detailed findings for the latest ADDM run. Database Time represents the sum of the nonidle time spent by sessions in the database for the analysis period. A specific impact percentage is given for each finding. The impact represents the time consumed by the corresponding issue compared with the database time for the analysis period. Click the View Report button to get details about the performance analysis in the form of a text report.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.ADDM Findings in Enterprise Manager Cloud Control
Background image
Oracle Database 12c: Administration Workshop 17 - 16You can also use Enterprise Manager Database Express to view ADDM information. Select Performance Hub from the Performance menu. Click the ADDM tab. Select a task to view detailed information.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.ADDM Findings in Enterprise Manager Database Express
Background image
Oracle Database 12c: Administration Workshop 17 - 17Advisors provide you with useful feedback about resource utilization and performance for their respective server components. For example, the Memory Advisor provides a recommended value for the MEMORY_TARGETinitialization parameter, which controls the total amount of memory used by the Oracle database instance.By building on the data captured in the AWR, the ADDM enables the Oracle Database server to diagnose its own performance and determine how identified problems can be resolved. ADDM runs automatically after each AWR statistics capture. It can potentially call other advisors.Here are the major benefits that are provided by the advisor infrastructure:All advisors use a uniform interface.All advisors have a common data source and results storage by using the workload repository.Not all advisors are shown in the slide (for example, the Data Recovery Advisor and the SQL Repair Advisor are not listed). Automatic Database Diagnostic Monitor (ADDM)The ADDM is a server-based expert that reviews database performance every 60 minutes. Its goal is to detect possible system bottlenecks early and recommend fixes before system performance degrades noticeably.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Advisory FrameworkADDMSQL Tuning AdvisorSQL Access AdvisorMemory AdvisorSpaceSGAAdvisorSegment AdvisorUndo AdvisorBuffer CacheAdvisorShared PoolAdvisorBackupMTTR AdvisorJava PoolAdvisorStreams PoolAdvisorPGAAdvisor
Background image
Oracle Database 12c: Administration Workshop 17 - 18Memory AdvisorsThe Memory Advisor is actually a collection of several advisory functions that help determine the best settings for the total memory used by the database instance. The System Global Area (SGA) has a set of advisors for the shared pool, database buffer cache, Java pool, and streams pool. The Java pool and streams pool advisors are not exposed on the Enterprise Manager Memory Advisor page. There is an advisor for the Program Global Area (PGA). In addition to the advisory functions, this advisor provides a central point of control for the large pool and the Java pool.Mean-Time-To-Recover (MTTR) AdvisorUsing the MTTR Advisor, you set the length of time required for the database to recover after an instance crash.Segment AdvisorThis advisor looks for tables and indexes that consume more space than they require. The advisor checks for inefficient space consumption at the tablespace or schema level and produces scripts to reduce space consumption where possible.SQL Access AdvisorThis advisor analyzes all SQL statements that are issued in a given period and suggests the creation of additional indexes or materialized views that will improve performance.SQL Tuning AdvisorThis advisor analyzes an individual SQL statement and makes recommendations for improving its performance. Recommendations may include actions, such as rewriting the statement, changing the instance configuration, or adding indexes.Undo Management AdvisorWith the Undo Management Advisor, you can determine the undo tablespace size that is required to support a given retention period. Undo management and the use of the advisor is covered in the lesson titled “Managing Undo Data.”Data Recovery AdvisorThis advisor automatically diagnoses persistent data failures, presents repair options to the user, and executes repairs at the user’s request. The purpose of the Data Recovery Advisor is to reduce the mean time to recover (MTTR) and provide a centralized tool for automated data repair. SQL Repair AdvisorYou run the SQL Repair Advisor after a SQL statement fails with a critical error that generates a problem in the Automatic Diagnostic Repository. The advisor analyzes the statement and, in many cases, recommends a patch to repair the statement. If you implement the recommendation, the applied SQL patch circumvents the failure by causing the query optimizer to choose an alternative execution plan for future executions. This is done without changing the SQL statement itself.
Background image
Oracle Database 12c: Administration Workshop 17 - 19The Advisor Central page is the main page of all advisors. You can reach this page by selecting Advisors Home in the Performance menu. It is also possible to have access to advisors in certain contexts.On the Advisors tab of the Advisor Central page, you can see all the advisor tasks that are registered in the workload repository. You can also filter this list by advisor type and for predefined time periods.The Checkers tab of the Advisor Central page enables you to schedule various database integrity checkers. You can see all the checker runs by name, type, or time period. Some advisors are described in greater detail in the lessons titled “Managing Undo Data,” “Managing Performance,” “Managing Performance: SQL Tuning,” and “Backup and Recovery Concepts.”Note:Use the Change Default Parameters page to change the default expiration (in days) for all future tasks. You can also use this page to change the parameters of some important advisors.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Viewing the Advisor Central Page in Enterprise Manager Cloud Control
Background image
Oracle Database 12c: Administration Workshop 17 - 20The DBMS_ADVISORpackage contains all constants and procedure declarations for all advisor modules. However, some of the advisors have their own separate packages. Oracle recommends that you use the advisor-specific package rather than DBMS_ADVISORfor the following advisors:Automatic Database Diagnostic Monitor (DBMS_ADDM)SQL Performance Analyzer (DBMS_SQLPA)SQL Repair Advisor (DBMS_SQLDIAG)SQL Tuning Advisor (DBMS_SQLTUNE)Compression Advisor (DBMS_COMPRESSION.GET_COMPRESSION_RATIO)You can use DBMS_ADVISORand the other advisor packages to execute tasks from the command line.To execute advisor procedures, you must be granted the ADVISORprivilege. The ADVISORprivilege permits full access to the advisor procedures and views.Note:For more information about all the procedures found in the advisor packages, refer to the Oracle Database PL/SQL Packages and Types Reference.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using Packages to Invoke the AdvisorsPackage NameAdvisor NameDBMS_ADDMAutomatic Database Diagnostic Monitor (DBMS_ADDM)DBMS_ADVISORSQL Access Advisor and Segment AdvisorDBMS_COMPRESSIONCompression AdvisorDBMS_SQLDIAGSQL Repair AdvisorDBMS_SQLPASQL Performance AnalyzerDBMS_SQLTUNESQL Tuning Advisor
Background image
Oracle Database 12c: Administration Workshop 17 - 21By analyzing the information stored in the AWR, the database server can identify the need to perform routine maintenance tasks, such as optimizer statistics refresh. The automated maintenance tasks infrastructure enables the Oracle Database server to automatically perform such operations. It uses the Scheduler to run such tasks in predefined maintenance windows.By default, the weekday maintenance windows start at 10:00 PM and last four hours. On Saturday and Sunday, the maintenance window starts at 6:00 AM and lasts for 20 hours. All attributes of the maintenance windows are customizable, including the start and end times, frequency, days of the week, and so on. In addition, the impact of automated maintenance tasks on normal database operations can be limited by associating a Database Resource Manager resource plan to the maintenance window.Examples of maintenance:Optimizer statistics are automatically refreshed by using the automatic maintenance task infrastructure.The Automatic Segment Advisor has default jobs, which run in the maintenance window.When creating a database with the DBCA, you can initiate regular database backups.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Automated Maintenance TasksAutotask 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 statisticsAutomatic Segment AdvisorAutomatic SQL Advisor
Background image
Oracle Database 12c: Administration Workshop 17 - 22To access the Automated Maintenance Task page, expand the Administration menu and select Automated Maintenance Tasks in the Oracle Scheduler submenu. On this page, you can view the automated maintenance task schedule and recent history. From here, you can drill down to details on some tasks. Click Configure to go to the Automated Maintenance Tasks Configuration page. A task executes in a window. The graph shows the last window in which a task was executed and the next window in which the task is scheduled to be executed.Note:The default windows for tasks are shown in the example. When the maintenance window closes, the Scheduler terminates the optimizer statistics–gathering job by default. The remaining objects are then processed in the next maintenance window.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Automated Maintenance Tasks
Background image
Oracle Database 12c: Administration Workshop 17 - 23On the Automated Maintenance Tasks Configuration page, you can enable and disable automatic maintenance tasks—all at once, by individual tasks, or by particular windows. You can also configure the settings that are used for optimizer statistics gathering and the job control parameters for the automatic SQL Tuning Advisor. Select the window name to view or edit the window schedule.Click Edit Window Group to add and remove windows in the window group.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Automated Maintenance Tasks Configuration
Background image
Oracle Database 12c: Administration Workshop 17 - 24Alerts are notifications of when a database is in an undesirable state and needs your attention. By default, the Oracle Database server provides alerts via Enterprise Manager. Optionally, Enterprise Manager can be configured to send an email message to the administrator about problem conditions as well as display alert information on the console. You can also set thresholds on many of the pertinent metrics for your system. Oracle Database proactively notifies you if the database deviates sufficiently from normal readings to reach those thresholds. An early notification of potential problems enables you to respond quickly and, in many cases, resolve issues before users even notice them.Approximately, 60 metrics are monitored by default, among which are:Broken Job CountDatabase Time Spent Waiting (%)Dump Area Used (%)SQL Response Time (%) compared to baselineTablespace Used (%)Generic IncidentA few additional key metrics can provide early problem notification:Average File Read Time (centiseconds)Response Time (per transaction)Wait Time (%)Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Server-Generated AlertsServeralertsqueue.Metric exceedsthreshold.AWREnterprise ManagerOracle instance
Background image
Oracle Database 12c: Administration Workshop 17 - 25To access the Metric and Collection Settings page, expand the Oracle Database menu and select Metric and Collection Settings from the Monitoring submenu.Enter your desired warning and critical threshold values for the metric. The appropriate alerts appear when the database reaches your specified values. The thresholds that are already set appear in the “Metrics with thresholds” list. By default, approximately 60 metrics have preset thresholds; you may change these as needed. The “All metrics” list shows the metrics that do not have thresholds set. Click the Edit icon to access a page where you can specify additional corrective actions for either warning or critical thresholds. Click a Collection Schedule link to change the scheduled collection interval. Be aware that each schedule affects a group of metrics.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Setting Metrics Thresholds
Background image
Oracle Database 12c: Administration Workshop 17 - 26When you receive an alert, follow the recommendations that it provides. Or you can consider running the ADDM (or another advisor as appropriate) to obtain more detailed diagnostics of system or object behavior. Alerts and incidents are generated for critical errors. Critical errors usually generate incidents that are collected into problems. You use the Support Workbench to investigate and possibly report the problem to Oracle Support. Most alerts (such as “Out of Space”) are cleared automatically when the cause of the problem disappears. However, other alerts (such as Generic Alert Log Error) are sent to you for notification and must be acknowledged by you. After taking the necessary corrective measures, you acknowledge an alert by clearing or purging it. Clearing an alert sends the alert to the Alert History, which is accessible from the Monitoring submenu. Purging an alert removes it from the Alert History.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Reacting to AlertsIf 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.
Background image
Oracle Database 12c: Administration Workshop 17 - 27There are two kinds of server-generated alerts: threshold and nonthreshold. Most server-generated alerts are configured by setting a warning and critical threshold values on database metrics. You can define thresholds for more than 120 metrics, including the following:Physical Reads Per SecUser Commits Per SecSQL Service Response TimeExcept for the Tablespace Space Usage metric, which is database related, the other metrics are instance related. Threshold alerts are also referred to as stateful alerts, which are automatically cleared when an alert condition clears. Stateful alerts appear in DBA_OUTSTANDING_ALERTSand, when cleared, go to DBA_ALERT_HISTORY. Other server-generated alerts correspond to specific database events, such as ORA-*errors, “Snapshot too old” errors, Recovery Area Low On Free Space, and Resumable Session Suspended. These are non-threshold-based alerts, also referred to as stateless alerts. Stateless alerts go directly to the history table.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Alert Types and Clearing AlertsMMON85% Warning97% CriticalClearedClearedAlertSnapshotToo OldResumableSessionSuspendedRecovery Area Low On Free SpaceMetric basedEvent basedThreshold(stateful)alertsNonthreshold (stateless)alertsDBA_OUTSTANDING_ALERTSDBA_ALERT_HISTORY
Background image
Oracle Database 12c: Administration Workshop 17 - 28Answer: bCopyright © 2013, Oracle and/or its affiliates. All rights reserved.QuizStateless alerts, such as SNAPSHOT TOO OLDcan be found in the dictionary view DBA_OUTSTANDING_ALERTS.a.Trueb.False
Background image
Oracle Database 12c: Administration Workshop 17 - 29Copyright © 2013, Oracle and/or its affiliates. All rights reserved.SummaryIn this lesson, you should have learned how to:Manage the Automatic Workload Repository (AWR)Use the Automatic Database Diagnostic Monitor (ADDM)Describe and use the advisory frameworkSet alert thresholds Use server-generated alertsUse automated tasks
Background image
Oracle Database 12c: Administration Workshop 17 - 30Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Practice: OverviewThis practice covers proactively managing your database with ADDM, including:Setting up an issue for analysisReviewing your database performanceImplementing a solution
Background image
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Managing Performance
Background image
Oracle Database 12c: Administration Workshop 18 - 2Copyright © 2013, Oracle and/or its affiliates. All rights reserved.ObjectivesAfter completing this lesson, you should be able to use:Enterprise Manager to monitor performanceAutomatic Memory Management (AMM)The Memory Advisor to size memory buffers
Background image
Oracle Database 12c: Administration Workshop 18 - 3To administer Oracle Database and keep it running smoothly, the database administrator (DBA) must regularly monitor its performance to locate bottlenecks and to correct problem areas. A DBA can look at hundreds of performance measurements, covering everything from network performance and disk input/output (I/O) speed to the time spent working on individual application operations. These performance measurements are commonly referred to as database metrics.Note:For more information about Oracle database performance, see the Oracle Database 12c: Performance Tuningcourse.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Performance MonitoringMemory allocationissuesInput/outputdevicecontentionApplication code problemsResourcecontentionNetwork bottlenecks?DBA
Background image
You can respond to changes in performance only if you know the performance has changed. Oracle Database provides several ways to monitor the current performance of the database instance. The database home page of Enterprise Manager Database Express provides a quick check of the health of the instance and the server, with graphs showing CPU usage, active sessions, memory and data storage usage. The home page also shows any alerts that have been triggered. Additional detail is available on the Performance Hub page. This page will be reviewed later in the lesson.The information displayed in Enterprise Manager is based on performance views that exist in the database. You can access these views directly with SQL*Plus. Occasionally, you may need to access these views for some detail about the raw statistics.Oracle Database 12c: Administration Workshop 18 - 4Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Performance Monitoring Use the Enterprise Manager Database Express home page for:Performance overview Graphs of metrics and details
Background image
The three facets of tuning involve performance planning, instance tuning, and SQL tuning. Performance planning is the process of establishing the environment: the hardware, software, operating system, network infrastructure, and so on. Instance tuning is the actual adjustment of Oracle database parameters and operating system (OS) parameters to gain better performance of the Oracle database. SQL tuning involves making your application submit efficient SQL statements. SQL tuning is performed for the application as a whole, as well as for individual statements. At the application level, you want to be sure that different parts of the application are taking advantage of each other’s work and are not competing for resources unnecessarily.Note: For more information about performance tuning, refer to the Oracle Database Performance Tuning Guide.Oracle Database 12c: Administration Workshop 18 - 5Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Tuning ActivitiesThe three activities in performance management are:Performance planningInstance tuningSQL tuning
Background image
There are many facets to performance planning. Planning must include a balance between performance (speed), cost, and reliability. You must consider the investment in your system architecture: the hardware and software infrastructure needed to meet your requirements. This, of course, requires analysis to determine the value for your given environment, application, and performance requirements. For example, the number of hard drives and controllers has an impact on the speed of data access.The ability of an application to scale is also important. This means that you are able to handle more and more users, clients, sessions, or transactions, without incurring a huge impact on overall system performance. The most obvious violator of scalability is serializing operations among users. If all users go through a single path one at a time, then, as more users are added, there are definitely adverse effects on performance. This is because more and more users line up to go through that path. Poorly written SQL also affects scalability. It requires many users to wait for inefficient SQL to complete; each user competing with the other on a large number of resources that they are not actually in need of.The principles of application design can greatly affect performance. Simplicity of design, use of views and indexes, and data modeling are all very important.Oracle Database 12c: Administration Workshop 18 - 6Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Performance PlanningInvestment optionsSystem architectureScalabilityApplication design principlesWorkload testing, modeling, and implementationDeploying new applications
Background image
Any application must be tested under a representative production workload. This requires estimating database size and workload, and generating test data and system load.Performance must be considered as new applications (or new versions of applications) are deployed. Sometimes, design decisions are made to maintain compatibility with old systems during the rollout. A new database should be configured (on the basis of the production environment) specifically for the applications that it hosts.A difficult and necessary task is testing the existing applications when changing the infrastructure. For example, upgrading the database to a newer version, or changing the operating system or server hardware. Before the application is deployed for production in the new configuration, you want to know the impact. The application will almost certainly require additional tuning. You need to know that the critical functionality will perform, without errors.Oracle Database 12c: Administration Workshop 18 - 7
Background image
At the start of any tuning activity, it is necessary to have specific goals. A goal, such as “Process 500 sales transactions per minute” is easier to work toward than one that says, “Make it go as fast as you can, and we’ll know when it’s good enough.”You must allocate Oracle database memory suitably for your application to attain optimum performance. You have a finite amount of memory to work with. Too little memory allotted to certain parts of the Oracle database server can cause inefficient background activity, which you may not even be aware of without doing some analysis.Disk I/O is often the bottleneck of a database and, therefore, requires a lot of attention at the outset of any database implementation.The operating system configuration can also affect the performance of an Oracle database. For more information, see theOracle Database Installation Guidefor your particular platform.Oracle Database 12c: Administration Workshop 18 - 8Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Instance TuningHave well-defined goals.Allocate memory to database structures.Consider I/O requirements in each part of the database.Tune the operating system for optimal performance of the database.
Background image
Oracle has developed a tuning methodology based on years of experience. The basic steps are:1.Check the OS statistics and general machine health before tuning the instance to be sure that the problem is in the database. Use the Enterprise Manager database home page.2.Tune from the top down. Start with the design, then the application, and then the instance. For example, try to eliminate the full tables scans causing the I/O contention before tuning the tablespace layout on disk. This activity often requires access to the application code. 3.Tune the area with the greatest potential benefit. The tuning methodology presented in this course is simple. Identify the biggest bottleneck and tune it. Repeat this step. All the various tuning tools have some way to identify the SQL statements, resource contention, or services that are taking the most time. The Oracle database provides a time model and metrics to automate the process of identifying bottlenecks. The Advisors available in Oracle Database use this methodology. 4.Stop tuning when you meet your goal. This step implies that you set tuning goals.This is a general approach to tuning the database instance and may require multiple passes.Oracle Database 12c: Administration Workshop 18 - 9Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Performance Tuning MethodologyThe tuning steps:Tune from the top down. Tune the:1.Design 2.Application code3.InstanceTune the area with the greatest potential benefit. Identify and tune:SQL using the greatest resourcesThe longest waitsThe largest service timesStop tuning when the goal is met.
Background image
The Oracle database server software captures information about its own operation. Three major types of data are collected: cumulative statistics, metrics, and sampled statistics. Cumulative statistics are counts and timing information of a variety of events that occur in the database server. Some are quite important, such as buffer busy waits. Others have little impact on tuning, such as index block split. The most important events for tuning are usually the ones showing the greatest cumulative time values. The statistics in Oracle Database are correlated by the use of a time model. The time model statistics are based on a percentage of DB time, giving them a common basis for comparison. Metrics are statistic counts per unit. The unit could be time (such as seconds), transaction, or session. Metrics provide a base to proactively monitor performance. You can set thresholds on a metric, causing an alert to be generated. For example, you can set thresholds for when the reads per millisecond exceed a previously recorded peak value or when the archive log area is 95% full. Sampled statistics are gathered automatically when STATISTICS_LEVELis set to TYPICALor ALL. Sampled statistics allow you to look back in time. You can view session and system statistics that were gathered in the past, in various dimensions, even if you had not thought of specifying data collection for these beforehand.Oracle Database 12c: Administration Workshop 18 - 10Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Performance Tuning DataType of data gathered:Cumulative statistics: Wait events with time informationTime modelMetrics: Statistic rates Sampled statistics: Active session historyStatistics by sessionStatistics by SQLStatistics by serviceOther dimensions
Background image
Oracle Database 12c: Administration Workshop 18 - 11You can access the Performance Hub page from the Performance menu. On the Performance Hub page, you can view all the performance data available for a specified time period.You can choose to view real-time data or historical data. More granular data is shown when you choose real-time data. When you view historical data, the data points are averaged out to the Automatic Workload Repository (AWR) interval (usually an hour).Different tabs are available on the Performance Hub page based on whether you choose real-time or historical data.The following tabs are available for both real-time and historical data:Summary:Provides an overall view of the performance of the system for the specified time periodRAC:Appears only when Enterprise Manager Database Express is being used with an Oracle Real Application Clusters (RAC) database or cluster databaseActivity:Shows Active Session History (ASH) analyticsWorkload:Profile charts show the pattern of user calls, parse calls, redo size, and SQL*Net over the last 60 minutes in real-time mode. The Sessions chart shows the logon rate, current logons, and open cursors.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using the Enterprise Manager Database Express Performance Hub Page
Background image
Monitored SQL:Shows information about monitored SQL statements that were executing or that completed during the selected time periodADDM:Shows performance findings and recommendations from the Automatic Database Diagnostics Monitor (ADDM) for tasks performed in the database during the selected time periodThe following tab is only available if you select real-time data:Current Findings:Shows ADDM findings for the past five minutesThe following tabs are only available if you select historical data:Database Time:Shows wait events by category for various metrics, and to view time statistics for various metrics for the selected time periodResources:Shows operating system resource usage statistics, I/O resource usage statistics, and memory usage statistics for the selected time periodSystem Statistics:Shows database statistics by value, per transaction, or per second for the selected time periodOracle Database 12c: Administration Workshop 18 - 12
Background image
Oracle Database 12c: Administration Workshop 18 - 13You can also use Enterprise Manager Cloud Control to manage the performance of your database. Access the Performance Home page by selecting Performance Home in the Performance menu.The Performance Home page provides an overall view of performance statistics for your database. You can use the information on this page to determine whether resources need to be added or redistributed.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using the Enterprise Manager Cloud Control Performance Home Page
Background image
Enterprise Manager Cloud Control provides session detail pages so that you can view the wait events occurring in individual sessions. Select Top Activity in the Performance menu to view the summary of all sessions. In the lower right corner of the Top Activity page is a list of the Top Sessions. Click the session identifier to view the Session Details page. The Top Activity page and Session Details page are based on performance views in the database. Oracle Database 12c: Administration Workshop 18 - 14Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Monitoring Session Performance
Background image
Oracle Database 12c: Administration Workshop 18 - 15At the bottom of the Top Activity page, click Top Consumers in the Additional Monitoring Links section to access the Top Consumers page.The Top Consumers Overview page shows in graphical format:Top services Top modules (by service) Top actions (by service and module) Top clientsOn the Top Consumers page, click the Top Sessions tab to see critical statistics of the sessions using the most resources:CPU PGA MemoryLogical ReadsPhysical Read Hard Parse countSort countClick a column name to have the results sorted by the value in that column.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Performance Monitoring: Top Sessions
Background image
You can display current session information for each user logged on by querying V$SESSION. For example, you can use V$SESSIONto determine whether a session represents a user session, or was created by a database server process (BACKGROUND).You can query either V$SESSIONor V$SESSION_WAITto determine the resources or events for which active sessions are waiting.You can view user session statistics in V$SESSTAT. The V$SESSION_EVENTview lists information about waits for an event by a session. Cumulative values for instance statistics are generally available through dynamic performance views, such as V$SESSTATand V$SYSSTAT. Note that the cumulative values in dynamic views are reset when the database instance is shut down. The V$MYSTATview displays the statistics of the current session.You can also query V$SESSMETRICto display the performance metric values for all active sessions. This view lists performance metrics, such as CPU usage, number of physical reads, number of hard parses, and the logical read ratio.Oracle Database 12c: Administration Workshop 18 - 16Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Displaying Session-Related StatisticsV$STATNAMESTATISTIC# NAME CLASSSTAT_IDDISPLAY_NAMECON_IDV$SESSTATSIDSTATISTIC#VALUECON_IDV$SESSIONSADDR SIDEVENT#EVENTP1/2/3TEXTP1/2/3P1/2/3RAWWAIT_CLASSWAIT_TIMESECONDS_IN_WAITSTATE...V$SESSION_EVENTSIDEVENTTOTAL_WAITSTOTAL_TIMEOUTSTIME_WAITEDAVERAGE_WAITMAX_WAITTIME_WAITED_MICROEVENT_IDV$EVENT_NAMEEVENT#EVENT_IDNAMEPARAMETER1PARAMETER2 PARAMETER3
Background image
Oracle Database 12c: Administration Workshop 18 - 17In multitier systems where there is an application server that is pooling database connections, viewing sessions may not provide the information you need to analyze performance. Grouping sessions into service names enables you to monitor performance more accurately. Regardless of the session that was used for a particular request, if it connected via one of these services, the performance data of the session is captured under that service name.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Performance Monitoring: Top Services
Background image
In an n-tier environment where there is an application server that is pooling database connections, viewing sessions may not provide the information you need to analyze performance. Grouping sessions into service names enables you to monitor performance more accurately. These two views provide the same information that their like-named session counterparts provide, except that the information is presented at the service level rather than at the session level.V$SERVICE_WAIT_CLASSshows wait statistics for each service, broken down by wait class.V$SERVICE_EVENTshows the same information as V$SERVICE_WAIT_CLASS, except that it is further broken down by event ID.You can define a service in the database by using the DBMS_SERVICEpackage and use the net service name to assign applications to a service. Oracle Database 12c: Administration Workshop 18 - 18Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Displaying Service-Related StatisticsFor n-tier environments, because session statistics are not as helpful, you can see service-level statistics in these views:V$SERVICE_EVENT:Aggregated wait counts and wait times for each service, on a per-event basisV$SERVICE_WAIT_CLASS:Aggregated wait counts and wait times for each service on a wait-class basis
Background image
Oracle Database 12c: Administration Workshop 18 - 19You can access detailed information on waits from the Average Active Sessions graph on the Performance Home page.When you drill down to a particular wait category, you can view details of specific five-minute intervals and also see the Top Working SQL and the Top Working Sessions associated with that particular wait event during that time. This enables you to perform after-the-fact analysis of system slowdowns and determine potential causes.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Viewing Wait Events
Background image
Wait events are statistics that are incremented by a server process or thread to indicate that it had to wait for an event to complete before being able to continue processing. Wait event data reveals various symptoms of problems that might be impacting performance, such as latch contention, buffer contention, and I/O contention. Remember that these are only symptoms of problems, not the actual causes.Wait events are grouped into classes. The wait event classes include: Administrative, Application, Cluster, Commit, Concurrency, Configuration, Idle, Network, Other, Scheduler, System I/O, and User I/O.There are more than 800 wait events in the Oracle database, including free buffer wait, latch free, buffer busy waits, db file sequential read, and db file scattered read.Oracle Database 12c: Administration Workshop 18 - 20Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Oracle Wait EventsA collection of wait events provides informationabout the sessions or processes that had to wait or must wait for different reasons.These events are listed in the V$EVENT_NAMEview.
Background image
Because there is a finite amount of memory available on a database server and thus, on an Oracle database instance, you must pay attention to how memory is allocated. If too much memory is allowed to be used by a particular area that does not need it, other areas may not function properly because of lack of memory. With the ability to have memory allocation automatically determined and maintained for you, the task is simplified greatly. But even automatically tuned memory needs to be monitored for optimization and may need to be manually configured to some extent.Oracle Database 12c: Administration Workshop 18 - 21Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Memory Management: OverviewDBAs must consider memory management to be a crucial part of their job because:There is a finite amount of memory availableAllocating more memory to serve certain types of functions can improve overall performanceAutomatically tuned memory allocation is often the appropriate configuration, but specific environments or even short-term conditions may require further attention
Background image
Oracle Database 12c: Administration Workshop 18 - 22Oracle Database enables you to specify the total memory allocated to the instance. Memory will be dynamically reallocated between the System Global Area (SGA) and Program Global Area (PGA) as needed. This method is called Automatic Memory Management (AMM) and is available on only those platforms that support dynamic release of memory. This simplifies your memory management tasks. Memory advisors are available to help you set the initialization parameters on various levels. The advisor available depends on the level on which you are specifying the memory parameters. If you enable AMM, only the Memory Size Advisor is available. Automatic Shared Memory Management (ASMM) enables you to manage the SGA as a whole. The SGA comprises several components. The sizes of many of these components are dynamically adjusted for best performance within the limits of the initialization parameters. When the AMM is enabled, the ASMM is automatically enabled. If the ASMM is enabled but not the AMM, the SGA Size Advisor is available.You can manage the size of individual components manually by setting the initialization parameter for each component. If the Oracle server notifies you of a performance problem that is related to the size of an SGA or PGA component, you can use the Memory Advisor for the component to determine appropriate new settings. The Memory Advisor can model the effect of parameter changes.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Managing Memory ComponentsAutomatic Memory Management (AMM) enables you to specify total memory allocated to instance (including both SGA and PGA)Automatic Shared Memory Management (ASMM):Enables you to specify total SGA memory through one initialization parameterEnables the Oracle server to manage the amount of memory allocated to the shared pool, Java pool, buffer cache, streams pool, and large poolManually setting shared memory management:Sizes the components through multiple individual initialization parametersUses the appropriate Memory Advisor to make recommendations
Background image
If possible, it is best to fit the SGA into physical memory, which provides the fastest access. Even though the OS may provide additional virtual memory, that memory, by its nature, can often be swapped out to disk. On some platforms, you can use the LOCK_SGAinitialization parameter to lock the SGA into physical memory. This parameter cannot be used in conjunction with AMM or ASMM.When a SQL statement executes, data blocks are requested for reading or writing, or both. This is considered a logical I/O. As the block is requested, the block is checked to see whether it already exists in memory. If it is not in memory, it is read from disk, which is called a physical I/O. When the block is found in memory, the cost is several orders of magnitude less than the cost of reading the block from disk. The size of the SGA components in combination with the workload has a large affect on the number of physical reads. A simple view of this implies that you should increase the memory for the SGA components as much as possible. A larger SGA is not always better. There is a point where adding more memory yields diminishing returns. This principle applies to the buffer cache, the shared pool, and other SGA components. In practice, you find that shifting memory from one SGA component to another may increase overall performance, without changing the total amount of memory given to the SGA depending on the characteristics of the workload.Oracle Database 12c: Administration Workshop 18 - 23Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Efficient Memory Usage: GuidelinesFit the SGA into physical memory.Use the Memory Advisors.Tune for the most efficient use of memoryReduce overall physical I/OReduce the total memory needs
Background image
Memory has an upper limit in all current machines. That limit may be imposed by the hardware, operating system, or the cost of the memory. The goal of memory tuning is to produce the most efficient use of existing memory. When the workload changes often, the most efficient division of memory between the SGA components will change. There is also the amount of memory allocated to SGA and PGA. Online transaction processing (OLTP) systems typically use very little PGA memory compared to data warehouse (DW) or decision support systems (DSS).Enterprise Manager Cloud Control and Enterprise Manager Database Express both provide Memory Advisors. These tools monitor the memory usage by the SGA components, and PGA, and project the differences in terms of efficiency for increased and decreased memory allocations. These projections use the current workload. They can help you size the SGA on the basis of the activity in your particular database. The advisors will make sizing recommendations for manual settings, when the automatic memory management is disabled. These same advisors provide input to the automatic memory management, to determine the most efficient component sizes. Using the existing memory efficiently also includes tuning the applications. A poorly tuned application can use large quantities of memory. For example, an application that uses frequent full table scans because indexes do not exist or are unusable can cause a large amount of I/O, reducing performance. The first and most effective tuning technique is to tune high cost SQL statements. Tuning SQL statements is covered in more detail in the lesson titled “Managing Performance: SQL Tuning.Oracle Database 12c: Administration Workshop 18 - 24
Background image
Automatic Memory Management (AMM) allows the Oracle Database server to manage SGA memory and instance PGA memory sizing automatically. To do so (on most platforms), you set only a target memory size initialization parameter (MEMORY_TARGET) and a maximum memory size initialization parameter (MEMORY_MAX_TARGET), and the database server dynamically exchanges memory between the SGA and the instance PGA as needed to meet processing demands. With this memory management method, the database server also dynamically tunes the sizes of the individual SGA components and the sizes of the individual PGAs.Because the target memory initialization parameter is dynamic, you can change the target memory size at any time without restarting the database instance. The maximum memory size serves as an upper limit so that you cannot accidentally set the target memory size too high. Because certain SGA components either cannot easily shrink or must remain at a minimum size, the database server also prevents you from setting the target memory size too low.This indirect memory transfer relies on the operating system (OS) mechanism of freeing shared memory. After memory is released to the OS, the other components can allocate memory by requesting memory from the OS. Currently, Automatic Memory Management is implemented on Linux, Solaris, HPUX, AIX, and Windows.Oracle Database 12c: Administration Workshop 18 - 25Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Automatic Memory Management: OverviewWith Automatic Memory Management, the database server can size the SGA and PGA automatically according to your workload.11gMemoryMax Target640 MB1000 MBALTER SYSTEM SET MEMORY_TARGET=800M;11gMemoryMax Target800 MB1000 MBOracle recommends the use of AMM unless you have special requirements.Memory TargetMemory Target
Background image
The graphic in the slide shows you the memory initialization parameters hierarchy. Although you have to set only MEMORY_TARGETto trigger Automatic Memory Management, you still have the ability to set lower bound values for various caches. Therefore, if the child parameters are user-set, they will be the minimum values below which the Oracle database server will not autotune that component.If SGA_TARGETand PGA_AGGREGATE_TARGETare set to a nonzero value, they are considered to be the minimum values for the sizes of the SGA and the PGA, respectively. MEMORY_TARGETcan take values from SGA_TARGET+ PGA_AGGREGATE_TARGETto MEMORY_MAX_SIZE.If SGA_TARGETis set, the database server autotunes only the sizes of the subcomponents of the SGA. PGA is autotuned independent of whether it is explicitly set or not. However, the whole SGA(SGA_TARGET) and the PGA (PGA_AGGREGATE_TARGET) are not autotuned—that is, do not grow or shrink automatically.Oracle Database 12c: Administration Workshop 18 - 26Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Oracle Database Memory ParametersDB_KEEP_CACHE_SIZEDB_RECYCLE_CACHE_SIZEDB_nK_CACHE_SIZESHARED_POOL_SIZEDB_CACHE_SIZELARGE_POOL_SIZEJAVA_POOL_SIZESTREAMS_POOL_SIZESGA_TARGETSGA_MAX_SIZEMEMORY_MAX_TARGETMEMORY_TARGETOthersPGA_AGGREGATE_TARGETPGA_AGGREGATE_LIMITChild parameters: Providing minimum valuesAutomatic change of size only with autotuned parametersLOG_BUFFERRESULT_CACHE_SIZEThis enables AMM.This enables ASMM.Changing SGA_TARGETaffects only automatically sized components.
Background image
Oracle Database 12c: Administration Workshop 18 - 27If you did not enable Automatic Memory Management (AMM) when you configured your database, you can enable it by performing the following steps:1.Select Memory Advisors in the Performance menu. 2.Click Enable for Automatic Memory Management. 3.The Enable Automatic Memory Management page appears. Set the values for Total Memory Size and Maximum Memory Size for Automatic Memory Management. Note:If you change the Maximum Memory Size, the database instance must be restarted. 4. Click OK. You can increase the size at a later time by increasing the value of the Total Memory Size field or the MEMORY_TARGETinitialization parameter. However, you cannot set it higher than the value specified by the Maximum Memory Size field or the MEMORY_MAX_TARGETparameter. For more information, see the Oracle Database Administrator’s Guide. After AMM is enabled, the Memory Size Advisor is available to help you adjust the maximum and target memory sizes.Note:Oracle recommends that you use Automatic Memory Management to simplify memory management tasks.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Enabling Automatic Memory Management (AMM) by Using Enterprise Manager Cloud ControlClick Enable to enable Automatic Memory Management.
Background image
After Automatic Memory Management is enabled, you can see the graphical representation of the history of your memory size components in the Allocation History section of the Memory Advisors page. The top portion in the first histogram is tunable PGA only and the lower portion is all of SGA. Additional data is available on the page showing the SGA components history and a graphical representation of the SGA allocation.On this page, you can also access the memory target advisor by clicking the Advice button. This advisor gives you the possible DB time improvement for various total memory sizes.Note:You can also look at the memory target advisor by using the V$MEMORY_TARGET_ADVISORview.Oracle Database 12c: Administration Workshop 18 - 28Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Monitoring Automatic Memory Management
Background image
The V$MEMORY_DYNAMIC_COMPONENTSdynamic performance view shows the current sizes of all dynamically tuned memory components, including the total sizes of the SGA and instance PGA. The V$MEMORY_TARGET_ADVICEview provides tuning advice for the MEMORY_TARGETinitialization parameter.In the V$MEMORY_TARGET_ADVICEview, the row with the MEMORY_SIZE_FACTORof 1 shows the current size of memory, as set by the MEMORY_TARGETinitialization parameter, and the amount of DB time required to complete the current workload. In previous and subsequent rows, the results show several alternative MEMORY_TARGETsizes. For each alternative size, the database server shows the size factor (the multiple of the current size), and the estimated DB time to complete the current workload if the MEMORY_TARGETparameter were changed to the alternative size. Notice that for a total memory size smaller than the current MEMORY_TARGETsize, the estimated DB time increases.Oracle Database 12c: Administration Workshop 18 - 29Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Monitoring Automatic Memory ManagementUse the following views to monitor Automatic Memory Management:V$MEMORY_DYNAMIC_COMPONENTS: Current status of all memory componentsV$MEMORY_RESIZE_OPS: Circular history buffer of the last 800 memory resize requestsV$MEMORY_TARGET_ADVICE: Tuning advice for the MEMORY_TARGETinitialization parameter
Background image
If AMM does not work for you, because you need a fixed PGA, consider the use of Automatic Shared Memory Management (ASMM) which simplifies SGA memory management. You specify the total amount of SGA memory available to an instance by using the SGA_TARGETinitialization parameter and Oracle Database server automatically distributes this memory among the various SGA components to ensure the most effective memory utilization.For example, in a system that runs large online transactional processing (OLTP) jobs during the day (requiring a large buffer cache) and runs parallel batch jobs at night (requiring a large value for the large pool), you would have to simultaneously configure both the buffer cache and the large pool to accommodate your peak requirements.With ASMM, when the OLTP job runs, the buffer cache uses most of the memory to allow for good I/O performance. When the data analysis and reporting batch job starts up later, the memory is automatically migrated to the large pool so that it can be used by parallel query operations without producing memory overflow errors.The Oracle Database server remembers the sizes of the automatically tuned components across instance shutdowns if you are using a server parameter file (SPFILE). As a result, the system does need to learn the characteristics of the workload again each time an instance is started. It can begin with information from the past instance and continue evaluating workload where it left off at the last shutdown.Oracle Database 12c: Administration Workshop 18 - 30Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Automatic Shared Memory Management: OverviewAutomatically adapts to workload changesMaximizes memory utilizationHelps eliminate out-of-memory errorsOnline usersBatch jobsBuffer cacheLarge poolShared poolJava poolStreams poolBuffer cacheLarge poolShared poolJava poolStreams poolExample:
Background image
Oracle Database 12c: Administration Workshop 18 - 31Automatic Shared Memory Management is automatically enabled if you have enabled AMM. If you have not enabled AMM or did not enable ASMM when you configured your database, you can enable Automatic Shared Memory Management by performing the following steps:1.Select Memory Advisors in the Performance menu.2.The Memory Advisors page appears. Scroll down to the SGA section. Click Enable for Automatic Shared Memory Management.3.The Enable Automatic Shared Memory Management page appears. Specify the total SGA size. Click OK.You can increase the total SGA size at a later time by increasing the value of the Total SGA Size field or the SGA_TARGETinitialization parameter. However, you cannot set it higher than the value specified by the Maximum SGA Size field or the SGA_MAX_SIZEparameter. For more information, see the Oracle Database Administrator’s Guide.When AMM is disabled, the PGA advisor is accessible. The PGA advisor is recommended for setting the PGA memory value. Click the PGA tab to access the PGA property page. Click Advice to invoke the PGA Advisor.Note:Oracle recommends that you use Automatic Shared Memory Management to simplify your memory management tasks.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Enabling Automatic SharedMemory Management (ASMM)Click Enable to enable Automatic Shared Memory Management.
Background image
The Automatic Shared Memory Management feature uses the SGA memory broker that is implemented by two background processes: Manageability Monitor (MMON) and Memory Manager (MMAN). Statistics and memory advisory data are periodically captured in memory by MMON. MMANcoordinates the sizing of the memory components according to MMONdecisions. The SGA memory broker keeps track of the sizes of the components and pending resize operations.The SGA memory broker observes the system and workload in order to determine the ideal distribution of memory. It performs this check every few minutes so that memory can always be present where needed. In the absence of Automatic Shared Memory Management, components had to be sized to anticipate their individual worst-case memory requirements.On the basis of workload information, Automatic Shared Memory Management:Captures statistics periodically in the backgroundUses memory advisorsPerforms what-if analysis to determine the best distribution of the memoryMoves memory to where it is most neededSaves component sizes across shutdown if an SPFILE is used (the sizes can be resurrected from before the last shutdown)Oracle Database 12c: Administration Workshop 18 - 32Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Understanding Automatic Shared Memory ManagementASMM is based on workload information that MMONcaptures in the background.MMONuses memory advisors.Memory is moved to where it is needed the most by MMAN.If an SPFILE is used (which is recommended):Component sizes are saved across shutdownsSaved values are used to bootstrap component sizesThere is no need to relearn optimal values
Background image
Oracle Database 12c: Administration Workshop 18 - 33Before enabling ASMM, you should remove the individual memory area parameters from the SPFILE because having them set can impose restrictions on ASMM. After ASMM is enabled, the SGA Size Advisor is available to help you choose the best value for total SGA size. If after seeing the effects of the ASMM allocations you decide that you want to adjust certain component allocations, you can specify values for those components. If the values you are specifying are lower than the current values, those values are treated as minimum memory sizes for their respective components. If the values you are specifying are larger than the current values, the sizes of the memory components are resized upward to the values you provided as long as free memory is available. Setting limits reduces the amount of memory available for automatic adjustment, but the capability is available and can help overall performance. The initialization parameters of concern are the following:SHARED_POOL_SIZELARGE_POOL_SIZEJAVA_POOL_SIZEDB_CACHE_SIZESTREAMS_POOL_SIZETo adjust these parameters while ASMM is enabled, you must use the ALTER SYSTEMcommand.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Automatic Shared Memory Advisor
Background image
The procedure for enabling ASMM differs depending on whether you are changing to ASMM from manual shared memory management or from automatic memory management. To change to ASMM from manual shared memory management:1.Execute the following query to obtain a value for SGA_TARGET:SELECT ((SELECT SUM(value) FROM V$SGA) - (SELECT CURRENT_SIZE FROM V$SGA_DYNAMIC_FREE_MEMORY)) “SGA_TARGET” FROM DUAL;2.Set the value of SGA_TARGET:ALTER SYSTEM SET SGA_TARGET=value[SCOPE={SPFILE|MEMORY|BOTH}]where valueis the value computed in step 1 or is some value between the sum of all SGA component sizes and SGA_MAX_SIZE. 3.Set the values of the automatically sized SGA components to 0. Do this by editing the text initialization parameter file or by issuing ALTER SYSTEMstatements. Restart the instance if required.To change to ASMM from automatic memory management:1.Set the MEMORY_TARGETinitialization parameter to 0.ALTER SYSTEM SET MEMORY_TARGET = 0;The database sets SGA_TARGETbased on current SGA memory allocation.2.Set the values of the automatically sized SGA components to 0. Restart the instance when finished.Oracle Database 12c: Administration Workshop 18 - 34Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Enabling Automatic Shared Memory ManagementTo enable ASMM from manual shared memory management:1.Get a value for SGA_TARGET:2.Use that value to set SGA_TARGET.3.Set the values of the automatically sized SGA components to 0. To switch to ASMM from Automatic Memory Management:1.Set the MEMORY_TARGETinitialization parameter to 0.2.Set the values of the automatically sized SGA components to 0. SELECT ((SELECT SUM(value) FROM V$SGA) - (SELECT CURRENT_SIZE FROM V$SGA_DYNAMIC_FREE_MEMORY)) "SGA_TARGET" FROM DUAL;
Background image
You can dynamically choose to disable Automatic Shared Memory Management by setting SGA_TARGETto 0. In this case, the values of all the autotuned parameters are set to the current sizes of the corresponding components, even if the user had earlier specified a different nonzero value for an autotuned parameter.In the example in the slide, the value of SGA_TARGETis 8 GB and the value of SHARED_POOL_SIZEis 1 GB. If the system has internally adjusted the size of the shared pool component to 2 GB, setting SGA_TARGETto 0 results in SHARED_POOL_SIZEbeing set to 2 GB, thereby overriding the original user-specified value.Oracle Database 12c: Administration Workshop 18 - 35Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Disabling Automatic Shared Memory Management Setting SGA_TARGETto 0 disables autotuning.Autotuned parameters are set to their current sizes.The SGA size as a whole is unaffected.SGA size = 8 GBParameters:sga_target = 8Gshared_pool_size = 1GParameters:sga_target = 0db_cache_size = 5Gshared_pool_size = 2Glarge_pool_size = 512Mjava_pool_size = 256Mstreams_pool_size = 256MSGA size = 8 GBOriginal values
Background image
When you specify a nonzero value for SGA_TARGETand do not specify a value for an autotuned SGA parameter, the value of the autotuned SGA parameters in the V$PARAMETERview is 0, and the value of the ISDEFAULTcolumn is TRUE.If you have specified a value for any of the autotuned SGA parameters, the value that is displayed when you query V$PARAMETERis the value that you specified for the parameter.Oracle Database 12c: Administration Workshop 18 - 36Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using V$PARAMETERto View Memory Component SizesSGA_TARGET = 8GSELECT name, value, isdefault FROM v$parameterWHERE name LIKE '%size';DB_CACHE_SIZE = 0JAVA_POOL_SIZE = 0LARGE_POOL_SIZE = 0SHARED_POOL_SIZE = 0STREAMS_POOL_SIZE = 0
Background image
The Program Global Area (PGA) is a memory region that contains data and control information for a server process. It is nonshared memory created by the Oracle server when a server process is started. Access to it is exclusive to that server process. The total PGA memory allocated by all server processes attached to an Oracle instance is also referred to as the aggregated PGAmemory allocated by the instance.Part of the PGA can be located in the SGA when using shared servers.PGA memory typically contains the following:Private SQL AreaA private SQL area also called the user global area (UGA) contains data, such as bind information and runtime memory structures. This information is specific to each session’s invocation of the SQL statement; bind variables hold different values, and the state of the cursor is different, among other things. Each session that issues a SQL statement has a private SQL area. Each user that submits the same SQL statement has his or her own private SQL area that uses a single shared SQL area. Thus, many private SQL areas can be associated with the same shared SQL area. The location of a private SQL area depends on the type of connection established for a session. If a session is connected through a dedicated server, private SQL areas are located in the server process’s PGA. However, if a session is connected through a shared server, part of the private SQL area is kept in the SGA. Oracle Database 12c: Administration Workshop 18 - 37Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Managing the Program Global Area (PGA)UGAServerprocessPGADedicatedconnectionsPrivateSQLareasCursorand SQLareaSessionmemoryWorkareaShared poolorlarge poolUGASharedserverPGAShared serverconnectionsAutomatic PGA memory management is enabled by default.UGA
Background image
Cursor and SQL AreasThe application developer of an Oracle Pro*C program or Oracle Call Interface (OCI) program can explicitly open cursorsor handles to specific private SQL areas, and use them as a named resource throughout the execution of the program. Recursive cursors that the database issues implicitly for some SQL statements also use shared SQL areas.Work AreaFor complex queries (for example, decision support queries), a big portion of the PGA is dedicated to work areas allocated by memory-intensive operators, such as:Sort-based operators, such as ORDERBY, GROUPBY, ROLLUP, and window functionsHash-joinBitmap mergeBitmap createWrite buffers used by bulk load operationsA sort operator uses a work area (the sort area) to perform the in-memory sort of a set of rows. Similarly, a hash-join operator uses a work area (the hash area) to build a hash table from its left input.The size of a work area can be controlled and tuned. Generally, bigger work areas can significantly improve the performance of a particular operator at the cost of higher memory consumption. Session MemorySession memory is the memory allocated to hold a session’s variables (logon information) and other information related to the session. For a shared server, the session memory is shared and not private.Automatic PGA Memory ManagementBy default, Oracle Database automatically and globally manages the total amount of memory dedicated to the instance PGA. You can control this amount by setting the initialization parameter PGA_AGGREGATE_TARGET. Oracle Database then tries to ensure that the total amount of PGA memory allocated across all database server processes and background processes never exceeds this target. But this is target value and not a hard limit. PGA_AGGREGATE_LIMITsets a hard limit for the amount of PGA that can be used. The minimum value is 1024MBand the maximum is 120% of physical memory minus the total SGA, and it must be at least as large as PGA_AGGREGATE TARGET. If PGA_AGGREGATE_LIMITis not set, it defaults to 200% of PGA_AGGREGATE_TARGETwithin the same minimum and maximum as stated. When PGA_AGGREGATE_LIMITis exceeded, the sessions using the most memory will have their calls aborted. Parallel queries will be treated as a unit. If the total PGA memory usage is still over the limit, sessions using the most memory will be terminated. SYSprocesses and fatal background processes are exempt from this limit.Oracle Database 12c: Administration Workshop 18 - 38
Background image
Oracle Database 12c: Administration Workshop 18 - 39Statistics must be available for the effective diagnosis of performance problems. The Oracle server generates many types of statistics for different levels of granularity. At the systemwide, session, and service levels, both wait events and accumulated statistics are computed. In the slide, the top row of views shows the cumulative statistics. The bottom row shows the wait event views. When analyzing a performance problem in any of these scopes, you typically look at the change in statistics (delta value) over the period of time you are interested in. All the possible wait events are cataloged in the V$EVENT_NAMEview. All statistics are cataloged in the V$STATNAMEview; approximately 480 statistics are available in Oracle Database.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.V$SYSTEM_EVENT• EVENT• TOTAL_WAITS• TOTAL_TIMEOUTS• TIME_WAITED• AVERAGE_WAIT• TIME_WAITED_MICRODynamic Performance StatisticsV$SYSSTAT• STATISTIC# • NAME• CLASS• VALUE• STAT_IDV$SESSION_EVENT• SID• EVENT• TOTAL_WAITS• TOTAL_TIMEOUTS• TIME_WAITED• AVERAGE_WAIT• MAX_WAIT• TIME_WAITED_MICRO• EVENT_IDV$SESSTAT• SID• STATISTIC#• VALUEV$SERVICE_EVENT• SERVICE_NAME• SERVICE_NAME_HASH• EVENT• EVENT_ID• TOTAL_WAITS• TOTAL_TIMEOUTS• TIME_WAITED• AVERAGE_WAIT• TIME_WAITED_MICROV$SERVICE_STATS• SERVICE_NAME_HASH• SERVICE_NAME• STAT_ID• STAT_NAME• VALUESystemwideSession specificService specificCumulative statsWait events
Background image
Oracle Database 12c: Administration Workshop 18 - 40Displaying Systemwide StatisticsExample:SQL>SELECT name, class, value FROM v$sysstat;NAMECLASS VALUE------------------------------- ------ ----------...table scans (short tables) 64 135116table scans (long tables) 64 250table scans (rowid ranges) 64 0table scans (cache partitions) 64 3table scans (direct read) 64 0table scan rows gotten 64 14789836table scan blocks gotten 64 558542...Systemwide statistics are classified by the tuning topic and the debugging purpose. The classes include general instance activity, redo log buffer activity, locking, database buffer cache activity, and so on.
Background image
Oracle Database 12c: Administration Workshop 18 - 41In the slide, some of the views that can help you determine the cause of performance problems or analyze the current status of your database are listed.For a complete description of these views, see the Oracle Database Reference.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Instance/DatabaseV$DATABASEV$INSTANCEV$PARAMETERV$SPPARAMETERV$SYSTEM_PARAMETERV$PROCESSV$BGPROCESSV$PX_PROCESS_SYSSTATV$SYSTEM_EVENTTroubleshooting and Tuning ViewsDiskV$DATAFILEV$FILESTATV$LOGV$LOG_HISTORYV$DBFILEV$TEMPFILEV$TEMPSEG_USAGEV$SEGMENT_STATISTICSContentionV$LOCKV$UNDOSTATV$WAITSTATV$LATCHMemoryV$BUFFER_POOL_STATISTICSV$LIBRARYCACHEV$SGAINFOV$PGASTAT
Background image
Oracle Database 12c: Administration Workshop 18 - 42Answer: cCopyright © 2013, Oracle and/or its affiliates. All rights reserved.QuizAutomatic Memory Management allows the Oracle instance to reallocate memory from the _______ to the SGA . a.Large Pool b.Log Bufferc.PGAd.Streams Pool
Background image
Oracle Database 12c: Administration Workshop 18 - 43Answer: bCopyright © 2013, Oracle and/or its affiliates. All rights reserved.QuizSGA_TARGETmay not be sized greater than __________ . a.LOG_BUFFER b.SGA_MAX_SIZEc.STREAMS_POOL_SIZEd.PGA_AGGREGATE_TARGET
Background image
Oracle Database 12c: Administration Workshop 18 - 44Copyright © 2013, Oracle and/or its affiliates. All rights reserved.SummaryIn this lesson, you should have learned how to use:Enterprise Manager to monitor performanceAutomatic Memory Management (AMM)The Memory Advisor to size memory buffers
Background image
Oracle Database 12c: Administration Workshop 18 - 45Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Practice: OverviewThis practice covers the following topics:Using the Performance page in Enterprise ManagerDiagnosing a memory allocation problemEnabling and implementing Automatic Memory ManagementMonitoring Top Services and Sessions
Background image
Background image
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Managing Performance: SQL Tuning
Background image
Oracle Database 12c: Administration Workshop 19 - 2Copyright © 2013, Oracle and/or its affiliates. All rights reserved.ObjectivesAfter completing this lesson, you should be able to:Manage optimizer statisticsUse the SQL Tuning Advisor to: Identify SQL statements that are using the most resourcesTune SQL statements that are using the most resourcesUse the SQL Access Advisor to tune a workload
Background image
Generally, the tuning effort that yields the most benefit is SQL tuning. Poorly tuned SQL uses more resources than required. This inefficiency prevents scalability, uses more OS and database resources, and increases response time. To tune poorly tuned SQL statements, they must be identified, and then tuned. SQL statements can be tuned individually, but often the solution that optimizes one statement can hurt the performance of several others. The SQL statements that use the most resources are by definition the statements in need of tuning. These are statements that have the longest elapsed time, use the most CPU, or do the most physical or logical reads. Tune the individual statements by checking the optimizer statistics, check the explain plan for the most efficient access path, test alternate SQL constructions, and test possible new indexes, materialized views, and partitioning. Test the application as a whole, using the tuned SQL statements. Is the overall performance better? The methodology is sound, but tedious. Tuning an individual statement is not difficult. Testing the overall impact of the individual statement tuning on an application can be very difficult.In Oracle Database, a set of SQL advisors are available to identify and tune statements, individually, or as a set. Oracle Database 12c: Administration Workshop 19 - 3Copyright © 2013, Oracle and/or its affiliates. All rights reserved.SQL Tuning SQL tuning processIdentify poorly tuned SQL statements.Tune the individual statements.Tune the application as a whole.
Background image
Oracle Database 12c: Administration Workshop 19 - 4The optimizer is the part of the Oracle Database server that creates the execution plan for a SQL statement. The determination of the execution plan is an important step in the processing of any SQL statement and can greatly affect execution time.The execution plan is a series of operations that are performed in sequence to execute the statement. The optimizer considers many factors related to the referenced objects and the conditions specified in the query. The information necessary to the optimizer includes:Statistics gathered for the system (I/O, CPU, and so on) as well as schema objects (number of rows, index, and so on)Information in the dictionaryWHEREclause qualifiersHints supplied by the developerWhen you use diagnostic tools, such as Enterprise Manager, EXPLAINPLAN, and SQL*Plus AUTOTRACE, you can see the execution plan that the optimizer chooses.Note:The Oracle optimizer has two names based on its functionality: the query optimizerand the Automatic Tuning Optimizer.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Oracle Optimizer: OverviewThe 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 conditionsUses object and system statisticsDecides how to access the dataDecides how to join tablesDetermines the most efficient path
Background image
Oracle Database 12c: Administration Workshop 19 - 5Optimizer statistics include table, column, index, and system statistics. Statistics for tables and indexes are stored in the data dictionary. These statistics are not intended to provide real-time data. They provide the optimizer a statisticallycorrect snapshot of data storage and distribution, which the optimizer uses to make decisions on how to access data.The statistics that are collected include:Size of the table or index in database blocksNumber of rows Average row size and chain count (tables only)Height and number of deleted leaf rows (indexes only)As data is inserted, deleted, and modified, these facts change. Because the performance impact of maintaining real-time data distribution statistics is prohibitive, these statistics are updated by periodically gathering statistics on tables and indexes.Optimizer statistics are collected automatically by an automatic maintenance job that runs during predefined maintenance windows once daily by default. System statistics are operating system characteristics that are used by the optimizer. These statistics are not collected automatically. For details about collecting system statistics, see the Oracle Database Performance Tuning Guide.Optimizer statistics are not the same as the database performance statistics that are gathered in the AWR snapshot.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Optimizer StatisticsOptimizer statistics are:A snapshot at a point in timePersistent across instance restartsCollected automaticallySQL> SELECT COUNT(*) FROM hr.employees;COUNT(*)----------214SQL> SELECT num_rows FROM dba_tables2 WHERE owner='HR'ANDtable_name='EMPLOYEES';NUM_ROWS----------107
Background image
Optimizer statistics are collections of data that are specific details about database objects. These statistics are essential for the query optimizer to choose the best execution plan for each SQL statement. These statistics are gathered periodically and do not change between gatherings.The recommended approach to gathering optimizer statistics is to allow the Oracle Database server to automatically gather the statistics. The Automatic Maintenance Tasks can be created automatically at database creation time and is managed by the Scheduler. It gathers statistics on all objects in the database that have either missing or stale optimizer statistics by default. You can change the default configuration through the Automatic Maintenance Tasks page. System statistics describe the system’s hardware characteristics, such as I/O and CPU performance and utilization, to the query optimizer. When choosing an execution plan, the optimizer estimates the I/O and CPU resources required for each query. System statistics enable the query optimizer to more accurately estimate I/O and CPU costs, and thereby choose a better execution plan. System statistics are collected using the DBMS_STATS.GATHER_SYSTEM_STATSprocedure. When the Oracle Database server gathers system statistics, it analyzes system activity in a specified period of time. System statistics are not automatically gathered. Oracle Corporation recommends that you use the DBMS_STATSpackage to gather system statistics.Oracle Database 12c: Administration Workshop 19 - 6Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Optimizer Statistics CollectionSQL performance tuning: Depends on collection of accurate statisticsOptimizer statistics:Object statisticsOperating system statisticsWays to collect statistics:Automatically: Automatic Maintenance TasksManually: DBMS_STATSpackageBy setting database initialization parametersBy importing statistics from another database
Background image
If you choose not to use automatic statistics gathering, you must manually collect statistics in all schemas, including system schemas. If the data in your database changes regularly, you also need to gather statistics regularly to ensure that the statistics accurately represent characteristics of your database objects. To manually collect statistics, use the DBMS_STATSpackage. This PL/SQL package is also used to modify, view, export, import, and delete statistics. You can also manage optimizer and system statistics collection through database initialization parameters. For example:The OPTIMIZER_DYNAMIC_SAMPLINGparameter controls the level of dynamic sampling performed by the optimizer. You can use dynamic sampling to estimate statistics for tables and relevant indexes when they are not available or are too out of date to trust. Dynamic sampling also estimates single-table predicate selectivity when collected statistics cannot be used or are likely to lead to significant errors in estimation. The STATISTICS_LEVELparameter controls all major statistics collections or advisories in the database and sets the statistics collection level for the database. The values for this parameter are BASIC, TYPICAL, and ALL. You can query the V$STATISTICS_LEVELview to determine which parameters are affected by the STATISTICAL_LEVELparameter. Note:Setting STATISTICS_LEVELto BASICdisables many automatic features and is not recommended.Oracle Database 12c: Administration Workshop 19 - 7
Background image
Oracle Database 12c: Administration Workshop 19 - 8To manage optimizer statistics in Enterprise Manager, select Optimizer Statistics in the SQL submenu of the Performance menu. On the Manage Optimizer Statistics page, you can perform the following tasks:Gather optimizer statistics manually.Restore optimizer statistics to a point in the past. The chosen point in time must be within the optimizer statistics retention period, which defaults to 30 days.Lock optimizer statistics to guarantee that the statistics for certain objects are never overwritten. This is useful if statistics have been calculated for a certain table at a time when well-representative data is present, and you want to always have those statistics. No fluctuations in the table affect the statistics if they are locked.Unlock optimizer statistics to undo the previously done lock.Delete optimizer statistics to delete statistics.Best-Practice TipUse the automatic maintenance tasks to gather optimizer statistics. To enable the task for gathering optimizer statistics gathering, you must ensure that the STATISTICS_LEVELinitialization parameter is set to TYPICALor ALL. Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using the Manage Optimizer Statistics Page
Background image
You can manage global preference settings by using Enterprise Manager. Click the Global Statistics Gathering Options link on the Manage Optimizer Statistics page.On the Global Statistics Gathering Options page, change the global preferences in the Gather Optimizer Statistics Default Options section. When finished, click the Apply button.Note:To change the statistics gathering options at the object level or schema level, click the Object Level Statistics Gathering Preferences link on the Manage Optimizer Statistics page.Oracle Database 12c: Administration Workshop 19 - 9Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Setting Global Preferences by UsingEnterprise Manager Cloud Control
Background image
Oracle Database 12c: Administration Workshop 19 - 10You may need to gather statistics manually at certain times, such as when the contents of a table have changed so much between automatic gathering jobs that the statistics no longer represent the table accurately. This is common for large tables that experience more than a 10 percent change in size in a 24-hour period.Best-practice tip:Collect statistics often enough that the table never changes by more than about 10 percent between collection periods. This may require manual statistics collection or additional maintenance windows. Statistics can be manually collected by using either Enterprise Manager or the DBMS_STATSpackage. System statistics can be gathered only by using the DBMS_STATSpackage. System statistics describe the system’s hardware characteristics, such as I/O and CPU performance and utilization, to the query optimizer.The Gather Optimizer Statistics menu selection starts a wizard that enables you to select the scope, objects, options, and schedule for a job that will gather optimizer statistics. The wizard submits a DBMS_STATS.GATHER_*_STATSjob at the scope you specify: table, schema, or database. In this wizard, you set the preferences for the default values used by the DBMS_STATSpackage and you schedule this job to run at a time that you determine.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Gathering Optimizer Statistics Manually
Background image
Oracle Database 12c: Administration Workshop 19 - 11Gathering statistics manually for routine statistics collection is not recommended because the statistics are gathered more efficiently and with less impact on users during the maintenance windows. A manual job can also be submitted if the automatic job has failed or been disabled. You can also gather optimizer statistics with the DBMS_STATSpackage directly:SQL> EXEC dbms_stats.gather_table_stats('HR','EMPLOYEES');SQL> SELECT num_rows FROM dba_tables2 WHERE owner='HR' AND table_name = 'EMPLOYEES';NUM_ROWS----------214Notice that the number of rows now correctly reflects what was in the table at the time that the statistics were gathered. DBMS_STATSalso enables manual collection of statistics for an entire schema or even for the whole database.System statistics do not change unless the workload significantly changes. As a result, system statistics do not need frequent adjustment. The DBMS_STATS.GATHER_SYSTEM_STATSprocedure will collect system statistics over a specified period, or you can start the gathering of system statistics and make another call to stop gathering. Best-practice tip:Use the following command when you create a database:SQL> EXEC dbms_stats.gather_system_stats('NOWORKLOAD');The NOWORKLOADoption takes a few minutes (depending on the size of the database) and captures estimates of I/O characteristics such as average read seek time and I/O transfer rate.
Background image
The DBMS_STATS.GATHER_*_STATSprocedures can be called at various levels to gather statistics for an entire database or for individual objects, such as tables. When the GATHER_*_STATSprocedures are called, several of the parameters are often allowed to default. The supplied defaults work well for most of the objects in the database, but for some objects or schemas the defaults need to be changed. Instead of running manual jobs for each of these objects, Oracle Database enables you to set values (called preferences) for individual objects, schemas, or databases, or to change the default values with the global-level command. The preferences specify the parameters that are given to the gather procedures. The SET_*_PREFS procedures create preference values for any object that is not owned by SYSor SYSTEM. The expected use is that the DBA will set the global preferences for any parameters that should be database-wide. These will be applied for any parameter that is allowed to default. The SET_DATATBASE_PREFSprocedure iterates over all the tables and schemas in the database setting the specified preference. SET_SCHEMA_PREFSiterates over the tables in the specified schema. SET_TABLE_PREFSsets the preference value for a single table. All object preferences—whether set at the database, schema, or table level—are held in a single table. Changing the preferences at the schema level overwrites the preferences that were previously set at the table level.Oracle Database 12c: Administration Workshop 19 - 12Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Setting Optimizer Statistics PreferencesOptimizer statistics preferences set the default values of parameters used by: Automatic statistics collectionDBMS_STATS.GATHER_*_STATS proceduresSet preferences at levels:Table, schema, database, or globalPreferences: CASCADE, DEGREE, ESTIMATE_PERCENT, NO_INVALIDATE, METHOD_OPT, GRANULARITY, INCREMENTAL, PUBLISH, STALE_PERCENTUse DBMS_STATS.SET| GET| DELETE| EXPORT| IMPORT_*_PREFSto manage preferencesOptimizer statisticsgathering taskEXEC DBMS_STATS.SET_TABLE_PREFS('SH','SALES','STALE_PERCENT','13');DBA
Background image
Oracle Database 12c: Administration Workshop 19 - 13When the various gather procedures execute, they retrieve the object-level preferences that were set for each object. You can view the object-level preferences in the DBA_TAB_STAT_PREFSview. Any preferences that are not set at the object level will be set to the global-level preferences. You can see the global preferences by calling the DBMS_STATS.GET_PREFSprocedure for each preference.You can set, get, delete, export, and import those preferences at the table, schema, database, and global levels. The preference values are expected to be set from global to table levels, applying the preferences to the smallest group last. Preferences include:CASCADE– Determines whether index statistics are collected as part of gathering table statisticsDEGREE– Sets the degree of parallelism that is used for gathering statisticsPUBLISH– Is used to decide whether to publish the statistics to the dictionary or store them in a private area. This enables the DBA to validate the statistics before publishing them to the data dictionary with the PUBLISH_PENDING_STATSprocedure.STALE_PERCENT– Is used to determine the threshold level at which an object is considered to have stale statistics. The value is a percentage of the rows modified since the last statistics gathering. The example changes the 10 percent default to 13 percent for SH.SALESonly.INCREMENTAL– Is used to gather global statistics on partitioned tables in an incremental wayMETHOD_OPT– Determines the columns and histogram parameters that are used to gather column statisticsGRANULARITY– Determines the granularity of statistics to collect (which is pertinent only if the table is partitioned) NO_INVALIDATE– Is used to determine whether to invalidate cursorsESTIMATE_PERCENT– Is used to determine the number of rows to sample to obtain good statistics. It is a percentage of the number of rows in the tableNote:For details about these preferences, see the DBMS_STATSdocumentation in the Oracle Database PL/SQL Packages and Types Reference.Preferences may be deleted with the DBMS_STATS.DELETE_*_PREFSprocedures at the table, schema, and database levels. You can reset the global preferences to the recommended values with the DBMS_STATS.RESET_PARAM_DEFAULTSprocedure.
Background image
Before Oracle Database 12c, the automatic statistics gather job gathered statistics one segment at a time. It now uses concurrency. In Oracle Database 12c, you can run multiple statistics gathering tasks concurrently which may provide considerable improvements in statistics gathering time by increasing the resource utilization rate, in particular, on multi-CPU systems.Employ smart scheduling mechanisms to have maximum degree of concurrency (to the extent that resources are available), for example, allow gathering of statistics for multiple partitioned tables concurrently.Oracle Database 12c: Administration Workshop 19 - 14Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Concurrent Statistics GatheringThe auto statistics gather job uses concurrency.Prevent concurrent statistics gathering to make the system overwhelmed through careful resource usage capping.Allow gathering index statistics concurrently. Allow gathering of statistics for multiple partitioned tables concurrently.
Background image
To effectively diagnose performance problems, statistics must be available. The Oracle Database instance generates many types of cumulative statistics for the system, sessions, and individual SQL statements at the instance level. The Oracle Database server also tracks cumulative statistics on segments and services. When analyzing a performance problem in any of these scopes, you typically look at the change in statistics (delta value) over the period of time you are interested in. Note:Instance statistics are dynamic and are reset at every instance startup. These statistics can be captured at a point in time and held in the database in the form of snapshots.Wait Events StatisticsAll the possible wait events are cataloged in the V$EVENT_NAMEview.Cumulative statistics for all sessions are stored in V$SYSTEM_EVENT, which shows the total waits for a particular event since instance startup.When you are troubleshooting, you need to know whether a process has waited for any resource.Systemwide StatisticsAll the systemwide statistics are cataloged in the V$STATNAMEview: Over 400 statistics are available in Oracle Database.Oracle Database 12c: Administration Workshop 19 - 15Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Viewing Statistics InformationV$SGASTATPOOLNAMEBYTESV$SYSSTATSTATISTIC# NAMECLASSVALUESTAT_IDV$SYSTEM_EVENTEVENTTOTAL_WAITSTOTAL_TIMEOUTSTIME_WAITEDAVERAGE_WAITTIME_WAITED_MICROV$EVENT_NAMEEVENT_NUMBEREVENT_IDNAMEPARAMETER1 PARAMETER2 PARAMETER3WAIT_CLASSV$SYSTEM_WAIT_CLASSWAIT_CLASS_ID WAIT_CLASS#WAIT_CLASSTOTAL_WAITSTIME_WAITED
Background image
The server displays all calculated system statistics in the V$SYSSTATview. You can query this view to find cumulative totals since the instance started.Example:SQL>SELECT name, class, value FROM v$sysstat;NAMECLASS VALUE------------------------------- ------ ----------...table scans (short tables) 64 135116table scans (long tables) 64 250table scans (rowid ranges) 64 0table scans (cache partitions) 64 3table scans (direct read) 64 0table scan rows gotten 64 14789836table scan blocks gotten 64 558542...Systemwide statistics are classified by the tuning topic and the debugging purpose. The classes include general instance activity, redo log buffer activity, locking, database buffer cache activity, and so on. Each of the system statistics can belong to more than one class, so you cannot do a simple join on V$SYSSTATS.CLASSand V$SYSTEM_WAIT_CLASS.WAIT_CLASS#.You can also view all wait events for a particular wait class by querying V$SYSTEM_WAIT_CLASS, as in this example (with formatting applied):SQL> SELECT * FROM V$SYSTEM_WAIT_CLASS2 WHERE wait_class LIKE '%I/O%';CLASS_ID CLASS# WAIT_CLASS TOTAL_WAITS TIME_WAITED---------- ------ ------------ ----------- -----------1740759767 8 User I/O 1119152 390384108307767 9 System I/O 296959 27929SGA Global StatisticsThe server displays all calculated memory statistics in the V$SGASTATview. You can query this view to find cumulative totals of detailed SGA usage since the instance started, as in the following example:SQL>SELECT * FROM v$sgastat;POOL NAME BYTES------------------------------- ----------fixed_sga 7780360buffer_cache 25165824log_buffer 262144shared pool sessions 1284644shared pool sql area 22376876...The results shown are only a partial display of the output.When the STATISTICS_LEVELparameter is set to BASIC, the value of the TIMED_STATISTICSparameter defaults to FALSE. Timing information is not collected for wait events and much of the performance-monitoring capability of the database is disabled. The explicit setting of TIMED_STATISTICSoverrides the value derived from STATISTICS_LEVEL.Oracle Database 12c: Administration Workshop 19 - 16
Background image
In Oracle Database 12c, the database server can use a SQL plan directive, which is additional information and instructions that the optimizer can use to generate a more optimal plan. For example, a SQL plan directive might instruct the optimizer to collect missing statistics, create column group statistics, or perform dynamic sampling. During SQL compilation or execution, the database analyzes the query expressions that are missing statistics or that misestimate optimizer cardinality to create SQL plan directives. When the optimizer generates an execution plan, the directives give the optimizer additional information about objects that are referenced in the plan.SQL plan directives are not tied to a specific SQL statement or SQL ID. The optimizer can use SQL plan directives for SQL statements that are nearly identical because SQL plan directives are defined on a query expression. For example, directives can help the optimizer with queries that use similar patterns, such as web-based queries that are the same except for a select list item. The database stores SQL plan directives persistently in the SYSAUXtablespace. When generating an execution plan, the optimizer can use SQL plan directives to obtain more information about the objects that are accessed in the plan. Directives are automatically maintained, created as needed, purged if not used after a year.Directives can be monitored in DBA_SQL_PLAN_DIR_OBJECTS. SQL plan directives improve plan accuracy by persisting both compilation and execution statistics in the SYSAUXtablespace, allowing them to be used by multiple SQL statements.Oracle Database 12c: Administration Workshop 19 - 17Copyright © 2013, Oracle and/or its affiliates. All rights reserved.SQL Plan DirectivesA SQL plan directive is additional information and instructions that the optimizer can use to generate a better plan:Collect missing statisticsCreate column group statisticsPerform dynamic samplingDirectives can be used for multiple statements:Directives are collected on query expressionsThey are persisted to disk in the SYSAUXtablespace.Directives are automatically maintained:Created as needed during compilation or execution:Missing statistics, cardinality misestimatesPurged if not used after a year
Background image
The Adaptive Execution Plans feature enables the optimizer to automatically adapt a poorly performing execution plan at run time and prevent a poor plan from being chosen on subsequent executions. The optimizer instruments its chosen plan so that at run time, it can be detected if the optimizer’s estimates are not optimal. Then the plan can be automatically adapted to the actual conditions. An adaptive plan is a plan that changes after optimization when optimizer estimates prove inaccurate.The optimizer can adapt plans based on statistics that are collected during statement execution. All adaptive mechanisms can execute a plan that differs from the plan which was originally determined during hard parse. This improves the ability of the query-processing engine (compilation and execution) to generate better execution plans.The two Adaptive Plan techniques are:Dynamic plans: A dynamic plan chooses among subplans during statement execution. For dynamic plans, the optimizer must decide which subplans to include in a dynamic plan, which statistics to collect to choose a subplan, and thresholds for this choice.Re-optimization:In contrast, re-optimization changes a plan for executions after the current execution. For re-optimization, the optimizer must decide which statistics to collect at which points in a plan and when re-optimization is feasible.Note:OPTIMIZER_ADAPTIVE_REPORTING_ONLYcontrols reporting-only mode for adaptive optimizations. When set to TRUE, adaptive optimizations run in reporting-only mode where the information required for an adaptive optimization is gathered, but no action is taken to change the plan.Oracle Database 12c: Administration Workshop 19 - 18Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Adaptive Execution PlansA query plan changes during execution because runtime conditions indicate that optimizer estimates are inaccurate.All adaptive execution plans rely on statistics that are collected during query execution.The two adaptive plan techniques are:Dynamic plansRe-optimizationThe database uses adaptive execution plans when OPTIMIZER_FEATURES_ENABLEis set to 12.1.0.1or higher, and OPTIMIZER_ADAPTIVE_REPORTING_ONLYis set to the default value of FALSE.
Background image
Oracle Database provides a set of advisors for SQL. The AWR identifies and records statistics about the recent high-load SQL statements.The SQL Access Advisor considers changes applied to a set of SQL statements and looks for a net gain in performance. This set can be a hypothetical set of SQL, a historical set, or a manually created set.The SQL Performance Analyzer can be used to predict and prevent potential performance problems for any database environment change that affects the structure of the SQL execution plans.The SQL Repair Advisor is run from the Support Workbench when a SQL statement fails with a critical error. A critical error also produces an incident. The repair advisor attempts to find and recommend a SQL patch. If no patch is found, you can continue in the Support Workbench to package the incident and submit the package to Oracle Support as a Service Request (SR).The SQL Tuning Advisor analyzes one or more SQL statements one at a time. It examines statistics, SQL profiles, indexes, materialized views, and restructured SQL. The SQL Tuning Advisor can be run manually at any time, but it is run during every maintenance window against the recent high-load SQL statements. Click Automatic SQL Tuning Results to view and implement the recommendations. This automatic job can be configured to automatically implement recommended SQL profiles for the high-load statements. Oracle Database 12c: Administration Workshop 19 - 19Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using the SQL Advisors
Background image
The Automatic SQL Tuning Task runs by default every night. You can access the Automatic SQL Tuning Result Summary page by selecting Automated Maintenance Tasks in the Oracle Scheduler submenu of the Administration menu. Select the Automatic SQL Tuning link to view the result summary page.Click Configure to display a page where you can change the defaults of the Automatic Tuning Task and enable automatic implementation of SQL profiles.Oracle Database 12c: Administration Workshop 19 - 20Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Automatic SQL Tuning Results
Background image
If you click View Report on the Automatic Tuning Results Summary page, you will see the Automatic SQL Tuning Result Details. You can implement all the recommendations or drill down to view or implement individual recommendations. On the Recommendations page, you can click the eyeglass icon on the right to see the differences that implementing a SQL profile will make in the explain plan. Oracle Database 12c: Administration Workshop 19 - 21Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Implementing Automatic Tuning Recommendations
Background image
The SQL Tuning Advisor is the primary driver of the tuning process. It performs several types of analyses:Statistics Analysis:Checks each query object for missing or stale statistics, and makes recommendations to gather relevant statistics.SQL Profiling:The optimizer verifies its own estimates and collects auxiliary information to remove estimation errors. It builds a SQL profile using the auxiliary information and makes a recommendation to create it. When a SQL profile is created, it enables the query optimizer to generate a well-tuned plan.Access Path Analysis:New indexes are considered if they significantly improve access to each table in the query. When appropriate, recommendations to create such objects are made.SQL Structure Analysis:SQL statements that use bad plans are identified and relevant suggestions are made to restructure them. The suggested changes can be syntactic as well as semantic.The SQL Tuning Advisor considers each SQL statement included in the advisor task independently. Creating a new index may help a query, but may hurt the response time of DML. So, a recommended index or other object should be checked with the SQL Access Advisor over a workload (a set of SQL statements) to determine whether there is a net gain in performance.Oracle Database 12c: Administration Workshop 19 - 22Copyright © 2013, Oracle and/or its affiliates. All rights reserved.SQL Tuning Advisor: OverviewAdd missing indexRestructure SQLTune SQL plan(SQL profile)Detect stale or missingstatisticsComprehensive SQL tuningSQL Tuning Advisor
Background image
The SQL Tuning Advisor runs automatically every night as the Automatic SQL Tuning Task. There may be times when a SQL statement needs immediate tuning action. You can use the SQL Tuning Advisor to analyze SQL statements and obtain performance recommendations at any time. Typically, you run this advisor as an ADDM performance-finding action.Additionally, you can run the SQL Tuning Advisor when you want to analyze the top SQL statements consuming the most CPU time, I/O, and memory.Even though you can submit multiple statements to be analyzed in a single task, each statement is analyzed independently. To obtain tuning recommendations that consider overall performance of a set of SQL, use the SQL Access Advisor.Oracle Database 12c: Administration Workshop 19 - 23Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using the SQL Tuning AdvisorUse the SQL Tuning Advisor to analyze SQL statements and obtain performance recommendations.Sources for SQL Tuning Advisor to analyze:Top Activity: Analyzes the top SQL statements currently activeSQL Tuning Sets: Analyzes a set of SQL statements you provideHistorical SQL (AWR): Analyzes SQL statements from statements collected by AWR snapshots
Background image
On the Schedule SQL Tuning Advisor page, you can choose the SQL statements to include and change the automatic defaults for a tuning task. You can set the source of the SQL statements, and if you have been granted the ADVISORsystem privilege, you can submit the task. Enterprise Manager then creates a tuning task for the SQL Tuning Advisor. The SQL statement options allow you to choose one or more SQL statements from recent Top Activity, choose Historical SQL stored in the AWR, or choose from a SQL Tuning Set that you have already created. It is important to choose the appropriate scope for the tuning task. If you choose the Limited option, the SQL Tuning Advisor produces recommendations based on statistics check, access path analysis, and SQL structure analysis. The Limited option will not make a SQL profile recommendation. If you choose the Comprehensive option, the SQL Tuning Advisor produces all the recommendations that the Limited option produces, but it also invokes the optimizer under the SQL profiling mode to build a SQL profile. With the Comprehensive option, you can also specify a time limit for the tuning task, which by default is 30 minutes. After you select Run SQL Tuning Advisor, configure your tuning task using the SQL Tuning Options page. Oracle Database 12c: Administration Workshop 19 - 24Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using the SQL Tuning Advisor
Background image
The SQL Tuning Results for the task are displayed as soon as the task completes and can also be accessed later from the Advisor Central page. A summary of the recommendations are displayed. You can review and implement individual recommendations. Select the statement and click view.Oracle Database 12c: Administration Workshop 19 - 25Copyright © 2013, Oracle and/or its affiliates. All rights reserved.SQL Tuning Advisor Recommendations
Background image
Duplicate SQL statements are statements that are different only in the literal values they use or in their formatting. Statements that are different each get a separate cursor in the Library Cache. Statements that are duplicates can use the same cursor if the literals are replaced with bind variables, and the formatting is made to be the same. Duplicate SQL statements can be identified by clicking Duplicate SQL in the Additional Monitoring Links section of the Performance Home page. SQL that is determined to be duplicate, except for formatting or literal differences, is listed together. This helps you determine which SQL in your application can be consolidated, thus lowering the requirements on the Library Cache and speeding up the execution of the statement.Oracle Database 12c: Administration Workshop 19 - 26Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Duplicate SQL
Background image
The SQL Access Advisor can recommend the proper set of materialized views, materialized view logs, partitioning, and indexes for a given workload. Understanding and using these structures is essential when optimizing SQL because they can result in significant performance improvements in data retrieval.The SQL Access Advisor recommends bitmap, function-based, and B-tree indexes. A bitmap index offers a reduced response time for many types of ad hoc queries and reduced storage requirements compared to other indexing techniques. B-tree indexes are most commonly used in a data warehouse to index unique or near-unique keys.Another component of the SQL Access Advisor also recommends how to optimize materialized views so that they can be fast refreshable and take advantage of general query rewrite.Note: For more information about materialized views and query rewrite, see the Oracle Database Performance Tuning Guide.Oracle Database 12c: Administration Workshop 19 - 27Copyright © 2013, Oracle and/or its affiliates. All rights reserved.SQL Access Advisor: OverviewSQL AccessAdvisorRecommendations-Indexes-Materialized views-Materialized view logs-PartitioningWorkload specification-SQL statement-SQL Tuning Set-SQL cache contents-Statistics-Schema name
Background image
Access the SQL Access Advisor by selecting SQL Access Advisor in the SQL submenu of the Performance menu.When starting a SQL Access Advisor session, you can select Use Default Options and start with a predefined set of advisor options that are recommended. Additionally, you can start a task and have it inherit a set of option values as defined by a template or task by selecting “Inherit Options from a Task or Template.” These include several generic templates designed for general-purpose environments, OLTP, and data warehousing databases. You can save custom templates from a previous task and reuse them when needed.Click Continue to launch the SQL Access Advisor Wizard.Oracle Database 12c: Administration Workshop 19 - 28Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using the SQL Access Advisor
Background image
Use the SQL Access Advisor Wizard’s Workload Source page to provide a defined workload that allows the Access Advisor to make recommendations. Supported workload sources are:Current and Recent SQL Activity:Uses the current SQL from the cache as the workloadUse an existing SQL Tuning Set:Enables you to specify a previously created SQL Tuning Set as the workload sourceCreate a Hypothetical Workload from the Following Schemas and Tables:Provides a schema that allows the advisor to search for dimension tables and produce a workload The scope of the workload can be further reduced by applying filters that you can access in the Filter Options section. With these options, you can reduce the scope of the SQL statements that are present in the workload. The filters are applied to the workload by the advisor to focus the tuning effort. Possible filter options are:Top resource consuming SQL statementsUsers, module identifier, or actionsTablesOracle Database 12c: Administration Workshop 19 - 29Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Workload Source
Background image
Use the Recommendations Options page to choose whether to limit the advisor to recommendations based on a single access method. Choose Indexes, Materialized Views, Partitioning, or a combination of those from the “Access Structures to Recommend” section. You can choose Evaluation Only to evaluate only existing access structures. In this mode, the advisor does not generate new recommendations but comments on the use of existing structures. This is useful to track the effectiveness of the current index, materialized view, and MV log usage over time.You can use the Scope section to specify a mode of Limited or Comprehensive. These modes affect the quality of recommendations as well as the length of time required for processing. In the Comprehensive mode, the advisor searches a large pool of candidates resulting in recommendations of the highest quality. In the Limited mode, the advisor performs quickly, limiting the candidate recommendations.Oracle Database 12c: Administration Workshop 19 - 30Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Recommendation Options
Background image
You can choose Advanced Options to show or hide options that enable you to set space restrictions, tuning options, and default storage locations. Use the Workload Categorization section to set options for Workload Volatility and Workload Scope. You can choose to favor read-only operations or you can consider the volatility of referenced objects when forming recommendations. You can also select Partial Workload, which does not include recommendations, to drop unused access structures, or Complete Workload, which does include recommendations to drop unused access structures.Use the Space Restrictions section to specify a hard space limit, which forces the advisor to produce recommendations only with total space requirements that do not exceed the specified limit. Use the Tuning Options section to specify options that customize the recommendations made by the advisor. Use the “Prioritize Tuning of SQL Statements by” drop-down list to prioritize by Optimizer Cost, Buffer Gets, CPU Time, Disk Reads, Elapsed Time, and Execution Count. Use the Default Storage Locations section to override the defaults defined for schema and tablespace locations. By default, indexes are placed in the schema and tablespace of the table they reference. Materialized views are placed in the schema and tablespace of the user who executed one of the queries that contributed to the materialized view recommendation.After you define these parameters, you can schedule and review your tuning task.Oracle Database 12c: Administration Workshop 19 - 31Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Recommendation Options
Background image
Using the Advisor Central page, you can list all the completed SQL Access Advisor tasks. Select the one for which you want to see the recommendations, and then click the View Result button. Use the Results for Task Summary page to get an overview of the advisor findings. The page presents charts and statistics that provide overall workload performance and query execution time potential improvement for the recommendations. You can use the page to show statement counts and recommendation action counts.To see other aspects of the results for the advisor task, click one of the three other tabs on the page: Recommendations, SQL Statements, or Details.The Recommendations page displays a chart and a table that show the top recommendations ordered by their percentage improvement to the total cost of the entire workload. The top recommendations have the biggest total performance improvement.By clicking the Show SQL button, you can see the generated SQL script for the selected recommendations. You can click the corresponding recommendation identifier in the table to see the list of actions that need to be performed in order to implement the recommendation. On the Actions page, you can actually see all the corresponding SQL statements to execute in order to implement the action. For recommendations that you do not want to implement, keep those check boxes deselected. Then, click the Schedule Implementation button to implement the retained actions. This step is executed in the form of a Scheduler job.Oracle Database 12c: Administration Workshop 19 - 32Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Reviewing Recommendations
Background image
Oracle Database includes SQL Performance Analyzer, which gives you an exact and accurate assessment of the impact of change on the SQL statements that make up the workload. SQL Performance Analyzer helps you forecast the impact of a potential change on the performance of a SQL query workload. This capability provides you with detailed information about the performance of SQL statements, such as before-and-after execution statistics, and statements with performance improvement or degradation. This enables you (for example) to make changes in a test environment to determine whether the workload performance will be improved through a database upgrade.Oracle Database 12c: Administration Workshop 19 - 33Copyright © 2013, Oracle and/or its affiliates. All rights reserved.SQL Performance Analyzer: OverviewTargeted users: DBAs, QAs, application developersHelps predict the impact of system changes on SQL workload response timeBuilds different versions of SQL workload performance (that is, SQL execution plans and execution statistics) Executes SQL serially (concurrency not honored)Analyzes performance differencesOffers fine-grained performance analysis on individual SQLIs integrated with SQL Tuning Advisor to tune regressions
Background image
SQL Performance Analyzer can be used to predict and prevent potential performance problems for any database environment change that affects the structure of the SQL execution plans. The changes can include (but are not limited to) any of the following:Database upgradesImplementation of tuning recommendationsSchema changesStatistics gatheringDatabase parameter changesOS and hardware changesYou can use SQL Performance Analyzer to predict SQL performance changes that result from changes for even the most complex environments. As applications evolve through the development life cycle, database application developers can test changes to schemas, database objects, and rewritten applications to mitigate any potential performance impact.SQL Performance Analyzer also enables the comparison of SQL performance statistics.You can access SQL Performance Analyzer through Enterprise Manager or by using the DBMS_SQLPApackage. For details about the DBMS_SQLPApackage, see the Oracle Database PL/SQL Packages and Types Reference Guide.Oracle Database 12c: Administration Workshop 19 - 34Copyright © 2013, Oracle and/or its affiliates. All rights reserved.SQL Performance Analyzer: Use CasesSQL Performance Analyzer is beneficial in the following use cases:Database upgradesImplementation of tuning recommendationsSchema changesStatistics gatheringDatabase parameter changesOS and hardware changesIt is accessible through Enterprise Manager and the DBMS_SQLPApackage.
Background image
1.Gather SQL:In this phase, you collect the set of SQL statements that represent your SQL workload on the production system.2.Transport:You must transport the resultant workload to the test system. The STS is exported from the production system and the STS is imported into the test system.3.Compute “before-version” performance:Before any changes take place, you execute the SQL statements, collecting baseline information that is needed to assess the impact that a future change might have on the performance of the workload.4.Make a change:After you have the before-version data, you can implement your planned change and start viewing the impact on performance.5. Compute “after-version” performance:This step takes place after the change is made in the database environment. Each statement of the SQL workload runs under a mock execution (collecting statistics only), collecting the same information as captured in step 3.6. Compare and analyze SQL Performance:After you have both versions of the SQL workload performance data, you can carry out the performance analysis by comparing the after-version data with the before-version data.7. Tune regressed SQL:At this stage, you have identified exactly which SQL statements may cause performance problems when the database change is made. Here, you can use any of the database tools to tune the system. After implementing any tuning action, you should repeat the process to create a new after-version and analyze the performance differences to ensure that the new performance is acceptable.Oracle Database 12c: Administration Workshop 19 - 35Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using SQL Performance Analyzer1.Capture SQL workload on production.2.Transport the SQL workload to a test system.3.Build “before-change” performance data.4.Make changes.5.Build “after-change” performance data.6.Compare results from steps 3 and 5.7.Tune regressed SQL.
Background image
Answer: bOracle Database 12c: Administration Workshop 19 - 36Copyright © 2013, Oracle and/or its affiliates. All rights reserved.QuizEven when you enable Automatic Maintenance tasks, the SQL Tuning Advisor always has to be started separately.a.Trueb.False
Background image
Answer: aOracle Database 12c: Administration Workshop 19 - 37Copyright © 2013, Oracle and/or its affiliates. All rights reserved.QuizYou can receive performance recommendations for historical SQL statements that are collected by AWR snapshots.a.Trueb.False
Background image
Answer: aOracle Database 12c: Administration Workshop 19 - 38Copyright © 2013, Oracle and/or its affiliates. All rights reserved.QuizThe SQL Access Advisor can recommend the proper set of materialized views, materialized view logs, partitioning, and indexes for a given workload.a.Trueb.False
Background image
Answer: aOracle Database 12c: Administration Workshop 19 - 39Copyright © 2013, Oracle and/or its affiliates. All rights reserved.QuizThe SQL Performance Analyzer provides you with detailed information about the performance of SQL statements, such as before-and-after execution statistics, and statements with performance improvement or degradation.a.Trueb.False
Background image
Oracle Database 12c: Administration Workshop 19 - 40Copyright © 2013, Oracle and/or its affiliates. All rights reserved.SummaryIn this lesson, you should have learned how to:Manage optimizer statisticsUse the SQL Tuning Advisor to: Identify SQL statements that are using the most resourcesTune SQL statements that are using the most resourcesUse the SQL Access Advisor to tune a workload
Background image
Oracle Database 12c: Administration Workshop 19 - 41Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Practice: OverviewThis practice covers the following topic:Using SQL Tuning Advisor
Background image
Background image
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using Database Resource Manager
Background image
Oracle Database 12c: Administration Workshop 20 - 2Copyright © 2013, Oracle and/or its affiliates. All rights reserved.ObjectivesAfter completing this lesson, you should be able to do the following:Configure the Database Resource ManagerAccess and create resource plansCreate consumer groupsSpecify directives for allocating resources to consumer groupsMap consumer groups to plansActivate a resource planMonitor the Resource Manager
Background image
By using the Database Resource Manager (also called the Resource Manager), you have more control over the allocation of machine resources than is normally possible through operating system resource management alone. If resource management decisions are made by the operating system, it can lead to problems such as:Excessive overhead resulting from operating system context switching of Oracle Database server processes when the number of server processes is highSuspension of a database server process that is holding a latchUnequal distribution of resources among all Oracle Database processes, and an inability to prioritize one task over anotherInability to manage database-specific resources, such as parallel execution servers and active sessionsThe Database Resource Manager controls the distribution of resources among various sessions by controlling the execution schedule inside the database. By controlling which sessions run and for how long, the Database Resource Manager can ensure that resource distribution matches the plan directive and, therefore, the business objectives. With the Database Resource Manager, you can guarantee groups of users a minimum amount of processing resources regardless of the load on the system and the number of users.The DBMS_RESOURCE_MANAGER_PRIVSpackage contains the procedures to grant and revoke the ADMINISTER_RESOURCE_MANAGERsystem privilege, which is a prerequisite for invoking the Resource Manager.Oracle Database 12c: Administration Workshop 20 - 3Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Database Resource Manager: OverviewUse the Resource Manager to:Manage mixed workloadControl system performanceMore resourcesOLTP usersDatabase Resource ManagerOracledatabaseBatch usersFewer resourcesLeast resourcesDSS users
Background image
Administering systems by using the Database Resource Manager involves the use of resource plans, resource consumer groups, and resource plan directives.A resource consumer groupdefines a set of users or sessions that have similar requirements for using system and database resources. A resource planspecifies how the resources are distributed among various resource consumer groups. The Database Resource Manager also allows for creation of plans within plans, called subplans. Resource plan directivesspecify how a particular resource is shared among consumer groups or subplans. You associate resource consumer groups and subplans with a particular resource plan through plan directives. Resource allocation methodsdetermine what policy to use when allocating for any particular resource. Resource allocation methods are used by resource plans and resource consumer groups. Oracle Database 12c: Administration Workshop 20 - 4Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Database Resource Manager: ConceptsUser groups or sessions with similar resource needs A blueprint for resource allocation among resource consumer groups (one active plan)Specifies how a resource is divided among the resource consumer groups (within the scope of allocation methods)Resource plan directivesResource consumer groupResource plan
Background image
The Database Resource Manager provides several means of allocating resources:CPU Method:Enables you to specify how CPU resources are allocated among consumer groups and subplans Degree of Parallelism Limit:Enables you to control the maximum degree of parallelism for any operation within a consumer groupActive Session Pool with Queuing: Allows you to limit the number of concurrent active sessions for a consumer group or subplan. If a group exceeds the maximum allowed number of sessions, new sessions are placed in a queue where they wait for an active session to complete. You can also specify a time limit on how long a session will wait before exiting with an error.Undo Pool:Enables you to control the total amount of undo that can be generated by a consumer group or subplan. Whenever the total undo space exceeds the amount specified by UNDO_POOL, no further INSERT, UPDATE, or DELETEcommands are allowed until undo space is freed by another session in the same group or the undo pool is increased for the consumer group. If the consumer group’s quota is exceeded during the execution of a DML statement, the operation aborts and returns an error. Queries are still allowed, even if a consumer group has exceeded its undo threshold.Oracle Database 12c: Administration Workshop 20 - 5Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using the Resource ManagerYou can manage database and operating system resources, such as:CPU usageDegree of parallelismNumber of active sessionsUndo generationOperation execution timeIdle timeDatabase consolidationServer consolidationYou can also specify criteria that, if met, cause the automatic switching of sessions to another consumer group.
Background image
Execution Time Limit:Allows you to specify a maximum execution time allowed for an operation. The Oracle Database server uses cost-based optimizer statistics to estimate how long an operation will take. If it is longer than the maximum time allowed (MAX_EST_EXEC_TIME), the operation returns an error and is not started. If a resource consumer group has more than one plan directive with MAX_EST_EXEC_TIMEspecified, the Resource Manager chooses the most restrictive of all incoming values.Idle Time Limit:Enables you to specify an amount of time for which a session can be idle, after which it will be terminated (MAX_IDLE_TIME). You can further restrict the Resource Manager to terminate only those sessions that are blocking other sessions (MAX_IDLE_TIME_BLOCKER).Consumer Group Switching:Specifies conditions that will cause a session to switch consumer groups. Typically, overuse of a resource is specified and a session is switched to a more restrictive consumer group. The session remains in the switched consumer group until it becomes idle, or if directed after the top-level call is completed. Then it will return to the initial consumer group. The initial consumer group is the group that a session is assigned to at login. The top is the current PL/SQL block or each SQL statement that is issued outside a PL/SQL block by the client. You can create a plan directive, so that the Resource Manager automatically switches the user back to the initial consumer group at the end of the top call.Database Consolidation: The Resource Manager enables you to optimize resource allocation among concurrent database sessions. Database consolidation requires that applications are isolated from each other. If one application experiences an increase in workload, that increase should not affect other applications. In addition, the performance of each application should be consistent. Good candidate applications for database consolidation are automated maintenance tasks because currently, these applications can take up to 100% of the server CPU resources. Server Consolidation: Because many test, development and small production databases are unable to fully utilize the servers that they are on, server consolidationprovides a possible alternative. With server consolidation, resources are more fully utilized by running multiple database instances on the server. The method for managing CPU allocations on a multi-CPU server with multiple database instances is called Instance Caging. Because Instance Caging is simple to configure and does not require any new software to be licensed or installed, it is an excellent alternative to other server consolidation tools, such as virtualization and O/S workload managers.You can access resource plans with the graphical interface of Enterprise Manager Cloud Control or the command line of the DBMS_RESOURCE_MANAGERpackage.Oracle Database 12c: Administration Workshop 20 - 6
Background image
The automated maintenance tasks rely on the Resource Manager being enabled during the maintenance windows. When a maintenance window opens, the DEFAULT_MAINTENANCE_PLANresource manager plan is automatically set to control the amount of CPU used by automated maintenance tasks. To be able to give different priorities to each possible task during a maintenance window, various consumer groups are assigned to DEFAULT_MAINTENANCE_PLAN. Oracle Database 12c: Administration Workshop 20 - 7Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Default Plan for Maintenance Windows
Background image
The DEFAULT_PLANresource plan is one of the default plans provided for you. It contains directives for the following provided consumer groups:SYS_GROUP: The initial consumer group for the SYSand SYSTEMusersOTHER_GROUPS: Used for all sessions that belong to consumer groups that are not part of the active resource plan. There must be a plan directive for OTHER_GROUPSin any active plan.ORA$AUTOTASK:A group with lower priority than SYS_GROUPand OTHER_GROUPSin this planThe initial consumer group of a user is the consumer group to which any session created by that user initially belongs. If you have not set the initial consumer group for a user, the user’s initial consumer group will automatically be DEFAULT_CONSUMER_GROUP. The DEFAULT_PLANand associated resource consumer groups can be used or not used. It can be a template for new resource plans; it can be modified or deleted. Use it as appropriate for your environment.Oracle Database 12c: Administration Workshop 20 - 8Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Default Plan
Background image
You can create a simple resource plan by using the DBMS_RESOURCE_MANAGER.CREATE_SIMPLE_PLANprocedure. You can create consumer groups and allocate resources to them by using this single procedure. The CREATE_SIMPLE_PLANprocedure accepts the following arguments:SIMPLE_PLAN: Name of the planCONSUMER_GROUP1(through CONSUMER_GROUP8): Consumer group name(s)GROUP1_PERCENT(through GROUP8_PERCENT): CPU resource allocated to the group(s)The plan uses the default CPU allocation policy (EMPHASIS). Each consumer group uses the default scheduling policy (ROUND_ROBIN).The consumer groups specified in the plan are allocated CPU percentage at level 2 as shown in the table in the slide. The plan also includes the SYS_GROUPconsumer group and the OTHER_GROUPSconsumer group. As shown in the table in the slide, SYSGROUPis allocated 100% of the CPU at level 1 and OTHER_GROUPSis allocated 100% of the CPU at level 3.Oracle Database 12c: Administration Workshop 20 - 9Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Creating a Simple Resource PlanCreate consumer groups and allocate resources to them by executing a single procedure call:BEGINDBMS_RESOURCE_MANAGER.CREATE_SIMPLE_PLAN(SIMPLE_PLAN => 'SIMPLE_RESPLAN1',CONSUMER_GROUP1 => 'CONSGROUP1', GROUP1_PERCENT => 80,CONSUMER_GROUP2 => 'CONSGROUP2', GROUP2_PERCENT => 20);END;Consumer GroupLevel 1Level 2Level 3SYSGROUP100%CONSGROUP180%CONSGROUP220%OTHER_GROUPS100%
Background image
Oracle Database 12c: Administration Workshop 20 - 10You can perform the following steps by using the named procedures in the DBMS_RESOURCE_MANAGERpackage or by using Enterprise Manager Cloud Control.1.Create a pending area: To create a new resource plan, or update or delete an existing resource plan, you must create a pending area. The pending area is a staging area where you can create and modify plans without affecting executing applications. After you create the pending area, the Oracle Database server copies existing plans into it so they can be updated if required. Create a pending area by using the CREATE_PENDING_AREAprocedure.2.Create, modify, or delete consumer groups: Create a resource consumer group and specify a resource allocation method (ROUND-ROBINor RUN-TO-COMPLETION) for distributing CPU among the sessions in the consumer group. Use the CREATE_CONSUMER_GROUPprocedure.3.Map sessions to consumer groups: Use the SET_CONSUMER_GROUP_MAPPINGprocedure to map a session attribute type and attribute value to a consumer group. The session attribute types include Oracle Database username, database service name, operating system username, client program name, and module name. Refer to the Oracle Database Administrator’s Guidefor a complete list of accepted session attributes.Note:Unassigned sessions are part of the OTHER_GROUPSconsumer group.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Creating a Complex Resource Plan1.Create a pending area.2.Create, modify, or delete consumer groups.3.Map sessions to consumer groups.4.Create the resource plan.5.Create resource plan directives.6.Validate the pending area.7.Submit the pending area.
Background image
4. Create the resource plan: When you create the resource plan, you provide a name and optionally specify the resource allocation method for CPU (EMPHASISor RATIO), active session pool resource allocation method (ACTIVE_SESS_POOL_ABSOLUTE), resource allocation method for degree of parallelism (PARALLEL_DEGREE_LIMIT_ABSOLUTE), and queuing resource allocation method (FIFO_TIMEOUT). Use CREATE_PLANto create a resource plan. Additional information follows in this lesson.5. Create resource plan directives: Resources are allocated to consumer groups based on the resource plan directives. Through resource plan directives, you can specify:-The maximum number of concurrently active sessions for a consumer group-A limit on the degree of parallelism for any operation-The time (in CPU seconds) that a call can execute before an action is taken-A maximum in kilobytes (K) on the total amount of undo for uncommitted transactions that can be generated by a consumer groupUse CREATE_PLAN_DIRECTIVEto specify resource plan directives. 6. Validate the pending area: Use the VALIDATE_PENDING_AREAprocedure to validate the pending area at any time. The validate procedure checks for the following:-Plans do not contain loops-All plans and resource consumer groups referred to by plan directives exist-All plans have plan directives that point to either plans or resource consumer groups-All percentages in any given level do not add up to greater than 100-A plan that is currently being used as a top plan by an active instance is not being deleted-That certain parameters appear only in plan directives that refer to resource consumer groups-No more than 28 resource consumer groups appear in any active plan-Plans and resource consumer groups do not have the same name-A plan directive for OTHER_GROUPSappears somewhere in any active plan7. Submit the pending area: After validating the pending area, submit it by using SUBMIT_PENDING_AREA. When you submit the pending area, new and updated plan information is stored in the data dictionary. New plans are not activated when the pending area is submitted. Modified plans are reactivated with their new plan definition. Oracle Database 12c: Administration Workshop 20 - 11
Background image
In Enterprise Manager Cloud Control, there are several property pages that you can use to specify plan directives:1.On the General page, associate consumer groups with plans and specify how much CPU each consumer group or subplan is allocated.2.On the Parallelism page, specify a limit on the degree of parallelism for any operation issued by this consumer group, a limit on the total number of parallel server processes that can be used by all sessions in this consumer group, and the maximum time a parallel statement can be queued.3.On the Thresholds page, specify the time duration or the resource limits under which a session can execute in a consumer group.4.On the Idle Time page, specify an amount of time that a session can be idle, after which it will be terminated. You can further restrict such termination to only those sessions that are blocking other sessions.Oracle Database 12c: Administration Workshop 20 - 12Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Specifying Resource Plan Directives
Background image
Resource allocation methods determine how the Resource Manager allocates a particular resource to a resource consumer group or resource plan. You specify values for the following resource allocation methods when creating the resource plan.There are two ways of specifying the CPU distribution with the MGMT_MTHparameter when you create a resource plan:EMPHASISis the default method for single-level plans. It is also used for multilevel plans that use percentages to specify how CPU is distributed among consumer groups. RATIOis for single-level plans that use ratios to specify how CPU is distributed.PARALLEL_DEGREE_LIMIT_MTHlimits the maximum degree of parallelism of any operation. This method can be specified only for resource consumer groups, not subplans. The PARALLEL_DEGREE_LIMIT_ABSOLUTEmethod is the only possible value, specifying how many processes may be assigned to an operation. If there are multiple plan directives referring to the same subplan or consumer group, the minimumof all the possible values is used as the parallel degree limit for that subplan or consumer group.The ACTIVE_SESS_POOL_MTHparameter limits the number of active sessions. All other sessions are inactive and wait in a queue to be activated. The only value (the only available method) for this parameter is ACTIVE_SESS_POOL_ABSOLUTE, which is its default value.QUEUING_MTHcontrols the order in which queued inactive sessions execute. FIFO_TIMEOUTis the default and only method available.Oracle Database 12c: Administration Workshop 20 - 13Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Resource Allocation Methods for Resource PlansParameterPossible ValuesMGMT_MTH: Allocating CPU usageEMPHASIS, RATIOPARALLEL_DEGREE_LIMIT_MTH: Limiting degree of parallelism of any operationPARALLEL_DEGREE_LIMIT_ABSOLUTEACTIVE_SESS_POOL_MTH: Limiting number of active sessions, queuing inactive onesACTIVE_SESS_POOL_ABSOLUTEQUEUING_MTH: Controlling queues, how inactive sessions enter active session poolFIFO_TIMEOUT
Background image
The CPU allocation method EMPHASISdetermines how much emphasis is given to sessions in different consumer groups in a resource plan. CPU usage is assigned levels from 1 through 8, with Level 1 having the highest priority. Percentages specify how to allocate CPU to each consumer group at each level. The following rules apply for the EMPHASISresource allocation method:CPU resources are distributed at a given level on the basis of the specified percentages. The percentage of CPU specified for a resource consumer group is a maximum for how much that consumer group can use at a given level. Consumer resources that are not used at a given level are made available to consumer groups at the next level. For example, if the consumer groups at Level 1 use only 60% of the available resources, the additional 40% is made available to consumer groups at Level 2.The sum of percentages at any given level must be less than or equal to 100.Any levels that have no plan directives explicitly specified have a default of 0% for all subplans or consumer groups. The EMPHASISresource allocation method avoids starvation problems, where consumers with lower priorities are not given the opportunity to run.Oracle Database 12c: Administration Workshop 20 - 14Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Comparison of EMPHASISand RATIOEMPHASISRATIOThe value specifies the maximum percentage of CPU resources a consumer group can use.The value specifies a number that indicates the ratio of CPU resources to be allocated to the consumer group.You can allocate resources for up to eight different levels.You can specify values for only one level.The sum of percentages at any given level must be less than or equal to 100.You must use integer values, but there is no limit on the sum of values.Default value is NULL.Default value is NULL.
Background image
The RATIOpolicy is a single-level CPU allocation method. Instead of percentages, you specify numbers corresponding to the ratio of CPU you want to give to the consumer group. For example, given three consumer groups OLTP_USERS, DSS_USERS, and BATCH_USERS, you can specify the following ratios:OLTP_USERS:4DSS_USERS:3BATCH_USERS:2OTHER:1This is similar to saying that OLTP users should get 40% of the resources, DSS users should get 30% of the resources, BATCH users should get 20% of the resources, and all other consumer groups should get 10% of the available resources.If there are no consumers in the OTHERor DSS_USERSconsumer groups currently utilizing CPU resources, the OLTP_USERSconsumer group would get two-thirds (4 shares out of 6 shares) of the available resources and the BATCH_USERSconsumer group would get the other third (2 shares out of 6). If all groups had sessions running, the division would be based on 10 shares.Oracle Database 12c: Administration Workshop 20 - 15
Background image
Using the Active Session Pool feature, you can control the maximum number of concurrently active sessions per resource consumer group. With this functionality, a DBA can indirectly control the amount of resources that any resource consumer group uses because resource consumption is proportional to the number of active sessions. Using an active session pool can help to reduce the number of servers taking resources in the system, thus avoiding inefficient paging, swapping, and other resource depletion (such as memory) resulting from attempting to run too many jobs simultaneously. After the Active Session Pool is filled with active sessions, the Resource Manager queues all subsequent sessions attempting to become active until other active sessions complete or become inactive. An active session is one currently involved in a transaction, query, or parallel operation. Individual parallel slaves are not counted as sessions; the entire parallel operation counts as one active session.There is only one queue per resource consumer group and the queuing method is first in, first out (FIFO) with a timeout. The queue is implemented as a memory structure and cannot be queried directly.Oracle Database 12c: Administration Workshop 20 - 16Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Active Session Pool MechanismOLTP usersACTIVE_SESS_POOL_P1=5DSS usersACTIVE_SESS_POOL_P1=3Sess6Sess7Sess8p001p002p003DSSactivesessionqueueSess10Sess9Sess1Sess2Sess3Sess5Sess4
Background image
You can define the maximum estimated execution time any operation can take at any given time by setting the resource plan directive’s MAX_EST_EXEC_TIMEparameter.When this parameter is set, the Database Resource Manager estimatesthe time a specific job will take, which is calculated using the statistics from the cost-based optimizer.If a resource consumer group has more than one plan directive referring to it, it may have more than one MAX_EST_EXEC_TIME. The Database Resource Manager then chooses the most restrictive of all incoming values.If the operation’s estimate is more than MAX_EST_EXEC_TIME, the operation does not start and the ORA-07455error is issued. This eliminates any exceptionally large jobs that would utilize too many system resources.The SWITCH_IO_MEGABYTESdirective specifies the amount of I/O (in MB) that a session can issue before an action is taken. The default is NULL, which means unlimited.The SWITCH_IO_REQSdirective specifies the number of I/O requests that a session can issue before an action is taken. The default is NULL, which means unlimited.The SWITCH_FOR_CALLdirective specifies that if an action is taken because of the SWITCH_TIME, SWITCH_IO_MEGABYTES, orSWITCH_IO_REQSparameters, the consumer group is restored to its original consumer group at the end of the top call. Default is FALSE, which means that the original consumer group is not restored at the end of the top call.Oracle Database 12c: Administration Workshop 20 - 17Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Specifying ThresholdsSpecifying execution time limit:Proactive estimation of the execution time for an operation (via cost-based optimizer statistics), default: UNLIMITEDSpecifying maximum estimated execution time at the resource consumer group levelHuge jobs will not be allowed to start if the estimate is longer than MAX_EST_EXEC_TIME:(ORA-07455)Specifying other thresholds:Limiting session I/O with SWITCH_IO_MEGABYTES(in MB)Limiting session I/O requests with SWITCH_IO_REQSReturning to original consumer group withSWITCH_FOR_CALL(Default: FALSE, consumer group is not restored)
Background image
This functionality is mostly beneficial for three-tier applications where the middle-tier server implements session pooling. In this case, the middle tier tends to do one call for an end user and then use the same session for a call for a different end user. Therefore, the boundaries of work are really calls, and the actions of a prior end user should not affect the next end user.Note:You cannot specify both the SWITCH_TIME_IN_CALLand SWITCH_TIMEparameters within the same directive. The SWITCH_TIMEparameter is primarily intended for client/server applications, whereas the SWITCH_TIME_IN_CALLparameter is for three-tier applications.Oracle Database 12c: Administration Workshop 20 - 18
Background image
In Enterprise Manager Cloud Control, use the Idle Time tab to set the maximum idle timeouts for a resource plan. “Max Idle Time (sec)” and “Max Idle Time if Blocking Another Session (sec)” are the respective equivalents of the NEW_MAX_IDLE_TIMEand NEW_MAX_IDLE_BLOCKER_TIMEresource directives in the DBMS_RESOURCE_MANAGER.UPDATE_PLAN_DIRECTIVEprocedure. They are both specified in seconds. NEW_MAX_IDLE_TIMEspecifies the time that a session is neither executing nor waiting for I/O. When the session exceeds the specified limit, the PMONprocess forcibly kills the session and cleans up its state. In addition to limiting the maximum idle time for a session, you can also limit the amount of time that an idle session can block another session. You impose this limit by setting the NEW_MAX_IDLE_BLOCKER_TIMEresource directive to the number of seconds to allow a session to be idle while blocking another session. You can also specify a value of UNLIMITEDto indicate that no maximum time has been set. The default is NULL, which means unlimited. These settings give you a more granular control than profiles, whose single value cannot distinguish between blocking and nonblocking sessions.In the slide example, the PMONprocess kills sessions that are idle for longer than 600 seconds. The PMONprocess also kills sessions that are idle for more than 300 seconds and are blocking other sessions. PMONchecks these limits once every minute and if it finds a session that has exceeded one of the limits, it forcibly kills the session and cleans up all its resources.Oracle Database 12c: Administration Workshop 20 - 19Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Setting Idle TimeoutsDBMS_RESOURCE_MANAGER.UPDATE_PLAN_DIRECTIVE(PLAN => 'DAY_PLAN',GROUP_OR_SUBPLAN => 'APPUSER',COMMENT => 'Limit Idle Time Example',NEW_MAX_IDLE_TIME => 600,NEW_MAX_IDLE_BLOCKER_TIME => 300);
Background image
For concurrent database sessions: Database consolidation requires that applications are isolated from each other. If one application experiences an increase in workload, that increase should not affect other applications. In addition, the performance of each application should be consistent.Fixed Policy CPU Resource ManagementThe MAX_UTILIZATION_LIMITattribute of resource plan directives enables you to impose an absolute upper limit on CPU utilization for a resource consumer group. This absolute limit overrides any redistribution of CPU within a plan.Note:Good candidate applications for database consolidation are automated maintenance tasks because currently these applications can take up to 100% of the server CPU resources. You can set a maximum limit for each auto-task consumer group.Oracle Database 12c: Administration Workshop 20 - 20Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Limiting CPU Utilization at the Database LevelDatabase consolidation requirements:Applications isolated from each otherConsistent performanceCPU directives can be used to:Specify a minimum CPU allocation for each applicationDesignate how unused allocations should be redistributedSpecify the MAX_UTILIZATION_LIMITattribute to impose an absolute upper limit on CPU utilization (which overrides any redistribution of CPU within a plan)Good candidate: Auto-maintenance tasks
Background image
The MAX_UTILIZATION_LIMITdirective limits the CPU consumption of an application. You can set minimum and maximum boundaries, as shown in the slide.The PL/SQL example in the slide specifies a minimum value percentage (50%) for the CPU allocation resource at level 1 for the APP_1consumer group. This example also specifies an absolute maximum CPU utilization percentage (60%) permitted for that same consumer group. The example uses the DB_CONSOLIDATION_PLANplan.Similar commands can be executed for each consumer group shown in the sample tables.Oracle Database 12c: Administration Workshop 20 - 21Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Limiting CPU Utilization at the Database LevelSpecify minimum and maximum CPU utilization limits.Specify maximum CPU utilization limits only.EXEC DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE( -plan => 'db_consolidation_plan',group_or_subplan => 'App_1',mgmt_p1 => 50,max_utilization_limit=> 60);DB Consolidation Plan #1CPU MaximumAllocation Utilization Limit App 1 50% 60%App 2 20% 30%App 3 20% 30%App 4 10% 20%DB Consolidation Plan #2CPU MaximumAllocation Utilization Limit App 1 null 50%App 2 null 20%App 3 null 20%App 4 null 10%
Background image
Because many test, development, and small production databases are unable to fully utilize the servers that they are on, server consolidationprovides a possible alternative. With server consolidation, resources are more fully utilized by running multiple database instances on the server. However, this may bring about CPU contention and an adverse impact due to workload surges on one instance.Instance caging is a method that uses the CPU_COUNTinitialization parameter to limit the number of CPUs that an instance can use. In addition, the Resource Manager is employed to allocate the CPUs for the database sessions based on the instance resource plan.Configure instance caging in two steps, by enabling:The Resource Manager, which limits the amount of CPU that the database instance consumesThe CPU_COUNTparameter, which specifies the maximum (the limit), not actual amount of CPU that the database instance can use at any time By default, the CPU Resource Manager assumes that the database instance can use all CPUs on a server. To enable instance caging, any resource plan with CPU directives can be used.Oracle Database 12c: Administration Workshop 20 - 22Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Limiting CPU Utilization at the Server Level: Instance CagingManaging CPU allocations on a multi-CPU server with multiple database instancesEnabling instance caging:Enable any CPU resource plan.Specify the maximum number of CPUs that the instance can use at any time.Two approaches:Over-provisioning: The sum of the CPU limit for each instance exceeds the actual number of CPUs.Partitioning: The sum of the CPU limit for each instance equals the actual number of CPUs.ALTER SYSTEM SET cpu_count=4;ALTER SYSTEM SETresource_manager_plan= 'default_plan';
Background image
Over-provisioning approach:This approach is appropriate for noncritical databases and low-load, noncritical production systems. Although the instances impact each other’s performance, at any given time, one or more of the instances may be idle or experiencing a low load.Although the database instances can impact each other’s performance, instance caging limits their impact and helps to provide predictable performance. In the example on the left, where all four instances have CPU_COUNTset to 8, the maximum percentage of CPU that a database instance can consume at any point in time is its own limit divided by the sum of the limits for all active databases. In this example, one instance will be able to consume 8 / (8 + 8 + 8 + 8) = 25% of the CPU. If only two instances are active, one instance will be able to consume 8 / (8 + 8) = 50% of the CPU.Partitioning approach:This approach is appropriate for critical product systems. It prevents the instances from interfering with each other and provides predictable performance.Instance caging can partition the CPU resources by ensuring that the sum of all CPU limits does not exceed the total number of CPUs. In the example on the right, if four database instances share a 16-CPU server, their limits can be set to 8, 4, 2, and 2. By dedicating CPU resources to a database instance, partitioning provides two advantages:One database instance’s CPU load cannot affect another’s.Each database instance’s CPU resources is fixed, leading to more predictable performance.Oracle Database 12c: Administration Workshop 20 - 23Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Instance Caging ExamplesWith all four instances active,one instance can get8 / (8 + 8 + 8 + 8) = 25% of CPU.Each instance has adedicated number of CPUs.Instance AInstance BInstance CInstance DSum of CPU_COUNT settings = 32162432Total number of CPUs = 168Instance AInstance BInstance CInstance DSum of CPU_COUNT= 1681216Total number of CPUs = 164Partitioning approach:One database instancecannot impact the others.Over-provisioning approach: One database instancecan still impact the others.
Background image
If the CPU_COUNTparameter is not set, no value is returned by the first query.If no rows are returned by the second query in the slide, the Resource Manager is not managing the CPU. If a row is returned, it indicates the active plan. Instance caging limits the CPU consumption of the foreground processes by throttling them. A foreground process is throttled when it is waiting on the “resmgr:cpu quantum” wait event. You can monitor the amount of throttling in two ways: The V$RSRCMGRMETRIC_HISTORYview shows the amount of CPU consumption (CPU_CONSUMED_TIME) and throttling (CPU_WAIT_TIME) for each minute in the past hour. Values are displayed in milliseconds.The V$RSRC_CONSUMER_GROUPview shows the amount of CPU consumption (CPU_CONSUMED_TIME)and throttling (CPU_WAIT_TIME) since CPU Resource Management was enabled. The time is displayed in milliseconds. Note:For case studies, see the Oracle White Paper titled Database Instance Caging: A Simple Approach to Server Consolidation.Oracle Database 12c: Administration Workshop 20 - 24Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Monitoring Instance CagingView value of the CPU_COUNTparameter:Determine the Resource Manager status:Manage throttling:SELECT value FROM v$parameter WHERE name = 'cpu_count' AND (isdefault = 'FALSE' OR ismodified != 'FALSE');SELECT name FROM v$rsrc_plan WHERE is_top_plan = 'TRUE' AND cpu_managed = 'ON';SELECT begin_time, consumer_group_name, cpu_consumed_time, cpu_wait_time FROM v$rsrcmgrmetric_history ORDER BY begin_time;SELECT name, consumed_cpu_time, cpu_wait_time FROM v$rsrc_consumer_group;
Background image
To better track runaway queries, Resource Manager included the following:Directive parameters:-SWITCH_IO_LOGICAL: Number of logical I/Os that will trigger the action specified by SWITCH_GROUP-SWITCH_ELAPSED_TIME: Elapsed time that will trigger the action specified by SWITCH_GROUPLOG_ONLYmeta-consumer group: This can be used as the argument for the SWITCH_GROUPparameter to log the runaway query without changing its consumer group or taking other action.Resource Manager integrates the runaway query information with SQL Monitor. To retain important results for Resource Manager, it pins up to five SQL statements per consumer group. SQL Monitor does not purge these SQL executions until they are unpinned. V$SQL_MONITORcolumns:-RM_LAST_ACTION: The most recent action that was taken on this SQL operation by Resource Manager. Its value is one of the following: CANCEL_SQL, KILL_SESSION, LOG_ONLY, SWITCH TO <CG NAME>Oracle Database 12c: Administration Workshop 20 - 25Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Runaway Queries and Resource ManagerParameters used to trigger consumer group switching:SWITCH_IO_LOGICALSWITCH_ELAPSED_TIMEMeta consumer group called LOG_ONLYColumns in V$SQL_MONITOR:RM_LAST_ACTIONRM_LAST_ACTION_REASONRM_LAST_ACTION_TIMERM_CONSUMER_GROUPV$RSRCMGRMETRICand V$RSRCMGRMETRIC_HISTORYalways populated
Background image
-RM_LAST_ACTION_REASON: The reason for the most recent action that was taken on this SQL operation by Resource Manager. Its value is one of the following: SWITCH_CPU_TIME, SWITCH_IO_REQS, SWITCH_IO_MBS, SWITCH_ELAPSED_TIME, SWITCH_IO_LOGICAL-RM_LAST_ACTION_TIME: The time of the most recent action that was taken on this SQL operation by Resource Manager-RM_CONSUMER_GROUP: The current consumer group for this SQL operationNote:V$RSRCMGRMETRICand V$RSRCMGRMETRIC_HISTORYwill always produce a row every minute regardless of whether there is a Resource Manager plan set.Oracle Database 12c: Administration Workshop 20 - 26
Background image
You can configure the Database Resource Manager to automatically assign consumer groups to sessions by providing mappings between session attributes and consumer groups. Further, you can prioritize the mappings so as to indicate which mapping has precedence in case of conflicts. There are two types of session attributes: login attributes and runtime attributes. The login attributes are meaningful only at session login time, when the Database Resource Manager determines the initial consumer group of the session. In contrast, a session that has already logged in can later be reassigned to another consumer group on the basis of its runtime attributes.Select Consumer Group Mappings on the Getting Started with Database Resource Manager page of Enterprise Manager Cloud Control. For each of the attributes, set up a mapping that consists of a way to identify a session (for example, username), and a consumer group. Add or remove rows for each of the resource consumer group categories, as required, and enter text identifying the user, client, module, or service in the corresponding group. You can establish a priority ordering between conflicting mappings of the attributes by using the Priorities tab. You can set the priority from the most important to the least important by using the navigational arrows. The mappings at the top of the list have the highest priority.Oracle Database 12c: Administration Workshop 20 - 27Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Resource Consumer Group Mapping
Background image
Example to give the Client OS User a higher priority than the Client Program:BEGINdbms_resource_manager.clear_pending_area();dbms_resource_manager.create_pending_area();dbms_resource_manager.set_consumer_group_mapping(dbms_resource_manager.oracle_user,'SCOTT','LOW_GROUP');dbms_resource_manager.set_consumer_group_mapping_pri(EXPLICIT => 1,SERVICE_MODULE_ACTION => 2,SERVICE_MODULE => 3,MODULE_NAME_ACTION => 4,MODULE_NAME => 5,SERVICE_NAME => 6,ORACLE_USER => 7,CLIENT_OS_USER => 8,CLIENT_PROGRAM => 9,CLIENT_MACHINE => 10);dbms_resource_manager.submit_pending_area();END; Oracle Database 12c: Administration Workshop 20 - 28
Background image
The plan for an instance is defined using the RESOURCE_MANAGER_PLANdatabase initialization parameter. This parameter specifies the top plan to be used for this instance. If no plan is specified, the Resource Manager is not activated for the instance.You can activate, deactivate, or change the current top plan by using an ALTERSYSTEMstatement. When a resource plan is changed using this command, the change takes effect instantly.If the parameter is set in a parameter file, and the plan specified is not defined in the database, the database cannot be opened with that parameter file. The following error is returned:ORA-07452: specified resource manager plan does not exist in the data dictionaryIf this error is encountered, the parameter must be modified to show a correct value before the instance can be restarted.You can use the Resource Plans page of Enterprise Manager Cloud Control to manage resource plans. To activate a plan, select the plan you want to make active, choose Activate from the Actions drop-down list, and then click Go. The plan you selected is then made the current top plan for the instance.Oracle Database 12c: Administration Workshop 20 - 29Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Activating a Resource PlanSQL> show parameter resource_manager_planNAMETYPE VALUE---------------------- ----------- -------------resource_manager_plan string DEFAULT_PLAN
Background image
Several data dictionary views are available to check the resource plans, consumer groups, and plan directives that are declared in the instance. This section discusses some useful information that can be obtained from these views. For more detailed information about the contents of each of these views, refer to theOracle Database Reference manual.Use the following query to obtain information about resource plans defined in the database:SQL> SELECT plan, num_plan_directives, status, mandatory2 FROM dba_rsrc_plans;PLAN NUM_PLAN_DIRECTIVES STATUS MAN-------------- ------------------- --------- ---DEFAULT_PLAN 3 ACTIVE NOINTERNAL_QUIESCE 2 ACTIVE YESINTERNAL_PLAN 1 ACTIVE YESBUGDB_PLAN 4 ACTIVE NOMAILDB_PLAN 3 ACTIVE NOMYDB_PLAN 3 ACTIVE NOA status of ACTIVEindicates that the plan has been submitted and can be used, whereas, a status of PENDINGshows that the plan has been created, but is still in the pending area.If the MANDATORYcolumn is assigned a value of YES, the plan cannot be deleted.Oracle Database 12c: Administration Workshop 20 - 30Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Database Resource Manager InformationView NameInformationDBA_RSRC_PLANSPlans and statusDBA_RSRC_PLAN_DIRECTIVESPlan directivesDBA_RSRC_CONSUMER_GROUPSConsumer groupsDBA_RSRC_CONSUMER_GROUP_PRIVSUsers/rolesDBA_RSRC_GROUP_MAPPINGSConsumer group mappingDBA_RSRC_MAPPING_PRIORITYMapping priorityDBA_USERSColumn INITIAL_RSRC_CONSUMER_GROUPDBA_RSRC_MANAGER_SYSTEM_PRIVSUsers/roles
Background image
You can access Resource Manager statistics by selecting Performance Statistics on the Getting Started with Database Resource Manager page in Enterprise Manager Cloud Control. Information is provided so that you can monitor the currently enabled resource plan.Oracle Database 12c: Administration Workshop 20 - 31Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Viewing Resource Manager Statistics
Background image
CPU UtilizationThere are at least three different views in the system that can provide you with information about the CPU utilization inside the Oracle database:V$RSRC_CONSUMER_GROUPshows CPU utilization statistics on a per consumer group basis, if you are running the Oracle Database Resource Manager. This view displays data related to currently active resource consumer groups.V$SYSSTATshows the Oracle database CPU usage for all sessions. The statistic “CPU used by this session” shows the aggregate CPU used by all sessions.V$SESSTATshows the Oracle database CPU usage per session. You can use this view to determine which particular session is using the most CPU.The V$RSRC_CONSUMER_GROUPview contains the following columns:NAME:Name of the consumer groupACTIVE_SESSIONS:Number of currently active sessions in this consumer groupEXECUTION_WAITERS:Number of active sessions waiting for a time sliceREQUESTS:Cumulative number of requests executed in this consumer groupCPU_WAIT_TIME:Cumulative amount of time that sessions waited for CPUCONSUMED_CPU_TIME:Cumulative amount of CPU time consumed by all sessionsOracle Database 12c: Administration Workshop 20 - 32Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Monitoring the Resource ManagerV$SESSION: Contains the RESOURCE_CONSUMER_GROUPcolumn that shows the current group for a sessionV$RSRC_PLAN: A view that shows the active resource planV$RSRC_CONSUMER_GROUP: A view that contains statistics for all active groups
Background image
There is no view that shows the Active Session Pool queue directly, but you can get some information from:V$SESSION:The CURRENT_QUEUE_DURATIONcolumn shows how long a session has been queued, or 0 (zero) if the session is not currently queued.V$RSRC_CONSUMER_GROUP:The QUEUE_LENGTHcolumn shows the number of sessions currently queued per consumer group.Oracle Database 12c: Administration Workshop 20 - 33
Background image
Answer: b, cOracle Database 12c: Administration Workshop 20 - 34Copyright © 2013, Oracle and/or its affiliates. All rights reserved.QuizSelect the statements that are true about the Resource Manager and its functionality:a.You can set threshold values only for execution time, not for session I/O.b.You can limit CPU utilization at the database level to isolate applications for each other.c.On a multi-CPU server with multiples database instances, you can limit each server’s CPU utilization by enabling instance caging.d.When the SWITCH_TIME, SWITCH_IO_MEGABYTES, orSWITCH_IO_REQSparameters cause a switch in consumer groups, you can never return to the original consumer groups.
Background image
Oracle Database 12c: Administration Workshop 20 - 35Copyright © 2013, Oracle and/or its affiliates. All rights reserved.SummaryIn this lesson, you should have learned how to do the following:Configure the Database Resource ManagerAccess and create resource plansCreate consumer groupsSpecify directives for allocating resources to consumer groupsMap consumer groups to plansActivate a resource planMonitor the Resource Manager
Background image
Oracle Database 12c: Administration Workshop 20 - 36Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Practice: OverviewThis practice covers the following topics:Creating a resource consumer group Specifying CPU resource allocation directives for consumer groups Associating users with a resource consumer groupActivating a resource planTesting in SQL*PlusDeactivating a resource plan
Background image
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using Oracle Scheduler to Automate Tasks
Background image
For information about the various Scheduler components and their interaction, see the Oracle Database Administrator’s Guide.For detailed information about the DBMS_SCHEDULERpackage, see the Oracle Database PL/SQL Packages and Types Reference.Oracle Database 12c: Administration Workshop 21 - 2Copyright © 2013, Oracle and/or its affiliates. All rights reserved.ObjectivesAfter completing this lesson, you should be able to:Simplify management tasks by using Oracle SchedulerCreate a job, program, and scheduleMonitor job executionUse a time-based or event-based schedule for executing Oracle Scheduler jobsDescribe the use of windows, window groups, job classes, and consumer groupsUse email notificationUse job chains to perform a series of related tasksDescribe Scheduler jobs on remote systemsUse advanced Scheduler features to prioritize jobs
Background image
Many tasks in the Oracle environment need job-scheduling capabilities. Routine database maintenance and application logic require jobs to be scheduled and run periodically. Business-to-business (B2B) applications require scheduling for their business events. DBAs need to schedule regular maintenance jobs in specified time windows.Oracle Database provides advanced scheduling capabilities through the Oracle Scheduler, which is a collection of functions and procedures in the DBMS_SCHEDULERpackage. The Scheduler can be invoked in any SQL environment, or through Enterprise Manager Cloud Control.The Scheduler enables database administrators and application developers to control when and where various tasks take place in the database environment. These tasks can be time consuming and complicated; using the Scheduler, you can manage and plan these tasks. Scheduler jobs can be started based on time or when a specified event occurs, and the Scheduler can raise events when a job’s state changes (for example, from RUNNINGto COMPLETE). You can also use a named series of programs that are linked together for a combined objective.Oracle Database 12c: Administration Workshop 21 - 3Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Simplifying Management TasksPerforming a seriesof month-end tasks on the last day of each monthReplicating table datavia materializedview refreshesComputing table and index statistics twice a dayGenerating an hourly report on invalid server access attempts Running a daily job to back up databaseStarting the batch load as soon as the filearrives on the file systemRunning a dequeueprocedure as soonas a message isenqueuedRebuilding an index whenfinished rebuildingthe current index
Background image
Oracle Database 12c: Administration Workshop 21 - 4A job has two key components: Action: “What” needs to be doneSchedule: “When” the action occurs In the example in the slide, the “what” is enclosed in the top box and the “when” portion is shown in the second box. The “what” is expressed in theJOB_TYPEand JOB_ACTIONparameters. The “when” is expressed in a “schedule,” which can be based on time (as shown by the START_DATEparameter) or events, or be dependent on the outcome of other jobs.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Understanding a Simple JobBEGINsys.dbms_scheduler.create_job( job_name => '"HR"."CREATE_LOG_TABLE_JOB"',job_type => 'PLSQL_BLOCK', job_action => 'beginexecute immediate (''create table session_history(snap_time TIMESTAMP WITH LOCAL TIME ZONE, num_sessions NUMBER)''); end;',start_date => systimestamp at time zone 'America/New_York',job_class => 'DEFAULT_JOB_CLASS',comments => 'Create the SESSION_HISTORY table',auto_drop => FALSE, enabled => TRUE);END;
Background image
The Scheduler offers a modularized approach for managing tasks within the Oracle database. By breaking down a task into its components, such as time, location, and database object, the Scheduler offers you an easier way to manage your database environment. The Scheduler uses the following basic components:A jobspecifies what needs to be executed. It could be as an example a PL/SQL procedure, a native binary executable, a Java application, or a shell script. You can specify the program (what) and schedule (when) as part of the job definition, or you can use an existing program or schedule instead. You can use arguments for a job to customize its runtime behavior.A schedulespecifies when and how many times a job is executed. A schedule can be based on time or an event. You can define a schedule for a job by using a series of dates, an event, or a combination of the two, along with additional specifications to denote repeating intervals. You can store the schedule for a job separately and then use the same schedule for multiple jobs.A programis a collection of metadata about a particular executable, script, or procedure. An automated job executes some task. Using a program enables you to modify the job task, or the “what,” without modifying the job itself. You can define arguments for a program, enabling users to modify the runtime behavior of the task.Oracle Database 12c: Administration Workshop 21 - 5Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Oracle Scheduler Core ComponentsArgumentsJobProgramJob attributesSchedule
Background image
You can perform all steps either by using Enterprise Manager Cloud Control or by using the DBMS_SCHEDULERPL/SQL package. 1. Creating a ProgramUse the CREATE_PROGRAMprocedure to create a program. Creating a program is an optional part of using the Scheduler. You can also encode the action to be performed within an anonymous PL/SQL block in the CREATE_JOBprocedure. By creating the program separately, you can define the action once, and then reuse this action within multiple jobs. This enables you to change the schedule for a job without having to re-create the PL/SQL block. A program is created in a disabled state by default (unless the ENABLEDparameter is set to TRUE). A disabled program cannot be executed by a job until it is enabled. You can specify that a program should be created in the enabled state by specifying a value of TRUEfor ENABLED.2. Creating and Using SchedulesThe schedule for a job can be a predefined schedule (created with the CREATE_SCHEDULEprocedure) or defined as part of the job creation. Oracle Database 12c: Administration Workshop 21 - 6Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using Oracle SchedulerTo simplify management tasks with the Scheduler:1.Create a program (enabled or disabled)—optionalTo reuse this action within multiple jobsTo change the schedule for a job without having tore-create the PL/SQL block2.Create and use a schedule.3.Create and submit a job.
Background image
The schedule specifies attributes about when the job is run, such as:A start time, which defines when the job is picked for execution and an end time, which specifies the time after which the job is no longer valid and is not scheduled any moreAn expression specifying a repeating interval for the jobA complex schedule created by combining existing schedules A condition or change in state, called an event, that must be met before the job is startedBy using a schedule (instead of specifying the execution times for a job within the job definition), you can manage the scheduled execution of multiple jobs without having to update multiple job definitions. If a schedule is modified, each job that uses that schedule automatically uses the new schedule.3. Creating and Running a JobA job is a combination of a schedule and a description of what to do, along with any additional arguments that are required by the job. There are many attributes that you can set for a job. Attributes control how the job executes. Oracle Database 12c: Administration Workshop 21 - 7
Background image
Answer: b, dOracle Database 12c: Administration Workshop 21 - 8Copyright © 2013, Oracle and/or its affiliates. All rights reserved.QuizSelect the statements that are true about the Scheduler:a.Creating a program is a mandatory part of using the Scheduler.b.When the job action is in a program (rather than directly in the job), you can change the job schedule without having to re-create the PL/SQL block.c.Creating a job is an optional part of using the Scheduler.d.Each job must have a schedule. It can be a predefined one or defined as part of the job creation.
Background image
A lightweight job: Is for customers who need to create hundreds of jobs a second. With regular jobs, each job creates a database object describing the job, modifying several tables, and creating redo in the process. The overhead associated with this type of job need is substantial. In the Oracle Database Scheduler, there is a persistent lightweight job. The goal of a lightweight job is to reduce the overhead and time required to start a job. A minimal amount of metadata is created for the job. This reduces the time required and redo created when the job starts. Has a small footprint on disk for the job metadata and for storing runtime data. The small footprint on disk also makes load-balancing possible in RAC environments. Is always created from a job template. The job template must be a stored procedure or a program. The stored procedure holds all the information needed for the job, including privileges. A few job attributes can be specified: job arguments and schedule. Must be created in command line. The JOB_STYLEargument is not available in Enterprise Manager Cloud Control. In the example, MY_PROGis the job template and the schedule is applied from a named schedule.Oracle Database 12c: Administration Workshop 21 - 9Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Persistent Lightweight JobsPersistent lightweight jobs:Reduce the overhead and time required to start a jobHave a small footprint on disk for the job metadata and for storing runtime dataAre created from a job template (in the command line) BEGINDBMS_SCHEDULER.CREATE_JOB (job_name => 'my_lightweight_job2', program_name => 'MY_PROG', schedule_name => 'MY_SCHED',job_style => 'LIGHTWEIGHT');END;/Choosing the right job: Use regular jobs for maximum flexibility.Use persistent lightweight jobs when you need to create a large number of jobs in a very short time.
Background image
To specify a time-based schedule for a job, you can specify either a calendaring expression or a date-time expression. When using a calendaring expression, the next start time for a job is calculated using the repeat interval and the start date of the job. When using date-time expressions, the specified expression determines the next time that the job should run. If no repeat interval is specified, the job runs only once on the specified start date.If a job uses an event-based schedule, the job runs when the event is raised. At a high level, an event can be viewed as a change in state. An event occurs when a Boolean condition changes its state from FALSEto TRUE, or TRUEto FALSE. The Scheduler uses Oracle Streams Advanced Queuing (AQ) to raise and consume events. Note:The Scheduler does not guarantee that a job executes on the exact time because the system may be overloaded and thus resources may be unavailable.Oracle Database 12c: Administration Workshop 21 - 10Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using a Time-Based or Event-Based ScheduleScheduleEventTimeCalendaring expressionDate-time expression
Background image
Use the CREATE_JOBprocedure of the DBMS_SCHEDULERpackage to create a job. Jobs are created disabled by default and they become active and scheduled only when they are explicitly enabled. All job names are of the form: [SCHEMA.]NAME.You should use SYSTIMESTAMPand specify a time zone so that when the time changes because of daylight saving time, your job adjusts its execution time automatically.By default, a job is created in the current schema. You can create a job in another schema by specifying the name of the schema, as shown in the example in the slide. The job owner is the user in whose schema the job is created, whereas the job creator is the user who created the job. Jobs are executed with the privileges of the job owner. The national language support (NLS) environment of the job when it runs is the same as that present at the time the job was created. The JOB_TYPEparameter indicates the type of task to be performed by the job. The possible values are:PLSQL_BLOCK:An anonymous PL/SQL blockSTORED_PROCEDURE:A named PL/SQL, Java, or external procedureEXECUTABLE:A command that can be executed from the operating system (OS) command lineOracle Database 12c: Administration Workshop 21 - 11Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Creating a Time-Based JobExample: Create a job that calls a backup script every night at 11:00, starting tonight.BEGINDBMS_SCHEDULER.CREATE_JOB(job_name=>'HR.DO_BACKUP',job_type=> 'EXECUTABLE',job_action=> '/home/usr/dba/rman/nightly_incr.sh',start_date=> SYSDATE,repeat_interval=>'FREQ=DAILY;BYHOUR=23', /* next night at 11:00 PM */comments => 'Nightly incremental backups');END;/
Background image
The JOB_ACTIONparameter can be the name of the procedure to run, the name of a script or operating system command, or an anonymous PL/SQL code block, depending on the value of the JOB_TYPEparameter.In the example in the slide, JOB_TYPEis specified as EXECUTABLEand JOB_ACTIONis the full OS-dependent path of the desired external executable plus optionally any command-line arguments.An external job is a job that runs outside the database. All external jobs run as a low-privileged guest user, as has been determined by the database administrator while configuring external job support. Because the executable is run as a low-privileged guest account, you should verify that it has access to necessary files and resources. Most, but not all, platforms support external jobs. For platforms that do not support external jobs, creating or setting the attribute of a job or a program to type EXECUTABLEreturns an error.Refer to your Oracle database platform-specific documentation for more information about configuring the environment to run external programs with the Scheduler. Oracle Database 12c: Administration Workshop 21 - 12
Background image
Jobs can be triggered based on events. An application can notify the Scheduler to start a job by enqueuing a message onto an Oracle Streams queue. A job started in this way is referred to as an event-based job. To create an event-based job, you must set the following two additional attributes with the CREATE_JOBprocedure:QUEUE_SPEC:A queue specification that includes the name of the queue where your application enqueues messages to raise job start events, or in the case of a secure queue, the <queue_name>, <agent_name> pairEVENT_CONDITION:A conditional expression based on message properties that must evaluate to TRUEfor the message to start the job. You can include user data properties in the expression, provided that the message payload is a user-defined object type, and that you prefix object attributes in the expression with TAB.USER_DATA.You can either specify QUEUE_SPECand EVENT_CONDITIONas inline job attributes, or create an event-based schedule with these attributes and then create a job that references this schedule.Oracle Database 12c: Administration Workshop 21 - 13Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Creating an Event-Based ScheduleTo create an event-based job, you must set:A queue specification (where your application enqueues messages to start a job)An event condition (same syntax as an Oracle Streams AQ rule condition) that if TRUEstarts the jobOracle Database SchedulerEvent ADT (AbstractData Type)QueueApplication
Background image
The Create Schedule page enables you to choose between a standard, time-based schedule and an event-based schedule. If you choose an event-based schedule, you can specify the queue name, agent name, and event condition, in addition to the other schedule attributes.Note: The Scheduler runs the event-based job for each occurrence of an event that matches EVENT_CONDITION. However, events that occur while the job is already running are ignored; the event gets consumed, but does not trigger another run of the job.ReferencesSee the Oracle Streams Advanced Queuing User’s Guide and Referencefor information about how to create queues and enqueue messages. For more information about Oracle Streams AQ rules and event conditions, see the DBMS_AQADM.ADD_SUBSCRIBERprocedure in Oracle Database PL/SQL Packages and Types Reference.Oracle Database 12c: Administration Workshop 21 - 14Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Creating Event-Based Schedules by Using Enterprise Manager Cloud Control
Background image
To specify event information as job attributes, you use an alternate syntax of CREATE_JOBthat includes the QUEUE_SPECand EVENT_CONDITIONattributes. The job can include event information inline as job attributes or can specify event information by pointing to an event schedule. The example shown in the slide uses an inline, event-based schedule.The example in the slide shows a job that is started when a file arrives on the operating system, as long as the file arrives before 9:00 AM. Assume that the message payload is an object with four attributes named OBJECT_OWNER, OBJECT_NAME, EVENT_TYPE, and EVENT_TIMESTAMP.The example uses a user-defined event. Therefore, before this job can be started, when the file arrives on the file system, a program or procedure must enqueue the event object type with the proper information into the specified event queue. The HR.LOAD_JOB_EVENT_Qqueue must be of the same type as the event object type used for notifying the Scheduler of an event occurrence. That is, the HR.LOAD_JOB_EVENT_Qqueue must be a typed queue where the type has four attributes named OBJECT_OWNER, OBJECT_NAME, Event_type, and EVENT_TIMESTAMP.For more information about how to create queues and enqueue messages, refer to the Oracle Streams Advanced Queuing User’s Guide and Reference documentation.Oracle Database 12c: Administration Workshop 21 - 15Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Creating an Event-Based JobExample: Create a job that runs if a batch load data file arrives on the file system before 9:00 AM.BEGINDBMS_SCHEDULER.CREATE_JOB(job_name=>'ADMIN.PERFORM_DATA_LOAD',job_type => 'EXECUTABLE',job_action => '/loaddir/start_my_load.sh',start_date => SYSTIMESTAMP,event_condition => 'tab.user_data.object_owner = ''HR'' and tab.user_data.object_name = ''DATA.TXT'' and tab.user_data.event_type = ''FILE_ARRIVAL'' and tab.user_data.event_timestamp < 9 ',queue_spec => 'HR.LOAD_JOB_EVENT_Q');END;
Background image
You can create a job that directly references an event as the means to start the job, instead of assigning a schedule to the job. There are two types of events:User-generated or application-generated events:An application can raise an event to be consumed by the Scheduler. The Scheduler reacts to the event by starting a job. An example of such events: a running job completes; a file arrives on the file system; an account within the database is locked; and the inventory reaches a low threshold.Scheduler-generated events:The Scheduler can raise an event to indicate state changes that occur within the Scheduler itself. For example, the Scheduler can raise an event when a job starts, when a job completes, when a job exceeds its allotted run time, and so on. The consumer of the event is an application that performs some action in response to the event.You can configure a job so that the Scheduler raises an event when the job’s state changes. You do this by setting the RAISE_EVENTSjob attribute. By default, a job does not raise any state change events until you alter the RAISE_EVENTSattribute for a job. To alter this attribute, you must first create the job by using the CREATE_JOBprocedure and then use the SET_ATTRIBUTEprocedure to modify the attribute’s default value. The example shows that the HR.DO_BACKUPjob is altered, so that it raises an event if the job fails.Oracle Database 12c: Administration Workshop 21 - 16Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Event-Based SchedulingEvent types:User-generated or application-generated eventsScheduler-generated eventsEvents raised by Scheduler jobs: JOB_STARTEDJOB_SCH_LIM_REACHEDJOB_SUCCEEDEDJOB_DISABLED JOB_FAILEDJOB_CHAIN_STALLED JOB_BROKENJOB_ALL_EVENTS JOB_COMPLETEDJOB_RUN_COMPLETEDJOB_STOPPEDJOB_OVER_MAX_DUR Example of raising an event:DBMS_SCHEDULER.SET_ATTRIBUTE('hr.do_backup', 'raise_events', DBMS_SCHEDULER.JOB_FAILED);
Background image
After you enable job state change events for a job, the Scheduler raises these events by enqueuing messages onto the default event queue SYS.SCHEDULER$_EVENT_QUEUE.The default Scheduler event queue is a secure queue. Depending on your application, you may have to configure the queue to enable certain users to perform operations on it. See the Oracle Streams Concepts and Administrationdocumentation for information about secure queues.The default Scheduler event queue is intended primarily for Scheduler-generated events. Oracle does not recommend the use of this queue for user applications, or user-defined events.Event TypeDescriptionJOB_STARTEDThe job is started.JOB_SUCCEEDEDThe job is successfully completed.JOB_FAILEDThe job failed, either by raising an error or by abnormally terminating. JOB_BROKENThe job is disabled and changed to the BROKENstate, because it exceeded the number of failures defined by the MAX_FAILURESjob attribute. JOB_COMPLETEDThe job is completed, because it reached the values set by the MAX_RUNSor END_DATEjob attributes. JOB_STOPPEDThe job is stopped by a call to the STOP_JOBprocedure. JOB_SCH_LIM_REACHEDThe job’s schedule limit is reached. The job is not started, because the delay in starting the job exceeded the value of the SCHEDULE_LIMITjob attribute. JOB_DISABLED The job is disabled by the scheduler or by a call to the SET_ATTRIBUTEprocedure.JOB_CHAIN_STALLED A job running a chain is put into the CHAIN_STALLEDstate. A running chain becomes stalled if there are no steps running or scheduled to run and the chain EVALUATION_INTERVALis set to NULL.The chain waits for manual intervention.JOB_ALL_EVENTS JOB_ALL_EVENTSis not an event, but a constant, that provides an easy way for you to enable all events.JOB_OVER_MAX_DUR The job has run over the maximum time it was set to be allowed to run. JOB_RUN_COMPLETED A job run is completed. It either failed, succeeded, or is stopped.Oracle Database 12c: Administration Workshop 21 - 17
Background image
A schedule is an object in the database. When you create schedules, they are automatically saved. You can use combinations of schedules to create more complex schedules. By combining schedules, you can add specific dates to or exclude specific dates from a calendaring expression. You can use the following options when defining the repeat interval for a schedule:INCLUDE:Adds a list of dates to the calendaring expression results EXCLUDE:Removes a list of dates from the calendaring expression resultsINTERSECT:Uses only the dates that are common to two or more schedulesWhen creating schedules to be used in combinations, you can code the list of dates by including hard-coded dates of the form [YYYY]MMDDor by including named schedules created with the CREATE_SCHEDULEprocedure. For example, you can specify a list of dates by using the following values for the repeat interval of a schedule:0115,0315,0325,0615,quarter_end_dates,1215 This string represents the dates January 15, March 15, March 25, June 15, December 15, and the list of dates specified by the QUARTER_END_DATESschedule.If you do not specify the optional year component for hard-coded dates in your schedule, the dates are included for every year.Oracle Database 12c: Administration Workshop 21 - 18Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Creating Complex SchedulesINCLUDEEXCLUDEINTERSECT
Background image
Answer: a, cOracle Database 12c: Administration Workshop 21 - 19Copyright © 2013, Oracle and/or its affiliates. All rights reserved.QuizSelect the statements that are true about persistent lightweight jobs:a.Persistent lightweight jobs have a small footprint on disk for the job metadata and also for storing runtime data.b.Use persistent lightweight jobs for maximum flexibility.c.Persistent lightweight jobs are created from a job template.d.Persistent lightweight jobs can be created in Enterprise Manager and via command line.
Background image
The job email notification feature enables you to add email notifications to existing jobs so that events of interest that happen to the job are emailed to specified email addresses. For each job, you can add notifications for different events. You can send the email notification to more than one recipient.To enable the email notification feature, you must:1.Set the EMAIL_SERVERScheduler attribute.2.Optionally, use the EMAIL_SENDERScheduler attribute to specify a default sender email address for the email notifications.3.After creating a job, execute the DBMS_SCHEDULER.ADD_JOB_EMAIL_NOTIFICATIONprocedure to add one or more notifications for the job.The data dictionary supports email notifications with the *_SCHEDULER_NOTIFICATIONSviews.Oracle Database 12c: Administration Workshop 21 - 20Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using Email NotificationEmail notifications for change of job stateTriggered by job state eventsMultiple notifications, multiple recipients*_SCHEDULER_NOTIFICATIONSviewsUsing Scheduler Email Notification:1.Specify the address of the SMTP server you will use to send email messages:2.Optionally, set a default sender email address:3.Add email notifications for a specified job. (continued)DBMS_SCHEDULER.SET_SCHEDULER_ATTRIBUTE('email_server','host[:port]');DBMS_SCHEDULER.SET_SCHEDULER_ATTRIBUTE('email_sender','valid email address');
Background image
Add one or more job email notifications with the DBMS_SCHEDULER.ADD_JOB_EMAIL_NOTIFICATIONprocedure. Email messages will be sent to the specified recipient addresses whenever any of the listed events are generated by the job. The job is automatically modified to raise these events. If a filter condition is specified, only events that match the specification in FILTER_CONDITIONwill generate an email message. This procedure will fail if the EMAIL_SERVERscheduler attribute is not set or if the specified job does not exist. The user calling this procedure must be the owner of the job, have the CREATEANYJOBsystem privilege, or have been granted the ALTERprivilege for the job.The subject of notification emails can contain the following variables for which values will be substituted: %job_owner%,%job_name%,%event_type%,%event_timestamp%,%log_id%,%error_code%,%error_message%,%run_count%,%failure_count%,%retry_count%, %job_subname%, %job_class_name%.The notification email messagebodycan contain any of the variables that are valid in the SUBJECT.The comma-separated list of eventscannot be NULL. Refer to the list of events for the RAISE_EVENTSattribute of JOBSfor valid events.If filter_conditionis NULL (the default), all occurrences of the specified events will be emailed to all specified recipient addresses.Remove one or more email notifications for a specified job with the DBMS_SCHEDULER.REMOVE_JOB_EMAIL_NOTIFICATIONprocedure.Oracle Database 12c: Administration Workshop 21 - 21Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Adding and Removing Email NotificationsDBMS_SCHEDULER.ADD_JOB_EMAIL_NOTIFICATION(job_name IN VARCHAR2,recipients IN VARCHAR2,sender IN VARCHAR2 DEFAULT NULL,subjectIN VARCHAR2DEFAULT dbms_scheduler.default_notification_subject,bodyIN VARCHAR2DEFAULT dbms_scheduler.default_notification_body,events IN VARCHAR2DEFAULT 'JOB_FAILED,JOB_BROKEN,JOB_SCH_LIM_REACHED,JOB_CHAIN_STALLED,JOB_OVER_MAX_DUR',filter_condition IN VARCHAR2 DEFAULT NULL);DBMS_SCHEDULER.REMOVE_JOB_EMAIL_NOTIFICATION(job_name IN VARCHAR2,recipients IN VARCHAR2 DEFAULT NULL,events IN VARCHAR2 DEFAULT NULL);Comma-separated list of email addressesMandatory comma-separated list
Background image
A chain is a named series of programs that are linked together for a combined objective. This is known as “dependency scheduling.” An example of a chain may be the following:Run program A and then program B, but only run program C if programs A and B complete successfully, otherwise run program D.Each position within a chain of interdependent programs is referred to as a step. Typically, after an initial set of chain steps has started, the execution of successive steps depends on the completion of one or more previous steps. To create and use a chain, you complete the following steps in order. All procedures mentioned are part of the DBMS_SCHEDULERpackage, unless noted otherwise. 1.Create a chainby using the CREATE_CHAINprocedure. The chain name can be optionally qualified with a schema name (for example, myschema.myname). 2.Define (one or more) chain steps. Defining a step gives it a name and specifies what happens during the step. Each step can point to one of the following: -A program-Another chain (a nested chain)-An eventYou define a step that points to a program or nested chain by calling the DEFINE_CHAIN_STEPprocedure. Oracle Database 12c: Administration Workshop 21 - 22Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Creating Job Chains1.Create a chain object. 2.Define chain steps. 3.Define chain rules.4.Starting the chain:Enable the chain.Create a job that points to the chain.JobJob chain
Background image
To define a step that waits for an event to occur, you use the DEFINE_CHAIN_EVENT_STEPprocedure. Procedure arguments can point to an event schedule or can include an inline queue specification and event condition. A step that points to an event waits until the specified event is raised. If the event occurs, the step completes successfully.3.After creating the chain object, you define chain rules. Chain rules define when steps run, and define dependencies between steps. Each rule has a conditionand an action:-If the condition evaluates to TRUE, the action is performed. The condition can contain any syntax that is valid in a SQL WHEREclause. Conditions are usually based on the outcome of one or more previous steps. For example, you may want one step to run if the two previous steps succeeded, and another to run if either of the two previous steps failed. -The action specifies what is to be done as a result of the rule being triggered. A typical action is to run a specified step. Possible actions include starting or stopping a step. You can also choose to end the execution of the job chain, returning either a value or a step name and error code.All rules added to a chain work together to define the overall behavior of the chain. When the job starts and at the end of each step, all rules are evaluated to see what action or actions occur next. You add a rule to a chain with the DEFINE_CHAIN_RULEprocedure. You call this procedure once for each rule that you want to add to the chain. 4.Starting the chaininvolves two actions: -Enable a chain with the ENABLEprocedure. (A chain is always created disabled, so you can add steps and rules to the chain before it is executed by any job.) Enabling an already enabled chain does not return an error.-To run a chain, you must create a job of type “CHAIN”. The job action must refer to the chain name. You can use either event-based or time-based schedules for this job.Oracle Database 12c: Administration Workshop 21 - 23
Background image
As an example of a chain, consider all the tasks and conditions that occur during a bulk data load. First, you must have data to load. Then load the data, observing the file system to make sure that you do not run out of space during the load. After the data load completes, you need to rebuild the indexes defined on the updated tables. Then you run reports against the newly loaded data. The slide shows an example of dependency scheduling.Oracle Database 12c: Administration Workshop 21 - 24Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Example of a ChainBULK_LOAD_CHAINDO_BULK_LOADJobLOAD_DATA_EVTENDREBUILD_INDXScheduleSTOP_WHEN_ DISK_FULL_EVTRun_reports(HR.GEN_REPORTS)START12534Dependency scheduling
Background image
Using advanced Scheduler features, you can exercise more control over various aspects of scheduling, such as job windows and prioritizing jobs. These advanced features are summarized below, and are discussed in detail in the following slides. A windowis represented by an interval of time with a well-defined beginning and end, and is used to activate different resource plans at different times. This allows you to change resource allocation during a time period, such as time of day or time of the sales year. A window grouprepresents a list of windows, and allows for easier management of windows. You can use a window or window group as the schedule for a job to ensure that the job runs only when a window and its associated resource plans are active.Ajob class defines a category of jobs that share common resource usage requirements and other characteristics. A job class groups jobs into larger entities.A resource consumer group associated with the job class determines the resources that are allocated to the jobs in the job class. A resource planenables users to prioritize resources (most notably CPU) among resource consumer groups.Note:The gray objects are not Scheduler objects.Oracle Database 12c: Administration Workshop 21 - 25Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using Advanced Scheduler FeaturesJobProgramArgumentsArgumentsScheduleEventTimeWindowJob chainWindowgroupResourceplanResourceconsumer groupDBservice nameJob class
Background image
Job classes are policies for their participating member jobs. Each job class specifies a set of attributes, such as the logging level. When you assign a job to a job class, the job inherits those attributes. For example, you can specify the same policy for purging log entries for all payroll jobs. You can use the CREATE_JOB_CLASSprocedure to create a job class. A class always belongs to the sysschema. To create a class, you must have the MANAGESCHEDULERprivilege. There is a default job class named DEFAULT_JOB_CLASSthat is created with the database.After a job class has been created, you can specify jobs as members of this job class when you create the jobs, or after the jobs are created, by using the SET_ATTRIBUTEprocedure of the DBMS_SCHEDULERpackage. If a job is not associated with a job class, the job belongs to this default job class. Set the service attribute of a job class to a desired database service name. This determines the instances in a Real Application Clusters environment that run the member jobs, and optionally, the system resources that are assigned to the member jobs.Oracle Database 12c: Administration Workshop 21 - 26Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Job ClassesAssign the same set of attribute values to member jobsAre created by the CREATE_JOB_CLASSprocedureSpecify jobs in a job class (with the SET_ATTRIBUTEprocedure )Belong to the SYSschemaSet resource allocation for member jobsSet the service attribute to a desired database service nameGroup jobs for prioritizationResource consumer groupDefault: DEFAULT_CONSUMER_GROUPDBservice nameJob classDefault: DEFAULT_JOB_CLASS
Background image
Set resource allocation for member jobs. Job classes provide the link between the Database Resource Manager and the Scheduler because each job class can specify a resource consumer group as an attribute. Member jobs then belong to the specified consumer group and are assigned resources according to settings in the current resource plan. Alternatively, you can leave the RESOURCE_CONSUMER_GROUPattribute as NULLand set the service attribute of a job class to a desired database service name. That service can in turn be mapped to a resource consumer group. If both the RESOURCE_CONSUMER_GROUPand service attributes are set, and the designated service maps to a resource consumer group, the resource consumer group named in the RESOURCE_CONSUMER_GROUPattribute takes precedence. If a resource consumer group is not specified when a job class is created, the job class maps to the DEFAULT_CONSUMER_GROUPresource consumer group. Jobs in the default job class or in a job class associated with the default resource consumer group may not be allocated enough resources to complete their tasks when the Resource Manager is enabled. Group jobs for prioritization. Within the same job class, you can assign priority values of 1–5 to individual jobs so that if two jobs in the class are scheduled to start at the same time, the one with the higher priority takes precedence. This ensures that you do not have a less important job preventing the timely completion of a more important one. If two jobs have the same assigned priority value, the job with the earlier start date takes precedence. If no priority is assigned to a job, its priority defaults to 3.Oracle Database 12c: Administration Workshop 21 - 27
Background image
The priority of jobs can change over a period of time. For example, you might want to allocate a high percentage of the database resources to data warehouse loading jobs at night and allocate a higher percentage of the resources during the day to the application jobs. To accomplish this, you can change the database resource plan by using a Scheduler window. Scheduler windows can automatically start jobs or change the resource allocation among jobs during various time periods of the day, week, and so on. A window is represented by an interval of time with a well-defined beginning and end, such as “from 12:00 AM to 6:00 AM.” Only one window can be in effect at any given time. You can create a window with the CREATE_WINDOWprocedure. Scheduler windows work with job classes to control resource allocation. Each window specifies the resource plan to activate when the window opens (becomes active), and each job class specifies a resource consumer group or specifies a database service, which can map to a consumer group. A job that runs within a window, therefore, has resources allocated to it according to the consumer group of its job class and the resource plan of the window (as shown in the graphic in this slide).Oracle Database 12c: Administration Workshop 21 - 28Copyright © 2013, Oracle and/or its affiliates. All rights reserved.WindowsScheduler windows:Can start jobs or change resource allocation among jobs for various time periodsOne active at a timeCreated with the CREATE_WINDOWprocedureResourceplanResourceconsumer groupWindowJob classJob
Background image
When creating multiple jobs in a database, you need a way to align the job processing with your business requirements and specify which jobs have the highest priority. For a particular window, you may have several classes of jobs running, each with its own priority. There are two levels at which jobs can be prioritized: at the class level and at the job level. The first prioritization is at the class level, using resource plans. Prioritization among jobs of different classes is done purely on a class resource allocation basis.The second prioritization is within the class, with the job priority attribute of the job. Prioritization levels are relevant only when two jobs within the same class are supposed to start at the same time. The job with the higher priority starts first.Prioritization is not guaranteed for jobs in different job classes. For example, a high-priority job in the APPL_JOBSjob class might not get started before a low-priority job in the ADMIN_JOBSjob class, even if they share the same schedule. If the APPL_JOBSjob class has a lower level of resources available, the high-priority job in that class has to wait for resources to become available, even if there are resources available to lower-priority jobs in a different job class.Oracle Database 12c: Administration Workshop 21 - 29Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Prioritizing Jobs Within a WindowPrioritizing jobs:At the class level (via resource plans) At the job level (with the job priority attribute)Not guaranteed for jobs in different job classesDaytime windowAPPL_JOBSJob1Job2ADMIN_JOBSJob4Job5OTHERJob3JobPriorityJob11Job22Job33Job45Job52
Background image
A more efficient way to create a set of jobs is the use of a job array. This also applies to lightweight jobs. In the example in the slide, 100 job specifications are created in a job array and submitted to the job queue in a single transaction. Notice that for a lightweight job, there is a very limited amount of information needed. In the example, the START_TIMEparameter defaults to NULL, so the job is scheduled to start immediately. 1.Declare the variable to hold a job definition and a job array variable.2. Initialize the job array using the SYS.JOB_ARRAYconstructor. This creates a place for one job in the array.3.Set the size of the array to the number of expected jobs. 4. Create each job and place it in the array. In the example in the slide, the only difference is the name of the job. The START_TIMEvariable of the job is omitted and it defaults to NULL, indicating that the job will run immediately. 5. Use the CREATE_JOBSprocedure to submit all the jobs in the array as one transaction. Note:If the array is very small, the performance will not be significantly better than submitting a single job.Oracle Database 12c: Administration Workshop 21 - 30Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Creating a Job ArrayDECLAREnewjob sys.job;newjobarr sys.job_array;BEGIN newjobarr := SYS.JOB_ARRAY();1.Declare variables of types sys.joband sys.job_array:2.Initialize the job array: newjobarr.EXTEND(100);3.Size the job array to hold the number of jobs needed:(… continued)
Background image
The full code of this example is: DECLAREnewjob sys.job;newjobarr sys.job_array;BEGIN-- Create an array of JOB object typesnewjobarr := sys.job_array();-- Allocate sufficient space in the arraynewjobarr.extend(100);-- Add definitions for jobsFOR i IN 1..100 LOOP-- Create a JOB object typenewjob := sys.job(job_name => 'LWTJK' || to_char(i),job_style => 'LIGHTWEIGHT',job_template => 'PROG_1',enabled => TRUE );-- Add job to the arraynewjobarr(i) := newjob;END LOOP;-- Call CREATE_JOBS to create jobs in one transactionDBMS_SCHEDULER.CREATE_JOBS(newjobarr, 'TRANSACTIONAL');END;/Oracle Database 12c: Administration Workshop 21 - 31Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Creating a Job ArrayDBMS_SCHEDULER.CREATE_JOBS(newjobarr, 'TRANSACTIONAL');FOR i IN 1..100 LOOPnewjob := SYS.JOB(job_name => 'LWTJK'||to_char(i),job_style => 'LIGHTWEIGHT',job_template => 'MY_PROG',enabled => TRUE );newjobarr(i) := newjob;END LOOP;4.Place jobs in the job array: 5.Submit the job array as one transaction:
Background image
Answer: a, c, dOracle Database 12c: Administration Workshop 21 - 32Copyright © 2013, Oracle and/or its affiliates. All rights reserved.QuizSelect the statements that are true about the advanced Scheduler features and functionality:a.Lightweight jobs can be created with a job array.b.Prioritizing jobs at the class level (via resource plans) and at the job level (with the job priority attribute) are mutually exclusive.c.Scheduler windows work with job classes to control resource allocation.d.Job chains are used to implement “dependency scheduling.”
Background image
Perform the following tasks to create a file watcher and create the event-based job that starts when the designated file arrives:1.Create a Scheduler credential object (a credential) with which to authenticate with the host operating system for access to the file and grant EXECUTEon the credential to the schema that owns the event-based job that the file watcher will start.2.Create a file watcher and grant EXECUTEon the file watcher to any schema that owns an event-based job that references the file watcher. Refer to the Oracle Database Administrator's Guidefor a detailed example of creating a file watcher.3.Create a Scheduler program object with a metadata argument that references the event message. -Define the metadata argument using the EVENT_MESSAGEattribute. -Create the stored procedure with an argument of the SYS.SCHEDULER_FILEWATCHER_RESULTtype that the program invokes. The stored procedure must have an argument of the SYS.SCHEDULER_FILEWATCHER_RESULTtype, which is the data type of the event message. The position of that argument must match the position of the defined metadata argument. The procedure can access attributes of this abstract data type to learn about the arrived file.Oracle Database 12c: Administration Workshop 21 - 33Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Creating a File Watcher and an Event-Based JobPerform the following tasks:1.Create a Scheduler credential object and grant EXECUTE.2.Create a file watcher and grant EXECUTE.3.Create a Scheduler program object with a metadata argument that references the event message.4.Create an event-based job that references the file watcher. (Optionally, enable the job to run for each instance of the file arrival event.)5.Enable the file watcher, the program, and the job.
Background image
4.Create an event-based job that references the file watcher. You can use the DBMS_SCHEDULER.SET_ATTRIBUTEprocedure to enable the job to run for each instance of the file arrival event, even if the job is already processing a previous event. Set the PARALLEL_INSTANCESattribute to TRUE. BEGINDBMS_SCHEDULER.SET_ATTRIBUTE('','PARALLEL_INSTANCES', TRUE); END;This enables the job to run as a lightweight job so that multiple instances of the job can be started quickly. If PARALLEL_INSTANCESis set to the default value of FALSE, file watcher events that occur while the event-based job is already processing another will be discarded.5.Enable the file watcher, the program, and the job.Oracle Database 12c: Administration Workshop 21 - 34
Background image
To receive file arrival events from a remote system, you must install the Scheduler agent on that system, and you must register the agent with the database. The remote system does not need an Oracle Database instance to generate file arrival events.Refer to the Oracle Database Administrator’s Guide for detailed information.Oracle Database 12c: Administration Workshop 21 - 35Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Enabling File Arrival Events from Remote SystemsPerform the following tasks to enable the raising of file arrival events at remote systems:1.Set up the database to run remote external jobs.2.Install, configure, register, and start the Scheduler agent on the first remote system.3.Repeat step 2 for each additional remote system.
Background image
You can now create a job that runs stored procedures and anonymous PL/SQL blocks on another database instance on the same host or a remote host. The target database can be any release of Oracle Database.There are no new procedures to support remote database jobs, rather there have been changes to existing DBMS_SCHEDULERprocedures to support this functionality. Additional information is provided over the next few pages.Oracle Database 12c: Administration Workshop 21 - 36Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Scheduling Remote Database JobsCreate a job that runs stored procedures and anonymous PL/SQL blocks on another database instance on the same host or a remote host.The target database can be any release of Oracle Database.DBMS_SCHEDULER.CREATE_DATABASE_DESTINATIONand DBMS_SCHEDULER.CREATE_CREDENTIALcan be used for remote database jobs.Jobs with job types of PLSQL_BLOCKand STORED_PROCEDUREcan be the subject of SET_ATTRIBUTEcalls for the DESTINATIONand CREDENTIALattributes.
Background image
You can perform the tasks listed in the slide to create a remote database job. To set up the originating database for remote jobs, perform the following steps:1.Verify that XML DB is installed.2.Enable HTTP connections to the database.BEGINDBMS_XDB.SETHTTPPORT(port);END;3.Execute the prvtrsch.plbscript.4.Set a registration password for the Scheduler agents.BEGINDBMS_SCHEDULER.SET_AGENT_REGISTRATION_PASS('password');END;Refer to the Oracle Database Administrator’s Guide for a detailed example.Oracle Database 12c: Administration Workshop 21 - 37Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Creating Remote Database JobsPerform the following tasks to create a remote job:1.Set up the originating database for remote jobs.2.Create the job by using DBMS_SCHEDULER.CREATE_JOB.3.Create a credential by using DBMS_SCHEDULER.CREATE_CREDENTIAL.4.Set the job CREDENTIAL_NAMEattribute by using DBMS_SCHEDULER.SET_ATTRIBUTE.5.Set the job DESTINATIONattribute by using DBMS_SCHEDULER.SET ATTRIBUTE.6.Enable the job by using DBMS_SCHEDULER.ENABLE.
Background image
The multiple destination jobs feature enables you to specify multiple targets on which the jobs should execute. You have the ability to monitor and control the jobs from the database at which you created them. The following capabilities are included:Specifying several databases or machines on which a job must executeModifying a job scheduled on multiple targets as a single entityStopping or dropping jobs running on one or more remote targetsFinding out the status of job instances on all of a job’s targetsNote that in the initial release of this feature, all destinations will run based on the time zone that is specified in the start date of the job or will default to the time zone of the source database.Oracle Database 12c: Administration Workshop 21 - 38Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Scheduling Multiple Destination JobsThis enables you to specify several targets on which your jobs should execute.It provides the ability to monitor and control the jobs from the database on which they were created. While running, a multiple-destination job is viewed as a collection of jobs, which are near-identical copies of each other.All jobs will execute based on the time zone that is specified in the start date of the job or will use the time zone of the source database.
Background image
The job table is a container for all the jobs, with one table per database. The job table stores information for all jobs, such as the owner name or the level of logging. You can find this information in the *_SCHEDULER_JOBSviews.Jobs are database objects, and can, therefore, accumulate and take up too much space. To avoid this, job objects are automatically dropped by default after completion. This behavior is controlled by the AUTO_DROPjob attribute.There are many views available to the DBA and privileged users that provide essential operating information regarding the scheduler, jobs, schedules, windows, and so on. These views include:*_SCHEDULER_PROGRAM_ARGS: Shows all arguments defined for all programs as well as the default values if they exist*_SCHEDULER_JOBS: Shows all jobs, enabled as well as disabled*_SCHEDULER_JOB_RUN_DETAILSshow all completed (failed or successful) job runs. It has a row for each job instance. Each row contains information about the job execution for that instance. The ERROR#column shows the number of the first error encountered*_SCHEDULER_GLOBAL_ATTRIBUTE: Shows the current values of Scheduler attributes*_SCHEDULER_JOB_ARGS: Shows all set argument values for all jobs*_SCHEDULER_JOB_CLASSES: Shows all job classesOracle Database 12c: Administration Workshop 21 - 39Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Viewing Scheduler Meta Data Scheduler management views, displaying:*_SCHEDULER_JOBS: All jobs, enabled and disabled*_SCHEDULER_SCHEDULES: All schedules*_SCHEDULER_PROGRAMS: All programs*_SCHEDULER_RUNNING_JOBS: Active job states*_SCHEDULER_JOB_LOG: All job state changes *_SCHEDULER_JOB_RUN_DETAILS: All completed job runsSELECT job_name, status, error#, run_durationFROM user_scheduler_job_run_details;JOB_NAME STATUS ERROR# RUN_DURATION ---------------------- ------------------GATHER_STATS_JOB SUCCESS 0 +000 00:08:20 PART_EXCHANGE_JOB FAILURE 6576 +000 00:00:00
Background image
For job chains:*_SCHEDULER_RUNNING_CHAINS: Shows all active chains*_SCHEDULER_CHAIN_STEPS: Shows all steps for all chains*_SCHEDULER_CHAINS: Shows all chains*_SCHEDULER_CHAIN_RULES: Shows all rules for all chainsFor windows an other advanced objects:*_SCHEDULER_WINDOWSshow all windows.*_SCHEDULER_WINDOW_GROUPSshow all window groups.*_SCHEDULER_WINGROUP_MEMBERSshow the members of all window groups, one row for each group member.*_SCHEDULER_JOB_LOGshows all state changes made to jobs.*_SCHEDULER_JOB_ROLESshow all jobs by database role.Lightweight jobs are visible through the same views as regular jobs:*_SCHEDULER_JOBS: Shows all jobs, including the JOB_STYLE=‘LIGHTWEIGHT’*_SCHEDULER_JOB_ARGS: Shows all set argument values also for lightweight jobsBecause lightweight jobs are not database objects, they are not visible through the *_OBJECTSviews.Starting with the Oracle Database 11g Release 2:*_SCHEDULER_NOTIFICATIONSshows which email notifications have been set.*_SCHEDULER_FILE_WATCHERSshows file watcher configuration information.The following views display information about multiple destination jobs:*_SCHEDULER_DESTS: Shows all the destinations on which remote jobs can be scheduled. The views contain both the external destinations (for remote external jobs) as well as the database destinations for remote database jobs.*_SCHEDULER_EXTERNAL_DESTS: Shows all the agents that have registered with the database and can be used as a destination for remote external jobs.*_SCHEDULER_DB_DESTS: Shows all the databases on which you can schedule remote database jobs.*_SCHEDULER_GROUPS: Shows the groups in your schema or all groups in the database.*_SCHEDULER_GROUP_MEMBERS: Shows the group members in your schema or all group members in the database.*_SCHEDULER_JOB_DESTS: Shows the state of a job at a remote database.Note:In the views listed above, the asterisk at the beginning of a view name can be replaced with DBA, ALL, or USER.Oracle Database 12c: Administration Workshop 21 - 40
Background image
Answer: b, cOracle Database 12c: Administration Workshop 21 - 41Copyright © 2013, Oracle and/or its affiliates. All rights reserved.QuizSelect the statements that are true about the Oracle Scheduler:a.Creating remote database jobs is a manual task requiring the use of OS-specific commands.b.A Scheduler credential is an object with which to authenticate with the host operating system for file access.c.You can specify several targets on which your jobs should execute and monitor them from the database on which they were created.
Background image
Oracle Database 12c: Administration Workshop 21 - 42Copyright © 2013, Oracle and/or its affiliates. All rights reserved.SummaryIn this lesson, you should have learned how to:Simplify management tasks by using the SchedulerCreate a job, program, and scheduleMonitor job executionUse a time-based or event-based schedule for executing Scheduler jobsDescribe the use of windows, window groups, job classes, and consumer groupsUse email notificationUse job chains to perform a series of related tasksDescribe Scheduler jobs on remote systemsUse advanced Scheduler features to prioritize jobs
Background image
This practice uses both Enterprise Manager Cloud Control and SQL*Plus.Oracle Database 12c: Administration Workshop 21 - 43Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Practice: OverviewThis practice covers the following topics:Creating a job that runs a program outside the databaseCreating a program and a scheduleCreating a job that uses a program and a scheduleCreate a lightweight jobMonitoring job runs
Background image
Background image
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Working with Oracle Support
Background image
Oracle Database 12c: Administration Workshop A - 2Copyright © 2013, Oracle and/or its affiliates. All rights reserved.ObjectivesAfter completing this lesson, you should be able to:Work with My Oracle SupportSearch My Oracle SupportLog service requests (SRs) Manage patchesApply a patchStage a patchUse the Enterprise Manager Cloud Control Support Workbench
Background image
Oracle Database 12c: Administration Workshop A - 3Oracle Support Services (OSS) provides 24×7 solution support to all Oracle customers throughout the world. OSS has support centers around the globe to provide this coverage whenever it is required, 365 days a year.Support is delivered to Oracle customers through the My Oracle Support Web site, on the telephone, and by using the Oracle Direct Connect (ODC) remote diagnostic tool.After purchasing Oracle software, customers are provided with a Customer Support Identifier (CSI) number. This number is used to track the software and support licensed to each customer. The CSI number provides access to all the available patches, documentation, and troubleshooting information on My Oracle Support. The CSI number enables customers to log a service request (SR) with OSS.Note:Service requests were formerly called technical assistance requests (TARs).Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Working with Oracle SupportOracle Support Services (OSS) provides 24×7 solution support.Support is delivered in the following ways:My Oracle Support websiteTelephoneOracle Direct Connect (ODC) remote diagnostic toolThe Customer Support Identifier (CSI) number is used to track the software and support that are licensed to each customer.
Background image
Oracle Database 12c: Administration Workshop A - 4To register for My Oracle Support, go to http://myoraclesupport.oracle.com/ and click the “New User? Register here” link. At the prompt, enter your CSI number and answer a few basic questions. After registering, you are ready to use My Oracle Support. Note that each CSI number has an administrator designated by the customer who controls new-user access to My Oracle Support. Customers must designate this individual, and then new users must work with this individual to create new accounts and grant appropriate My Oracle Support access.My Oracle Support has a variety of tools and methods available for researching problems.Searching for answers on My Oracle Support through the standard and advanced search engines is relatively straightforward. A common problem is that too many results are returned. The following are some simple steps that can improve the quality and relevance of search results:Use full and exact error text when performing your search. For example, ORA-1400: mandatory (NOT NULL) columnreturns more relevant answers than ORA-1400.When researching errors in Oracle E-Business Suite, enter the name of the code as part of the search criteria. For example, APXINWKB ORA-1400: mandatory (NOT NULL) columnreturns fewer and better results than if you supply only the error message.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using My Oracle Support
Background image
Oracle Database 12c: Administration Workshop A - 5You can use the Knowledge tab to access the Knowledge Browser if you prefer a drilldown method of searching for information rather than searching by keyword. The Knowledge Browser provides easy-to-use access to OSS’s most frequently used technical content.The Knowledge Browser is organized to provide up-to-date information at your fingertips:Recent announcements and information in the Featured News and ArticlessectionInformation by product categoryCase studiesTools and trainingOnline documentationElectronic technical reference manuals (eTRMs)Oracle Integration RepositoryCustomer Knowledge ExchangeMy Oracle Support Forums (Forums) enables you to interact with other Oracle customers to share ideas and discuss Oracle products. You can use My Oracle Support Forums to find out how other customers perform complex tasks or meet various business requirements with Oracle products. You should not use Forums as a substitute for logging an SR. Customers can use the patch engine to search for patches by using a variety of methods. The following are the most common patch searches:Patch Number:If you know the patch number, you can enter it.Latest Consolidated Patch:You can use this when upgrading to determine the latest patches for the products you are using.Includes File:When a problem is encountered in a specific piece of code, a patch is often available to fix the issue. For this reason, support representatives often recommend that customers apply a patch to update code to the most current version available for the release. You can find and apply the latest versions of Oracle software by identifying the name and version of the code and then using the patch search utility to find out whether a more current version of the code is available.Note:For detailed information about performing these searches, refer to My Oracle Support Technical Note 166650.1 (“Working Effectively with Global Customer Support”). You can use the BUGs link to search the BUG database when researching issues. A variety of methods are available for searching the BUG database.
Background image
Oracle Database 12c: Administration Workshop A - 6My Oracle Support provides several resources that can be used to research an issue. The following steps outline basic troubleshooting techniques that use My Oracle Support resources:1.Keyword search:Most issues can be resolved quickly and easily by using the keyword search utility on My Oracle Support. Effective searches can provide much information about a specific problem and its solutions.2.Documentation:If keyword searching fails to yield a solution, you should review the documentation to ensure that setup problems are not the root cause. Setup issues account for more than one-third of all service requests; it is always good to review setups early in the troubleshooting process. Documentation consists of user guides and implementation manuals published in PDF format as well as product README files and installation notes published in HTML. Both of these document types are available on My Oracle Support and can be accessed through the self-service toolkits for each product.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Researching an IssueTo research an issue on My Oracle Support, perform the following steps:1.Perform a keyword search.2.Review the documentation.3.Use the self-service toolkits.4.Use the automated diagnostic tests and business flows.5.Search for applicable patches.6.Log a service request (SR).
Background image
Oracle Database 12c: Administration Workshop A - 73.Self-service toolkits:Self-service toolkits (SSTKs) provide a wealth of information about each product. In most cases, they contain FAQs, patch listings, and other helpful information that can assist you in researching and troubleshooting the issues that you are facing. Because SSTKs contain the most frequently used content about each product, you should reference them periodically to identify known issues before they cause problems within your environment.4.Diagnostics and flows:Many recent innovations in Oracle Support Services have been in the area of automated diagnostic tests and business flows. Tests and flows have been created for you to check the setup of your system or gather information about a problem. In the case of diagnostic tests, this can be done by running a Java or SQL script. The output of these tests can help you in resolving issues and can also help Oracle Support Services identify the cause of your problem if it becomes necessary to log a service request.5.Patches and BUGs:There are times when BUGs are found in Oracle products, and patches are required to correct the problem. When troubleshooting a problem, you should review your system to see whether patches are available to provide you with a more recent release of the product. With the patch search tool, you can search for patches that contain specific files. Searching for the latest code and patching your environment to the most recent version improves the troubleshooting process by eliminating existing BUGs that could be possible candidates for the problem. You should also leverage the BUG search engine to see whether a BUG has been logged for your issue but not yet fixed.6.Logging a service request (SR):When all self-service options fail, it may become necessary to engage a support representative to assist in resolving your issue.
Background image
Oracle Database 12c: Administration Workshop A - 8You may research an issue on My Oracle Support, but may be unable to locate a solution. In this case, you should log a service request (SR) through My Oracle Support. You can log an SR by clicking the Service Request tab on the My Oracle Support home page. The first step in creating an SR is the selection of a CSI number and SR profile. After the required profile information has been submitted, My Oracle Support gathers some specifics about the problem, including the problem type, error message, brief summary of the issue, and language preference. My Oracle Support performs a search by using this information and attempts to find a solution. The search conducted during this phase may provide different results than the searches you have performed earlier. Both searches retrieve notes and BUGs from the same database; however, the search engines and weighting are slightly different. Because the search results can differ, it is important that the search results are reviewed during the SR creation process, even if previous searches have been conducted by using the My Oracle Support search engine.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Logging Service RequestsLog an SR by clicking the Service Request tab on the My Oracle Support home page.My Oracle Support performs searches based on the CSI number and SR profile.Provide the following information when logging an SR:Explanation of the issue, including error messagesSteps taken to troubleshoot the issueSoftware versionSteps required to reproduce the problemBusiness impact of the issue
Background image
Oracle Database 12c: Administration Workshop A - 9If the search results fail to resolve the issue, the SR creation process continues with a series of questions and requests for information. After the questions are answered, the SR is submitted electronically and routed to a support representative who analyzes the issue further. Any files, screenshots, or other additional information must be uploaded immediately after the SR is logged by using the upload utility provided in the SR section of My Oracle Support.You must ensure that the following items are clearly documented in the SR. By providing the following information, you can equip the support representative effectively to prioritize and work on the issue:Clear explanation of the problem, including exact error messagesExplanation of the steps taken to troubleshoot the problem and the findingsExact versions of the softwareSteps required to reproduce the problemBusiness impact of this issue, including milestones, dates, and costsEach SR is assigned a unique identifier called an SR number. When you log an SR, My Oracle Support provides you with the SR number (or your support representative advises you about the SR number if you log the SR by telephone). The support representative subsequently receives the SR in his or her queue through an automated allocation process that Oracle Support Services uses to distribute all phone- and web-sourced service requests. This automated process ensures that all SRs are assigned to the support representative who is best able to work on the specific issue that is being reported.Note:For more information, refer to My Oracle Support Technical Note 166650.1 (“WorkingEffectively with Global Customer Support”).
Background image
Oracle Database 12c: Administration Workshop A - 10My Oracle Support Community is a multi-channel interactive community for sharing information, posting questions and answers, and providing suggestions about Oracle products, services, and related technologies.If you have access to My Oracle Support you are automatically a member. There is no additional registration required. Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Accessing My Oracle Support Community
Background image
Oracle Database 12c: Administration Workshop A - 11You can apply different kinds of patches at different times for different reasons.Interim patches (also known as one-offor one-of patches) are created to solve a specific problem. They do not go through a full regression test. Interim patches are typically installed with the opatchutility. The Enterprise Manager Patching Wizard can help automate the patching process by downloading, applying, and staging the patches. This wizard uses the opatchutility in the background. Security Patch Updates (SPU) patches—formally, Critical Patch Update (CPU) patches—are cumulative, which means fixes from previous Oracle security alerts and critical patch updates are included. Patch Set Update (PSU) patches include Security Patch Updates (SPU) and dependent non-security patches. PSU patches are cumulative. It is not required to have previous security patches applied before applying PSU patches. However, you must be on the stated patch set level. PSU patches are for a specific patch release level (such as 10.2.0.3). PSU patches are installed with the opatchutility or through EM Patching Wizard. PSU patches are issued quarterly. PSU patches and interim patches can also be removed from your system with opatch rollback -id <patch id>.Oracle does extensive testing of Patch Set Updates with its own applications, as well as running regression tests for the PSUs themselves. To verify that a patch has been applied, query the inventory withopatch -lsinventoryand see if the patch is listed.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Managing Patches Kinds of patchesInterim patches For specific issuesNo regression testingSecurity Patch Updates (SPUs)Critical security issuesRegression testingDoes not advance version numberPatch Set Updates (PSUs)Patch releases
Background image
Oracle Database 12c: Administration Workshop A - 12Software management involves keeping your Oracle software up-to-date with the latest product fixes. Periodically, Oracle issues patch releases (product fixes) for its software. Patch releases are fully tested product fixes. Application of a patch release affects only the software residing in your Oracle home, with no upgrade or change to the database.Patches are individual bug fixes. Patch sets are a collection of bug fixes up to the time of the patch set release. All patch and patch set releases carry version numbers. For example, 11.1.0.3 is an available patch set for Oracle Database 11gRelease 11.1.0.2. Every patch or patch set also has a patch number to identify it. Every patch release has an associated README file that describes its bug fixes. The README also has instructions for manually applying the patch. Enterprise Manager enables you to find the latest patch release on the My Oracle Support website and download it to your Oracle home.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Applying a Patch ReleasePatch releases are fully tested product fixes that:Affect only the software residing in your Oracle home on installationContain individual bug fixesCarry version numbersTo apply a patch:1.Determine your Oracle software environment.2.Set your My Oracle Support login credentials.3.Stage the patch release.
Background image
Oracle Database 12c: Administration Workshop A - 13Oracle Enterprise Manager Cloud Control significantly facilitates software patching with its built-in My Oracle Support integration. Enterprise Manager Cloud Control automatically alerts users to new critical patches and flags all systems that require a specific patch. You can invoke the Enterprise Manager Cloud Control patch wizard to determine what interim patches are available for installation. Alternatively, you can use the patch wizard to select an interim patch and determine whether any of your systems require that patch. You can review the patch details and README patch notes directly from within Enterprise Manager Cloud Control.You can use the patch wizard to download interim patches from My Oracle Support into the Enterprise Manager Cloud Control patch cache, eliminating the need for repeated downloads. You can stage appropriate patches on the destination system or systems for manual application at a later time. To further automate the patching process, you can also provide a customizable patch application script that is executed on the destination system at a user-defined time by the resident Enterprise Manager Cloud Control agents. As patches are applied to a system, the corresponding Oracle Universal Installer (OUI) inventory is automatically updated to keep track of the systems’ correct patch level.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Enterprise Manager Cloud Control:My Oracle Support IntegrationEnterprise Manager Cloud Control automatically alerts users to new critical patches.The Enterprise Manager Cloud Control patch wizard can be used to select an interim patch.You can review the patch’s README file from within Enterprise Manager Cloud Control.You can download the selected patches from My Oracle Support into the Enterprise Manager Cloud Control patch cache.
Background image
Oracle Database 12c: Administration Workshop A - 14In Enterprise Manager Cloud Control, you can access the Patches & Updates page by expanding Enterprise and selecting Patches & Updates in the Provisioning and Patching menu. Note that this menu is at the Enterprise, not database target level.In the Patch Search section, you can search for patches by patch number and name, you can search for all patches for a specific product, and you can invoke the Patch Advisor. The Patch Advisor enables you to search for recommended patches for specified products and combinations of products.Refer to the Enterprise Manager Cloud Control documentation and online help for additional information. You may also want to attend the Using Oracle Enterprise Manager Cloud Control 12ccourse for detailed information about using Enterprise Manager Cloud Control.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using the Patch Advisor
Background image
Oracle Database 12c: Administration Workshop A - 15Online patching provides the ability to install, enable, and disable a bug fix or diagnostic patch on a live, running Oracle instance. Using online patching is the recommended solution for avoiding down time when applying online patches. Oracle provides the capability to perform online patching with any Oracle database using the opatch command-line utility. Online patches can be provided when the changed code is small in scope and complexity (for example, with diagnostic patches or small bug fixes).Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Online Patching: OverviewFor a bug fix or diagnostic patch on a running Oracle instance, online patching provides the ability to do the following:InstallEnableDisable
Background image
Oracle Database 12c: Administration Workshop A - 16Unlike traditional patching mechanisms, applying an online patch does not require instance shutdown or restart.Similar to traditional patching, you can use OPatch to install an online patch.You can determine whether a patch is an online patch by using the following commands:opatch query -is_online_patch <patch location>oropatch query <patch location> -all Note:The patched code is shipped as a dynamic/shared library, which is then mapped to memory by each Oracle process.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Installing an Online PatchApplying an online patch does not require instance shutdown, relinking of the Oracle binary, or instance restart.OPatch can be used to install or uninstall an online patch.OPatch detects conflicts between two online patches, as well as between an online patch and a conventional patch.To determine if a patch is an online patch:opatch query -is_online_patch <patch location>ORopatch query <patch location> -all
Background image
Oracle Database 12c: Administration Workshop A - 17You do not have to shut down your database instance while you apply the online patch. Unlike conventional patching, online patching enables fast installation and uninstallation. Because online patching uses OPatch, you get all the benefits that you already have with conventional patching that uses OPatch. It does not matter how long or how many times you shut down your database—an online patch always persists across instance shutdown and startup.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Benefits of Online PatchingNo down time and no interruption of businessExtremely fast installation and uninstallation timesIntegration with OPatch:Conflict detectionListed in patch inventoryWorks in RAC environmentPersistence across instance shutdown and startup
Background image
Oracle Database 12c: Administration Workshop A - 18Conventional patching basically requires a shutdown of your database instance.Online patching does not require any down time. Applications can keep running while you install an online patch. Similarly, online patches that have been installed can be uninstalled with no down time.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Conventional Patching and Online PatchingTake only a few seconds to install or uninstallTake several minutes to install or uninstallPersist across instance startup and shutdownPersist across instance startup and shutdownAre installed and uninstalled via OPatchAre installed and uninstalled via OPatchDo not require down time to apply or removeRequire down time to applyor removeOnline PatchesConventional Patches
Background image
Oracle Database 12c: Administration Workshop A - 19One operating system (OS) page is typically 4 KB on Linux x86 and 8 KB on Solaris SPARC64. With an average of approximately one thousand Oracle processes running at the same time, this represents around 4 MB of extra memory for a small online patch.A vast majority of diagnostic patches are available as online patches. For bug fixes, it really depends on their nature. Not every bug fix or diagnostic patch is available as an online patch. But the long-term goal of the online-patching facility is to provide online-patching capabilities for Critical Patch Updates.Note:You must uninstall the online patch before applying the conventional patch.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Online Patching ConsiderationsSome extra memory is consumed. Exact amount depends on the size of the patch and number of concurrently running Oracle processesMinimum amount of memory: Approximately one OS page per running Oracle processThere may be a small delay (a few seconds) before every Oracle process installs or uninstalls an online patch.Not all bug fixes and diagnostic patches are available as an online patch.Use online patches in situations when down time is not feasible.When down time is possible, you should install all relevant bug fixes as conventional patches.
Background image
Oracle Database 12c: Administration Workshop A - 20Answer: a, c, dCopyright © 2013, Oracle and/or its affiliates. All rights reserved.QuizWhich of the following statements are true about online patches?a.Can be installed using OPatchb.Require down time to applyc.Persist across instance startup and shutdownd.Do not require down time to remove
Background image
Oracle Database 12c: Administration Workshop A - 21Using the Enterprise Manager Cloud Control Support Workbench, you can investigate, report, and (in some cases) resolve a problem by performing the following general steps:1.On the Database Home page in Enterprise Manager, review critical error alerts. View the details by selecting an alert.2. Examine the problem details and view a list of all incidents that were recorded for the problem. Display findings from any health checks that were automatically run.3. (Optional) Run additional health checks and invoke the SQL Test Case Builder, which gathers all required data related to a SQL problem and packages the information in a way that enables the problem to be reproduced at Oracle Support.4. Create a service request with My Oracle Support and (optionally) record the service request number with the problem information.5. Invoke the Incident Packaging Service, which packages all gathered diagnostic data for a problem and (optionally) uploads the data to Oracle Support. You can edit the data to remove sensitive information before uploading.6. You can maintain an activity log for the service request in the Support Workbench. Run Oracle advisors to help repair SQL failures or corrupted data.7. Set the status for one, some, or all incidents for the problem to be closed.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Using the Support WorkbenchView criticalerror alerts inEnterprise Manager.View problemdetails.Gather additionaldiagnostic information.Create aservice request.Package and uploaddiagnostic datato Oracle Support.Track the servicerequest andimplement repairs.Close incidents.1234567
Background image
Oracle Database 12c: Administration Workshop A - 22You can access the Support Workbench page directly by expanding the Oracle Database menu, and then selecting Support Workbench in the Diagnostics submenu.Note:The tasks described in this section are all performed in Enterprise Manager Cloud Control. You can also accomplish all of these tasks with the ADRCI command-line utility. See the Oracle Database Utilitiesguide for more information about the ADRCI utility.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Accessing the Support WorkbenchClick to access the Problem Details page.
Background image
Oracle Database 12c: Administration Workshop A - 23On the Problems subpage on the Support Workbench page, click the ID of the problem that you want to investigate. This takes you to the corresponding Problem Details page.On this page, you can see all incidents that are related to your problem. You can associate your problem with a My Oracle Support service request and bug number. In the “Investigate and Resolve” section of the page, you see a Self Service subpage that has direct links to the operations that you can perform for this problem. In the same section, the Oracle Support subpage has direct links to My Oracle Support.The Activity Log subpage shows you the system-generated operations that have occurred on your problem so far. This subpage enables you to add your own comments while investigating the problem.On the Incidents subpage, you can click a related incident ID to access the corresponding Incident Details page.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Viewing Problem DetailsClick to access the Incident Details page.
Background image
Oracle Database 12c: Administration Workshop A - 24When you access the Incident Details page, the Dump Files subpage lists all corresponding dump files. You can then click the eyeglass icon for a particular dump file to visualize the file content with its various sections.On the Incident Details page, click Checker Findings to view the Checker Findings subpage. This page displays findings from any health checks that were automatically run when the critical error was detected. You will usually have the opportunity to select one or more findings and invoke an advisor to fix the issue.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Viewing Incident Details
Background image
Oracle Database 12c: Administration Workshop A - 25The Support Workbench provides two methods for creating and uploading an incident package: the Quick Packaging method and the Advanced Packaging method. The example in the slide shows how to use Quick Packaging.Quick Packaging is a more automated method with minimum steps. You select a single problem, provide an incident package name and description, and then schedule the incident package upload, either immediately or at a specified date and time. The Support Workbench automatically places diagnostic data related to the problem into the incident package, finalizes the incident package, creates the ZIP file, and then uploads the file. With this method, you do not have the opportunity to add, edit, or remove incident package files or add other diagnostic data such as SQL test cases.If you have not registered with My Oracle Support, a link will appear so that you can register. You must register with My Oracle Support to send the package to Oracle Support.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Packaging and Uploading Diagnostic Data to Oracle Support
Background image
Oracle Database 12c: Administration Workshop A - 26After uploading diagnostic information to Oracle Support, you can perform various activities to track the service request and implement repairs. Among these activities are the following:Add an Oracle bug number to the problem information. On the Problem Details page, click the Edit button that is adjacent to the Bug# label. This is for your reference only.Add comments to the problem activity log:1.Access the Problem Details page for the problem.2.Click Activity Log to display the Activity Log subpage.3.In the Comment field, enter a comment and then click Add Comment. Your comment is recorded in the activity log.Respond to a request by Oracle Support to provide additional diagnostics. Your Oracle Support representative can provide instructions for gathering and uploading additional diagnostics.Copyright © 2013, Oracle and/or its affiliates. All rights reserved.Tracking the Service Request and Implementing Repairs
Background image
Oracle Database 12c: Administration Workshop A - 27Copyright © 2013, Oracle and/or its affiliates. All rights reserved.SummaryIn this lesson, you should have learned how to:Use the Support Workbench Work with Oracle SupportSearch My Oracle SupportLog service requests Manage patchesApply a patch releaseStage a patch release
Background image
Background image
___________________ Appendix B Basic Linux and vi Commands ___________________
Background image
Oracle Database 12c: Administration Workshop B - 2 viCommands The Visual Interpreter/Editor (vi) is the most widely used text editor available for the UNIX environment. While almost everybody curses its unwieldy command syntax, it is still the only editor that is almost certain to be included with every version of the UNIX and Linux operating system. The following is a partial list of available vicommands. vihas two modes: Command-line (where anything typed is taken as an editing command) and input mode (where everything typed will be treated as part of the file being edited). To enter the input mode, type a, A, i, I, o, O, c, C, s, S, r, or R. To return to the command-line mode, use the Esc key. To access the vieditor from SQLPlus, enter the following command: SQL>define _editor=vi To edit a file from the SQLPlus prompt, edit <filename> (press Enter); and from the Linux command prompt, vi <filename> (press Enter). To MOVE the cursor: h - move left j - move down k - move up l - move right w - one word forward b - one word backward e - end of current word W, B, or E - same as lowercase but ignores punctuation 0 (zero) - Move to beginning of current line $ - end of current line G - go to last line of file H - go to top line on the screen L - go to last line on screen M - go to middle line on the screen /<string> - Search forward to the next occurrence of <string> ?<string> - Search backward to the next occurrence of <string> n - Repeat previous search N - Repeat previous search in opposite direction Ctrl + f - Scroll forward one page Ctrl + b - Scroll backward one page To UNDO previous changes: u - Will undo the most recent change U - Will undo the most recently deleted text :e! - re-edit current file without saving any changes made since last change To ENTER NEW text: a - Append text after the current cursor position. A - Append text to the end of a line (jumps to end of line and begin appending) c - Change object C - Change from current cursor position to end of the line i - Insert text before the current cursor position I - Insert text at the beginning of a line
Background image
Oracle Database 12c: Administration Workshop B - 3 o - Insert a blank line BELOW the current cursor position O - Insert a blank line ABOVE the current cursor position r - Replace character at current cursor position R - Replace all characters until Esc is pressed s - Substitute text for character under cursor :s/A/B/opt substitutes string B for string A. %s/A/B/opt is global replace options include: g (change all occurences on current line) c (confirm prior to each change) p (print changed lines) S - Substitute entire line to the end . <period> - repeat last change n. <integer><period> repeat last change ntimes To leave the input mode, press Esc. To DELETE existing text: x - Will delete the character directly under the current cursor location dd - Will delete the entire line where the cursor is located dnd (where nis some integer) - Will delete nlines from current cursor position dw - Delete current word D - Delete to end of current line J - Delete return at end of current line. Join this line and the next. <int> J - Join the next <int> lines COPY, CUT, and PASTE:viuses a single buffer where the last changed or deleted text is stored. This text may be manipulated with the following commands: Y - Yank a copy of the current line y <integer> - Yank a copy of next <int> lines yw - Yank a copy of the current word yb - Yank a copy of the previous word p - Put buffer contents after cursor P - Put buffer contents before cursor Also, see the s and S commands under the input section To SAVE edited changes to an operating system file: zz - Will terminate edit mode :w filename - Will save changes to the filename specified :wq - Write all changes and quit the edit mode To QUIT without saving changes: ZZ - Will terminate edit mode :q! - Will terminate the file without saving changes
Background image
Oracle Database 12c: Administration Workshop B - 4 Basic Linux Commands This appendix is meant to serve only as a quick reference while you are in class. For more details on these commands, consult the man pages, your Linux documentation, or other Linux command reference books. Files and Directories Linux CommandsDescription/CommentsCommand manual man <command> man –k <string> man man Find the manual entry for this <command>. Show all the manual entries that contain this <string>. Displays the manual page forman.Command information info <command> Show the information system entry for this command. Using info infoshows a tutorial of the infodocumentation system.Print to standard out cat <file> Concatenate and print; print the named file to the terminal screen. List users cat /etc/password Change working directory cd <directory> Change working directory to specified directory cd with no parameters changes to $HOME.Copy a file cp <source_file> <destination_file> Copy a source file to a destination file.View a file less <file> View a file a page at a time. This is a GNU version of more, or pg. View a file more <file> View a file a page at a time. BSD version.List directory ls <directory> Options: –l: long listing, -R: recursive, -a: show hidden files, -t: sort by time, -r: reverse sort, default directory is current working directory.Create a directory mkdir <directory> Make a directory defaults into the current working directory, full path may be specified.Move or rename a file mv <old_file> <new_file> Move changes the name of a file or moves it to a different directory. Process List ps ps -ef Shows the processes report Shows all processes on the system with a full listing. Many option exist see the man page for details.
Background image
Oracle Database 12c: Administration Workshop B - 5 Print working directory pwd Print to stdout the current working directory.Remove or erase a file rm <file> Removing a file on Linux is permanent. Options –r: recursive, and –f: force (including subdirectories) are very dangerous. Often the rmcommand is aliased with rm iThe option –iasks ‘Are you sure?’ Create an empty file touch <file> Create a file.Name of the machine hostname Returns the name of the machine.The IP address of the machine host <machine_name> Queries the Domain Name Server, and returns the IP address of the machine name. Remote shell rsh <host> <command> Execute a <command> on <host>. Rsh is not secure, use ssh instead.Remote shell ssh <host> Secure shell, has features to replace rsh, rcp, ftp, and telnet.Remote shell telnet <host> Start a terminal session on <host>. Telnet is not secure use ssh instead.Search a file for a pattern grep <option> <pattern> <file> Search a <file> or stream for a regular expression defined by <pattern> and show the line that contains that pattern. A common option is –ifor case insensitive. grepcan accept input from a file or stdinthrough a pipe as in: netstat –a| grep ESTABLISHED Source a script . <script_file> In the bashshell this command ‘.’ forces the script to run in the shell. Normal behavior is for the script to run in a child shell.
Background image
Oracle Database 12c: Administration Workshop B - 6 An interpreter awk A macro language for reformatting or interpreting input. For each line of input, a variety of actions can be taken. May be referred to as nawk – for “new awk.”Sort a file sort Sort a file takes input from stdin or a filename argument, many options to sort by a particular column, field, etc. See man page. Command-line editor sed Sed is a command-line editor, with many possible commands and options that are very good for editing from a shell script.Visual editor vi <file> Terminal based editor available on every UNIX system, Linux provides vim, an improved vi, that is a superset of vi.Gnu editor emacs <file> This is a GPL editor with extensive customizable features available on most UNIX and Linux distributions.WYSIWYG editor gedit <file> A full-screen editor, requiring X. Available under Gnome.WYSIWYG kate <file> A full-screen editor, requires X. Available under KDETerminal output stdout Standard out (stdout) is not a command but a concept, most Linux commands write to stdout by default unless redirected.Terminal input (keyboard) stdin Standard in (stdin) is not a command but a concept, most Linux commands read from stdin by default unless redirected.Alias alias <command> <alias> Make a substitution when a user types <command> substitute and execute <alias>, common alias is alias ‘rm’ ‘rm –i’. These aliases are set in the .bashrcfile.Show shell variables set Prints all of the variables that are currently defined in the shell.
Background image
Oracle Database 12c: Administration Workshop B - 7 Show environment variables printenv or env Prints all the environment variables – an environment variable has been ‘exported’ so that it will be inherited by child processes.File Creation mask umask S u=rwx,g=rx,o=rx Set the default permissions for all files created by this shell or its children. The –Soption uses the symbolic notation, the numeric notation is obsolete.Clock xclock An X client that shows a clock on the screen. Often used to test the X windows system.X access control xhost xhost +<Xclient> Show the current access control in place. Add an Xclient that is allowed to access the local DISPLAY, if no <Xclient> is given all are allowed.
Background image
Oracle Database 12c: Administration Workshop B - 8 System AdministrationLinux CommandsDescription / CommentsSubstitute user su - username Change the user that is currently performing the work. This can be used by any user to change who is the effective id of the session user. Normal users must provide a password, root does not. The ‘-‘ parameter is optional. It runs the new users login scripts.Limited root privileges sudo The root user may configure which users can execute certain commands as root, and whether a password is required or not. Useful for allowing specific users to perform certain root commands e.g. mount and unmount removable volumes such as CDROMs.Root file system / The root directory for the system directory tree.Home Directory /home Typically the directory where all user home directories are placed. For example: /home/oracle. Tmp directory /tmp A temporary storage area. Do not put anything here you want to keep. SA often has a cron job to remove everything periodically.Boot directory /boot A small partition to hold the kernel image(s) and boot loader instructions.Log directory /var/log The location of most system log files.Sample configuration files /etc/inittab Configuration files are located per the application. Any configuration file that you change after installation should be included in the backup.Password files /etc/passwd /etc/shadow The /etc/passwdfile holds user information and must be readable by others; even with encrypted passwords this can be a security hole. The /etc/shadowfile holds the encrypted passwords and is only readable by root.
Background image
Oracle Database 12c: Administration Workshop B - 9 Groups file /etc/group The /etc/groupsfile defines the groups on a server and the users that are members of the group; primary group for a user is defined in the /etc/passwdfile.X configuration file /etc/X11/XF86Config The file that sets the X server settings for your video card, monitor, mouse, and keyboard. Usually set up with an OS vendor-supplied tool. Schedule a command to run at a regularly scheduled time crontab -e Use this command to edit the crontabfile, to create the specification for the crondaemon to use.Schedule a script to run at a particular frequency /etc/anacrontab Edit the file to specify a script to run at a particular frequency (see man anacrontabfor details).Schedule a command to run at a single specified time at <options> TIME Runs a job specified by <options> at a specified TIME parameter.Schedule a command batch <options> <TIME> Run a command when the load average drops below .8, optionally after a set TIME.Mount a file system mount <opt> <dev> <mount_point> Mount a file system on device <dev> at <mount_point> with the options specified by <dev>.Unmount a file system umount <dev> umount <mount_point> Unmount the file system or device.Maximum # of user ID 65535 Recover root password {lilo} control-x linux S passwd root {grub} c kernel vmlinuz-2.4.9-13 singlero root=/dev/hda8 initrd /initrd-2.4.9-13.img boot passwd root This is a procedure to recover the root password if it is lost. This requires physical access to the machine and system console. You start by rebooting the machine, then during the LILO boot press and hold Ctrl + X to get a prompt and command LILO to boot linux to runlevel S. The second procedure uses the grub boot loader. Create new user useradd The –Doption alone shows the defaults.
Background image
Oracle Database 12c: Administration Workshop B - 10 –Dwith other options changes the defaults options; without –Doverride, the default (e.g., –g) sets a primary group. Delete user userdel Remove a user and optionally all files belonging to the user.Modify user account usermod Change /etc/passwordinformation.Create new group groupadd –gsets the group id; default is first free value above 500.Delete group groupdel Remove a group from the system. May not remove a group that is a primary group for a user. Files owned by deleted group must be manually changed with chown.Change run levels init <runlevel> The initcommand causes the rcN.d scripts to be evaluated, for the change in run level. init 6forces a reboot.Synchronize the disks sync Forces the buffer cache and page cache to write all dirty buffers to disk. Used just before a reboot to prevent disk corruption.Shut down the Linux system shutdown <mode> <delay> Do a graceful shutdown of the system, shut down processes, run all shutdown scripts, and sync disks. The modes are –r(reboot) and –h(halt). The delay is a required parameter is a number in seconds or ‘now’. Option shutdown warning message may be sent as well.Error logs dmesg View boot messages. This log is circular, and limited system errors could overwrite boot information after a time.Network IP configuration /etc/sysconfig/network-scripts/ This directory holds scripts executed as part of the boot up sequence by rc.sysinit.
Background image
Oracle Database 12c: Administration Workshop B - 11 Hosts IP addresses /etc/hosts A list of hosts that your machine knows about. Must at minimum include the name of the local machine and loopback IP.Name service switch /etc/nsswitch.conf Network parameters sysctl -a | grep net View all net parameters that are set for the kernel.Routing daemon routed NIC Configurations ifconfig -a Show all the network devices currently configured.Secondary IP Address modprobe ip_alias ifconfig eth0:1 IP Login prompt /etc/issue Banner message user sees when issued the login prompt.YP/NIS service binder /sbin/ypbind Finds and attaches to a NIS server for name resolution and other services.Module information modinfo <options> <module> Display information about kernel modules: –lshows license, –pparameters, –ddescription.List modules lsmod Show currently loaded modules.Load module insmod Load a loadable module.Unload module rmmod Unload a loadable module.Install Software rpm -ivh package Install –i, verbose –v, with progress hash marks –h.Uninstall software rpm -e package Erase package –e; will not uninstall if dependencies exist.List installed software rpm -qa Query –q, All –a, lists all installed packages.Verify installed software rpm -V package Compares installed files with the rpm database information.List all files rpm -ql package List all the files that are part of a package.Package owner rpm -qf file List the package when given the full file name.Machine model uname -m Shows CPU level (e.g., i686).OS Level uname -r Shows kernel version.Run Level runlevel Shows previous and current runlevel.Kernel Parameters sysctl -a Show settings of all settable kernel parameters.
Background image
Oracle Database 12c: Administration Workshop B - 12 Max # File Descriptors sysctl fs.file-max Shows the value of maximum number of file descriptor per process. Kernel parameter settings /etc/sysctl.conf Compiled in kernel parameters; may be reset at bootup by setting them in this file. Change Kernel Parameter echo <value> > </proc/<file> Write the new value of a kernel parameter into the /proc file system.echo 2147483648 >/proc/sys/kernel/shmmax Set the value of the maximum size of a shared memory segment.Shared Memory sysctl kernel.shmmax Show the shmmaxparameter. Change Kernel Parameter sysctl –w <parameter>=<value> Change a kernel parameter; the poption reads the setting from a file and sets them. The default file is /etc/sysctl.confSet Process limits ulimit <option> <value> Set limits on a shell and processes started by the shell. Users can make limits more restrictive; generally only root can make limit less restrictive; some options require root privilege. Options: –usets number of processes, –nnumber of file handles; many others (see man bash). Show process limits ulimit Without options ulimit shows the current limit settings.Interprocess Communication (Shared Memory and Semaphores) ipcs <option> Options: –mthe current usage of shared memory; –susage of semaphores; –ashows all.Remove a shared memory segment ipcrm shm <shmid> Releases the shared memory segment identified by <shmid>. This is very dangerous. You can corrupt a database that is using the segment that is released.
Background image
Oracle Database 12c: Administration Workshop B - 13 System PerformanceLinux CommandsDescription / CommentsPerformance monitor top View real-time OS and process statistics.System activity reporter sar <options> <interval> <count> Options: –qshows CPU queue, uCPU utilization, –ddevice activity, –nDEV network device activity, many more (see manpage). Interval is in seconds.Virtual Memory statistics vmstat <interval> < count> Interval is in seconds.Virtual Memory statistics cat /proc/meminfo Shows instantaneous virtual memory usage. Kernel Cache statistics cat /proc/slabinfo Kernel slab allocator statistics: frequently allocated cache objects such as inode, dentries, and asynchronous IO buffers. I/O statistics iostat <option> <interval> <count> Options: –ddevice activity, –cCPU activity, –xextended disk activity statistics. The interval is in seconds.Multiprocessor Statistics mpstat –P <cpu> <count> <interval> Return CPU statistics for particular processor or allCPUs in an smp system. Physical RAM 64 GB(Theoretical) Maximum physical RAM requires enterprise kernel (Red Hat Enterprise Linux AS 21 supports only up to 16 GB).Swap device swapon -s Shows devices currently in use for swap. The swap device is arbitrary designated at install. It may be changed or added to. Multiple swap devices may be created; swap size should be at least as large as physical memory.
Background image
Oracle Database 12c: Administration Workshop B - 14 Display swap size free Show the current memory and swap usage.Activate Swap swapon -a Turn on swap.Free disk blocks df -k Measured in KB; use –mfor MB units.Device listing cat /proc/devices List devices known to the system by major and minor number.Disk information cat /proc/scsi/scsi0/sda/model cat /proc/ide/ide0/hda/model View SCSI disk information. View IDE disk information.Print network statistics netstat <options> Print a wide variety of network statistics (see man netstat).Graphical system statistics viewer xosview An X-based display of recent OS statistics.
Background image
Oracle Database 12c: Administration Workshop B - 15 Misc System InformationLinux CommandsDescription / CommentsNFS exported /etc/exports Database files are not supported on simple NFS.NFS Client mounted directories /var/lib/nfs/xtab Max File System 2 TB with 4KB block size (on 32 kernel) With ext3 and ext2, others vary.Max File Size File size can not exceed file system 2 GB {512B block size} 2 TB {4KB block size} The Oracle database can create files up to 64 GB with a 16 KB database block size. The 32-bit kernel limits file and block devices to 2 TB.File System Block size dumpe2fs <device> Dump the file system properties to stdout.Filesystem table /etc/fstab Mounts these file systems at boot up.Journal Filesystem types ext3 reiserfs Disk Label fdisk -l fdiskis not available on all distributions.Extend File system resize2fs Extending a file system is applicable to only some file system types. resize_reiserfs Backup tar cvf /dev/rst0 / Create a backup of the root / file system.Restore tar xvf /dev/rst0 Restore the root / file system.Prepare boot volumes /sbin/lilo Must be run after changing /etc/lilo.confto push changes to boot loader.Startup script /etc/rc.d/rc Kernel /boot/vmlinuz Kernel Bits getconf WORD_BIT POSIX call to get kernel information. There are many other variables besides WORD_BIT.
Background image
Oracle Database 12c: Administration Workshop B - 16 Boot single user {lilo} control-x linux S {grub} c kernel vmlinuz-2.4.9-13 singlero root=/dev/hda8 initrd /initrd-2.4.9-13.img boot Use LILO facility. Use GRUB Boot Loader.Time zone Management /etc/sysconfig/clock SW Directory /var/lib/rpm Directory where rpm databases are kept.Devices /dev This directory holds all the device files.CPU cat /proc/cpuinfo Shows CPU static information.Whole Disk /dev/sda Device name.CDROM /dev/cdrom Usually mounted at /mnt/cdrom.CDROM file type iso9660 Floppy drive /dev/fd0 Usually mounted at /mnt/floppy. System information /proc The /procfile system is a memory-based file system that allows access to process and kernel settings and statistics.Compile and link a executable make –f <file> <command> Use a make file <file> to determine which parts of a large program need to be recompiled, and issue the commands required to compile, link, and prepare the executable for use.
Background image
Oracle Database 12c: Administration Workshop B - 17 LVM Linux (UnitedLinux)Description / CommentsLVM Logical Volume Manager This package is not provided by Red Hat Enterprise Linux AS 2.1 and may not be added without tainting the kernel. Kernel support is provided in United Linux.LVM Concepts logical extents A logical volume is made up of logical extents.logical volume A set of logical extents taken from a volume group and presented to the OS as a disk volume. These extents may be striped across multiple disks.volume group A set of physical disk partitions created by fdiskor the like, initialized with pvcreate, then grouped into a physical volume with vgcreate.Display volume group vgdisplay -v Modify physical volume pvchange Prepare physical disk pvcreate List physical volume pvdisplay Remove disk from volume group vgreduce Move logical volumes to another physical volumes pvmove Create volume group vgcreate Remove volume group vgremove Volume group availability vgchange Restore volume group vgcfgrestore
Background image
Oracle Database 12c: Administration Workshop B - 18 Exports volume group vgexport Imports volume group vgimport Volume group listing vgscan Change logical volume characteristics lvchange List logical volume lvdisplay Make logical volume lvcreate Extend logical volume lvextend Reduce logical volume lvreduce Remove logical volume lvremove Create striped volumes lvcreate -i 3 -I 64
Background image