ocp instructors guide for oracle dba certification manager ... finding problem queries ... ocp...

13
OCP Instructors Guide for Oracle DBA Certification A Study Guide to Advanced Oracle Certified Professional Database Administration Techniques Christopher Foot

Upload: trinhthuan

Post on 06-Mar-2018

231 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: OCP Instructors Guide for Oracle DBA Certification Manager ... Finding Problem Queries ... OCP Instructors Guide for Oracle DBA Certification Christopher Foot

OCP Instructors Guide for Oracle DBA Certification A Study Guide to Advanced Oracle Certified Professional Database Administration Techniques

Christopher Foot

Page 2: OCP Instructors Guide for Oracle DBA Certification Manager ... Finding Problem Queries ... OCP Instructors Guide for Oracle DBA Certification Christopher Foot

OCP Instructors Guide for Oracle DBA Certification A Study Guide to Advanced Oracle Certified Professional Database Administration Techniques

By Christopher Foot Copyright © 2003 by BMC Software and DBAzine. Used with permission. Printed in the United States of America. Published in Kittrell, North Carolina, USA Oracle In-Focus Series: Book #14 Series Editor: Don Burleson Production Manager: Robert Strickland Production Editor: Teri Wade Cover Design: Bryan Hoff Printing History: August 2003 for First Edition Oracle, Oracle7, Oracle8, Oracle8i and Oracle9i are trademarks of Oracle Corporation.

Many of the designations used by computer vendors to distinguish their products are claimed as Trademarks. All names known to Rampant TechPress to be trademark names appear in this text as initial caps. The information provided by the authors of this work is believed to be accurate and reliable, but because of the possibility of human error by our authors and staff, BMC Software, DBAZine and Rampant TechPress cannot guarantee the accuracy or completeness of any information included in this work and is not responsible for any errors, omissions or inaccurate results obtained from the use of information or scripts in this work. Links to external sites are subject to change; DBAZine.com, BMC Software and Rampant TechPress do not control or endorse the content of these external web sites, and are not responsible for their content. ISBN: 0-9740716-1-7

iv

Page 3: OCP Instructors Guide for Oracle DBA Certification Manager ... Finding Problem Queries ... OCP Instructors Guide for Oracle DBA Certification Christopher Foot

Table of Contents Using the Online Code Depot......................................................xiv Conventions Used in this Book.....................................................xv Acknowledgements .......................................................................xvii Foreword .......................................................................................xviii

Chapter 1 - Getting Started .................................................... 1 Why Become an Oracle Database Administrator? .......................1 Oracle Database Administration Responsibilities ........................3 Oracle Classroom Education ...........................................................8 Oracle9i Curriculum Changes........................................................10 Oracle9i Oracle Certifications .......................................................11

Oracle Certified Database Associate (OCA) ...................................12 Oracle Certified Database Professional (OCP).................................13 Oracle Certified Master Database Administrator (OCM) ...............14

Oracle9i DBA OCP Upgrade Path...............................................14 Other Recommend Classes ............................................................16 Preparing for the Oracle Certified Professional Exams ............17 Taking the Certification Exams.....................................................18 Finding Information Quickly – The Key to Success .................19

Reference Manuals ...........................................................................20 Oracle Internal Resources .................................................................21 External Resources ..........................................................................22 Book Recommendations ...................................................................23

Conclusion ........................................................................................25 Chapter 2 - Oracle Database Architectures ......................... 27

Oracle Database Architectures ......................................................27 Oracle on Microsoft Windows Platforms....................................28 Oracle on LINUX Platforms.........................................................30 Oracle on Unix Platforms ..............................................................32 Database Architecture Comparison Worksheet .........................34 Venturing into the Great Unknown – New Database Architectures.....................................................................................36

Table of Contents v

Page 4: OCP Instructors Guide for Oracle DBA Certification Manager ... Finding Problem Queries ... OCP Instructors Guide for Oracle DBA Certification Christopher Foot

Conclusion ........................................................................................36 Chapter 3 - Review Meetings............................................... 38

Oracle Database Design Review Meetings ..................................38 Initial Overview of Proposed System...........................................40 Logical Data Model Review ...........................................................41 Designing for Performance............................................................42 Setting up a Successful Test System in Oracle ............................44 Monitoring Performance During Testing ....................................45 Performance Design Reviews ........................................................46 Preparation for Production Turnover ..........................................48 Post Production Turnover .............................................................49 Oracle Database Design Review Meetings – Conclusion .........50 Conclusion ........................................................................................50

Chapter 4 - Oracle Database Administration....................... 52 Oracle Software Installation...........................................................52 Migrating to Newer Oracle Releases ............................................53 UNIX and LINUX Semaphores and Shared Memory ..............56

