Tài liệu ORACLE8i- P18 docx

40 264 0
Tài liệu ORACLE8i- P18 docx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

CHAPTER 15 • ORACLE8i PERFORMANCE MONITORING AND DATABASE-LEVEL TUNING 676 NOTE To save space, we do not provide a sample utlestat report here. These reports tend to be long, and to be honest, a great deal of the information supplied is not terribly important most of the time. You should first look over the report and note if any negative figures appear in it. If so, this probably indicates that the database was shut down and restarted between the time you ran the utlbstat and utlestat scripts. In this case, your reports are worthless. You will see that a lot of the report has to do with waits and latching. We will cover these topics in detail in Chapter 17. However, note that the following wait events listed in the report can be ignored: • SQL*Net message from client • SQL*Net more data from client • RDBMS IPC message • Pipe get • Null event • PMON timer • SMON timer • Parallel query dequeue These are known as “idle” waits, which are generally representative of the database waiting to do some work, and therefore are of little or no consequence. Many of the items on the report provide the same information as we have already discussed earlier in this chapter. For example, the file I/O report replicates the file I/O query that you saw in the “Monitoring System File I/O” section earlier in this chapter, but it’s providing that information in a cumulative fashion. The utlbstat/utlestat report is nice to have, and it augments any monitoring that you are doing, but the report is not a facility to replace ongoing monitoring and reporting. We will discuss the monitoring process in the “Introducing a Monitoring Methodology” section later in this chapter. Using the Oracle Statspack One of the problems with the utlbstat/utlestat report, and even the other reports we have presented throughout this chapter, is that it is difficult to generate a true baseline with them. Also, it is hard to gauge trends in these reports, because they are just snapshots at a point in time. In addition to these reports, DBAs often create C opyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 677 repositories to store historical information about databases. These repositories usually contain performance data, table sizing, and table growth information. This informa- tion allows the DBA to determine trends and predict future space and processing requirements. To help collect this information, Oracle introduced Statspack in version 8.1.6 (Oracle8i release 2). Statspack is different from the utlbstat.sql and utlestat.sql scripts in several ways: • It collects additional information that is specific to Oracle8i. • It stores this data permanently in Oracle tables that are owned by a user called PERFSTAT. • Certain ratios (such as the buffer cache hit ratio) are calculated for you. • Data collection and the generation of the Statspack report are separate functions. Data collection can be scheduled through the Oracle Job Scheduler so that it occurs on a regular basis, allowing the DBA to generate a baseline of normal database performance over time. Thus, when there is a database performance problem, you can compare the baseline statistics against the current statistics, which should allow you to target your database tuning efforts. Installing Statspack in the Database To install Statspack, you run an installation script called spcreate.sql. You can find this script in the $ORACLE_HOME/rdbms/admin directory on Unix systems, or in the $ORACLE_HOME\rdbms\admin directory on NT systems. Note the following about the installation process: • You need to run the installation script from SQL*Plus, not Server Manager. The spcreate.sql script uses SQL*Plus commands to prompt you for the user and default tablespaces. The creation of Statspack will fail if you use Server Manager. • You can run this script for each node in a parallel server configuration. Each instance’s data is stored, and the primary keys are created in such a way that the instance data is always unique, in case you later want to combine data from multiple instances. • The Statspack tables take a minimum of about 35MB to create, because all of the tables have a 1MB initial extent. You may need to modify the creation scripts to create smaller tables, if this is a problem. If you find you need to modify the storage parameters for the tables, you will find those parameters in the statsctab.sql script, which is in $ORACLE_HOME\rdbms\admin. USING ORACLE DATABASE PERFORMANCE MONITORING TOOLS Beyond Simple Database Management PART III C opyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. CHAPTER 15 • ORACLE8i PERFORMANCE MONITORING AND DATABASE-LEVEL TUNING 678 • Make sure that you change the password of the PERFSTAT user once the spcreate.sql script has successfully completed. Statspack is fairly easy to install. The spcreate.sql script will create the PERFSTAT user, and then it will prompt you for the default and temporary tablespaces that the PERFSTAT user should use. Once the script has completed, Statspack will have been installed. The following is an example of the installation of Statspack. Note that run- ning spcreate.sql actually results in the execution of several other SQL programs, as shown in the example below. We removed some of the redundant output for space reasons. D:\ORACLE\ORA816\RDBMS\ADMIN>sqlplus “/ as sysdba” /nolog SQL> SPOOL d:\oracle\spcreate.log SQL> @spcreate.sql SQL> REM $Header: statscre.sql 06-dec-99.18:33:17 cdialeri Exp $ SQL> REM statscre.sql SQL> REM Copyright (c) Oracle Corporation 1999. All Rights Reserved. SQL> REM NAME SQL> REM statscre.sql - Statistics Create Installing Required Packages Package created. Grant succeeded. View created. … blah blah… more of the same output here truncated by author… Creating PERFSTAT user Below are the list of online tablespaces in this database. Decide which tablespace you wish to create the Statspack tables and indexes. It is not recommended to use the system tablespace for storing statistics data. TABLESPACE_NAME RBS USERS TEMP TOOLS INDX Specify PERFSTAT user’s default tablespace: tools C opyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 679 User altered. User altered. Specify PERFSTAT user’s temporary tablespace: temp User altered. … blah blah… more of the same output here truncated by author… Below is the list of online tablespaces in this database. Decide which tablespace you wish to create the Statspack tables and indexes. It is not recommended to use the system tablespace for storing statistics data. Ensure the PERFSTAT user has sufficient quota in the tablespace you specify. TABLESPACE_NAME RBS USERS TEMP TOOLS INDX Enter tablespace where Statspack objects will be created: tools Creating STATS$SNAPSHOT_ID Sequence Sequence created. … blah blah… more of the same output here truncated by author… Below are the list of online tablespaces in this database. Decide which tablespace you wish to create the STATSPACK tables and indexes. This will also be the PERFSTAT user’s default tablespace. Using the SYSTEM tablespace to store statistical data is NOT recommended. TABLESPACE_NAME RBS USERS TEMP TOOLS INDX TEMPTEMP PERFSTAT USING ORACLE DATABASE PERFORMANCE MONITORING TOOLS Beyond Simple Database Management PART III C opyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. CHAPTER 15 • ORACLE8i PERFORMANCE MONITORING AND DATABASE-LEVEL TUNING 680 7 rows selected. Specify PERFSTAT user’s default tablespace Enter value for default_tablespace: perfstat Using perfstat for the default tablespace User altered. Specify PERFSTAT user’s temporary tablespace Enter value for temporary_tablespace: temp Using temp for the temporary tablespace User altered. … blah blah… more of the same output here truncated by author… Creating Package STATSPACK Package created. No errors. Creating Package Body STATSPACK Package body created. No errors. NOTE: SPCPKG complete. Please check spcpkg.lis for any errors. NOTE No indexes, except primary key indexes, are created during the Statspack instal- lation process. As you add historical data, you may find that you need to add more indexes to help performance. In different versions of Oracle8i, the names of the SQL procedures used with Statspack have changed. The procedures you see listed in this chapter are associated with Oracle release 8.1.7. The following lists the old names (pre-8.1.7) and the new names in 8.1.7: Pre-8.1.7 Name 8.1.7 Name statspack.doc spdoc.txt statscre.sql spcreate.sql statsrep.sql spreport.sql statsauto.sql spauto.sql statsdrp.sql spdrop.sql TIP spdrop.sql can be used to remove the Statspack tables. It is contained in $ORACLE_ HOME/rdbms/admin. C opyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 681 Taking Database Snapshots Now that Statspack has been installed, you can start collecting database data. The principle package used with Statspack is the STATSPACK package. In particular, you will use the SNAP procedure within the STATSPACK package to create what is called a snapshot. A snapshot, in this case, should not be confused with a snapshot in refer- ence to replication. This snapshot is the collection of database performance informa- tion at a given time. The SNAP procedure takes a snapshot of your database and stores the information collected in that snapshot in the Statspack repository. Later, you can generate Statspack reports based on the differences in snapshots, which occurred over a given period of time. The STATSPACK.SNAP package has the following definition: PROCEDURE SNAP Argument Name Type In/Out Default? I_SNAP_LEVEL NUMBER IN DEFAULT I_SESSION_ID NUMBER IN DEFAULT I_UCOMMENT VARCHAR2 IN DEFAULT I_NUM_SQL NUMBER IN DEFAULT I_EXECUTIONS_TH NUMBER IN DEFAULT I_PARSE_CALLS_TH NUMBER IN DEFAULT I_DISK_READS_TH NUMBER IN DEFAULT I_BUFFER_GETS_TH NUMBER IN DEFAULT I_SHARABLE_MEM_TH NUMBER IN DEFAULT I_VERSION_COUNT_TH NUMBER IN DEFAULT I_ALL_INIT VARCHAR2 IN DEFAULT I_PIN_STATSPACK VARCHAR2 IN DEFAULT I_MODIFY_PARAMETER VARCHAR2 IN DEFAULT The parameters and their meanings are shown in Table 15.7. TABLE 15.7: STATSPACK.SNAP PARAMETERS Parameter Default Value Purpose I_SNAP_LEVEL 5 Determines the level of detail col- lected by the Statspack snapshot I_SESSION_ID 0 (report on all sessions) Allows you to define a specific ses- sion ID to snapshot USING ORACLE DATABASE PERFORMANCE MONITORING TOOLS Beyond Simple Database Management PART III C opyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. CHAPTER 15 • ORACLE8i PERFORMANCE MONITORING AND DATABASE-LEVEL TUNING 682 TABLE 15.7: STATSPACK.SNAP PARAMETERS (CONTINUED) Parameter Default Value Purpose I_UCOMMENT Blank A comment that will be stored with the snapshot I_NUM_SQL Undocumented (Oracle internal use only) I_EXECUTIONS_TH 100 Reports on only SQL statements that have been executed a minimum of the specified number of times I_PARSE_CALLS_TH 1000 Reports on only SQL statements that have been parsed a minimum of the specified number of times I_DISK_READS_TH 1000 Reports on only SQL statements that have caused a minimum of the spec- ified number of disk reads I_BUFFER_GETS_TH 10000 Reports on only SQL statements that have caused a minimum of the spec- ified number of buffer gets I_SHARABLE_MEM_TH 1048576 Reports on only SQL statements that have used a minimum of the speci- fied amount of shared memory I_VERSION_COUNT_TH 20 Reports on only SQL statements that have a minimum of the specified number of versions I_ALL_INIT Undocumented (Oracle internal use only) I_PIN_STATSPACK Undocumented (Oracle internal use only) I_MODIFY_PARAMETER FALSE Allows you to save these parameters for future runs of the STATSPACK.SNAP procedure Note that each of these parameters has a default value associated with it. This allows you to execute the SNAP procedure without any parameters, like this: SQL> EXEC STATSPACK.SNAP On the other hand, you may wish to provide parameters to customize the statistics that are gathered. You can collect data at various levels of detail and set thresholds. Of C opyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 683 course, the more detail you collect, the more space required for that data, and the big- ger the impact on your system of running the collection process. There are three levels of detail you can collect: level 0, level 5, and level 10. At level 0, general performance statistics are collected. These include wait statistics, system event statistics, rollback segment information, row cache information, SGA statistics, background events, session events, lock status and statistics, buffer pool statistics, and parent latching information. Level 5 includes all of the statistics included with level 0, plus information about SQL statements that have high-resource usage. This means that SQL statements will be stored by Statspack if they exceed four threshold parameters: • The total number of times the SQL statement was executed (the default is 100) • The total number of disk reads the SQL statement has caused (the default is 1000) • The total number of parse calls the SQL statement has caused (the default is 1000) • The total number of buffer gets the SQL statement has caused (the default is 10000) Level 10 collection consists of all of the information collected in level 5 plus the parent and child latch information. You can modify the threshold defaults by changing them in the STATS$STATSPACK_ PARAMETER table. Alternatively, you can set the I_MODIFY_PARAMETER in the STATSPACK.SNAP package, and the defaults will be changed to reflect the defaults selected in the execution of STATSPACK.SNAP. Here is an example of setting some STATSPACK.SNAP parameters: SQL> EXEC STATSPACK.SNAP(i_snap_level=>10, i_disk_reads_th=>10000); This command sets data collection level 10 and limits the collection of SQL state- ments to just those that are causing 10,000 or more disk reads. Automating Statistics Collection To collect statistics on a regular, frequent basis, you will want to automate the process. One way to schedule statistics collection is to use Oracle’s Job Scheduler in the Oracle DBMS_JOB package to set up a recurring job that executes the STATSPACK.SNAP SQL script. NOTE You can also use your operating system’s scheduling facility (such as cron in Unix) to schedule the execution of the statistics collection job using SQL*Plus. See your operating system documentation for information about how to use your operating sys- tem’s job scheduling facility. USING ORACLE DATABASE PERFORMANCE MONITORING TOOLS Beyond Simple Database Management PART III C opyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. CHAPTER 15 • ORACLE8i PERFORMANCE MONITORING AND DATABASE-LEVEL TUNING 684 Before you can use the Job Scheduler, you need to make sure that it’s enabled by checking the init.ora parameter JOB_QUEUE_PROCESSES. This parameter should be greater than 0. (The Job Scheduler is discussed in detail in Chapter 20.) Once you have enabled the Job Scheduler, issue the following command to have statistics col- lected on your system once every 6 hours: DECLARE jobno NUMBER; BEGIN DBMS_JOB.SUBMIT(:jobno,’STATSPACK.SNAP;’, - TRUNC(sysdate+1/6,’HH’),’TRUNC(SYSDATE+1/6,’’HH’’)’ ); END; / TIP Oracle provides a SQL script called spauto.sql that can help you automate the running of your statistics jobs (after you’ve set up the Job Scheduler). This script, which can be found in the $ORACLE_HOME/rdbms/admin directory, will set up a scheduled job that will run STATSPACK.SNAP every hour. Viewing the Statspack Report After you’ve collected several Statspack snapshots, you’ll be ready to look at that data and see how your database is doing. Oracle provides a single report that contains the collected information. This report is run by using the script spreport.sql. When you run spreport.sql, it will provide you with a list of snapshots currently stored in the database. You will then be prompted to select the beginning and ending snapshot to report on and to specify the output report name. Here is an example of running spreport.sql: SQL> @spreport DB Id DB Name Inst Num Instance 1598904557 ORA817 1 ora817 C opyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 685 Completed Snapshots Snap Snap Instance DB Name Id Snap Started Level Comment ora817 ORA817 1 23 Jul 2001 16:00 5 2 23 Jul 2001 16:10 5 Specify the Begin and End Snapshot Ids ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Enter value for begin_snap: 1 Begin Snapshot Id specified: 1 Enter value for end_snap: 2 End Snapshot Id specified: 2 Specify the Report Name ~~~~~~~~~~~~~~~~~~~~~~~ The default report file name is sp_1_2. To use this name, press <return> to continue, otherwise enter an alternative. Enter value for report_name: c:\sql\snap.rpt Using the report name c:\sql\snap.rpt STATSPACK report for DB Name DB Id Instance Inst Num Release OPS Host ORA817 1598904557 ora817 1 8.1.7.0.0 NO WS-JAX Snap Id Snap Time Sessions Begin Snap: 1 23-Jul-01 16:00:53 9 End Snap: 2 23-Jul-01 16:10:31 9 Elapsed: 9.63 (mins) USING ORACLE DATABASE PERFORMANCE MONITORING TOOLS Beyond Simple Database Management PART III C opyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

Ngày đăng: 22/01/2014, 00:20

Mục lục

  • Using Your Sybex Electronic Book

  • MASTERING ORACLE8i

    • ACKNOWLEDGMENTS

    • INTRODUCTION

      • Is This Book for You?

      • What You Need to Know

      • Conventions Used in This Book

      • How to Use This Book

      • What's On the CD

      • Come Visit Us

      • Part I: Oracle Essentials

        • Chapter 1: Elements of Oracle Database Management

          • What Is a DBA?

          • Introducing Oracle8i

            • Relational Theory-Briefly

            • A Brief History of Oracle

            • Oracle Internals

              • Instances vs. Databases

              • The Physilogical Oracle

              • Fundamental Oracle Principles

                • Database Consistency

                • Transactions

                • Constraints

                • NULL Values

                • Environment Settings

                • The Oracle SQL Interface Tools

                  • Server Manager

                  • SQL*Plus

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan