9
Rampant TechPress Oracle DBA made simple Oracle database administration techniques Mike Ault

Oracle DBA Made Simple - DedicatedTeacher.com · Oracle DBA made simple Oracle database administration techniques ... Rollback Segments ... network related configuration. 2

  • Upload
    lenhi

  • View
    233

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Oracle DBA Made Simple - DedicatedTeacher.com · Oracle DBA made simple Oracle database administration techniques ... Rollback Segments ... network related configuration. 2

Rampant TechPress

Oracle DBA made simple Oracle database administration techniques

Mike Ault

Page 2: Oracle DBA Made Simple - DedicatedTeacher.com · Oracle DBA made simple Oracle database administration techniques ... Rollback Segments ... network related configuration. 2

ROBO BOOKS MONOGRAPH DATABASE ADMINISTRATION

RAMPANT TECHPRESS EBOOK PAGE III

Oracle DBA made simple Oracle database administration techniques By Mike Ault Copyright © 2003 by Rampant TechPress. All rights reserved. Published by Rampant TechPress, Kittrell, North Carolina, USA Series Editor: Don Burleson Production Editor: Teri Wade Cover Design: Bryan Hoff Oracle, Oracle7, Oracle8, Oracle8i, and Oracle9i are trademarks of Oracle Corporation. Oracle In-Focus is a registered Trademark of Rampant TechPress. 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, 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. Visit www.rampant.cc for information on other Oracle In-Focus books. ISBN: 0-9740716-5-X

COPYRIGHT © 2003 RAMPANT TECHPRESS. ALL RIGHTS RESERVED.

Page 3: Oracle DBA Made Simple - DedicatedTeacher.com · Oracle DBA made simple Oracle database administration techniques ... Rollback Segments ... network related configuration. 2

ROBO BOOKS MONOGRAPH DATABASE ADMINISTRATION

RAMPANT TECHPRESS EBOOK PAGE IV

Table Of Contents Notice............................................................................................. ii

Publication Information .............................................................. iii

Table Of Contents ........................................................................ iv

Introduction ................................................................................... 1

System Planning ........................................................................... 1 Resource and Capacity Planning ......................................................... 2

Resource Specification for Oracle .................................................. 2 Optimal Flexible Architecture (OFA) ................................................. 7

Minimum OFA Configuration ........................................................ 8 Oracle Structures and How They Affect Installation ........................ 10

Executables ................................................................................... 11 Data Files ...................................................................................... 11 Redo Logs ..................................................................................... 12 Control Files.................................................................................. 12 Exports .......................................................................................... 13 Archive Logs................................................................................. 13 LOB Storage ................................................................................. 14 BFILE Storage .............................................................................. 14

Disk Striping, Shadowing, RAID, and Other Topics ........................ 14 Disk Striping ................................................................................. 15 Disk Shadowing or Mirroring....................................................... 16 RAID—Redundant Arrays of Inexpensive Disks......................... 17

New Technologies ............................................................................. 18 Optical Disk Systems.................................................................... 18 Tape Systems ................................................................................ 19 RAM Drives (Random Access Memory) ..................................... 19

Backup & recovery ..................................................................... 20

COPYRIGHT © 2003 RAMPANT TECHPRESS. ALL RIGHTS RESERVED.

Page 4: Oracle DBA Made Simple - DedicatedTeacher.com · Oracle DBA made simple Oracle database administration techniques ... Rollback Segments ... network related configuration. 2

ROBO BOOKS MONOGRAPH DATABASE ADMINISTRATION

RAMPANT TECHPRESS EBOOK PAGE V

Backups.............................................................................................. 21 Cold Backups ................................................................................ 21 Hot Backups.................................................................................. 23 Example Documentation Procedure for NT Online Backup and Recovery Scripts ........................................................................... 48

Imports/Exports ................................................................................. 51 Limitations on export/import: ...................................................... 51 Exports .......................................................................................... 51 IMPORT ....................................................................................... 53

Archive Logs ..................................................................................... 54

Backup Methodologies ...................................................................... 56 NT or UNIX System Backup........................................................ 56 Import/Export ............................................................................... 57 Archive Logging ........................................................................... 57

Recovery Types ................................................................................. 57

Oracle7 Enterprise Backup Utility..................................................... 59

Oracle8 RECOVERY MANAGER FACILITY................................ 63 Installing the RMAN Catalog ....................................................... 66 Incomplete restore scenario .......................................................... 69