Semaphores......................................................................................56 Shared Memory ...............................................................................59

Relinking Oracle8i and Oracle9i Products...................................60 Windows Services ............................................................................61 Oracle Instance Administration ....................................................62 Oracle9i Persistent Initialization Parameter Files .......................63 Remote Startup/Shutdown ............................................................66 Multiple Buffer Pools......................................................................68 Specifying Default, Keep and Recycle Bufferpools in Oracle8 and Oracle8i......................................................................................69 Specifying Default, Keep and Recycle Bufferpools in Oracle9i70 Large Pool.........................................................................................70 Java Pool ...........................................................................................71 Redo log Buffer Performance........................................................71 Buffer Performance is critical to Good Oracle Performance...72 DBWR_IO_SLAVES vs DB_WRITER_PROCESSES ..........73

vi OCP Instructors Guide

Page 5: OCP Instructors Guide for Oracle DBA Certification Manager ... Finding Problem Queries ... OCP Instructors Guide for Oracle DBA Certification Christopher Foot

Conclusion ........................................................................................75 Chapter 5 - Oracle Database Objects .................................. 76

What Database Are You Working In? .........................................76 Choosing a Database Block Size ...................................................77 Copying Databases Between Servers............................................79 Oracle Tablespaces ..........................................................................82

Temporary Tablespaces ....................................................................82 Create Tablespace Temporary vs. Create Temporary Tablespace .......84

Partitioning .......................................................................................85 Oracle 8 - Range Partitioning ........................................................87 Index Partitioning ............................................................................88 Equi-Partitioned Objects................................................................89 Local Indexes....................................................................................89 Global Indexes .................................................................................90 Oracle8i – Hash and Range/Hash Composite Partitioning .....90

Hash Partitioning............................................................................90 Combining Range and Hash Partitioning – Range/Hash Composite Partitioning .....................................................................................91

Oracle9i – List and Range/List Composite Partitioning...........91 List Partitioning ..............................................................................91 Range/List Composite Partitioning .................................................92

Which Partitioning Technique Do I Choose?.............................93 Oracle9i Tablespace Changes ........................................................95 Locally Managed System Tablespaces ........................................100 Rollback Segments.........................................................................101

When is the System Rollback Segment Used?.................................102 Rollback Segments and Transaction Processing Workloads ............102

Batch and On-line Processing .....................................................103 Rollback Segments and Users – Who’s Using What? ..............104 Oracle9i - Database Managed Undo Segments.........................105 Redo Logs .......................................................................................107 Checkpoint Not Complete...........................................................108 Resizing Redo Logs .......................................................................110

Table of Contents vii

Page 6: OCP Instructors Guide for Oracle DBA Certification Manager ... Finding Problem Queries ... OCP Instructors Guide for Oracle DBA Certification Christopher Foot

Oracle Tables and Indexes ...........................................................112 Space Utilization for Parallel Table Creates...............................112 Index-only Tables ..........................................................................112 Single Table Hash Clusters...........................................................114 Oracle9i External Tables ..............................................................116 ALTER TABLE MOVE Statement...........................................119

ALTER COLUMN RENAME.............................................120 On-Line Table Reorganizations ..................................................120 PCTFREE and PCTUSED..........................................................124 Clustering Data in Tables .............................................................124 Merging Tables to Increase Query Performance......................124 How Many Indexes Can I Build? ................................................125 Parameters that Impact Index Usage..........................................127 Index-Only Access ........................................................................128 Index Rebuilds ...............................................................................130 Index Coalesce vs Index Rebuild ................................................130 Function-Based Indexes ...............................................................133 Bitmap Indexes ..............................................................................134 Optimizer and Bitmap Indexes ...................................................135 Concurrency and Bitmap Indexes...............................................135 When to Use Bitmap Indexes......................................................136 Bitmap vs B-Tree...........................................................................137 Indexing Hints Tips and Tricks...................................................138 Index Monitoring...........................................................................139 Conclusion ......................................................................................141

Chapter 6 - Oracle Backup and Recovery...........................143 It’s the Little Things That Bite You............................................143 Keep Your Skills Sharp.................................................................143 RELAX and Plan Your Attack...................................................144 Don’t Be Afraid to Ask Others ...................................................144 Instance Recovery and the Oracle Synchronization Process..145

Uncommitted Data on the Data Files............................................146 Committed Data Not On the Data Files.......................................147

viii OCP Instructors Guide

Page 7: OCP Instructors Guide for Oracle DBA Certification Manager ... Finding Problem Queries ... OCP Instructors Guide for Oracle DBA Certification Christopher Foot

The Synchronization Process ..........................................................147 Roll Forward Phase.......................................................................147 Roll Backward Phase ....................................................................148

Exports and Recovery...................................................................148 V$RECOVERFILE......................................................................148 Watch the NOLOGGING Option............................................149 Striped File Systems.......................................................................149 Data Files and Redo Logs ............................................................149 Redo Log and Control File Multiplexing ...................................150 OCOPY for Windows ..................................................................150 Hot Backup Scripts for Windows ...............................................150 Hot Backup Scripts for UNIX ....................................................151 Oracle9i – Lazy Checkpointer .....................................................154 Recovery Manager .........................................................................156

Recovery Catalog............................................................................157 Recovery Manager Backup Types ...................................................158

Backup Sets ...........................................................................158 Image Copies.........................................................................159

Parallel Backup and Recovery ........................................................159 Multiplexed Backup Sets...............................................................159 Backup/Recovery Reports ..............................................................160 Database Recovery .........................................................................160 RMAN Examples .......................................................................160

db_verify ............................................................................................162 Conclusion ......................................................................................162

Chapter 7 - Tuning and Performance .................................165 Be careful with the ANALYZE command ...............................165 Finding Problem Queries .............................................................166 Optimizer Plan Stability................................................................167 Pinning Objects in the Shared Pool............................................169 PCTFREE and PCTUSED..........................................................170 Caching Tables ...............................................................................170 Clustering Data in Tables .............................................................170

Table of Contents ix

Page 8: OCP Instructors Guide for Oracle DBA Certification Manager ... Finding Problem Queries ... OCP Instructors Guide for Oracle DBA Certification Christopher Foot

Merging Tables to Increase Query Performance......................171 Hints ................................................................................................171 Parallel Hints ..................................................................................172 Performance Testing .....................................................................172 Parallel Query .................................................................................173 Tuning Oracle on Windows.........................................................173 Tuning Pack....................................................................................173 Direct Load Inserts........................................................................174 Parallel DML Processing ..............................................................175 Materialized Views.........................................................................177 Database Resource Management ................................................178 STATSPACK .................................................................................179 V$ TABLES vs. Oracle BSTAT/ESTAT and STATSPACK181 Segment-Level Performance Statistics Collection ....................181 Performance Tuning Intelligent Advisories ..............................183 Optimizer Dynamic Sampling .....................................................184 Data Segment Compression.........................................................186 Using Explain Pan to Determine Access Paths ........................187 Explain Plan Output .....................................................................190 SQL*PLUS AUTOTRACE.........................................................191 High Water Mark and Table Scans .............................................192 Allocating too Much Memory to the Shared Pool and Data Buffers .............................................................................................193 Conclusion ......................................................................................194

Chapter 8 - Miscellaneous Oracle Information ..................196 The Foot Rule of Thumb.............................................................196 Monitor By Day So You Don’t Get Called at Night ...............197 Monitoring Space Utilization and Performance Statistics Historically ......................................................................................199 Latches and Enqueues ..................................................................201 Deadlock Detection ......................................................................202 Unindexed Foreign Keys and Locking Problems.....................203 Using PUPBLD .............................................................................206

x OCP Instructors Guide

Page 9: OCP Instructors Guide for Oracle DBA Certification Manager ... Finding Problem Queries ... OCP Instructors Guide for Oracle DBA Certification Christopher Foot

Copying databases between servers ............................................207 Oracle9i - Resumable Space Allocation .....................................207 Oracle9i – Flashback Query.........................................................209 Full Database Exports ..................................................................213 Large Table Imports......................................................................214 Compressing Export Output Files in UNIX ............................214 Terminating Oracle Processes (Threads) in Windows Systems ............................................................................................214 Truncating vs Deleting..................................................................215 Copy Command in SQL*PLUS ..................................................215 Displaying Time in Milliseconds .................................................215 !, $ and Host Command Differences..........................................216 Learn Command Line BEFORE Using "Sissy GUI Tools" Like Oracle Enterprise Manager ..........................................................216 Don’t Write Scripts........................................................................216 Don’t’ Write Iterative SQL Statements – Generate SQL with SQL..................................................................................................216 Input Truncated to 9 Characters .................................................217 Conclusion ......................................................................................217

Chapter 9 - Evaluating Third-Party Products.................... 220 Initial Analysis ................................................................................220 Determine Impact to the Information Technology Support Infrastructure..................................................................................221 Analysis Evaluation .......................................................................222 Obtain Business Unit and IT Management Commitment ......223 Create Evaluation Team ...............................................................224 Locate Potential Vendors .............................................................225 Initial Elimination..........................................................................225 Vendor Evaluation ........................................................................227 Communicate Results ...................................................................228 Conclusion ......................................................................................229

Chapter 10 - Ease of Administration...................................231 Good Documentation is Essential..............................................231

