Oracle DBA on Unix and Linux
Michael Wessler
800 East 96th St., Indianapolis, Indiana, 46240 USA
Oracle DBA on Unix and Linux
ASSOCIATE PUBLISHER
Copyright © 2002 by Sams
Jeff Koch
All rights reserved. No part of this book shall be reproduced, stored in a
retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information
contained herein. Although every precaution has been taken in the preparation
of this book, the publisher and author assume no responsibility for errors or
omissions. Nor is any liability assumed for damages resulting from the use of
the information contained herein.
ACQUISITIONS EDITOR
International Standard Book Number: 0-672-32158-0
Natalie F. Harris
Library of Congress Catalog Card Number: 2001089580
COPY EDITOR
Printed in the United States of America
Kezia Endsley
First Printing: November 2001
Second Printing with corrections: April 2002
INDEXER
06
PROOFREADER
05
04
7
6
5
4
Kathryn Purdum
DEVELOPMENT EDITOR
Kevin Howard
MANAGING EDITOR
Matt Purcell
PROJECT EDITOR
Erika Millen
Trademarks
Jody Larsen
All terms mentioned in this book that are known to be trademarks or service
marks have been appropriately capitalized. Sams cannot attest to the accuracy
of this information. Use of a term in this book should not be regarded as
affecting the validity of any trademark or service mark.
TECHNICAL EDITORS
Warning and Disclaimer
Vicki Harding
Denni Bannister
Every effort has been made to make this book as complete and as accurate as
possible, but no warranty or fitness is implied. The information provided is on
an “as is” basis. The author and the publisher shall have neither liability nor
responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book.
Jim Kotan
Paul Love
TEAM COORDINATOR
INTERIOR DESIGNER
Dan Armstrong
COVER DESIGNER
Aren Howell
Bulk Sales
PAGE LAYOUT
Sams Publishing offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales. For more information, please contact
Lizbeth Patterson
Heather Stephenson
U.S. Corporate and Government Sales
1-800-382-3419
For sales outside of the U.S., please contact
International Sales
1-317-428-3341
Contents at a Glance
Introduction 1
1
Role of the DBA 5
2
Architecture of the Oracle Server 29
3
Planning a Database 63
4
Machine Setup and Installation
5
Creating a Database 111
6
Daily Activities
7
GUI Management Products 175
8
DBA Utilities
9
Backup and Recovery
87
139
203
237
10
When Things Go Wrong 271
11
Oracle Server Tuning 293
12
Unix Operation System Architecture 321
13
Unix Server Monitoring 341
14
Patches and Upgrades
15
Migrations 395
16
Java Inside the Database Server 417
17
Web DB/Oracle Portal
18
Internet Application Server (iAS) 463
19
9i Server New Features 485
20
Growth of the DBA 511
A
Basic Unix Commands
B
vi Editor
C
Scripts
D
Glossary 543
Index
533
537
551
373
437
525
Contents
Introduction
1
Who Should Read This Book? ..........................................................2
What Makes This Book Different? ..................................................3
1
Role of the DBA
5
What Is a DBA? ......................................................................................6
Depends on the Shop ........................................................................6
Where DBAs Come From ................................................................6
Paths to Becoming a DBA ................................................................7
System Administrator (SA) ..............................................................7
Developer/Programmer ....................................................................7
Systems Designer/Data Modeler ......................................................8
Other Paths ........................................................................................8
Types of DBAs ........................................................................................8
Application DBA ..............................................................................8
Systems DBA ....................................................................................8
Maintenance DBA ............................................................................9
Database Administration Principles ........................................................9
Data Protection ..................................................................................9
Data Availability ..............................................................................11
Database Administration Responsibilities ..........................................12
Database Technical Responsibilities ..............................................12
Non-Technical Responsibilities ......................................................16
Skills Needed ..................................................................................18
Roles Within the IT Organization ........................................................22
System Administrators ....................................................................22
Programmers/Developers ................................................................24
Management ....................................................................................24
Customers and End Users ..............................................................25
Outside Organizations ....................................................................26
DBA Mindset ........................................................................................26
Summary ..............................................................................................27
2
Architecture of the
Oracle Server
29
Oracle Products Relating to Database Servers ....................................30
SQL*Plus ........................................................................................31
Server Manager ..............................................................................32
Net8 ................................................................................................32
Oracle DBA on Unix and Linux
Database Versus Instance ......................................................................33
Oracle File Types ..................................................................................34
Control Files ....................................................................................34
Data Files ........................................................................................35
System ............................................................................................36
Data ..................................................................................................36
Index ................................................................................................37
Temp ................................................................................................38
Rollback ..........................................................................................38
Online Redo Logs ............................................................................40
Memory Structures ..............................................................................42
Shared Global Area (SGA) ..............................................................42
Shared Pool ......................................................................................46
Redo Log Buffer ..............................................................................47
Large Pool ......................................................................................48
Java Pool ..........................................................................................48
Oracle Processes ..................................................................................49
Server Processes ..............................................................................50
Background Processes ....................................................................52
System Monitor Process (SMON) ..................................................53
Process Monitor Process (PMON) ..................................................53
Database Writer Process (DBWn) ..................................................53
Log Writer Process (LGWR) ..........................................................54
Checkpoint Process (CKPT) ..........................................................55
Archiver Process (ARCn) ................................................................56
Recover Process (RECO) ................................................................56
Job Queue Processes (SNPnn) ........................................................56
Queue Monitor Processes (QMNnn) ..............................................56
Dispatcher Processes (Dnnn) ..........................................................56
Shared Server Processes (Snnn) ......................................................56
Transaction Control ..............................................................................57
Miscellaneous Database Files ..............................................................59
Oracle Database Parameter and Log Files ......................................59
Summary ..............................................................................................62
3.
Planning a Database
63
System Architecture ..............................................................................64
Two-Tier Basic Client Server Architecture (2 Tier) ........................65
Three-Tier Client Server Architecture ............................................66
Capacity Planning/Sizing ......................................................................67
Optimal Flexible Architecture ..............................................................71
v
582
Unix
filesystems
ext2, 332
free space, 332
iso9660, 333
mount points, 331
mounting, 331-332
nfs, 332
problem solving, 333-334
ufs, 332
unmounting, 333
vxfs, 333
I/O subsystem, 335
kernel, 322-323
memory
pages, 329
paging, 329-330
swap area, 328
swapping, 329-330
thrashing, 329
virtual memory, 328
monitoring, 342-343
CPUs, 362-367
disk I/O, 356-361
importance of, 342
memory, 354-356
network performance,
368-371
shared memory, 344-353
MPPs (Massively Parallel
Processors), 340
NUMAs (NonUniform Memory
Access), 340
processes, 323
creating, 326
initialized data, 325
multitasking, 323
parent processes, 326
priorities, 324
process tables, 324
RT (Real Time), 324
scheduler process, 324
stack, 325
states, 325
SYS (System), 324
text area, 325
TS (Time Share), 324
viewing, 327
shared-everything architecture,
338
shared-nothing architecture,
340
shutdown process, 337
SMP (symmetrical multiprocessor) machines, 338
startup process
run levels, 336
sequence of events, 335-336
uniprocessor machines, 337-338
unmounting filesystems, 333
updating SPFILEs (server
parameter files), 492-493
upgrades
defined, 374-375
example, 388-391
import/export commands, 402
installing, 386-388
ORACLE_HOME directory,
386-387
parameter files, 388
preparation, 385-386
tips and recommendations, 391392
upgrade scripts, 387
when to perform, 375-376
uptime command, 276,
365-366, 530
user dump (udump) files, 74
User Global Area (UGA), 49
user interfaces
Net8, 32-33
Server Manager, 32
SQL*Plus, 31
user-level exports, 205-206
useradd command, 94
USERID export parameter, 206
USERID import parameter, 212
users, 25
creating, 94, 149
groups
creating, 93-94
oinstall, 94
killing, 146, 367
logged-in users, displaying, 531
logging off, 527
MIGRATE, 406
OUTLN, 406
privileges, 149-150
quotas, 151-152
roles, 151, 449-450
USER_X view, 140
utilities. See commands; scripts
UTLBSTAT script, 296-298
UTLESTAT script, 296-298
V
V$ view, 140
V$SESSION_EVENT view,
310-311
V$SESSION_WAIT view, 311
V$SYSTEM_EVENT view, 310
/var/opt/oracle directory, 96
variables, environment
CLASSPATH, 100
DISPLAY, 100-101
displaying, 527
LD_LIBRARY_PATH, 99
NLS_LANG, 99
ORACLE_BASE, 99
ORACLE_HOME, 99
ORACLE_SID, 99
ORA_NLS33, 99
PATH, 100
vendors, capacity-planning
issues, 71
verifying
database instances, 125-127
databases and connectivity,
163-164
Intelligent Agents, 188
Oracle installation, 107-108
Veritas filesystem (vxfs), 333
vi editor, 534
viewing. See displaying
views, 140-141
obtaining descriptions of, 141
obtaining list of, 141
V$SESSION_EVENT, 310-311
Zombie state
V$SESSION_WAIT, 311
V$SYSTEM_EVENT, 310
virtual memory, 328
vmstat command, 355-356, 531
CPU usage statistics, 366
disk I/O monitoring, 361
vxfs (Veritas) filesystem, 333
W
w command, 535
wait events, 309-310
V$SESSION_EVENT view,
310-311
V$SESSION_WAIT view, 311
V$SYSTEM_EVENT view, 310
wall command, 531
wc command, 531
Web architecture, 464-466
availability, 468
clients, 465
database tier, 465
middle tier, 465
scalability, 467-468
technological design, 467
Web cache (iAS), 471-472
Web servers. See servers
Web sites
Java, 420
MetaLink, 378, 514
OCP (Oracle Certified
Professional) program, 517
Oracle University, 513
Perpetual Technologies, 17, 514
Technet, 514
WebDB. See Oracle Portal
WebLogic server, 466
which command, 531
who command, 531
word count, displaying, 531
wq command, 535
wraps (rollback segments), 308
X-Z
x command, 535
yy command, 535
Zombie state, 325
583