Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Oracle10 g


Published on

Published in: Technology, News & Politics
  • Be the first to comment

Oracle10 g

  1. 1. Oracle Database 10g:Administration Workshop IVolume II • Student GuideD17090GC30Edition 3.0November 2005D22681®Oracle Internal & OAI Use Only
  2. 2. Copyright © 2005, Oracle. All rights reserved.DisclaimerThis document contains proprietary information and is protected by copyright andother intellectual property laws. You may copy and print this document solely for yourown use in an Oracle training course. The document may not be modified or altered inany way. Except where your use constitutes "fair use" under copyright law, you maynot use, share, download, upload, copy, print, display, perform, reproduce, publish,license, post, transmit, or distribute this document in whole or in part without theexpress authorization of Oracle.The information contained in this document is subject to change without notice. If youfind any problems in the document, please report them in writing to: Oracle University,500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is notwarranted to be error-free.Restricted Rights NoticeIf this documentation is delivered to the United States Government or anyone usingthe documentation on behalf of the United States Government, the following notice isapplicable:U.S. GOVERNMENT RIGHTSThe U.S. Government’s rights to use, modify, reproduce, release, perform, display, ordisclose these training materials are restricted by the terms of the applicable Oraclelicense agreement and/or the applicable U.S. Government contract.Trademark NoticeOracle, JD Edwards, and PeopleSoft are registered trademarks of Oracle Corporationand/or its affiliates. Other names may be trademarks of their respective owners.AuthorsTom BestM.J. BillingsTechnical Contributorsand ReviewersAnthony WoodellBarry TruteCelia AntonioChristine JealDonna KeeslingHoward BradleyJames SpillerJanet SternJean-Francois VerrierJoel GoodmanJohn HibbardLarry BaumannMagnus IsakssonM.J. BryksaPaul NeedhamPierre LabrousseRaza SiddiquiSandra CheeversStefan LindbladStella KisterSteve FriedbergSteven KaramSushma JagannathTammy BednarEditorsNavratan SinghNita PavitranRaj KumarGraphic DesignersSatish BettegowdaSteve ElwoodPublisherJoseph FernandezOracle Internal & OAI Use Only
  3. 3. Preface1 IntroductionCourse Objectives 1-2Suggested Schedule 1-3Lesson Objectives 1-4Oracle Products and Services 1-5Oracle Database 10g: “g” Stands for Grid 1-6Oracle Database Architecture 1-8Database Structures 1-9Oracle Memory Structures 1-10Process Structures 1-12Oracle Instance Management 1-13Server Process and Database Buffer Cache 1-14Physical Database Structure 1-15Tablespaces and Data Files 1-17SYSTEM and SYSAUX Tablespaces 1-18Segments, Extents, and Blocks 1-19Logical and Physical Database Structures 1-20Course Examples: The HR Schema 1-22Database Architecture: Summary of Structural Components 1-23Summary 1-242 Installing the Oracle Database SoftwareObjectives 2-2Tasks of an Oracle Database Administrator 2-3Tools Used to Administer an Oracle Database 2-4Installation: System Requirements 2-6Checking the System Requirements 2-7Optimal Flexible Architecture (OFA) 2-8Using Optimal Flexible Architecture 2-9Setting Environment Variables 2-11Oracle Universal Installer (OUI) 2-13Installing the Oracle Software 2-14Database Configuration Options 2-15Executing Configuration Scripts 2-16Completing Your Installation 2-17Advanced Installation Options 2-18Installation Option: Silent Mode 2-19Summary 2-20Practice Overview: Installing the Oracle Software 2-21ContentsiiiOracle Internal & OAI Use Only
  4. 4. 3 Creating an Oracle DatabaseObjectives 3-2Planning the Database 3-3Databases: Examples 3-4Database Configuration Assistant (DBCA) 3-5Using the DBCA to Create a Database 3-6Password Management 3-12Creating a Database Design Template 3-13Using the DBCA to Delete a Database 3-14Summary 3-16Practice Overview: Using the DBCA 3-174 Managing the Oracle InstanceObjectives 4-2Management Framework 4-3Starting and Stopping Database Control 4-4Oracle Enterprise Manager 4-5Accessing Oracle Enterprise Manager 4-6Database Home Page 4-7Using SQL*Plus and iSQL*Plus to Access Your Database 4-8Using iSQL*Plus 4-9Setting Up iSQL*Plus for SYSDBA and SYSOPER Access 4-10Using SQL*Plus 4-12Calling SQL*Plus from a Shell Script 4-13Calling a SQL Script from SQL*Plus 4-14Initialization Parameter Files 4-15Simplified Initialization Parameters 4-16Viewing and Modifying Initialization Parameters 4-18Database Startup and Shutdown 4-19Starting Up an Oracle Database Instance 4-20Starting Up an Oracle Database Instance: NOMOUNT 4-21Starting Up an Oracle Database Instance: MOUNT 4-22Starting Up an Oracle Database Instance: OPEN 4-23Shutting Down an Oracle Database Instance 4-24Shutdown Modes 4-25SHUTDOWN Options 4-26Using SQL*Plus to Start Up and Shut Down 4-29Viewing the Alert Log 4-30Viewing the Alert History 4-31Dynamic Performance Views 4-32ivOracle Internal & OAI Use Only
  5. 5. Dynamic Performance Views: Usage Examples 4-33Dynamic Performance Views: Considerations 4-34Summary 4-35Practice Overview: Managing the Oracle Instance 4-365 Managing Database Storage StructuresObjectives 5-2Storage Structures 5-3How Table Data Is Stored 5-4Anatomy of a Database Block 5-5Tablespaces and Data Files 5-6Oracle Managed Files (OMF) 5-7Space Management in Tablespaces 5-8Exploring the Storage Structure 5-9Creating a New Tablespace 5-10Storage for Locally Managed Tablespaces 5-12Tablespaces in the Preconfigured Database 5-14Altering a Tablespace 5-16Actions with Tablespaces 5-19Dropping Tablespaces 5-21Viewing Tablespace Information 5-22Gathering Storage Information 5-23Viewing Tablespace Contents 5-24Enlarging the Database 5-25What Is Automatic Storage Management? 5-26ASM: Key Features and Benefits 5-27ASM: Concepts 5-28Summary 5-29Practice Overview: Managing Database Storage Structures 5-306 Administering User SecurityObjectives 6-2Database User Accounts 6-3Predefined Accounts: SYS and SYSTEM 6-5Creating a User 6-6Authenticating Users 6-7Administrator Authentication 6-9Unlocking a User Account and Resetting the Password 6-10Privileges 6-11System Privileges 6-12Object Privileges 6-14vOracle Internal & OAI Use Only
  6. 6. Revoking System Privileges with ADMIN OPTION 6-15Revoking Object Privileges with GRANT OPTION 6-16Benefits of Roles 6-17Assigning Privileges to Roles and Roles to Users 6-18Predefined Roles 6-19Creating a Role 6-20Secure Roles 6-21Assigning Roles to Users 6-22Profiles and Users 6-23Implementing Password Security Features 6-25Creating a Password Profile 6-27Supplied Password Verification Function: VERIFY_FUNCTION 6-28Assigning Quota to Users 6-29Summary 6-31Practice Overview: Administering Users 6-327 Managing Schema ObjectsObjectives 7-2What Is a Schema? 7-3Accessing Schema Objects 7-5Naming Database Objects 7-6Specifying Data Types in Tables 7-8Creating and Modifying Tables 7-11Understanding Data Integrity 7-13Defining Constraints 7-15Constraint Violations 7-16Constraint States 7-17Constraint Checking 7-19Creating Constraints with SQL: Examples 7-20Viewing the Columns in a Table 7-21Viewing the Contents of a Table 7-22Actions with Tables 7-23Dropping a Table 7-24Truncating a Table 7-25Indexes 7-26Types of Indexes 7-27B-Tree Index 7-28Bitmap Indexes 7-30Index Options 7-32Creating Indexes 7-34viOracle Internal & OAI Use Only
  7. 7. What Is a View? 7-35Creating Views 7-36Sequences 7-37Creating a Sequence 7-38Using a Sequence 7-40Temporary Tables 7-41Temporary Tables: Considerations 7-43Data Dictionary: Overview 7-44Data Dictionary Views 7-45Data Dictionary: Usage Examples 7-47Summary 7-48Practice Overview: Administering Schema Objects 7-498 Managing Data and ConcurrencyObjectives 8-2Manipulating Data Through SQL 8-3The INSERT Command 8-4The UPDATE Command 8-5The DELETE Command 8-6The MERGE Command 8-7The COMMIT and ROLLBACK Commands 8-9PL/SQL 8-10Administering PL/SQL Objects 8-12PL/SQL Objects 8-13Functions 8-14Procedures 8-15Packages 8-16Package Specification and Body 8-17Built-in Packages 8-18Triggers 8-19Triggering Events 8-20Locks 8-21Locking Mechanism 8-22Data Concurrency 8-23DML Locks 8-25Enqueue Mechanism 8-26Lock Conflicts 8-27Possible Causes of Lock Conflicts 8-28Detecting Lock Conflicts 8-29Resolving Lock Conflicts 8-30viiOracle Internal & OAI Use Only
  8. 8. Resolving Lock Conflicts Using SQL 8-31Deadlocks 8-32Summary 8-33Practice Overview: Managing Data and Concurrency 8-349 Managing Undo DataObjectives 9-2Data Manipulation 9-3Undo Data 9-4Transactions and Undo Data 9-6Storing Undo Information 9-7Undo Data Versus Redo Data 9-8Monitoring Undo 9-9Administering Undo 9-11Configuring Undo Retention 9-12Guaranteeing Undo Retention 9-14Sizing the Undo Tablespace 9-15Using the Undo Advisor 9-16Summary 9-17Practice Overview: Managing Undo Segments 9-1810 Implementing Oracle Database SecurityObjectives 10-2Industry Security Requirements 10-3Separation of Responsibilities 10-5Database Security 10-6Principle of Least Privilege 10-8Applying the Principle of Least Privilege 10-9Monitoring for Suspicious Activity 10-11Standard Database Auditing 10-12Enabling Auditing 10-13Uniform Audit Trails 10-14Enterprise Manager Audit Page 10-15Specifying Audit Options 10-16Using and Maintaining Audit Information 10-17Value-Based Auditing 10-18Fine-Grained Auditing 10-20FGA Policy 10-21Audited DML Statement: Considerations 10-23FGA Guidelines 10-24DBA Auditing 10-25viiiOracle Internal & OAI Use Only
  9. 9. Maintaining the Audit Trail 10-26Security Updates 10-27Applying Security Patches 10-28Summary 10-29Practice Overview: Implementing Oracle Database Security 10-3011 Configuring the Oracle Network EnvironmentObjectives 11-2Oracle Net Services 11-3Oracle Net Listener 11-4Establishing Net Connections 11-5Establishing a Connection 11-6User Sessions 11-7Tools for Configuring and Managing the Oracle Network 11-8Listener Control Utility 11-9Listener Control Utility Syntax 11-10Listener Home Page 11-12Net Services Administration Pages 11-13Creating a Listener 11-14Adding Listener Addresses 11-15Database Service Registration 11-16Naming Methods 11-17Easy Connect 11-18Local Naming 11-19Directory Naming 11-20External Naming Method 11-21Configuring Service Aliases 11-22Advanced Connection Options 11-23Testing Oracle Net Connectivity 11-25User Sessions: Dedicated Server 11-26User Sessions: Shared Servers 11-27SGA and PGA 11-28Shared Server: Connection Pooling 11-29When Not to Use a Shared Server 11-30Summary 11-31Practice Overview: Working with Oracle Network Components 11-3212 Proactive MaintenanceObjectives 12-2Proactive Maintenance 12-3Introducing Terminology 12-4ixOracle Internal & OAI Use Only
  10. 10. Optimizer Statistics 12-5Using the Manage Optimizer Statistics Page 12-7Statistic Levels 12-9Automatic Workload Repository (AWR) 12-10AWR Infrastructure 12-11AWR Snapshot Sets 12-12Enterprise Manager and AWR 12-13Managing the AWR 12-14Automatic Database Diagnostic Monitor (ADDM) 12-15ADDM Findings 12-16ADDM Recommendations 12-17Advisory Framework 12-18Enterprise Manager and Advisors 12-20The DBMS_ADVISOR Package 12-21Server-Generated Alerts 12-22Default Server-Generated Alerts 12-23Setting Thresholds 12-24Creating and Testing an Alert 12-25Alerts Notification 12-26Reacting to Alerts 12-28Alert Types and Clearing Alerts 12-29Automated Maintenance Tasks 12-30Summary 12-31Practice Overview: Proactive Maintenance 12-3213 Performance ManagementObjectives 13-2Performance Monitoring 13-3Performance Monitoring: Top Sessions 13-7Performance Monitoring: Top Services 13-8SQL Tuning Advisor: Overview 13-9SQL Tuning Advisor Options and Recommendations 13-10Using the SQL Tuning Advisor 13-11Using the SQL Tuning Advisor: Example 13-12SQL Tuning Advisor: SQL Statistics 13-13SQL Tuning Advisor: Identifying Duplicate SQL 13-14Using the SQL Access Advisor 13-15Managing Memory Components 13-17Enabling Automatic Shared Memory Management (ASMM) 13-18Manually Setting Shared Memory Management 13-20xOracle Internal & OAI Use Only
  11. 11. Using the Memory Advisor 13-21Dynamic Performance Statistics 13-22Troubleshooting and Tuning Views 13-24Invalid and Unusable Objects 13-25Summary 13-27Practice Overview: Monitoring and Improving Performance 13-2814 Backup and Recovery ConceptsObjectives 14-2Part of Your Job 14-3Categories of Failures 14-4Statement Failure 14-5User Process Failure 14-6Network Failure 14-7User Error 14-8Instance Failure 14-10Background Processes and Recovery: Checkpoint (CKPT) 14-11Background Processes and Recovery: Redo Log Files and LogWriter 14-12Background Processes and Recovery: Archiver (ARCn) 14-13Instance Recovery 14-14Phases of Instance Recovery 14-15Tuning Instance Recovery 14-16Using the MTTR Advisor 14-17Media Failure 14-18Configuring for Recoverability 14-19Control Files 14-20Redo Log Files 14-21Multiplexing the Redo Log 14-22Archive Log Files 14-23Archive Log File: Naming and Destinations 14-24ARCHIVELOG Mode 14-26Summary 14-27Practice Overview: Configuring for Recoverability 14-2815 Performing Database BackupsObjectives 15-2Backup Solutions: Overview 15-3Oracle Secure Backup 15-4User-Managed Backup 15-5Terminology 15-6Recovery Manager (RMAN) 15-8xiOracle Internal & OAI Use Only
  12. 12. Configuring Backup Settings 15-9Scheduling Backups: Strategy 15-11Scheduling Backups: Options 15-12Scheduling Backups: Settings 15-13Scheduling Backups: Schedule 15-14Scheduling Backups: Review 15-15Backing Up the Control File to a Trace File 15-16Managing Backups 15-18Flash Recovery Area 15-19Summary 15-20Practice Overview: Creating Database Backups 15-2116 Performing Database RecoveryObjectives 16-2Opening a Database 16-3Changing Instance Status 16-5Keeping a Database Open 16-6Loss of a Control File 16-7Loss of a Redo Log File 16-8Loss of a Data File in NOARCHIVELOG Mode 16-9Loss of a Noncritical Data File in ARCHIVELOG Mode 16-10Loss of a System-Critical Data File in ARCHIVELOG Mode 16-11Summary 16-12Practice Overview: Performing Database Recovery 16-1317 Performing FlashbackObjectives 17-2Flashback Technology: Benefits 17-3When to Use the Flashback Technology 17-4Flashing Back Any Error 17-5Flashback Database: Overview 17-6Flashback Database: Reducing Restore Time 17-7Flashback Database: Considerations 17-8Flashback Database: Limitations 17-9Enabling Flashback Database 17-10Flashback Table: Overview 17-11Flashback Table 17-12Enabling Row Movement on a Table 17-13Performing Flashback Table 17-14Flashback Table: Considerations 17-16Flashback Drop: Overview 17-17xiiOracle Internal & OAI Use Only
  13. 13. Flashing Back Dropped Tables Through Enterprise Manager 17-18Flashback Drop: Considerations 17-19Flashback Time Navigation 17-20Flashback Query: Overview 17-21Flashback Query: Example 17-22Flashback Versions Query: Overview 17-23Flashback Versions Query Through Enterprise Manager 17-24Flashback Versions Query: Considerations 17-25Flashback Transaction Query: Overview 17-26Flashback Transaction Query Through Enterprise Manager 17-27Flashback Transaction Query: Considerations 17-28Summary 17-29Practice Overview: Using Flashback 17-3018 Moving DataObjectives 18-2Moving Data: General Architecture 18-3Directory Object: Overview 18-4Creating Directory Objects 18-5SQL*Loader: Overview 18-6Loading Data with SQL*Loader 18-8SQL*Loader Control File 18-9Loading Methods 18-11Data Pump: Overview 18-13Data Pump: Benefits 18-14Data Pump Export and Import: Overview 18-15Data Pump Utility: Interfaces and Modes 18-16Fine-Grained Object Selection 18-17Advanced Feature: Sampling 18-18Export Options: Files 18-19Data Pump File Locations 18-20Scheduling and Running a Job 18-22Data Pump File Naming and Size 18-23Data Pump Import 18-24Data Pump Import: Transformations 18-25Data Pump: Performance Consideration 18-27Performance Initialization Parameters 18-28Data Pump Access Path: Considerations 18-29Using Enterprise Manager to Monitor Data Pump Jobs 18-30External Table Population 18-31xiiiOracle Internal & OAI Use Only
  14. 14. Using External Tables 18-32External Table Population with ORACLE_DATAPUMP 18-33External Table Population with ORACLE_LOADER 18-34Data Dictionary 18-35Summary 18-36Practice Overview: Moving Data 18-37Appendix A: PracticesAppendix B: SolutionsAppendix C: Basic Linux and vi CommandsAppendix D: SQL Statement SyntaxAppendix E: Acronyms and TermsAppendix F: Next Steps Continuing Your EducationIndexxivOracle Internal & OAI Use Only
  15. 15. Copyright © 2005, Oracle. All rights reserved.Configuring theOracle Network EnvironmentOracle Internal & OAI Use Only
  16. 16. Oracle Database 10g: Administration Workshop I 11-2Copyright © 2005, Oracle. All rights reserved.ObjectivesAfter completing this lesson, you should be able to:• Use Enterprise Manager to:– Create additional listeners– Create Oracle Net Service aliases– Configure connect-time failover– Control the Oracle Net Listener• Use tnsping to test Oracle Net connectivity• Identify when to use shared servers versusdedicated serversResources• Oracle Database, Net Services Administrator’s Guide, 10g Release 2 (10.2), Part No.B14212-01• Oracle Database, Net Services Reference, 10g Release 2 (10.2), Part No. B14213-01Oracle Internal & OAI Use Only
  17. 17. Oracle Database 10g: Administration Workshop I 11-3Copyright © 2005, Oracle. All rights reserved.Oracle Net ServicesApplicationOracle NetRDBMSOracle NetClient ormiddle tierDatabase serverTCP/IPnetworkListenerOracle Netconfiguration filesOracle Netconfiguration filesOracle Net ServicesOracle Net Services enable network connections from a client or middle-tier application to theOracle server. After a network session is established, Oracle Net acts as the data courier for boththe client application and the database server. It is responsible for establishing and maintainingthe connection between the client application and database server, as well as exchangingmessages between them. Oracle Net, or something that simulates Oracle Net, such as JavaDatabase Connectivity (JDBC), is located on each computer that needs to talk to the databaseserver.On the client computer, Oracle Net is a background component for application connections tothe database.On the database server, Oracle Net includes an active process called the listener. The Oracle NetListener is responsible for coordinating connections between the database and externalapplications.The most common use of Oracle Net Services is to allow incoming database connections. Youcan configure additional net services to allow access to external code libraries (EXTPROC) andto connect the Oracle instance to non-Oracle data sources, such as Sybase, Informix, DB2, andSQL Server through Oracle Heterogeneous Services.Oracle Internal & OAI Use Only
  18. 18. Oracle Database 10g: Administration Workshop I 11-4Copyright © 2005, Oracle. All rights reserved.Oracle Net ListenerListener<oracle_home>/network/admin/listener.orasqlnet.oraOracle databasesOracle Netconfiguration filesEnterpriseManagerDatabaseControlOracle Net ListenerThe Oracle Net Listener is the gateway to the Oracle instance for all nonlocal user connections.A single listener can service multiple database instances and thousands of client connections.Enterprise Manager is one of the ways to access the listener. You can control the configurationof the actual listener as well as general parameters such as password protection and log filelocations.Advanced administrators can also configure Oracle Net Services by manually editing theconfiguration files with a standard operating system (OS) text editor, such as vi or gedit, ifnecessary.Oracle Internal & OAI Use Only
  19. 19. Oracle Database 10g: Administration Workshop I 11-5Copyright © 2005, Oracle. All rights reserved.Establishing Net ConnectionsTo make a client or middle-tier connection, Oracle Netrequires the client to know the:• Host where the listener is running• Port that the listener is monitoring• Protocol that the listener is using• Name of the service that the listener is handlingNames ResolutionEstablishing Net ConnectionsFor an application to connect to a service through an Oracle Net Listener, the application musthave information about that service, including the address or host where the listener resides, theprotocol that the listener accepts, and the port that the listener monitors. After the listener islocated, the final piece of information that the application needs is the name of the service that itwants to connect to.The process of determining this connection information is called “names resolution”.Oracle Internal & OAI Use Only
  20. 20. Oracle Database 10g: Administration Workshop I 11-6Copyright © 2005, Oracle. All rights reserved.ListenerEstablishing a ConnectionIncomingconnection requestEstablishing a ConnectionAfter Oracle Net Names Resolution is complete, a connection request is passed from the user ormiddle-tier application (referred to as the user process from here onward) to the Oracle NetListener. The listener receives a CONNECT packet and checks whether that CONNECT packet isrequesting a valid Oracle Net service name.If the service name is not requested (as in the case of a tnsping request), the listeneracknowledges the connect request and does nothing else. If an invalid service name is requested,the listener transmits an error code to the user process.Oracle Internal & OAI Use Only
  21. 21. Oracle Database 10g: Administration Workshop I 11-7Copyright © 2005, Oracle. All rights reserved.ServerprocessUser SessionsPGAListenerUser sessionUser processUser SessionsIf the CONNECT packet requests a valid service name, the listener spawns a new process to dealwith the connection. This new process is known as the “server process.” The listener connects tothe process and passes it the initialization information, including the address information for theuser process. At this point, the listener no longer deals with the connection and all work is passedon to the server process.The server process checks the user’s authentication credentials (usually a password), and if thecredentials are valid, a user session is created.Dedicated server process: With the session established, the server process now acts as theuser’s agent on the server. The server process is responsible for:• Parsing and running any SQL statements issued through the application• Checking the database buffer cache for data blocks required to perform SQL statements• Reading necessary data blocks from data files on the disk into the database buffer cacheportion of the System Global Area (SGA), if the blocks are not already present in the SGA• Managing all sorting activity. A portion of the server process called the Program GlobalArea (PGA) contains a memory area known as the Sort Area that is used to work withsorting.• Returning results to the user process in such a way that the application can process theinformation• Reading auditing options and reporting user processes to the audit destinationOracle Internal & OAI Use Only
  22. 22. Oracle Database 10g: Administration Workshop I 11-8Copyright © 2005, Oracle. All rights reserved.Tools for Configuring and Managingthe Oracle Network• Enterprise Manager Net Services Administrationpage• Oracle Net Manager• Oracle Net Configuration Assistant launched byOracle Universal Installer• Command lineTools for Configuring and Managing the Oracle NetworkYou can use any of the following tools or applications to manage your Oracle Networkconfiguration:• Enterprise Manager: Provides an integrated environment for configuring and managingOracle Net Services. Use Enterprise Manager to configure Oracle Net Services for anyOracle home across multiple file systems and to administer listeners.• Oracle Net Manager: Provides a graphical user interface (GUI) through which you canconfigure Oracle Net Services for an Oracle home on a local client or a server host• Oracle Net Configuration Assistant: Is launched by Oracle Universal Installer when youinstall the Oracle software. The Oracle Net Configuration Assistant enables you toconfigure the listening protocol address and service information for an Oracle database.• Command Line: Is used to start, stop, and view the status of the listener process. It is anOS user (in class, oracle) that starts or stops the listener. If the listener is not started, youcannot use Enterprise Manager.Oracle Internal & OAI Use Only
  23. 23. Oracle Database 10g: Administration Workshop I 11-9Copyright © 2005, Oracle. All rights reserved.Listener Control UtilityOracle Net listeners can be controlled with thecommand-line lsnrctl utility (or from EM).$lsnrctlLSNRCTL for Linux: Version on 12-MAY-2005 13:27:51Copyright (c) 1991, 2004, Oracle. All rights reserved.Welcome to LSNRCTL, type "help" for information.LSNRCTL> helpThe following operations are availableAn asterisk (*) denotes a modifier or extended command:start stop statusservices version reloadsave_config trace spawnchange_password quit exitset* show*Listener Control UtilityWhen an instance starts, a listener process establishes a communication pathway to the Oracledatabase. The listener is then able to accept database connection requests.The listener control utility enables you to control the listener. With lsnrctl, you can:• Start the listener• Stop the listener• Check the status of the listener• Reinitialize the listener from the configuration file parameters• Dynamically configure many listeners• Change the listener passwordThe basic command syntax for this utility is as follows:LSNRCTL> command [listener_name]When the lsnrctl command is issued, the command acts on the default listener (named“LISTENER”) unless a different listener name is specified or the SET CURRENT_LISTENERcommand is executed. If the listener name is LISTENER, the listener_name argument canbe omitted.The valid commands for lsnrctl are shown in the slide.Oracle Internal & OAI Use Only
  24. 24. Oracle Database 10g: Administration Workshop I 11-10Copyright © 2005, Oracle. All rights reserved.Listener Control Utility SyntaxCommands from the listener control utility can beissued from the command line or from the LSNRCTLprompt.• UNIX or Linux command-line syntax:• Prompt syntax:$ lsnrctl <command name>$ lsnrctl start$ lsnrctl statusLSNRCTL> <command name>LSNRCTL> startLSNRCTL> statusListener Control Utility SyntaxThe lsnrctl commands can be issued from within the utility (prompt syntax) or the commandline. The following two commands have the identical effect—first, by using the command-linesyntax:$ lsnrctl startand then by using the prompt syntax:$ lsnrctlLSNRCTL for Linux: Version on 12-MAY-2005Copyright (c) 1991, 2004, Oracle. All rights reserved.Welcome to LSNRCTL, type "help" for information.LSNRCTL> startUsually, the command-line syntax is used to execute an individual command or scriptedcommands. If you plan to execute several consecutive lsnrctl commands, then the promptsyntax is the most efficient. Notice that the listener_name argument is omitted, and so thestop command would affect the listener named LISTENER. Prompt syntax must be used if yourlistener is password protected.Oracle Internal & OAI Use Only
  25. 25. Oracle Database 10g: Administration Workshop I 11-11Listener Control Utility Syntax (continued)Remember that if your listener is named something other than LISTENER, you must eitherinclude the listener name with the command or use the SET CURRENT_LISTENER command.Suppose your listener is named BACKUP. Following are two examples of stopping a listenernamed BACKUP using prompt syntax:LSNRCTL> stop backupConnecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rhel)(PORT=5521)))The command completed successfullyThis produces the same results as follows:LSNRCTL> set cur backupCurrent Listener is backupLSNRCTL> stopConnecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rhel)(PORT=5521)))The command completed successfullyNote: In the preceding syntax, current_listener can be abbreviated as cur.You can also achieve the same results with the command-line syntax:/home/oracle> lsnrctl stop backupLSNRCTL for Linux:Version on 12-MAY-2005 15:19:33Copyright (c) 1991, 2004, Oracle. All rights reserved.Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rhel)(PORT=5521)))The command completed successfullyOracle Internal & OAI Use Only
  26. 26. Oracle Database 10g: Administration Workshop I 11-12Copyright © 2005, Oracle. All rights reserved.Listener Home PageListener Home PageClick the Listener link on the Enterprise Manager Database Home page to access the ListenerHome page.On this page, you can see:• The listener status and availability within the last 24 hours• The listener version and Oracle home• The first listening address for the listener• The location of the configuration files that are used to start the listener• The listener start time and host informationTo start the listener, go to the Database home page, and click the listener name to open theListener home page. Click Stop to stop the listener if it is running, or click Start to start thelistener if it is not running. Log on to the host as the OS user that can start and stop the listener.Oracle Internal & OAI Use Only
  27. 27. Oracle Database 10g: Administration Workshop I 11-13Copyright © 2005, Oracle. All rights reserved.Net Services Administration PagesNet Services Administration PagesThe Net Services Administration page enables you to configure Oracle Net Services for anyOracle home across multiple file systems. It also provides common administration functions forlisteners. You can use Net Services Administration to configure and administer the following:• Listeners: You can add, remove, start, and stop a listener, as well as change its tracing andlogging characteristics. You can also look at a listener’s control status report.• Directory Naming: Define simple names and connect identifiers, and map them to connectdescriptors to identify the network location and identification of a service. Save databaseservices, Net Services, and Net Service aliases in a centralized directory service.• Local Naming: Save Net Service names in the tnsnames.ora file.• Profiles: Configure the sqlnet.ora parameters.• File Location: Change the location of the configuration files of Net Services.Oracle Internal & OAI Use Only
  28. 28. Oracle Database 10g: Administration Workshop I 11-14Copyright © 2005, Oracle. All rights reserved.Creating a Listener1234Creating a ListenerTo create an Oracle Net Listener, click Net Services Administration in the Related Links regionof the Listener properties page. Perform the following steps:1. Select Listeners from the Administer drop-down list, and click Go.2. Click Create.3. Enter a listener name. The name must be unique for this server.4. Add a listener address. Each listener must have at least one listener address.Oracle Internal & OAI Use Only
  29. 29. Oracle Database 10g: Administration Workshop I 11-15Copyright © 2005, Oracle. All rights reserved.Adding Listener Addresses567Adding Listener AddressesThe workflow to create a listener continues:5. Select the network protocol. TCP/IP is the most commonly used and is the default. Otherchoices are Internal Process Communication (IPC)—normally used for connecting to localapplications (resident on the database server)—or external code libraries (EXTPROC),Named Pipes (NMP), and TCP/IP with SSL.Note: The NMP and EXTPROC protocols are configured by using the Other Services tab.6. Enter the port that you want the listener to monitor. Oracle Net’s default port is 1521. Ifyou choose to use a port other than 1521, then additional configuration is required for thelistener or for the instance.7. Enter the name or IP address of the server that the listener will run on.8. All other configuration steps are optional for the listener. Click OK to save the address.The only required configuration is the listening address and name. Click OK to save yourchanges.9. To start the new listener, select Start/Stop from the Actions drop-down list, and click Go.Oracle Internal & OAI Use Only
  30. 30. Oracle Database 10g: Administration Workshop I 11-16Copyright © 2005, Oracle. All rights reserved.Database Service RegistrationDatabase Service RegistrationFor a listener to forward client connections to an instance, the listener must know the name ofthe instance and where the instance’s ORACLE_HOME is located. The listener can find thisinformation in two ways:• Dynamic service registration: Oracle8i, Oracle9i, and Oracle Database 10g instancesautomatically register with the default listener on database startup. No additional listenerconfiguration is required for the default listener.• Static service registration: The earlier releases of the Oracle database do notautomatically register with the listener and, therefore, require that the listener configurationfile contain a list of all database services that the listener will serve. You may still chooseto use static service registration with newer releases if:- Your listener is not on the default port of 1521, and you do not want to configure yourinstance to register with a nondefault port- Your application requires static service registrationTo add a static database service, click Static Database Registration on the Edit Listener page, andclick the Add button. Enter the service name (same as the global database name<DB_NAME>.<DB_DOMAIN>), ORACLE_HOME path, and SID (same as the instance name).Click OK. You must restart your listener for the changes to take effect.Oracle Internal & OAI Use Only
  31. 31. Oracle Database 10g: Administration Workshop I 11-17Copyright © 2005, Oracle. All rights reserved.Naming MethodsOracle Net supports several methods of resolvingconnection information:• Easy connect naming: Uses a TCP/IP connectstring• Local naming: Uses a local configuration file• Directory naming: Uses a centralizedLDAP-compliant directory server• External naming: Uses a supported non-Oraclenaming serviceClient/application serverOracle NetOracle Net configuration filesNaming MethodsOracle Net provides support for the following naming methods:• Easy connect naming: The easy connect naming method enables clients to connect to anOracle database server by using a TCP/IP connect string consisting of a host name, andoptional port and service name as follows:CONNECT username/password@host[:port][/service_name]The easy connect naming method requires no configuration.• Local naming: The local naming method stores connect descriptors, identified by their netservice name, in a local configuration file named tnsnames.ora on the client.• Directory naming: The directory naming method stores connect identifiers in a centralizedLightweight Directory Access Protocol (LDAP)–compliant directory server to access adatabase service.• External naming: The external naming method stores net service names in a supportednon-Oracle naming service. Supported third-party services include:- Network Information Service (NIS) External Naming- Distributed Computing Environment (DCE) Cell Directory Services (CDS)Oracle Internal & OAI Use Only
  32. 32. Oracle Database 10g: Administration Workshop I 11-18Copyright © 2005, Oracle. All rights reserved.Easy Connect• Is enabled by default• Requires no client-side configuration• Supports only TCP/IP (no SSL)• Offers no support for advanced connectionoptions, such as:– Connect-time failover– Source routing– Load balancingSQL> CONNECT hr/ Oracle Net configuration filesEasy ConnectWith Easy Connect, you supply all information required for the Oracle Net connection as part ofthe connect string. Easy Connect connection strings take the form of:<username>/<password>@<hostname>:<listener port>/<service name>The listener port and service name are optional. If the listener port is not provided, Oracle Netassumes that the default port of 1521 is being used. If the service name is not provided, OracleNet assumes that the database service name and host name provided in the connect string areidentical.Assuming that the listener uses TCP to listen on port 1521 and the SERVICE_NAMES=db instance parameters, the connect string shown in the slide canbe shortened to:SQL> connect hr/ The SERVICE_NAMES initialization parameter can accept multiple comma-separatedvalues. Only one of those values must be db for this scenario to work.Oracle Internal & OAI Use Only
  33. 33. Oracle Database 10g: Administration Workshop I 11-19Copyright © 2005, Oracle. All rights reserved.Local Naming• Requires a client-side Names Resolution file• Supports all Oracle Net protocols• Supports advanced connection options, such as:– Connect-time failover– Source routing– Load balancingSQL> CONNECT hr/hr@orclOracle Netconfiguration filesLocal NamingWith local naming, the user supplies an alias for the Oracle Net service. Oracle Net checks thealias against a local list of known services and, if it finds a match, converts the alias into host,protocol, port, and service name.One advantage of local naming is that the database users need to remember only a short aliasrather than the long connect string required by Easy Connect.The local list of known services is stored in the text configuration file:<oracle_home>/network/admin/tnsnames.ora. This is the default location of thetnsnames.ora file, but the file can be located elsewhere using the TNS_ADMIN environmentvariable.Local naming is appropriate for organizations where Oracle Net service configurations do notchange often.Oracle Internal & OAI Use Only
  34. 34. Oracle Database 10g: Administration Workshop I 11-20Copyright © 2005, Oracle. All rights reserved.Directory Naming• Requires LDAP with Oracle Net Names Resolutioninformation loaded:– Oracle Internet Directory– Microsoft Active Directory Services• Supports all Oracle Net protocols• Supports advanced connection optionsSQL> CONNECT hr/hr@orclLDAP directoryOracle Netconfiguration filesDirectory NamingWith directory naming, the user supplies an alias for the Oracle Net service. Oracle Net checksthe alias against an external list of known services and, if it finds a match, converts the alias intohost, protocol, port, and service name. Like local naming, database users need to remember onlya short alias.One advantage of directory naming is that as soon as a new service name is added to the LDAPdirectory, the service name is available for users to connect with. With local naming, thedatabase administrator (DBA) must first distribute updated tnsnames.ora files containing thechanged service name information before users can connect to new or modified services.Directory naming is appropriate for organizations where Oracle Net service configurationschange frequently.Oracle Internal & OAI Use Only
  35. 35. Oracle Database 10g: Administration Workshop I 11-21Copyright © 2005, Oracle. All rights reserved.External Naming Method• Uses a supported non-Oracle naming service• Includes:– Network Information Service (NIS) External Naming– Distributed Computing Environment (DCE) CellDirectory Services (CDS)Oracle NetNon-OraclenamingserviceExternal Naming MethodThe external naming method stores net service names in a supported non-Oracle naming service.Supported third-party services include:• Network Information Service (NIS) External Naming• Distributed Computing Environment (DCE) Cell Directory Services (CDS)Conceptually, external naming is similar to directory naming.Oracle Internal & OAI Use Only
  36. 36. Oracle Database 10g: Administration Workshop I 11-22Copyright © 2005, Oracle. All rights reserved.Configuring Service AliasesCreate oreditConfiguring Service AliasesTo create a local Oracle Net service alias, select Local Naming from the Administer drop-downlist and click Go, and then click Create.You can configure service aliases for directory naming by selecting Directory Naming instead ofLocal Naming.Note: If directory naming has not already been configured, you cannot select the DirectoryNaming option. Directory naming is discussed in the Oracle Enterprise Identity Managementcourse as well as in the Oracle Advanced Security Administration manual.On the Create Net Service Name page, enter a unique name in the Net Service Name field (Thisis the name that users enter when they want to use this alias.). Enter the service name or systemidentifier (SID) of the database that you want to connect to, and click the Add button to enter theaddress for the service name.For the address, enter the protocol, port, and host used by the listener for the service that youwant to connect to.Oracle Internal & OAI Use Only
  37. 37. Oracle Database 10g: Administration Workshop I 11-23Copyright © 2005, Oracle. All rights reserved.Advanced Connection OptionsOracle Net supports the following advancedconnection options with local and directory naming:• Connect-time failover• Load balancing• Source routingAdvanced Connection OptionsWith advanced connection options, Oracle Net can take advantage of listener failover and loadbalancing, as well as Oracle Connection Manager source routing.With connect-time failover enabled, the alias has two or more listener addresses listed. If thefirst address is not available, the second is tried. Oracle Net keeps trying addresses in the listedorder until it reaches a listener that is functioning or until all addresses have been tried andfailed.With load balancing enabled, Oracle Net picks an address at random from the list of addresses.Source routing is used with Oracle Connection Manager. Oracle Connection Manager serves asa proxy server for Oracle Net traffic, enabling Oracle Net traffic to be routed securely through afirewall. Oracle Net treats the addresses as a list of relays, connecting to the first address, andthen requesting to be passed from the first to the second until the destination is reached. It differsfrom failover or load balancing in that all addresses are used each time a connection is made.Oracle Internal & OAI Use Only
  38. 38. Oracle Database 10g: Administration Workshop I 11-24Advanced Connection Options (continued)Note that there are five choices for connect-time failover and load balancing. The five optionstranslate to the following:NoneUse only the first address.Source routingUse each address in order until the destinationis reached.Load balancingTry one address selected at random.FailoverLoad balancingTry each address, randomly, until one succeeds.FailoverTry each address, in order, until one succeeds.AdvancedFunctionalityOptionOracle Internal & OAI Use Only
  39. 39. Oracle Database 10g: Administration Workshop I 11-25Copyright © 2005, Oracle. All rights reserved.Testing Oracle Net ConnectivityThe tnsping utility that tests Oracle Net servicealiases:• Ensures connectivity between the client and theOracle Net Listener• Does not verify that the requested service isavailable• Supports Easy Connect Names Resolution:• Supports local and directory naming:tnsping orclTesting Oracle Net Connectivitytnsping is the Oracle Net equivalent of the TCP/IP ping utility. It offers a quick test to verifythat the network path to a destination is good. For example, enter tnsping orcl in acommand-line window.The utility validates that the host name, port, and protocol reach a listener. It does not actuallycheck whether the listener handles the service name. Another useful thing that tnsping revealsis the location of the configuration files. In a system with multiple ORACLE_HOME locations,this can be helpful.Oracle Internal & OAI Use Only
  40. 40. Oracle Database 10g: Administration Workshop I 11-26Copyright © 2005, Oracle. All rights reserved.User Sessions: Dedicated ServerServer processServer processUser sessionsServer processListenerUser Sessions: Dedicated ServerWith dedicated server processes, there is a one-to-one ratio between server processes and userprocesses. Each server process uses system resources, including CPU cycles and memory.In a heavily loaded system, the memory and CPU resources that are used by dedicated serverprocesses can be prohibitive and can negatively affect the system’s scalability. If your system isbeing negatively impacted by the resource demands of the dedicated server architecture, youhave the following two options:• Increasing system resources by adding more memory and additional CPU capability• Using the Oracle Shared Server architectureOracle Internal & OAI Use Only
  41. 41. Oracle Database 10g: Administration Workshop I 11-27Copyright © 2005, Oracle. All rights reserved.User Sessions: Shared ServersListenerDispatcherServer processServer processServer processUser sessionsUser Sessions: Shared ServersEach service that participates in the shared server architecture has at least one (and usually more)dispatcher process. When a connection request arrives, the listener does not spawn a dedicatedserver process. Instead, the listener maintains a list of dispatchers that are available for eachservice name, along with the connection load (number of concurrent connections) for eachdispatcher.Connection requests are routed to the lightest loaded dispatcher that is servicing a given servicename. Users remain connected to the same dispatcher for the duration of a session.Unlike dedicated server processes, a single dispatcher can manage hundreds of user sessions.Dispatchers do not actually handle the work of user requests. Instead, they pass user requests to acommon queue located in the shared pool portion of the SGA.Shared server processes take over most of the work of dedicated server processes, pullingrequests from the queue and processing them until complete.Because a single user session may have requests processed by multiple shared server processes,most of the memory structures that are usually stored in the PGA must be in a shared memorylocation (by default, in the shared pool). However, if the large pool is configured orSGA_TARGET is set for Automatic Memory Management, these memory structures are stored inthe large pool portion of the SGA.Oracle Internal & OAI Use Only
  42. 42. Oracle Database 10g: Administration Workshop I 11-28Copyright © 2005, Oracle. All rights reserved.SGALarge pool andother memorystructuresStackspacePGASGA and PGAUsersessiondataCursorstateOracle Shared Server: User session data is held in theSGA.SortdataRemember to factor in shared server memoryrequirement when sizing the SGA.SGA and PGAThe contents of the SGA and the PGA differ when dedicated servers or shared servers are used:• Text and parsed forms of all SQL statements are stored in the SGA.• The cursor state contains run-time memory values for the SQL statement, such as rowsretrieved.• User-session data includes security and resource usage information.• The stack space contains local variables for the process.Technical NoteThe change in the SGA and the PGA is transparent to the user; however, if you are supportingmultiple users, you need to increase the LARGE_POOL_SIZE initialization parameter. Eachshared server process must access the data spaces of all sessions so that any server can handlerequests from any session. Space is allocated in the SGA for each session’s data space. You canlimit the amount of space that a session can allocate by setting the PRIVATE_SGA resourcelimit in the Database Services region of the General page of the user’s profile.Oracle Internal & OAI Use Only
  43. 43. Oracle Database 10g: Administration Workshop I 11-29Copyright © 2005, Oracle. All rights reserved.Shared Server: Connection PoolingThe client application has beenidle past the specified time, andan incoming client requests aconnection.The maximumnumber ofconnections isconfigured to 255.This client connection is the 256thconnection into the server. Connectionpooling is turned on, so that thisconnection can be accepted.DatabaseserverIdleclientActiveclientNewclientShared Server: Connection PoolingThe connection pooling feature enables the database server to time out an idle session and usethe connection to service an active session. The idle logical session remains open, and thephysical connection is automatically reestablished when the next request comes from thatsession. Therefore, Web applications can allow larger numbers of concurrent users to beaccommodated with existing hardware. Connection pooling is configurable through the sharedserver.In this example, the Oracle database server has been configured with 255 connections. One ofthe clients has been idle past the specified time. Connection pooling makes this connectionavailable to an incoming client connection, which is the 256thconnection. When the idle clienthas more work to do, the connection is reestablished for that client with another client’s idleconnection.Oracle Internal & OAI Use Only
  44. 44. Oracle Database 10g: Administration Workshop I 11-30Copyright © 2005, Oracle. All rights reserved.When Not to Use a Shared ServerCertain types of database work must not be performedby using shared servers:• Database administration• Backup and recovery operations• Batch processing and bulk load operations• Data warehouse operationsDispatcher DedicatedServer processWhen Not to Use a Shared ServerThe Oracle Shared Server architecture is an efficient process and memory use model, but it is notappropriate for all connections. Because of the common request queue and the fact that manyusers may share a dispatcher response queue, shared servers do not perform well with operationsthat must deal with large sets of data, such as warehouse queries or batch processing.Backup and recovery sessions that use Oracle Recovery Manager (discussed in later lessons) alsodeal with very large data sets and must make use of dedicated connections.Many administration tasks must not (and cannot) be performed by using shared serverconnections. These include starting up and shutting down the instance, creating tablespaces ordata files, maintaining indexes and tables, analyzing statistics, and many other tasks that arecommonly performed by the DBA. All DBA sessions must choose dedicated servers.Oracle Internal & OAI Use Only
  45. 45. Oracle Database 10g: Administration Workshop I 11-31Copyright © 2005, Oracle. All rights reserved.SummaryIn this lesson, you should have learned how to:• Use Enterprise Manager to:– Create additional listeners– Create Oracle Net Service aliases– Configure connect-time failover– Control the Oracle Net Listener• Use tnsping to test Oracle Net connectivity• Identify when to use shared servers versusdedicated serversOracle Internal & OAI Use Only
  46. 46. Oracle Database 10g: Administration Workshop I 11-32Copyright © 2005, Oracle. All rights reserved.Practice Overview:Working with Oracle Network ComponentsThis practice covers:• Configuring local Names Resolution to connect toanother database• Creating a second listener for connect-timefailoverOracle Internal & OAI Use Only
  47. 47. Copyright © 2005, Oracle. All rights reserved.Proactive MaintenanceOracle Internal & OAI Use Only
  48. 48. Oracle Database 10g: Administration Workshop I 12-2Copyright © 2005, Oracle. All rights reserved.ObjectivesAfter completing this lesson, you should be able to dothe following:• Use statistics• Manage the Automatic Workload Repository(AWR)• Use the Automatic Database Diagnostic Monitor(ADDM)• Describe the advisory framework• Set alert thresholds• Use server-generated alerts• Use automated tasksOracle Internal & OAI Use Only
  49. 49. Oracle Database 10g: Administration Workshop I 12-3Copyright © 2005, Oracle. All rights reserved.Proactive MaintenanceAutomaticWorkloadRepositoryServeralertsAutomatedtasksAdvisoryframeworkData warehouseof the databaseAutomatic collectionof important statisticsDirect memoryaccessAutomatic ProactiveEfficientProactive MaintenanceProactive maintenance is made easy by the sophisticated infrastructure of the Oracle database.The main elements are as follows:• The Automatic Workload Repository (AWR) is a built-in repository in each Oracledatabase. At regular intervals, the Oracle database makes a snapshot of all its vital statisticsand workload information and stores them in the AWR. The captured data can be analyzedby you, by the database itself, or by both.• By analyzing the information that is stored in the AWR, the database can identify the needto perform routine maintenance tasks, such as performing regular backups to maximizeavailability or refreshing statistics, which are used to optimize the execution of SQLstatements.• For problems that cannot be resolved automatically and require administrators to benotified (such as running out of space), the Oracle database provides server-generatedalerts. The Oracle database can monitor itself and send out alerts to notify you of anyproblem. The alerts not only notify you of the problem, they also provide recommendationson how the reported problem can be resolved.• Recommendations are generated from a number of advisors, each of which is responsiblefor a subsystem. For example, there are memory and SQL advisors.Oracle Internal & OAI Use Only
  50. 50. Oracle Database 10g: Administration Workshop I 12-4Copyright © 2005, Oracle. All rights reserved.Introducing Terminology• Automatic Workload Repository (AWR):Infrastructure for data gathering, analysis, andsolutions recommendations• Baseline: Data gathered of a “normal runningdatabase” for performance comparison• Metric: Rate of change in a cumulative statistic• Statistics: Data collections used for optimizinginternal operations, such as execution of a SQLstatement• Threshold: A boundary value againstwhich metric values are comparedIntroducing TerminologyAutomatic Workload Repository (AWR) provides services to internal Oracle server componentsto collect, process, maintain, and utilize performance statistics for problem detection and self-tuning purposes.Active Session History (ASH) is the history of recent session activity, stored in the AWR.Statistics are a collection of data that provide more details about the database and the objects inthe database. Optimizer statistics are used by the query optimizer to choose the best executionplan for each SQL statement.Baseline data should include:• Application statistics (transaction volumes, response time)• Database statistics• Operating system statistics• Disk I/O statistics• Network statisticsOracle Internal & OAI Use Only
  51. 51. Oracle Database 10g: Administration Workshop I 12-5Copyright © 2005, Oracle. All rights reserved.Optimizer StatisticsOptimizer statistics are:• Not real time• Persistent across instance restarts• Collected automaticallySQL> SELECT COUNT(*) FROM hr.employees;COUNT(*)----------214SQL> SELECT num_rows FROM dba_tables2 WHERE owner=HR AND table_name = EMPLOYEES;NUM_ROWS----------107> StatisticsAWRADDMAdvisorsAlertsAutoTasksOptimizer StatisticsOptimizer statistics include table, column, index, and system statistics. Statistics for tables andindexes are stored in the data dictionary. These statistics are not intended to provide real-timedata. They provide the optimizer a statistically correct 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 blocks• Number 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. The performance impact ofmaintaining real-time data distribution statistics would be prohibitive, so these statistics areupdated by periodically gathering statistics on tables and indexes.Optimizer statistics are collected automatically by the preconfigured GATHER_STATS_JOB,which runs during predefined maintenance windows, once per day.Oracle Internal & OAI Use Only
  52. 52. Oracle Database 10g: Administration Workshop I 12-6Optimizer Statistics (continued)A large table that experiences 10 percent growth (or reduction) within a 24-hour period isusually considered too volatile for statistics collection once per day to be sufficient. For tablesthat experience this level of change, Oracle recommends collecting statistics more frequently,preferably often enough that the table never changes by more than about 10 percent betweencollection periods. This requires manual statistics collection.Statistics can be manually collected by using Enterprise Manager or through the use of theDBMS_STATS package as shown here: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----------214Note that the number of rows now correctly reflects what was in the table as of the timestatistics were gathered. DBMS_STATS also enables manual collection of statistics for anentire schema or even the whole database.Oracle Internal & OAI Use Only
  53. 53. Oracle Database 10g: Administration Workshop I 12-7Copyright © 2005, Oracle. All rights reserved.Using the Manage OptimizerStatistics PageUsing the Manage Optimizer Statistics PageGo to the Enterprise Manager page for managing optimizer statistics by clicking ManageOptimizer Statistics on the Administration tabbed page. Note that (as this page shows)GATHER_STATS_JOB is enabled; it has run nine times; and last time, it successfully ranagainst 97 objects, which took a little over a minute. For GATHER_STATS_JOB to workproperly, you must be sure that the STATISTICS_LEVEL initialization parameter is set to atleast TYPICAL.Note: The default window for this job is 10:00 p.m. to 6:00 a.m. on weekdays, and 12:00 a.m.Saturday to 12:00 a.m. Monday, on weekends. When the maintenance window closes, by default,the Scheduler terminates GATHER_STATS_JOB. The remaining objects are then processed inthe next maintenance window.Oracle Internal & OAI Use Only
  54. 54. Oracle Database 10g: Administration Workshop I 12-8Using the Manage Optimizer Statistics Page (continued)From this page, you can perform the following tasks on statistics:• Gather optimizer statistics manually. This action submits the job thatGATHER_STATS_JOB automatically does. This should be done in the case where atable’s contents have changed so much between automatic gathering jobs that thestatistics no longer represent the table accurately. Examples of this are a table that istruncated in the middle of the day and a batch job that runs and adds large amounts ofdata to a table.• Restore optimizer statistics to a point in the past. The point in time chosen must bewithin the optimizer statistics retention period, which defaults to 30 days.• Lock optimizer statistics to guarantee that the statistics for certain objects are neveroverwritten. This is useful if statistics have been calculated for a certain table at a timewhen well-representative data is present, and you want to always have those statistics.No fluctuation in the table affects the statistics if they are locked.• Unlock optimizer statistics to undo the previously done lock• Delete optimizer statistics to delete statisticsOracle Internal & OAI Use Only
  55. 55. Oracle Database 10g: Administration Workshop I 12-9Copyright © 2005, Oracle. All rights reserved.Statistic LevelsSTATISTICS_LEVELBASIC TYPICAL ALLRecommendeddefault valueAdditional statisticsfor manualSQL diagnosticsSelf-tuningcapabilities disabledStatistic LevelsYou can control the set of statistics to capture by using the STATISTICS_LEVEL initializationparameter, which has the following levels of capture:• BASIC: The computation of AWR statistics and metrics is turned off.• TYPICAL: Only some of the statistics are collected. They represent what is typicallyneeded to monitor the Oracle database behavior. This automatic gathering of statisticsreduces the likelihood of poorly performing SQL statements due to stale or invalidstatistics.• ALL: All possible statistics are captured. This level of capture should not be used except incertain rare cases for which you need extra SQL diagnostics information.Oracle Internal & OAI Use Only
  56. 56. Oracle Database 10g: Administration Workshop I 12-10Copyright © 2005, Oracle. All rights reserved.Automatic Workload Repository .(AWR)• Built-in repository of performanceinformation• Snapshots of database metrics taken every60 minutes and retained for 7 days• Foundation for all self-managementfunctionsMMONIn-memorystatisticsSnapshotsAWRSGA60 minutesStatistics> AWRADDMAdvisorsAlertsAutoTasksAutomatic Workload Repository (AWR)The AWR is the infrastructure that provides services to Oracle Database 10g components tocollect, maintain, and utilize statistics for problem detection and self-tuning purposes. You canview it as a data warehouse for database statistics, metrics, and so on.By default, every 60 minutes, the database automatically captures statistical information fromthe SGA and stores it inside the AWR in the form of snapshots. These snapshots are stored onthe disk by a background process called Manageability Monitor (MMON). By default, snapshotsare retained for seven days. You can modify both the snapshot interval and retention intervals.The AWR contains hundreds of tables, all belonging to the SYSMAN schema and stored in theSYSAUX tablespace. The Oracle database does not support direct SQL access to the repository.Instead, use Enterprise Manager or the DBMS_WORKLOAD_REPOSITORY package to workwith the AWR.Oracle Internal & OAI Use Only
  57. 57. Oracle Database 10g: Administration Workshop I 12-11Copyright © 2005, Oracle. All rights reserved.AWR InfrastructureSGAV$ DBA_*ADDMSelf-tuningcomponentSelf-tuningcomponent…Internal clientsExternal clientsEM SQL*Plus …Efficientin-memorystatisticscollectionAWRsnapshotsMMONAWR InfrastructureThe AWR infrastructure consists of two major parts:• An in-memory statistics collection facility that is used by Oracle Database 10g componentsto 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 snapshotsare accessible through data dictionary views and Enterprise Manager Database Control.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 ofmemory shortage, the replaced data can be stored for later use.The memory version of the statistics is transferred to the disk on a regular basis by the MMONbackground process. With the AWR, the Oracle database provides a way to capture historicalstatistics data automatically, without the intervention of DBAs.Oracle Internal & OAI Use Only
  58. 58. Oracle Database 10g: Administration Workshop I 12-12Copyright © 2005, Oracle. All rights reserved.AWR Snapshot SetsDBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE ( -start_snap_id IN NUMBER ,end_snap_id IN NUMBER ,baseline_name IN VARCHAR2);Relevant periodin the pastAWR Snapshot SetsUsing snapshot sets is the mechanism for you to tag sets of snapshot data for important periods.A snapshot set is defined on a pair of snapshots; the snapshots are identified by their snapshotsequence numbers (snap_id). Each snapshot set corresponds to one and only one pair ofsnapshots.A snapshot set can be identified by either a user-supplied name or a system-generated identifier.You simply create a snapshot set by executing theDBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE procedure and specifying a nameand a pair of snapshot identifiers. A snapshot set identifier is assigned to the newly createdsnapshot set. Snapshot set identifiers are unique for the life of a database.Snapshot sets are used to retain snapshot data. Therefore, snapshots belonging to snapshot setsare retained until the snapshot sets are dropped.You set up snapshot sets, usually from some representative periods in the past, to be used forcomparisons with current system behavior. You can also set up threshold-based alerts by usingsnapshot sets from Database Control.You can get snap_ids directly from DBA_HIST_SNAPSHOT or Enterprise ManagerDatabase Control.Note: For more information about the DBMS_WORKLOAD_REPOSITORY package, see theOracle Database PL/SQL Packages and Types Reference guide.Oracle Internal & OAI Use Only
  59. 59. Oracle Database 10g: Administration Workshop I 12-13Copyright © 2005, Oracle. All rights reserved.Enterprise Manager and AWREnterprise Manager and AWRSelect Administration > Database Administration > Statistics Management > AutomaticWorkload Repository and click Edit to change the settings.From the Automatic Workload Repository page, you can:• Edit the workload repository settings• Look at the detailed information about created snapshots and manually create new ones• Create baselines, also called Preserved Snapshot Sets• Generate an AWR reportOracle Internal & OAI Use Only
  60. 60. Oracle Database 10g: Administration Workshop I 12-14Copyright © 2005, Oracle. All rights reserved.Managing the AWR• Retention period– The default is 7 days– Consider storage needs• Collection interval– The default is60 minutes– Consider storage needs and performance impact• Collection level– Basic (disables most of ADDM functionality)– Typical (recommended)– All (adds additional SQL tuning information tosnapshots)Managing the AWRAWR settings include retention period, collection interval, and collection level. Remember thatdecreasing any of these settings impacts the functionality of components that depend on theAWR, including the advisors.Increasing the settings can provide improved advisor recommendations, but at the cost of thespace required to store the snapshots and the performance expended in collecting the snapshotinformation.Consider setting collection level to ALL when tuning a new application. The ALL setting collectsSQL execution plans and timing statistics that enhance the recommendations of the SQLadvisors. When tuning is complete, this setting should be returned to the TYPICAL setting.Oracle Internal & OAI Use Only
  61. 61. Oracle Database 10g: Administration Workshop I 12-15Copyright © 2005, Oracle. All rights reserved.Automatic Database Diagnostic .Monitor (ADDM)• Runs after each AWR snapshot• Monitors the instance; detects bottlenecks• Stores results within the AWRSnapshotsADDMAWREMADDM resultsStatisticsAWR> ADDMAdvisorsAlertsAutoTasksAutomatic Database Diagnostic Monitor (ADDM)Unlike the other advisors, the ADDM runs automatically after each AWR snapshot. Each time asnapshot is taken, the ADDM performs an analysis of the period corresponding to the last twosnapshots. The ADDM proactively monitors the instance and detects most bottlenecks beforethey become a significant problem.In many cases, the ADDM recommends solutions for detected problems and even quantifies thebenefits for the recommendations.Some common problems that are detected by the ADDM include:• CPU bottlenecks• Poor Oracle Net connection management• Lock contention• Input/output (I/O) capacity• Undersizing of Oracle memory structures• High-load SQL statements• High PL/SQL and Java time• High checkpoint load and cause (for example, small log files)The results of each ADDM analysis are stored inside the AWR and are also accessible throughEnterprise Manager.Oracle Internal & OAI Use Only
  62. 62. Oracle Database 10g: Administration Workshop I 12-16Copyright © 2005, Oracle. All rights reserved.ADDM Findings123ADDM FindingsOn the Automatic Database Diagnostic Monitor (ADDM) page, you can see the detailed findingsfor the latest ADDM run. Database Time represents the sum of the nonidle time spent bysessions in the database for the analysis period. A specific Impact percentage is given for eachfinding. The impact represents the time consumed by the corresponding issue as compared withthe database time for the analysis period. In this slide, you see the following:1. The graphic shows that the number of average active users increased dramatically at thispoint. Also, the major problem was a Wait problem.2. The icon shows that the ADDM output displayed at the bottom of the page corresponds tothis point in time. You can go into the past (to view previous analysis) by clicking the othericons.3. The findings give you a short summary of what ADDM has found as tunable areas. Byclicking a particular issue, you are directed to the Performance Finding Details page.You can click the View Report button to get details about the performance analysis in the formof a text report.Oracle Internal & OAI Use Only
  63. 63. Oracle Database 10g: Administration Workshop I 12-17Copyright © 2005, Oracle. All rights reserved.ADDM RecommendationsADDM RecommendationsOn the Performance Finding Details page, you are given some recommendations to solve thecorresponding issue. Recommendations are grouped into Schema, SQL Tuning, DatabaseConfiguration, and many other categories. The Benefit (%) column gives you the maximumreduction in database elapsed time, if the recommendation is implemented.ADDM considers a variety of changes to a system, and its recommendations can include:• Hardware changes: Adding CPUs or changing the I/O subsystem configuration• Database configuration: Changing initialization parameter settings• Schema changes: Hash-partitioning a table or index, or using Automatic Segment SpaceManagement (ASSM)• Application changes: Using the cache option for sequences or using bind variables• Using other advisors: Running the SQL Tuning Advisor on high-load SQL or running theSegment Advisor on hot objectsOracle Internal & OAI Use Only
  64. 64. Oracle Database 10g: Administration Workshop I 12-18Copyright © 2005, Oracle. All rights reserved.Advisory FrameworkADDMSQL TuningAdvisorSQL AccessAdvisorMemorySpacePGA AdvisorSGASegment AdvisorUndo AdvisorBuffer CacheAdvisorLibrary CacheAdvisorPGABackup MTTR AdvisorStatisticsAWRADDM> AdvisorsAlertsAutoTasksAdvisory FrameworkAdvisors are server components that provide you with useful feedback about resource utilizationand performance of their respective components.By building upon the data captured in the AWR, the ADDM enables the Oracle database todiagnose its own performance and determine how identified problems can be resolved. ADDMruns automatically after each AWR statistics capture. It can potentially call other advisors.Here are the major benefits that are provided by the advisor infrastructure:• It uses a uniform interface for all advisors.• All advisors have a common data source and results storage by using the workloadrepository.Oracle Internal & OAI Use Only
  65. 65. Oracle Database 10g: Administration Workshop I 12-19Advisory Framework (continued)Automatic Database Diagnostic Monitor (ADDM)It is a server-based expert that reviews database performance every 60 minutes. ADDM’s goal isto detect possible system bottlenecks early and recommend fixes before system performancedegrades noticeably.Memory AdvisorsThe Memory Advisor is actually a collection of several advisory functions that help determinethe best settings for the shared pool, database buffer cache, and Program Global Area (PGA). Inaddition to the advisory functions, this page provides a central point of control for the large pooland the Java pool.Mean-Time-To-Recover (MTTR) AdvisorUsing the MTTR Advisor, you can set the length of time required for the database to recoverafter an instance crash.Segment AdvisorThis advisor looks for tables and indexes that consume more space than they require. Theadvisor checks for inefficient space consumption at the tablespace or schema level and producesscripts to reduce space consumption where possible.SQL Access AdvisorThis advisor analyzes all SQL statements that are issued within a given period and suggests thecreation of additional indexes or materialized views that will improve performance.SQL Tuning AdvisorThis advisor analyzes an individual SQL statement and makes recommendations for improvingits performance. Recommendations may include actions such as rewriting the statement,changing the instance configuration, or adding indexes. The SQL Tuning Advisor is not invokeddirectly. Instead, it is called from within other tools, such as Top SQL or Top Sessions, to helpoptimize high-impact SQL statements.Undo Management AdvisorWith the Undo Management Advisor, you can determine the undo tablespace size that is requiredto support a given retention period. Undo management and the use of the advisor is covered inthe lesson titled “Managing Undo Data.”Oracle Internal & OAI Use Only
  66. 66. Oracle Database 10g: Administration Workshop I 12-20Copyright © 2005, Oracle. All rights reserved.Enterprise Manager and AdvisorsEnterprise Manager and AdvisorsThe Advisor Central page is the main page of all advisors. You can reach this page by clickingthe Advisor Central link in the list of Related Links of the Database Control Home page.However, this is not the only place in Database Control where advisors can be invoked. It is alsopossible to have access to advisors in certain contexts.On the Advisor Central page, you can list all the advisor tasks that are registered in the workloadrepository. You can also filter this list by advisor type and for predefined time periods.Some advisors are described in greater detail in the lessons titled “Managing Undo Data”,“Performance Management”, and “Backup and Recovery Concepts”.Note: Use the Change Default Parameters page to change the default expiration in days for allfuture tasks. You can also use this page to change some important advisor’s parameters.Oracle Internal & OAI Use Only
  67. 67. Oracle Database 10g: Administration Workshop I 12-21Copyright © 2005, Oracle. All rights reserved.The DBMS_ADVISOR PackageCreates a script of all therecommendations that are acceptedGET_TASK_SCRIPTMarks one or more recommendations asaccepted, rejected, or ignoredMARK_RECOMMENDATIONModifies a task parameterSET_TASK_PARAMETERUpdates task attributesUPDATE_TASK_ATTRIBUTESCauses a suspended task to resumeRESUME_TASKCreates and returns a text report for thespecified taskGET_TASK_REPORTSuspends a task that is currentlyexecutingINTERRUPT_TASKInitiates execution of the taskEXECUTE_TASKDeletes a task from the repositoryDELETE_TASKCreates a new task in the repositoryCREATE_TASKDescriptionProcedureThe DBMS_ADVISOR PackageThe DBMS_ADVISOR package contains all constants and procedure declarations for all advisormodules. You can use this package to execute tasks via command line.To execute advisor procedures, you must be granted the ADVISOR privilege. The ADVISORprivilege permits full access to the advisor procedures and views.Note: For more information about all the procedures found in the DBMS_ADVISOR package, seethe Oracle Database PL/SQL Packages and Types Reference guide.Oracle Internal & OAI Use Only
  68. 68. Oracle Database 10g: Administration Workshop I 12-22Copyright © 2005, Oracle. All rights reserved.Server-Generated AlertsServeralertsqueue.Metric exceedsthreshold.AWREnterprise ManagerOracleinstanceStatisticsAWRADDMAdvisors> AlertsAutoTasksServer-Generated AlertsAlerts are notifications of when a database is in an undesirable state and needs your attention. Bydefault, the Oracle database provides alerts via Enterprise Manager Database Control.Optionally, Enterprise Manager can be configured to send an e-mail to the administrator aboutproblem 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 Database10g proactively notifies you if the database deviates from normal readings enough to reach thosethresholds. An early notification of potential problems enables you to respond quickly, and oftenresolve issues before users even notice them.A few key metrics that can provide early problem notification are:• Average File Read Time (centiseconds)• Dump Area Used (%)• Response Time (per transaction)• SQL Response Time (%)• Tablespace Used (%)• Wait Time (%)Oracle Internal & OAI Use Only
  69. 69. Oracle Database 10g: Administration Workshop I 12-23Copyright © 2005, Oracle. All rights reserved.Default Server-Generated AlertsResumableSessionSuspendedSnapshotToo OldRecovery AreaLow OnFree Space85% Warning97% CriticalTablespaceSpace UsageDatabase Control:SYSTEM metricsTablespaceDefault Server-Generated AlertsBy default, the following server-generated alerts are enabled:• Tablespace Space Usage (warning 85%, critical 97%)• Snapshot Too Old• Recovery Area Low On Free Space• Resumable Session SuspendedNote: Enterprise Manager Database Control automatically sets thresholds on server metrics withthe SYSTEM object type.Oracle Internal & OAI Use Only
  70. 70. Oracle Database 10g: Administration Workshop I 12-24Copyright © 2005, Oracle. All rights reserved.Setting ThresholdsSetting ThresholdsTo set or edit a threshold for your whole database, select Manage Metrics in the Related Linksregion of the database home page. Click Edit Threshold. Enter your desired Warning and CriticalThreshold values. The appropriate alerts appear when the database reaches your specified values.If required, you can specify an additional response action.Oracle Internal & OAI Use Only
  71. 71. Oracle Database 10g: Administration Workshop I 12-25Copyright © 2005, Oracle. All rights reserved.Creating and Testing an Alert1. Specify a threshold.2. Create a test case.3. Check for an alert.213Creating and Testing an AlertYou can also set thresholds for a specific object.Example: You decide that you need to receive a critical alert if the space used in theINVENTORY tablespace exceeds 75%. (This tablespace does not allow its data files toautomatically extend.) To create and test the alert, perform the following steps:1. In Enterprise Manager, navigate to the tablespace administration, and set your desiredthreshold.2. Use the “Create like” action to duplicate an existing table, and fill it using SQL*Plus.3. After you receive an error that this table is unable to extend, check the Database Instancehome page for the associated alert.Most alerts contain a name of an associated advisor that can be invoked to give you moredetailed advice. For each corresponding alert message, Database Control provides a link toinvoke the corresponding advisor.Oracle Internal & OAI Use Only
  72. 72. Oracle Database 10g: Administration Workshop I 12-26Copyright © 2005, Oracle. All rights reserved.Alerts NotificationAlerts NotificationThe notification mechanism uses the user interface because it is already available in EnterpriseManager. It is based on the concept of a notification rule that establishes the appropriatenotification mechanism for a set of upcoming alerts.Using Database Control, you can edit the notification rules. On the home page, click thePreferences link. This displays the General page, where you can specify your e-mail address atwhich you want to receive notifications.On the General page, click the Rules link in the Notification region. Select the DatabaseAvailability and Critical States rule, and then click the Edit button. This takes you to the EditNotification Rule Database Availability and Critical States wizard page, where you can select themetrics (and their severities) for which you want to receive notifications.Oracle Internal & OAI Use Only
  73. 73. Oracle Database 10g: Administration Workshop I 12-27Alerts Notification (continued)You can optionally specify that Enterprise Manager provide you with direct notification whenspecific alerts arise. For example, if you specify that you want e-mail notification for criticalalerts, and you have a critical threshold set for the system response time for each call metric,then you may send an e-mail containing a message similar to the following:Host Time per CallTimestamp=08-NOV-2005 10:10:01 (GMT -7:00)Severity=CriticalMessage=Response time per call has exceeded the threshold.See the latest ADDM analysis.Rule Name= RuleOwner=SYSMANThe e-mail contains a link to the host name and the latest ADDM analysis.By default, alerts in critical state such as DB Down, Generic Alert Log Error Status, andTablespace Used are set up for notification. However, to receive these notifications, you must setup your e-mail information by following these steps:1. On any Database Control page, click the Setup link, which is visible in the header andfooter area.2. On the Setup page, select Notification Methods.3. Enter the required information in the Mail Server region of the Notifications Methods page.There are other methods of notification, including scripts and Simplified Network ManagementProtocol (SNMP) traps. The latter can be used to communicate with third-party applications.To receive notifications, perform the following steps:1. On any Database Control page, click the Preferences link, which is visible in the headerand footer area.2. On the Preferences page, select General. Enter your e-mail address in the E-mail Addressesregion.3. You can optionally edit notification rules, such as to change the severity state for receivingnotification. To do so, select Notification Rules. The Notification Rules page appears. Formore information about configuring notification rules, see the Oracle Enterprise ManagerAdvanced Configuration documentation.Oracle Internal & OAI Use Only
  74. 74. Oracle Database 10g: Administration Workshop I 12-28Copyright © 2005, Oracle. All rights reserved.Reacting to Alerts• If needed, gather more input, for example, byrunning ADDM or another advisor.• Take corrective measures.• Acknowledge alerts, which are not automaticallycleared.Reacting to AlertsWhen you receive an alert, follow any recommendations it provides, or consider running ADDMor another advisor as appropriate to get more detailed diagnostics of system or object behavior.Most alerts, such as the Out of Space alert, are cleared automatically when the cause of theproblem disappears. However, other alerts such as Generic Alert Log Error are sent to you fornotification and need to be acknowledged by you. After taking the necessary correctivemeasures, you can acknowledge an alert by clearing or purging it. Clearing an alert sends thealert to the Alert History, which is viewable from the home page under Related Links. Purgingan alert removes it from the Alert History.To clear an alert such as Generic Alert Log Error, from the home page under DiagnosticSummary, click the Alert Log link. The Alert Log Errors page appears. Select the alert to clearand click Clear. To purge an alert, select it and click Purge. You can also Clear Every OpenAlert or Purge Every Alert using these buttons.Oracle Internal & OAI Use Only
  75. 75. Oracle Database 10g: Administration Workshop I 12-29Copyright © 2005, Oracle. All rights reserved.Alert Types and Clearing AlertsMMON85% Warning97% Critical ClearedClearedAlertSnapshotToo OldResumableSessionSuspendedRecovery AreaLow OnFree SpaceMetric basedEvent basedThreshold(stateful)alertsNonthreshold(stateless)alertsDBA_OUTSTANDING_ALERTS DBA_ALERT_HISTORYAlert Types and Clearing AlertsThere are two kinds of server-generated alerts: threshold and nonthreshold.Most server-generated alerts are configured by setting a warning and critical threshold values ondatabase metrics. You can define thresholds for more than 120 metrics. For example:• Physical Reads Per Sec• User Commits Per Sec• SQL Service Response TimeExcept for the Tablespace Space Usage metric, which is database related, the other metrics areinstance related. Threshold alerts are also referred to as stateful alerts. These alerts areautomatically cleared when an alert condition clears. Stateful alerts appear inDBA_OUTSTANDING_ALERTS and, when cleared, go to DBA_ALERT_HISTORY.Other server-generated alerts correspond to specific database events such as Snapshot Too Olderrors, Recovery Area Low On Free Space, and Resumable Session Suspended. These arenon-threshold-based alerts, also referred to as stateless alerts. Stateless alerts go directly to thehistory table. Clearing a stateless alert makes sense only in the Database Control environmentbecause Database Control stores stateless alerts in its own repository.Oracle Internal & OAI Use Only
  76. 76. Oracle Database 10g: Administration Workshop I 12-30Copyright © 2005, Oracle. All rights reserved.Automated Maintenance Tasks .• Scheduler initiates jobs• Jobs run in the default maintenancewindow• Limit maintenance impact on normaloperation by using Resource ManagerExamples of maintenance:• Gathering optimizer statistics• Gathering segment information• Backing up databaseStatisticsAWRADDMAdvisorsAlerts> AutoTasksAutomated Maintenance TasksBy analyzing the information stored in the AWR, the database can identify the need to performroutine maintenance tasks, such as optimizer statistics refresh. The automated maintenance tasksinfrastructure enables the Oracle database to automatically perform such operations. It uses theScheduler to run such tasks in a predefined “maintenance window.”By default, the maintenance window starts at 10 p.m. every night and lasts until 6 a.m. the nextmorning and throughout the weekend. All attributes of the maintenance window arecustomizable, including the start and end time, frequency, days of the week, and so on. Also, theimpact of automated maintenance tasks on normal database operations can be limited byassociating a Database Resource Manager resource plan to the maintenance window.The examples of maintenance are as follows:• Optimizer statistics are automatically refreshed by using the automatic maintenance taskinfrastructure.• The Segment Advisor has default jobs, which run in the maintenance window.• When creating a database with the DBCA, you can initiate regular database backups.Oracle Internal & OAI Use Only
  77. 77. Oracle Database 10g: Administration Workshop I 12-31Copyright © 2005, Oracle. All rights reserved.SummaryIn this lesson, you should have learned how to:• Use statistics• Manage the Automatic Workload Repository• Use the Automatic Database Diagnostic Monitor• Describe the advisory framework• Set alert thresholds• Use server-generated alerts• Use automated tasksOracle Internal & OAI Use Only
  78. 78. Oracle Database 10g: Administration Workshop I 12-32Copyright © 2005, Oracle. All rights reserved.Practice Overview:Proactive MaintenanceThis practice covers the following topics:• Proactively managing your database by usingADDM– Setting up an issue for analysis– Reviewing your database performance– Implementing a solutionOracle Internal & OAI Use Only
  79. 79. Copyright © 2005, Oracle. All rights reserved.Performance ManagementOracle Internal & OAI Use Only
  80. 80. Oracle Database 10g: Administration Workshop I 13-2Copyright © 2005, Oracle. All rights reserved.ObjectivesAfter completing this lesson, you should be able to dothe following:• Use Enterprise Manager to monitor performance• Tune SQL by using the SQL Tuning Advisor• Tune SQL by using the SQL Access Advisor• Use Automatic Shared Memory Management(ASSM)• Use the Memory Advisor to size memory buffers• View performance-related dynamic views• Troubleshoot invalid and unusable objectsOracle Internal & OAI Use Only
  81. 81. Oracle Database 10g: Administration Workshop I 13-3Copyright © 2005, Oracle. All rights reserved.Performance MonitoringMemoryallocationissuesInput/outputdevicecontentionApplicationcodeproblemsResourcecontentionNetworkbottlenecks?DBA> Perf MonTuning AdvAccess AdvMemoryStatsInvalid ObjPerformance MonitoringTo administer Oracle Database 10g and keep it running smoothly, the databaseadministrator (DBA) must regularly monitor its performance to locate bottlenecks andcorrect problem areas.There are hundreds of performance measurements the DBA can look at, coveringeverything from network performance and disk input/output (I/O) speed to the time spentworking on individual application operations. These performance measurements arecommonly referred to as database metrics.Note: For more information about Oracle database performance, see the Oracle Database10g: SQL Tuning Workshop course.Oracle Internal & OAI Use Only
  82. 82. Oracle Database 10g: Administration Workshop I 13-4Copyright © 2005, Oracle. All rights reserved.Performance MonitoringPerformance Monitoring (continued)The Performance tabbed page in Enterprise Manager is the portal to a powerful set ofperformance monitoring and tuning tools. The first screen on this page summarizesprocesses and active session activity. The Average Active Sessions graph shows the levelof CPU usage and what resources are causing the most wait events. In the screen in theslide, you see that there was a recent increase in CPU usage and waits for User I/O,System I/O, and Concurrency. You can click any one of these categories to see moredetails about the waits. The I/O data is broken down into types of I/O—for example, logfile read, control file write, and so on.Oracle Internal & OAI Use Only
  83. 83. Oracle Database 10g: Administration Workshop I 13-5Copyright © 2005, Oracle. All rights reserved.Performance MonitoringPerformance Monitoring (continued)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 Sessionsassociated with that particular wait event during that time. This enables you to performafter-the-fact analysis of system slowdowns, and determine potential causes.Oracle Internal & OAI Use Only
  84. 84. Oracle Database 10g: Administration Workshop I 13-6Copyright © 2005, Oracle. All rights reserved.Performance MonitoringPerformance Monitoring (continued)Instance Disk I/O and Instance Throughput are also reflected on the main Performancetabbed page.Oracle Internal & OAI Use Only
  85. 85. Oracle Database 10g: Administration Workshop I 13-7Copyright © 2005, Oracle. All rights reserved.Performance Monitoring: Top SessionsPerformance Monitoring: Top SessionsIf you click one of the I/O category names, you see the Top Consumers page, which liststhe top services, modules, actions, clients, and sessions, including critical statistics such aslogical and physical read and write count, parse count, and sort count. If you click an I/Ocategory name, the associated statistic is the ordering value for the list.The table on this page lists the sessions, sorted by CPU usage. This shows that the user SHin session 152 is the greatest consumer of CPU at this particular time.Oracle Internal & OAI Use Only
  86. 86. Oracle Database 10g: Administration Workshop I 13-8Copyright © 2005, Oracle. All rights reserved.Performance Monitoring: Top ServicesPerformance Monitoring: Top ServicesIn multitier systems, where there is an application server that is pooling databaseconnections, viewing sessions may not provide the information you need to analyzeperformance. Grouping sessions into service names enables you to monitor performancemore accurately. In the example in the slide, there are three services: inventory, orcl,and hr. Regardless of what session was used for a particular request, if it connected viaone of these services, then the sessions performance data is captured under that servicename. It is clear from this listing that, of the three application services, the inventoryservice was the most active during this five-minute interval.Oracle Internal & OAI Use Only
  87. 87. Oracle Database 10g: Administration Workshop I 13-9Copyright © 2005, Oracle. All rights reserved.SQL Tuning Advisor: OverviewAdd missing indexRun access advisorRestructure SQLTune SQL plan(SQL profile)Automatic Tuning OptimizerSQL analysisoptimization modeAccess analysisoptimization modePlan tuningoptimization modeStatistics checkoptimization mode Detect stale or missingstatisticsComprehensive SQL tuningSQL TuningAdvisorPerf Mon> Tuning AdvAccess AdvMemoryStatsInvalid ObjSQL Tuning Advisor: OverviewThe SQL Tuning Advisor is the primary driver of the tuning process. It calls the AutomaticTuning Optimizer (ATO) to perform four specific types of analyses:• Statistics Analysis: The Automatic Tuning Optimizer checks each query object formissing or stale statistics, and makes recommendations to gather relevant statistics.• SQL Profiling: The ATO verifies its own estimates and collects auxiliaryinformation to remove estimation errors. It builds a SQL profile using the auxiliaryinformation and makes a recommendation to create it. When a SQL profile iscreated, it enables the query optimizer to generate a well-tuned plan.• Access Path Analysis: The ATO explores whether a new index can be used tosignificantly improve access to each table in the query and, when appropriate, makesrecommendations to create such indexes.• SQL Structure Analysis: The ATO tries to identify SQL statements that use badplans and makes relevant suggestions to restructure them. The suggested changes canbe syntactic as well as semantic.Oracle Internal & OAI Use Only
  88. 88. Oracle Database 10g: Administration Workshop I 13-10Copyright © 2005, Oracle. All rights reserved.SQL Tuning Advisor Options andRecommendationsSQL Tuning Advisor Options and RecommendationsAfter the SQL Tuning Advisor is launched, Enterprise Manager automatically creates atuning task, provided that the user has appropriate ADVISOR privileges to do so.Enterprise Manager shows the tuning task and automatic default options on the SQLTuning Options page. On this page, the user can change the automatic defaults for a tuningtask. It is important to choose the appropriate scope for the tuning task If you choose theLimited option, then the SQL Tuning Advisor produces recommendations based onstatistics check, access path analysis, and SQL structure analysis. No SQL profilerecommendation is generated with the Limited option. If you choose the Comprehensiveoption, the SQL Tuning Advisor produces all the recommendations that the Limited optionproduces, but it also invokes the optimizer under the SQL profiling mode to build a SQLprofile, if applicable. With the Comprehensive option, you can also specify a time limit forthe tuning task, which by default is 60 minutes. After you select Run SQL Tuning Advisor,configure your tuning task using the SQL Tuning Options page. Go back to the Top SQLpage and click the tuned statement to go to the SQL Details page on which theRecommendations history is displayed. The Recommendations history shows you thecompleted tuning task. Click the task to see its general recommendation information. ClickView Recommendations to see the details about the task .Oracle Internal & OAI Use Only