Table of Contents xi

Page 10: OCP Instructors Guide for Oracle DBA Certification Manager ... Finding Problem Queries ... OCP Instructors Guide for Oracle DBA Certification Christopher Foot

Follow OFA Naming Conventions ............................................235 Proceduralize Administrative Support for the Application Development Process ...................................................................236 Proceduralize the Change Request Process ...............................236 Create and Standardize Monitoring and Administration Scripts ..............................................................................................239 Repeatable Processes.....................................................................239 Create Service Level Agreements................................................240 DBA Report Cards and the 360-Degree Review Process .......240 Corrective Action Reports ...........................................................241 Conclusion ......................................................................................241

Chapter 11 - Oracle Database Security............................... 243 Protecting Data Requires More than just Protecting the Production Database.....................................................................243 Identifying Granted Privileges .....................................................244 Accounts Created During Database Creation...........................246 Wrapping PL/SQL Programs......................................................248 Using OPS$ Accounts ..................................................................249 Using Security Profiles ..................................................................250 SYS and SYSTEM Passwords .....................................................251 GRANT ANY OBJECT Privilege..............................................252 Administrative User Auditing ......................................................253 Moving the AUD$ Table..............................................................254 Conclusion ......................................................................................255

Chapter 12 - Certification Test Preparation ....................... 257 Introduction....................................................................................257 Oracle Certified Associate Tests .................................................258

Exam 1Z0-007 – Introduction to Oracle9i SQL.........................258 Exam 1Z0-031 – Oracle Database Fundamentals I ....................260

Oracle Certified Professional Tests ............................................267 Exam 1Z0-032 – Oracle Database Fundamentals II ..................267 Exam 1Z0-033 – Oracle Database Performance Tuning..............275

Conclusion ......................................................................................280

xii OCP Instructors Guide

Page 11: OCP Instructors Guide for Oracle DBA Certification Manager ... Finding Problem Queries ... OCP Instructors Guide for Oracle DBA Certification Christopher Foot

Book Conclusion ...........................................................................281 Index .................................................................................. 283 About the Author ............................................................... 286

Table of Contents xiii

Page 12: OCP Instructors Guide for Oracle DBA Certification Manager ... Finding Problem Queries ... OCP Instructors Guide for Oracle DBA Certification Christopher Foot

1 Getting Started CHAPTER

Why Become an Oracle Database Administrator? The Oracle database plays a strategic role in most organizations. Over time, Oracle has evolved and advanced from its humble beginnings as a pure data storage system to a point where it can be currently classified as an application-processing environment that is able to store physical data, business rules and executable business logic. The Oracle database’s area of influence has expanded to where it is now the heart of the modern IT infrastructure. Oracle also provides the communication programs for the client, middle-tier applications and database server. The entire application (data, business rules, executable business logic, database and system monitoring) can now being controlled by the Oracle database engine. The Oracle environment of the future will have a thorough understanding of complicated business rules and configure itself automatically to changing data access patterns. Oracle will continue to push the envelope by integrating advanced technologies into its database engine, offering challenging and rewarding careers to database administrators of the future. Database Administrators (DBAs) are responsible for designing, administering and securing the enterprise’s database data stores. As a result, the DBA plays a pivotal role in the organization. The DBA is often seen as the "GOTO" technician because of their traditionally strong problem solving skills. In addition, the DBA is seen as the IT staff’s technical generalist because of the

Why Become an Oracle Database Administrator? 1

Page 13: OCP Instructors Guide for Oracle DBA Certification Manager ... Finding Problem Queries ... OCP Instructors Guide for Oracle DBA Certification Christopher Foot

working knowledge they have in many different facets of information technology: Data administration – The data administration role,

although important, is often undefined in many IT organizations. Those responsibilities, by default, are usually awarded to the shop’s database administration unit. Data administrators view data from the business perspective and must have an understanding of the business to be truly effective. DAs organize, categorize and model data based on the relationships between the data elements themselves and the business rules that govern them. Data administrators provide the framework for defining and interpreting data and its structure enabling the organization to share timely and accurate data across diverse program areas resulting in sound information-based decisions.

Operating system – The only folks that spend more time in the operating system than DBAs are the system administrators themselves. Database administrators must have an intimate knowledge of the operating systems and hardware platforms their databases are running on. DBAs automate many functions and are usually accomplished operating system scriptwriters. They have a strong understanding of operating system kernel parameters, disk and file subsystems, operating system performance monitoring tools and various operating system commands.

Networking – Database administrators are responsible for end-to-end performance management. End users don’t care where the bottleneck is, they just want their data returned quickly. DBAs need to have expertise in basic networking concepts, terminologies and technology to converse intelligently with LAN administrators.

2 OCP Instructors Guide