DB_VERIFY UTILITY..................................................................... 71 The following example shows how to get on-line help: ............... 72

The DBMS_REPAIR Utility ............................................................. 73 DBMS_REPAIR Enumeration Types........................................... 74 DBMS_REPAIR Exceptions ........................................................ 74 DBMS_REPAIR Procedures ........................................................ 75 ADMIN_TABLES........................................................................ 76 CHECK_OBJECT ........................................................................ 81 DUMP_ORPHAN_KEYS ............................................................ 84 FIX_CORRUPT_BLOCKS.......................................................... 85 REBUILD_FREELISTS............................................................... 86 SKIP_CORRUPT_BLOCKS........................................................ 88

Oracle RDBMS Architecture............................................................. 89 Background Processes .................................................................. 90

COPYRIGHT © 2003 RAMPANT TECHPRESS. ALL RIGHTS RESERVED.

Page 5: Oracle DBA Made Simple - DedicatedTeacher.com · Oracle DBA made simple Oracle database administration techniques ... Rollback Segments ... network related configuration. 2

ROBO BOOKS MONOGRAPH DATABASE ADMINISTRATION

RAMPANT TECHPRESS EBOOK PAGE VI

Datafiles ........................................................................................ 94 Datafile Sizing ................................................................................... 96

Rollback Segments...................................................................... 102 Redo log files .............................................................................. 104 Control files ................................................................................ 105 Initialization File......................................................................... 105 The Undocumented Initialization Parameters (“_”) ................... 126 The Initialization File Event Settings ......................................... 145

System Global Area......................................................................... 157 SGA............................................................................................. 157 Modifying the INIT.ORA ........................................................... 158 Allocating And Caching Memory............................................... 159 Use of the Default Pool............................................................... 159 Use of The KEEP Pool ............................................................... 160 Use of the RECYCLE Pool......................................................... 160 Tuning the Three Pools............................................................... 161 Shared Pool ................................................................................. 162

Putting it All In Perspective............................................................. 180 What to Pin ................................................................................. 185 The Shared Pool and MTS.......................................................... 190 Large Pool Sizing........................................................................ 191 A Matter Of Hashing .................................................................. 194 Disk IO and the Shared Pool....................................................... 198 Monitoring Library and Data Dictionary Caches ....................... 201 In Summary................................................................................. 204

Managing the Database.................................................................... 209 Find USER locking others/Kill problem USER ......................... 209

Methods of Murder .......................................................................... 213 Killing From the Oracle Side...................................................... 213 Killing From the Operating System Side.................................... 215 Creating and starting the database .............................................. 215

Database Creation............................................................................ 216

Re-creation of a Database................................................................ 219

Database Startup and Shutdown ...................................................... 229

COPYRIGHT © 2003 RAMPANT TECHPRESS. ALL RIGHTS RESERVED.

Page 6: Oracle DBA Made Simple - DedicatedTeacher.com · Oracle DBA made simple Oracle database administration techniques ... Rollback Segments ... network related configuration. 2

ROBO BOOKS MONOGRAPH DATABASE ADMINISTRATION

RAMPANT TECHPRESS EBOOK PAGE VII

Startup......................................................................................... 230 Shutdown .................................................................................... 232

Tuning Responsibilities ................................................................... 234 Step 1: Tune the Business Rules................................................. 234 Step 2: Tune the Data Design ..................................................... 234 Step 3: Tune the Application Design.......................................... 235 Step 4: Tune the Logical Structure of the Database ................... 235 Step 5: Tune Database Operations.............................................. 235 Step 6: Tune the Access Paths .................................................... 236 Step 7: Tune Memory Allocation ............................................... 236 Step 8: Tune I/O and Physical Structure..................................... 237 Step 9: Tune Resource Contention ............................................. 238 Step 10: Tune the Underlying Platform(s).................................. 238 Tuning Summary ........................................................................ 238

Layout & Fragmentation.................................................................. 239 Tablespace Segments & Free Space ........................................... 241 Tables & Indexes/Partitioning .................................................... 242

The V$ views................................................................................... 243 How are they used?..................................................................... 244

The Optimizers & the Analyze Command ...................................... 248 RULE Based Optimizer .............................................................. 249 COST Based Optimizer .............................................................. 250

The Parallel Query Option............................................................... 253 Parallel query settings ................................................................. 253

Problems In Parallel Query Usage................................................... 258

Security ............................................................................................ 258 Users ........................................................................................... 258 Altering Users ............................................................................. 264 Dropping Users ........................................................................... 265

Grants............................................................................................... 266 System Privileges........................................................................ 267 Object Privileges......................................................................... 276 Column Privileges....................................................................... 281

COPYRIGHT © 2003 RAMPANT TECHPRESS. ALL RIGHTS RESERVED.

View Grants ................................................................................ 283

Page 7: Oracle DBA Made Simple - DedicatedTeacher.com · Oracle DBA made simple Oracle database administration techniques ... Rollback Segments ... network related configuration. 2

ROBO BOOKS MONOGRAPH DATABASE ADMINISTRATION

RAMPANT TECHPRESS EBOOK PAGE VIII

Other Grants................................................................................ 283 Revoking Grants .............................................................................. 283

Use Of Roles.................................................................................... 285 Creating Roles............................................................................. 286

Grants To Roles ............................................................................... 287

Setting Roles.................................................................................... 289

Special Roles ................................................................................... 290 OSOPER And OSDBA............................................................... 292 CONNECT, RESOURCE, And DBA Roles .............................. 293 Export/Import Roles.................................................................... 294 Using PROFILES........................................................................ 295

Profiles and Resource Limits........................................................... 297 Altering Profiles.......................................................................... 300 Profiles and Passwords ............................................................... 301

Managing CPU Utilization for in Oracle8i...................................... 303 Creating a Resource Plan ............................................................ 304

Restricting Access by Rows in Oracle8i ......................................... 329 Policy Usage ............................................................................... 335 DBMS_RLS Package.................................................................. 337

Summary.................................................................................... 340

COPYRIGHT © 2003 RAMPANT TECHPRESS. ALL RIGHTS RESERVED.

Page 8: Oracle DBA Made Simple - DedicatedTeacher.com · Oracle DBA made simple Oracle database administration techniques ... Rollback Segments ... network related configuration. 2

DATABASE ADMINISTRATION ROBO BOOKS MONOGRAPH DATABASE ADMINISTRATION

RAMPANT TECHPRESS EBOOK PAGE 1

Introduction Database Administration has grown over the years from the mere management of a few tables and indexes to a complex interlocking set of responsibilities ranging from managing database objects to participating in enterprise wide decisions on hardware, software and development tools. In order to fully perform these functions the modern Oracle DBA needs a large skill set. Over the next few hours we will discuss the skills needed and specifically how they apply to an Oracle DBA.

System Planning In a green field operation (one where you are there before the equipment and database) a DBA will have a critical part to play in the planning and configuration of the new system. Even in existing environments the ability to plan for new servers, new databases or improvements to existing databases and systems is critical. Essentially the DBA must concern themselves with two major issues:

1. Get enough server to insure adequate performance 2. Allow for enough backup and recovery horsepower to get

backup and recovery performed within the required time constraints.

All of this actually falls under the topic resource and capacity planning.

COPYRIGHT © 2003 RAMPANT TECHPRESS. ALL RIGHTS RESERVED.

Page 9: Oracle DBA Made Simple - DedicatedTeacher.com · Oracle DBA made simple Oracle database administration techniques ... Rollback Segments ... network related configuration. 2

DATABASE ADMINISTRATION ROBO BOOKS MONOGRAPH DATABASE ADMINISTRATION

RAMPANT TECHPRESS EBOOK PAGE 2

Resource and Capacity Planning Oracle is a resource intensive database system. The more memory, CPU and disk resources you can provide Oracle, the better it performs. Resource planning with Oracle becomes more a game of "how much can we afford to buy" instead of "what is the minimum configuration". A minimally configured Oracle server will not function in an efficient manner.

Resource Specification for Oracle

In resource specification there are several questions that must be answered. 1. How many users will be using the system both now and in the

future? 2. How much data will the system contain both now and in the

future, do we know growth rates? 3. What response times are expected? 4. What system availability is expected? Why are these questions important? 1. How many users will be using the system both now and in the

future?

This question is important because it effects how much processing power is going to be required. The number of users will determine number and speed of CPUs, size of memory, network related configuration.

2. How much data will the system contain both now and in the

future, do we know growth rates?

COPYRIGHT © 2003 RAMPANT TECHPRESS. ALL RIGHTS RESERVED.