You are on page 1of 438

Oracle Database 10g: Managing

Oracle on Linux for DBAs

Student Guide
m y
d e
ca
e A
c l
r a
O ly
l & On
D46590GC11

n a e
Edition 1.1
April 2007

t e r U s
D49900

I n
c l e ®

r a
O
Authors Copyright © 2007, Oracle. All rights reserved.

Tom Best Disclaimer


S. Matt Taylor Jr. This document contains proprietary information and is protected by copyright and
other intellectual property laws. You may copy and print this document solely for your
Technical Contributors own use in an Oracle training course. The document may not be modified or altered in
any way. Except where your use constitutes "fair use" under copyright law, you may
and Reviewers not use, share, download, upload, copy, print, display, perform, reproduce, publish,
Maria Billings license, post, transmit, or distribute this document in whole or in part without the
express authorization of Oracle.
MJ Bryksa
Al Flournoy The information contained in this document is subject to change without notice. If you
Mark Fuller find any problems in the document, please report them in writing to: Oracle University,
Sush Jagannath 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not
warranted to be error-free.
Donna Keesling
Sergio Leunissen Restricted Rights Notice
Greg Marsden
Prasanth Narayanan If this documentation is delivered to the United States Government or anyone using
the documentation on behalf of the United States Government, the following notice is
Abhishek Singh applicable:
James Spiller
Herbert van den Bergh U.S. GOVERNMENT RIGHTS
Harald van Breederode The U.S. Government’s rights to use, modify, reproduce, release, perform, display, or
disclose these training materials are restricted by the terms of the applicable Oracle
James Womack license agreement and/or the applicable U.S. Government contract.

Editor Trademark Notice


Amitha Narayan
Oracle, JD Edwards, PeopleSoft, and Siebel are registered trademarks of Oracle
Corporation and/or its affiliates. Other names may be trademarks of their respective
Graphic Designers owners.

Satish Bettegowda
Samir Mozumdar
m y
Publishers
d e
Sujatha Nagendra
Nita Brozowski
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Contents

Preface

1 Introduction
Objectives 1-2
Suggested Course Schedule 1-3
Supported Linux Distributions 1-4
Linux Distribution: Overview 1-5
Linux Packages 1-6
Linux Kernel 1-7
Verifying the Kernel 1-8
Interpreting the Linux Kernel Version Number 1-9
A Tainted Linux Kernel 1-10
Checking for a Tainted Kernel 1-11
Supported Hardware 1-12
Common Linux Commands and Programs 1-13
m y
Navigating the File System 1-15
d e
The Virtual File System 1-16
Using the Virtual File System 1-17
ca
Bash Shell Scripting 1-18

e
Bash Shell Scripting: Environment Variables 1-19 A
c l
Redirecting Input and Output 1-21

r a
Bash Shell Scripting: Conditions 1-23
Bash Shell Scripting: case 1-24
O ly
Bash Shell Scripting: while 1-25

l & On
Bash Shell Scripting: In-List Syntax of for 1-26

Summary 1-28
n a e
Bash Shell Scripting: Controlled Loop Syntax of for 1-27

e r s
Practice 1 Overview: Working with Linux 1-29

t U
2
I n
Preparing Linux for Oracle

c l e
Objectives 2-2
Setting Kernel Parameters 2-3

r a Linux Shared Memory: Overview 2-6


Shared Memory Parameters for 32-Bit Linux 2-7

O Semaphores 2-9

iii
Setting Semaphore Parameters 2-10
Setting the File Handles Parameter 2-11
Setting Other Parameters 2-12
Shell Limits 2-13
Setting Shell Limits 2-15
Managing Packages 2-17
Required Software 2-19
Linux Patches 2-21
Configuring the X Window System 2-22
Testing the X Window System 2-23
Creating Groups 2-25
Creating and Viewing a Group 2-27
Creating the Oracle Software Owner 2-28
The nobody User 2-30
Summary 2-31
Practice 2 Overview: Preparing Linux for Oracle 2-32

3 Installing Oracle on Linux


Objectives 3-2
File System Security 3-3
m y
File Security Attributes 3-4
SETUID and SETGID Bits 3-5
d e
Choosing a Shell 3-6
ca
Setting Environment Variables 3-7
User File Creation Mask 3-8
e A
c l
Setting Oracle Environment Variables 3-9
Optimal Flexible Architecture 3-10
OFA Characteristics 3-11
r a
Mount Points 3-13
O ly
l & On
ORACLE_HOME and ORACLE_BASE 3-14
Creating the Oracle Directories 3-15

a e
Installing New Releases 3-16
n
t e r U s
Managing Multiple Versions 3-17
Setting Oracle Environment Variables 3-19

I n
Mounting the CD-ROM 3-21
Starting the Installer 3-22

l e
Oracle Universal Installer 3-23
c
r aInstallation Log Files 3-24
Prerequisite Check Results 3-25

O Oracle Patch Utility 3-26

iv
Oracle Relink Utility 3-28
Troubleshooting 3-30
Summary 3-31
Practice 3 Overview: Installing Oracle on Linux 3-32

4 Managing Storage
Objectives 4-2
Certified and Supported File Systems 4-3
Disk Partitioning 4-4
Comparing File Systems 4-6
File System Characteristics 4-7
Automatic Storage Management 4-9
ext2 and ext3 4-10
Oracle Clustered File System 2 4-11
Network File System 4-12
Summary 4-13

5 Automatic Storage Management and Automatic Storage Management Library


Driver
Objectives 5-2
m y
Automatic Storage Management 5-3
Automatic Storage Management Library Driver (ASMLib) 5-4
d e
Installing and Initializing ASMLib 5-5
ca
Configuring Disks 5-6

e
Marking Disks As Automatic Storage Management Disks 5-7A
Creating an ASM Instance 5-8
c l
r a
ASM and ASMLib Installation and Configuration Summary 5-9
ASM Installation: Best Practices 5-10

O ly
Disk Group: Best Practices 5-11
Summary 5-12

l & On
Practice 5 Overview: Installing and Configuring ASMLib and ASM 5-13

n a e
6

t e
Objectives 6-2 r
Creating the Database

U s
I n
Creating a Database 6-3
Choosing the Storage Mechanism 6-4

c l e
Specifying the ASM Disk Groups 6-5
Assigning ASM Disk Groups 6-6

r a dbca Log Files 6-7

O The Instance admin Directory 6-8

v
Parameter and Dump Files 6-9
The portlist.ini File 6-10
URL Deployment Information 6-11
Miscellaneous Files 6-12
Background Processes 6-13
Server Processes 6-15
Process Hierarchy 6-16
Implementing OS Authentication for DBAs 6-17
Summary 6-18
Practice 6 Overview: Creating a Database 6-19

7 Customizing Oracle on Linux


Objectives 7-2
Controlling Oracle Database 7-3
Linux Startup Sequence 7-4
Linux Runlevels 7-7
Database Startup and Shutdown 7-8
Administrative Scripts 7-10
Managing Services with chkconfig 7-12
Automating Jobs 7-13
m y
OS Scheduling Tools 7-14
d e
Job Capabilities of DB Console 7-16
Database Backups 7-17
ca
Backing Up with RMAN 7-18
Server Parameter File 7-19
e A
Summary 7-20
c l
a
Practice 7 Overview: Automating Tasks 7-21

r
8 Managing Memory
O ly
Objectives 8-2
Swap Space 8-3
l & On
Swap Cache 8-4
n a e
Sizing Swap Space 8-6
/proc/meminfo 8-7
t e r U s
I n
Evaluating Free Memory 8-8
Memory Terminology 8-9

l e
Page Address Extensions (PAE) 8-10
c
r aHugepages 8-11
Implementing Hugepages on 32-Bit Linux 8-12

O Implementing a Large SGA 8-14

vi
Standard Linux Memory Map 8-15
Modified Linux Memory Map 8-16
Altering the Linux Memory Map 8-17
Relocating the SGA 8-19
Relocating the Database Buffer Cache 8-20
hugemem Kernel 8-22
Summary 8-23
Practice 8 Overview: Managing Memory 8-24

9 Using Linux Measurement Tools


Objectives 9-2
Basic Tuning Methodology 9-3
Standard Measurement Tools 9-4
Linux Tools 9-6
Common Areas to Tune 9-8
Monitoring and Tuning CPU 9-9
Is the CPU a Bottleneck? 9-10
CPU Measurements 9-12
Measuring CPU Activity with vmstat 9-14
Interpreting CPU Measurements 9-17
m y
Reducing CPU Bottlenecks 9-19
Monitoring and Tuning Memory 9-20
d e
Measuring Memory Usage 9-21
c a
Measuring Total Memory 9-23
Measuring Memory with sar 9-25
e A
c l
Interpreting Memory Measurements 9-27

r a
Reducing Memory Bottlenecks 9-29
Monitoring and Tuning I/O 9-30

O ly
Is I/O a Bottleneck? 9-31
I/O Measurements 9-32

l & On
Measuring I/O with iostat 9-33

a e
Interpreting I/O Measurements 9-36
n
t
Summary 9-38
e r U s
Reducing I/O Bottlenecks 9-37

I n
Practice 9 Overview: Using Linux Measurement Tools 9-39

l e
10 Tuning Oracle on Linux
c
r a Objectives 10-2
Basic Oracle Database Optimizations 10-3

O Sizing Database Blocks 10-4

vii
LOG_BUFFER and Redo Log File 10-6
Advanced Features of Oracle Server 10-8
Multiple DBWR Processes 10-9
DB Writer Slaves 10-10
Changing SGA Behavior 10-11
Automatic Shared Memory Management 10-12
Basic Linux Optimizations 10-13
Choosing a Kernel 10-14
Summary 10-15
Practice 10 Overview: Tuning Performance 10-16

11 Dedugging Oracle on Linux


Objectives 11-2
OS Watcher 11-3
Installing OSW 11-4
Configuring OSW 11-5
Running OSW 11-6
Viewing OSW Output 11-7
Remote Diagnostics Agent 11-8
Installing the RDA 11-9
m y
Running the RDA 11-10
Viewing the RDA Output 11-11
d e
Navigating the RDA Output 11-12
ca
strace 11-13
ORA-600 Errors 11-15
e A
ORA-7445 Errors 11-16
c l
Summary 11-19
r a
Resolving ORA-600/ORA-7445 Errors 11-17

O ly
Practice 11 Overview: Debugging Oracle on Linux 11-20

Appendix A: Practices
l & On
a e
Appendix B: Practice Solutions
n
t e r U s
Appendix C: Basic Linux and vi Commands

Index
I n
c l e
r a
O
viii
Preface

m y
d e
ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
m y
d e
ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Profile
Before You Begin This Course
Before you begin this course, you should have working knowledge with
administering an Oracle database.
How This Course Is Organized
Oracle Database 10g: Managing Oracle on Linux for DBAs is an instructor-led
course featuring lectures and hands-on exercises. Online demonstrations and written
practice sessions reinforce the concepts and skills that are introduced.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Preface - 3
Related Publications
Oracle Publications
Title Part Number
Oracle® Database Administrator's Guide
10g Release 2 (10.2) B14231-02
Oracle® Database Installation Guide
10g Release 2 (10.2) for Linux x86 B15660-02
Oracle® Database Release Notes
10g Release 2 (10.2) for Linux x86 B15659-05
Additional Publications
• System release bulletins
• Installation and user’s guides
• Read-me files
• International Oracle User’s Group (IOUG) articles
• Oracle Magazine

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Preface - 4
Typographic Conventions
What follows are two lists of typographical conventions that are used specifically
within text or within code.
Typographic Conventions Within Text
Convention Object or Term Example
Uppercase Commands, Use the SELECT command to view
functions, information stored in the LAST_NAME
column names, column of the EMPLOYEES table.
table names,
PL/SQL objects,
schemas
Lowercase, Filenames, where: role is the name of the role
italic syntax variables, to be created.
usernames,
passwords
Initial cap Trigger and Assign a When-Validate-Item trigger to
button names the ORD block.
Choose Cancel.
Italic Books, names of
courses and
For more information on the subject see
Oracle SQL Reference
m y
manuals, and Manual
d e
emphasized
words or phrases
c a
Do not save changes to the database.
Quotation marks Lesson module
titles referenced
e A
This subject is covered in Lesson 3,
“Working with Objects.”
within a course
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Preface - 5
Typographic Conventions (continued)
Typographic Conventions Within Code
Convention Object or Term Example
Uppercase Commands, SELECT employee_id
functions FROM employees;
Lowercase, Syntax variables CREATE ROLE role;
italic
Initial cap Forms triggers Form module: ORD
Trigger level: S_ITEM.QUANTITY
item
Trigger name: When-Validate-Item
. . .
Lowercase Column names, . . .
table names, OG_ACTIVATE_LAYER
filenames, (OG_GET_LAYER ('prod_pie_layer'))
PL/SQL objects . . .
SELECT last_name
FROM employees;
Bold Text that must
be entered by a
./runInstaller
m y
user
d e
ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Preface - 6
Introduction

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Objectives

After completing this lesson, you should be able to:


• Interpret Linux kernel version information
• Identify a tainted kernel
• Use common Linux commands
• Write a simple bash shell script

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 2
Suggested Course Schedule

1: Introduction
2: Preparing Linux for Oracle
3: Installing Oracle on Linux
4: Managing Storage
5: Automatic Storage Management
6: Creating the Database

7: Customizing Oracle on Linux


8: Managing Memory
9: Using Linux Measurement Tools
10: Tuning Performance
11: Debugging Oracle on Linux

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 3
Supported Linux Distributions

x86 x86-64 Itanium

EL 4

RHEL AS/ES 3

RHEL AS/ES 4

SuSE SLES-9

SuSE SLES-10

Asianux 2.0

m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Supported Linux Distributions

e A
c l
This chart shows the supported Linux distributions for Oracle Database 10gR2.
Enterprise Linux is available on x86 and x86-64 platforms.
The Red Hat versions are:
r a
• Advanced Server 3 and 4 (RHEL/AS)
• Edge Server 3 and 4 (RHEL/ES) O ly
l & On
The supported SuSE Linux version is SuSE Linux Enterprise Server 9.

a e
The supported Asianux-based distributions are:
n
t e r
• Red Flag DC Server 5.0 and later
• Miracle Linux 4.0 and later
U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 4
Linux Distribution: Overview

• The core parts of the Linux system are the following:


– Packages
– The kernel
• Certified distributions are made up of packages that
contain programs.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Linux Distribution: Overview

e A
c l
The Linux software distribution consists of a software set that is provided by a vendor, usually in the
form of packages. Various packages are installed based on the responses in the dialog that occurs

r a
during installation. Packages can provide the kernel, kernel patches, modules, applications, and file
systems.
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 5
Linux Packages

The Linux system is made up of software that is delivered


as packages:
• Packages deliver:
– Applications
– The kernel
– Configurations
• Packages are built from:
– Sources
– Patches
Enterprise Linux uses the Red Hat Package Manager (RPM)
package format.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Linux Packages

e A
Modules
c l
The modules in a Linux distribution can be either kernel based or loadable. Kernel-based modules

r a
have to be compiled in, whereas loadable modules can be added without recompiling. All the stock
kernels include support for loadable modules.
Packages O ly
& On
The Linux software for most of the supported distributions is assembled into packages. These are
l
n a e
precompiled binaries that can be installed on and removed from your system with a package
manager. With packages, you can update the kernel, patch, and add functionality. Some third-party

t e r U s
vendors distribute binary modules that are loaded into the kernel. These modules may be proprietary
modules where the source code is not available for Linux developers to investigate. If there are such

I n
modules loaded, then Oracle will support that OS fully, except in the event that the problem is caused
by a proprietary module. In this case, support will be deferred to the supplier of that module.

l e
Note: Package management is covered in detail in the lesson titled “Preparing Linux for Oracle.”
c
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 6
Linux Kernel

The Linux kernel is the core of the operating system. It is:


• Configurable
• Supportable
– Supplied kernel
– Patched by vendor
– A certified, unmodified distribution

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Linux Kernel

e A
c l
Linux, like most modern operating systems, has a kernel that is loaded at boot time and stays in the
memory. The kernel in Linux, unlike in many other operating systems, can be customized infinitely.

r a
You can include or exclude modules that make up the kernel, by using the kernel configuration file.

O ly
If the kernel still does not behave to your satisfaction, source code is available for you to change it to
your specification. This can lead to a support problem. If you are running a kernel that is different
& On
than the one that was tested by the vendor, then Oracle Support Services (OSS) cannot identify where
l
n a e
the problem is, in your database or the OS.
Oracle Corporation supports only stock kernels. That means only kernels supplied by the certified

t e r U s
distributions are supported. Kernels that are patched by packages by the kernel vendor are also
supported. For more information about kernel support, see note 228374.1, Linux Operating System
Support, on MetaLink.
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 7
Verifying the Kernel

• Execute the uname -r command to see the kernel


release:

# uname -r
2.6.9-42.0.0.0.1.ELsmp

• Check the release number returned in MetaLink


for support.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Verifying the Kernel

e A
c l
View the kernel release using the uname command, as shown.
You can see the name of the release on EL by viewing the /etc/enterprise-release file.
For example:
r a
# cat enterprise-release
O ly
Enterprise Linux Enterprise Linux AS release 4 (October Update 4)

l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 8
Interpreting the Linux Kernel
Version Number

<Base>-<Errata>.<Mod><Type>

Base kernel version


Source modifier

Integers separated
by periods
None: Uniprocessor
smp: SMP up to 16 GB
hugemem: SMP up to 64 GB

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Interpreting the Linux Kernel Version Number

e A
c l
The Linux kernel version numbers reflect information about the kernel. More than just what revision
of the source code was used to compile it, it shows what machine models it runs on, and also the

r a
source from where the kernel originated. The fields of the version number are as follows:
• Base: The base kernel version. This is typically three or four integers separated by periods. This
O ly
number can be traced back to a year when that kernel version was first made available. The first

l & On
two integers do not change very often. For example, the current version, referred to as “the two
six kernel” for 2.6, was originally available in 2003, and is still, as of 2006, the base version
a e
number. This course is based on the 2.6.9 kernel.
n
t e r s
• Errata: An extra version number to reflect fixes after the base version was released. This
typically reflects errors that were fixed, or minor enhancements to the kernel.
U
I n
• Mod: The source modifier for the kernel. This indicates where the kernel originated from. The
values of this field can vary greatly. For example, it could be a developer’s initials, or an

c l e
organization’s initials. The kernel being used in this course has EL as a source modifier, which
stands for Enterprise Linux.

r a
• Type: The type of architecture the kernel is targeted for. This can be hugemem, smp, or
blank. The meanings of hugemem and smp are covered in the lesson titled “Managing

O Memory.”

Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 9


A Tainted Linux Kernel

Loadable Kernel
Modules (LKMs)

T
Kernel

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
A Tainted Linux Kernel

e A
c l
A General Public License (GPL) is a software license that provides for basically free use of software
under certain conditions. It is commonly used in the open source community.

r a
A kernel that is delivered with a GPL distribution is considered untainted. There are two actions that
cause a kernel to become tainted:
O ly
• A non-GPL module is loaded into the kernel.
& On
• A module is force-loaded into the kernel. Consider that a given module is compiled for use with
l
n a e
a specific version of a kernel. If that module is introduced to a kernel with a different version
number, then an error is returned, and the module is not loaded into the kernel. The sysadmin

marked as tainted.
t e r U s
(SA) may choose to force the module to load anyway. Force loading causes the kernel to be

I n
If a kernel is tainted, Oracle may or may not support it, depending on the source of the tainting. Here
are two cases where a tainted kernel is supported:

l e
• OCFS: See MetaLink note 276450.1.
c
• EMC Powerpath driver: See MetaLink note 284823.1.

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 10
Checking for a Tainted Kernel

Determine whether a kernel is tainted by:


• Viewing the contents of /proc/sys/kernel/tainted:

# cat /proc/sys/kernel/tainted
0

0 = not tainted
1 = tainted
• Running lsmod to list the status of modules:
# lsmod
Module Size Used by Not tainted
oracleasm
loop
48020
15817
1
4
m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Checking for a Tainted Kernel

e A
c l
A tainted kernel is one that has had modifications done to it that are not normally supported.
The /proc/sys/kernel/tainted file indicates whether the kernel is tainted or not. Zero

r a
means it is not tainted, and one means it is tainted.

O ly
You can also run the lsmod command, and look for the tainted string in the header. This may also
be blank, indicating it is not tainted.

l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 11
Supported Hardware

• Oracle Corporation does not certify hardware;


only OS platforms.
• Customers must check with the OS vendors for
supported hardware.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Supported Hardware

e A
c l
Oracle Corporation supports a given Linux distribution on any platform or drivers that the vendor
supports. For details about hardware configurations that are certified with Enterprise Linux, see
http://linux.oracle.com/hardware.html.
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 12
Common Linux Commands and Programs

• ls: List files


• cp: Copy files
• mv: Move and rename files
• mkdir: Make a directory
• alias: Define command macros
• rm: Remove files and directories
• more: Page through output
• head: Show beginning of file contents
• tail: Show end of file contents
• df: Display filesystem space usage
• du: Display directory disk space usage
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 13
Common Linux Commands and Programs

• cat: Show and concatenate files


• grep: Search for patterns in files
• chmod: Change permissions of files
• chown: Change owner of files
• zip: Compress and package files together
• gedit: A WYSIWYG text editor
• export: Make environment settings global
• ps: List running processes
• touch: Change file time stamps
• id: Show information about the current user
• sudo: Execute commands as another user
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Note

e A
c l
Use the man command to see the manual pages for any command. For example, the following
displays the manual pages for the touch command:
$ man touch
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 14
Navigating the File System

$ whoami
oracle Each of these
$ cd changes to current
$ cd ~ user's home directory
$ pwd
/home/oracle
$ ls -l
total 40
drwxrwxrwx 2 root root 4096 Oct 4 10:07 Desktop
-rwxrwxrwx 1 tbest oracle 57 Dec 7 2005 diary
drwxr-xr-x 3 oracle oinstall 4096 Sep 30 13:48 osw
drwxrwxrwx 2 oracle oinstall 4096 Oct 9 14:08 prog
drwxr-xr-x 3 oracle oinstall 4096 Sep 29 11:46 rda

y
drwxr-xr-x 3 oracle oinstall 4096 Sep 30 12:07 rda2
drwxr-xr-x 2 oracle oinstall 4096 Oct 11 11:47 stuff

e m
Copyright © 2007, Oracle. All rights reserved.
a d
Navigating the File System A c
l e
Use the following conventions when navigating the file system:
• Use a slash to separate directory names.
c
r a
• Use a period to indicate the current directory.
• Each user has a home directory, which can be referred to using the tilde character.
O ly
• Mostly use cd, pwd, and ls to navigate and explore the file system from the command line.

l & On
• Permissions are noted in the form of a user and group associated with the entry, and a set of
permission bits. File system security and permission bits are covered in detail in the lesson titled
“Installing Oracle on Linux.”
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 15
The Virtual File System

The virtual file system on Linux is referenced as the /proc


directory, and:
• Does not exist on any permanent media
• Is a representation of what is in kernel memory
• Can be compared to the v$ views in an Oracle
database instance, except that they can be modified

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
The Virtual File System

e A
c l
The contents of the /proc file system represent the current state of the operating system kernel.
This information is stored in memory, actually in the kernel. The /proc file system is a means for

r a
allowing a system administrator to access it easily, because a file system is a ubiquitous information
structure.
O ly
Some of the information is simply represented as files under the /proc directory, such as:

l & On
• meminfo: Memory segment sizes and statistics
• uptime: Number of seconds since the system was rebooted, followed by the number of

n a e
seconds the system has been idle

t e r U s
• partitions: Names and sizes of disk partitions

But there are also virtual files stored under subdirectories, such as:

I n
• net: Network-related information
• sys: Low-level operating system settings, including kernel parameters

c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 16
Using the Virtual File System

You use the virtual file system to:


• View the current state of the kernel
• Change kernel parameters
# cd /proc/sys/kernel
# ls -l threads-max
-rw-r--r-- 1 root root 0 Dec 28 18:12 threads-max
# echo 16375 >/proc/sys/kernel/threads-max

# cd /proc/sys/kernel
# ls -l tainted
-r--r--r-- 1 root root 0 Dec 28 18:14 tainted
# echo 0 >tainted

y
-bash: tainted: Operation not permitted

e m
Copyright © 2007, Oracle. All rights reserved.
a d
Using the Virtual File System A c
l e
You can consider the virtual file system as a set of files. The can be viewed simply by using
c
commands such as cat or more. You can also change the values of some kernel parameters by

r a
writing values into the appropriate file. You can tell if the file can be changed by looking at its write
permissions. If it has the write bit on, then you can edit it. If it does not, then you are not able to
O ly
update it; it is intended to be read-only.

& On
The first example in the slide modifies the maximum number of threads on the system. Note that the
l
n a e
file listing shows up as writable.
In the second example, an attempt is made to change the tainted flag, using the virtual file system.

t e r U s
Because it is not a writable file, the change fails.

I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 17
Bash Shell Scripting

Basic attributes of bash shell scripting are:


• Environment variables $ SOMEVAR=thisvalue
$ echo $SOMEVAR
thisvalue
• Input and output redirecting
– Write output to file: $ ls -l >/tmp/filelist
– Append output to file: $ date >>/tmp/filelist
– Pipe output to another command: $ ls -l | more
• Flow control
– if: Test a condition and branch based on the result
– case: Actions to take based on a list of conditions


while: Loop while a condition exists
for: Loop while a condition or list exists m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Bash Shell Scripting

e A
c l
The following are the major scripting features provided by the bash shell:
• Environment variables: You can set and interrogate environment variables. You must not put

r a
any spaces on either side of the equal sign; an error results if you do so.
• Input and Output redirection: You can direct output from one program to be the input of
O ly
another program. You can also direct input to come from a file, and output to go into a file. Use

l & On
the greater than sign (“>”) in front of the file name to direct output to the file, creating it if it
does not exist, or replacing any existing contents if it does exist. Use two greater than signs
a e
(">>") to append the output to an existing file.
n
t e r s
• Flow control: You have the ability to control the flow of the script using conditional logic. The
following are the most common control constructs:
U
I n
- if: Test a condition and branch based on the result
- case: Specify actions to take based on a list of conditions

c l e
- while: Loop while a condition exists
- for: Loop while a condition exists or until a list is exhausted

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 18
Bash Shell Scripting: Environment Variables

The following are some of the variables that are available:


• Built-in shell variables:
– PWD: The current working directory
– $#: Number of command shell variables
– $?: Exit value of last command
– $n: Positional command-line arguments
– $*: All command-line arguments
• Other variables:
– HOME: The current user's home directory
– PATH: List of directories to search for programs
– PS1: Primary prompt string

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Bash Shell Scripting: Environment Variables

e A
• PWD: The current working directory
c l
The following variables are available in the bash shell:

$ echo $PWD
r a
O ly
/home/oracle
• $#: The number of command shell variables. This allows you to know how many command-like


l & On
values were provided so that they can be processed, for example, by a loop.
$?: The exit status value of the last command. This is useful for taking action based on the

a e
success or failure of previous commands or other called shell scripts.
n

t e r
$n: Any of the command-line parameters, according to their position (for example, $1, $2, and
s
so on). $0 is the command or script name as it was invoked on the command line.
U
- For this example script called showparams.sh:
echo $0
I n
- e
echo $2

l
This is the output, based on this invocation:
c
r a $ ./showparms.sh abc xyz
./showparms.sh

O •
xyz
$*: All command-line parameters passed in to the shell script

Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 19


Bash Shell Scripting: Environment Variables (continued)
The following variables are also available in the bash shell:
• HOME: The current user's home directory. A shortcut for this is the tilde character (“~”). For
example:
$ echo $HOME
/home/oracle
$ cd ~
$ pwd
/home/oracle
• PATH: The list of directories to be searched when looking for a command or executable file that
is being invoked. Each directory is separated by a colon (“:”) .
- An example of a PATH setting is:
/usr/local/bin:/bin:/usr/bin:/home/vncuser/bin
- Which means that any unqualified command or script names entered on the command line
will be located by searching these directories, in the order specified. An unqualified script is
one that has no directory specification in front of it.
• PS1: Primary prompt string. This defines what is displayed at the command-line prompt. This
can contain literal strings, but special characters may be included to display dynamic values
based on your environment. These are some of the most often used characters:
- \h: The host name, up to the first period
- \u: The current user's name
- \w: The current directory, shown fully
- \W: The same as \w, except that it shows only the last subdirectory name, not the full
m y
directory name

d e
In the following example, the username, machine name, and current directory are included in the
prompt:
[vncuser@EDRSR9P1 ~]$ echo $PS1
c a
[\u@\h \W]\$
[vncuser@EDRSR9P1 ~]$ cd /tmp/files
e A
[vncuser@EDRSR9P1 files]$

c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 20
Redirecting Input and Output

1 4
$ command
$ command1
>
|
File $ command2
2 | tee
$ command $ command3
<
|
File
File2 $ command4
3 |

$ command1 $ command2
m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Redirecting Input and Output

e A
c l
You can redirect from where input for a command program comes, and also to where the output
goes. This enables you to string together many commands and files in a single OS command line
submittal.
r a
O ly
When redirecting input and output from and to a file, respectively, you use the I/O redirection syntax,
which is made up of the following characters:

l & On
• >: The greater than sign, which means direct the output to the specified file
• <: The less than sign, which means read the input from the specified file

n a e
• >>: Two greater than signs, which means append the output to the specified file that may
already exist

t e r U s
If you want to direct input and output from or to another command, respectively, then use the pipe

I n
character, which is |(the vertical bar).

l e
You can also direct output to a file and to the terminal at the same time. This is a way to see the
output on the terminal and also have it written to a file. Use the tee keyword to do this.
c
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 21
Redirecting Input and Output (continued)
In the slide, the following scenarios are illustrated:
1. A command is run, and its output is written to a file. The following example writes the
directory listing out to the out.txt file:
ls –a >out.txt
2. A command is run, and its input is taken from a file. In the example, the factor command
is used, which calculates and displays the prime factors of the provided number, which come
from the standard input stream. You can indicate that factor should read a list of numbers
from a file by redirecting input from a file that contains those numbers:
$ factor <numbers.dat
23: 23
55: 5 11
103: 103
86: 2 43
256: 2 2 2 2 2 2 2 2
This presumes the numbers.dat file has the following contents:
23
55
103
86
256
3. A command is run, and its output is provided as input to a second command. In the following
example, the process listing is searched for incidents of the string _pmon_, which is the
Oracle Database process monitor. There are three occurrences: one for each database
m y
at the time.
d e
instance running, and one for the grep command itself because it is also a running process

$ ps -ef | grep _pmon_


c a
oracle 6985
oracle 6886
1 0 Sep27 ?
1 0 Oct15 ?
00:01:29 asm_pmon_+ASM
00:00:22 ora_pmon_orcl

e A
c l
oracle 3571 21645 0 12:34 pts/3 00:00:00 grep _pmon_
4. A series of four commands are run, each accepting as input the output of the previous

r a
command. Also, the output of the second command is written to a file. This example parses
out the process listing down to displaying only the names of the two database instances that
O ly
are currently running a pmon process. Note that grep –v searches for those lines in the

l & On
input that do not have the given string. That serves to eliminate the process that is the grep
command itself, which was shown in example (3). The cut command is used here to extract

a e
only characters 58 through 61 inclusive.

n
c58-61
+ASM
t e r
$ ps -ef | grep _pmon_ | tee all_pmon.txt | grep -v grep | cut -

U s
orcl
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 22
Bash Shell Scripting: Conditions

Compare numbers: Test strings:


-eq: = s: Not null
-gt: > -n s: Nonzero length
-ge: >= -z s: Zero length
-lt: < =: Strings are equal
-le: <= <: Less than
-ne: <> >: Greater than

Test files: Modify conditions:


-a: Exists !: NOT
-d: Is a directory -a: AND
-w: Is writable -o: OR
-x: Is executable

m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Bash Shell Scripting: Conditions

e A
expression inside brackets:
c l
In the slide are some common syntaxes for testing conditions in the bash shell. Put the condition

[ cond ]
r a
O ly
It is required that you put a space on each side of the condition to separate it from the brackets. You
can use the test syntax instead of the brackets, but there are some syntax variations for some
& On
constructs. For details, see the manual pages for bash and test.
l
n a e
Some examples of condition-testing syntax are listed below:
• Test if the first command-line argument is a number greater than 5:
[ $1 > 5 ]

t e r U s
• Test if the file somefile.dat exists in the current directory:

I n
[ -a somefile.dat ]

c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 23
Bash Shell Scripting: case

Syntax:
case value in
pattern1) commands1;;
pattern2) commands2;;
esac

Example: case $1 in
up) sqlplus / as sysdba <<-END1
startup;
END1
;;
down) sqlplus / as sysdba <<-END2
shutdown immediate;
END2

y
;;
*) echo Unknown;;
esac
e m
Copyright © 2007, Oracle. All rights reserved.
a d
Bash Shell Scripting: case
A c
l e
The case statement provides a way for you to define criteria, and then execute certain commands

c
based upon that criteria. It is much like a series of if-then-else statements. The value is

r a
evaluated, and based upon its match to the patterns listed, the corresponding commands are executed.
Only the commands associated with the first pattern matched are executed.
O ly
The example in the slide either starts up or shuts down the database, based on the input parameter,
& On
which can either be up or down. If it is neither of these, then the string Unknown is output.
l
n a e
Not unique to the case statement are the labels that delimit the input to the sqlplus invocation.
When sqlplus is called, all the data appearing until the label name, END1 or END2, is encountered

t e r U s
are sent to the sqlplus program as input.

I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 24
Bash Shell Scripting: while

Syntax:
while condition
do
commands
done

Example:
ps -ef | grep -i oracle |\
awk '{print $2}' |\
while read PID
do
kill -9 ${PID}

y
done

e m
Copyright © 2007, Oracle. All rights reserved.
a d
Bash Shell Scripting: while
A c
l e
The while statement specifies a loop to execute as long as a certain condition remains true. In the

c
example in the slide, a series of commands are run to filter down to the list of process IDs that have

r a
anything to do with oracle. Each of those process IDs is read by the while loop and fed to a kill
command. This, in effect, kills all of these processes.
O ly
The commands, which pipe their output to one another, work together to filter out the process IDs
thus:
l & On
1. The ps command lists every process on the system, in full format. This causes the user name

n a e
and program name to be included in the listing.

regardless of case.
t e r U s
2. The grep command searches for and outputs only those lines that contain the string oracle,

I n
3. The awk command, which is actually a programming language in itself, outputs only the second
field of the listing. The first field is the username, and the second field is the process ID.

l e
So, only the process ID is piped into the while loop, which reads one at the top of each iteration,
c
until they are exhausted. The kill statement refers to the variable that appeared in the read statement

r a
in the while condition. There is nothing special about the variable name. Here, it is PID, but it

Ocould be anything.
Note: For more information about awk, see the man pages.

Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 25


Bash Shell Scripting:
In-List Syntax of for
Syntax:
Example: 1
for var [ in list ]
do for args;
commands do
done echo $args
done

Example: 2
for mnt in `df | grep / | awk '{print $6}'`;
do
echo -n $mnt ' '
ls -l $mnt | wc -l
done

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Bash Shell Scripting: In-List Syntax of for

e A
c l
There are two types of syntax for the for statement. The in-list syntax takes a list of items as input
for processing in the loop. If no list is specified, the list of arguments supplied on the command line

r a
is processed. If a list is specified, that list is processed. The list can be the output of a command.

O ly
In the first example in the slide, because it is simply a variable name in the in-list, the values are
taken from the command line provided as the shell was invoked. So, this would in effect display the
& On
white-space delimited arguments, each on a line by itself.
l
n a e
In example number two, the in-list is a command. The command generates a set of values, and each
of those values is passed through the for loop separately. In this case, the df command generates a

t e r U s
list of mount points, which are filtered down to only the mount points by searching for a slash. That
is needed to remove the headings from the df output. Then the awk statement prints the mount point

I n
itself, such as /dev/shm. So, just the mount point is passed into the for loop. In the loop, the
mount point is printed without a carriage return. That is done with the –n parameter of the echo

l e
command. A space is also printed, just for visual separation. Then, the number of entries in the
c
mount point is printed using the ls command, and the entries are counted using the wc command.

r a
This does a word count, but the –l parameter causes it to count the lines instead.

O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 26
Bash Shell Scripting:
Controlled Loop Syntax of for

Syntax:
for (init; cond; stmt)
do
commands
done

Example:
for ((j=2; j<=8; j+=2))
do
grep my_name file$j
done

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Bash Shell Scripting: Controlled Loop Syntax of for

e A
c l
The controlled loop syntax is made up of three specifications that control the loop duration. The
init expression is evaluated once, at the top of the first iteration of the loop. At the top of each loop

r a
iteration (including the first), cond (which is the condition for which to remain in the loop) is
evaluated. If it is true, execution continues with the commands in the loop body. If it is false, then
O ly
the loop is immediately exited, and execution continues after the done statement. At the bottom of

l & On
each loop iteration, stmt is executed. This is usually a statement that increments or decrements a
counter variable, upon which cond depends.

n a e
The example in the slide looks for the string “my_name” in the following files: file2, file4,
file6, file8.

t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 27
Summary

In this lesson, you should have learned how to:


• Interpret Linux kernel version information
• Identify a tainted kernel
• Use common Linux commands
• Write a simple bash shell script

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 28
Practice 1 Overview:
Working with Linux

This practice covers the following topics:


• Identifying the kernel type
• Using Linux commands
• Writing a simple shell script

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 1 - 29
m y
d e
ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Preparing Linux for Oracle

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Objectives

After completing this lesson, you should be able to:


• Use the package manager to determine and update
package support
• Set up the operating system environment for Oracle
Database
• Create the necessary groups and users for Oracle
Database

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 2
Setting Kernel Parameters

# cd /proc/sys
# ls
debug dev fs kernel net proc sunrpc vm
# cd net
# ls
core ethernet ipv4 ipv6 token-ring unix
# cd core
# ls rmem*
rmem_default rmem_max
# cat rmem_max
262144

Entry in the
/etc/sysctl.conf file
net.core.rmem_max = 262144
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Setting Kernel Parameters

e A
c l
The kernel parameters can be set in either the /proc/sys file system or the
/etc/sysctl.conf file. In the /etc/sysctl.conf file, each entry corresponds

r a
hierarchically to one of the files in the /proc/sys directory. The subdirectory names and the file
name combine to define the parameter entry as it appears in the /etc/sysctl.conf file.
O ly
In the example in the slide, the current value of the rmem_max parameter can be viewed by looking

l & On
at the /proc/sys/net/core/rmem_max file. Also, the corresponding /etc/sysctl.conf
entry is shown as net.core.rmem_max.

n a e
The difference between these two methods of changing kernel parameters is explained in the
following slides.

t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 3
Setting Kernel Parameters

New value

/proc/sys/…/<file> Non persistent

Or

/etc/sysctl.conf
Persistent: Set
+
# sysctl -p
during each startup

m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Setting Kernel Parameters (continued)

e A
# sysctl –a
c l
To view the current values of kernel parameters, use the sysctl utility:

r a
To change a kernel parameter that will be effective only until the next reboot, write the new value

O ly
into the appropriate file in the /proc/sys file system. For example, to change the SHMMAX
parameter for this boot session only, use:
& On
echo 2147483648 >/proc/sys/kernel/shmmax

l
n a e
After that, if the system is rebooted, this change is gone.
Further, you can make the parameter change such that it is reapplied each time the system is

e r s
rebooted. This effectively makes the change persistent because it is reapplied during each boot
t U
sequence. To do this, edit the appropriate line in the /etc/sysctl.conf file, and then issue the

I n
sysctl –p command. The following is an example of an edited line in the sysctl.conf file:

e
kernel.shmmax = 2147483648

l
Alternatively, you can issue the following command, and the same persistent setting will be done:
c
r a sysctl -w kernel.shmmax = 2147483648

O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 4
Setting Kernel Parameters (continued)
You must have root privileges to perform these operations.
Note: If you make a mistake with a parameter setting and your system does not start, then you must
start Linux in the single-user runlevel (runlevel 1). At this runlevel, the /etc/sysctl.conf file
is not run. The different runlevels will be discussed in detail in the lesson titled “Customizing Oracle
on Linux.”

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 5
Linux Shared Memory: Overview

Shared memory can be accessed by multiple processes,


and thus is used for the System Global Area (SGA). It has
the following characteristics:
• Shared memory is allocated in segments.
• Segments have a maximum size.
• A limited number of segments can be allocated.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Linux Shared Memory: Overview

e A
c l
The shared memory system on Linux works much like the shared memory on other UNIX platforms.
Shared memory is allocated in segments. The maximum number of systemwide shared memory

r a
segments is set by the SHMMNI kernel parameter. The maximum size of each segment is determined
by SHMMAX. A segment is not necessarily as large as the maximum size; it is only as big as is
O ly
allocated. If a process needs a larger shared memory area than can be allocated in one segment, then
it may allocate multiple segments.
l & On
n a e
Database instances often allocate multiple segments to accommodate a large SGA. The maximum
number of segments to which one process may attach is set by SHMSEG.

t e r U s
For details about setting shared memory parameters for your Oracle database, refer to the MetaLink
note 153961.1, Semaphores and Shared Memory – An Overview. For more information, refer to the

I n
MetaLink note 15566.1, TECH: Unix Semaphores and Shared Memory Explained.

c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 6
Shared Memory Parameters
for 32-Bit Linux

Definition Default Oracle Oracle


Minimum Recommendation
Requirement
shmall Max number 2097152 2097152 2097152
of shared (0x200000) (0x200000) (0x200000)
memory
pages

shmmax Max shared 33554432 Half the size 2147483648


segment (0x2000000) of physical (0x80000000)
size in bytes memory

shmmni Max number 4096 4096 4096


of shared
segments

m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Shared Memory Parameters for 32-Bit Linux

e A
c l
There are three memory-related kernel parameters. For Oracle Database, the shmmax parameter is
the only one that needs to be modified from its default value. This parameter limits the size of each

r a
of the shared memory segments on the system. It should be equal to or larger than the largest SGA on
the system; otherwise, the SGA is made up of multiple memory segments. The recommended
O ly
number shown in the slide is 2 GB. This has been shown to be the setting that provides the greatest

l & On
efficiency in Oracle’s shared memory management. Too small a setting would result in a high
number of segments, requiring more work in managing them. Too large a setting could result in
a e
failed attempts to allocate the memory segments. In that case, Oracle is forced to attempt other
n
t e r s
mechanisms that allocate separate shared memory segments. While they are separate, they are
returned to the requesting database instance as a single segment. Oracle will attempt to allocate
U
I n
contiguous segments first. If that is not possible, it will allocate non-contiguous segments. The
maximum value of this parameter is 4 GB.

l e
The shmall parameter defines the maximum amount of shared memory that may be in use at any

c
time on the system. If this is too small, you see out-of-memory errors because the needed memory is

r a
not allowed to be allocated. The default allows for over two million pages, which is sufficient for a
4 GB RAM system. This value should always be at least 90% of the physical RAM, divided by the
Opage size. For example, if you have 16 GB of RAM, and a 4 KB page size, then this parameter
should be set to:
(17179869184 * .9 ) / 4096 = 3774873 KB

Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 7


Shared Memory Parameters for 32-Bit Linux (continued)
The shmmni parameter defines the maximum number of shared memory segments across the
system. The default 4096 value is sufficient for any size SGA. This is because any larger SGA would
instead require an increase in the size of each shared memory segment.
Note: For details about these kernel parameters, refer to the Oracle Database Installation Guide 10g
Release 2 (10.2) for Linux x86.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 8
Semaphores

Semaphores control access to critical resources, code,


and shared memory:
• semmsl: Maximum number of semaphores per set
• semmns: Total number of semaphores in the system
• semopm: Maximum number of operations per semop call
• semmni: Maximum number of semaphore sets

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Semaphores

e A
c l
Semaphores are a robust method of controlling access to critical resources. The Oracle instance uses
semaphores primarily to control access to shared memory. Semaphores are allocated based on the
PROCESSES initialization parameter.
r a
O ly
Each Oracle instance tries to allocate one semaphore set at startup. This set must allocate at least as
many semaphores as the value of PROCESSES. If it does not, the Oracle instance gets more sets to
& On
satisfy the number of semaphores that it needs. If the instance cannot allocate enough semaphores
l
n a e
(either in one set or in multiple sets), then the instance does not start.
A semop call is a call to a function that actually uses the semaphores (for example, testing, setting,
and clearing).

t e r U s
Note: For details about setting semaphore parameters for your Oracle instance, refer to the Oracle

I n
Database installation guide for your particular platform.

c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 9
Setting Semaphore Parameters

kernel.sem

250 32000 100 128

semmsl Semaphore settings in


/proc/sys/kernel/sem
semmns and sysctl.conf are
semopn positional.

semmni

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Setting Semaphore Parameters

e A
parameters.
c l
Changing the kernel parameters for semaphores works the same way as the shared memory

r a
All four of the semaphore parameters are set in a single file, that is, the sem file in the
/proc/sys/kernel directory.
O ly
Here are some general recommendations for the settings of the semaphore parameters on Enterprise

l & On
Linux. You must test and adjust these depending on your system:

a e
For semmsl – 250 or the largest PROCESSES parameter of an Oracle database plus 10

n
t e r s
For semmns – 32000 or sum of the PROCESSES parameters for each Oracle database, adding the
largest one twice, and adding an additional 10 for each database
U
For semopm – 100
For semmni – 128 I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 10
Setting the File Handles Parameter

fs.file-max 65536

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Setting the File Handles Parameter

e A
c l
File Handles is the parameter that determines the maximum number of file handles that the Linux
kernel will allocate. The Oracle database background processes open all the data files in addition to

r a
redo logs, the alert log, and other supporting files. So, fs.file-max needs to be high enough to
include all the data files within your database, and all supporting files. The Oracle10g Release 2
O ly
database can have up to 65,533 data files.

& On
This value is set in /proc/sys/fs/file-max. The default value is 65536, so you can leave
l
that as it is.

n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 11
Setting Other Parameters

net.ipv4.ip_local_port_range 1024 65000

Minimum Maximum

net.core.rmem_default 1048576

net.core.rmem_max 1048576

net.core.wmem_default 262144

net.core.wmem_max 262144
m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Setting Other Parameters

e A
Setting Socket Parameters
c l
An IP port is assigned to a database-dedicated server process when it starts. The IP port is used to

r a
communicate with the user process. By default, the range available is 32768 through 61000. In some

O ly
databases with a very large number of users, the default range of ports that are available to non-root
processes may not be adequate. In the example in the slide, the IP port range is set to be from port
& On
1024 through 65000. These ports may be used for Oracle Net connections. Ports below 1024 are
l
n a e
reserved for processes running with root privileges.
Setting TCP/IP Window Size Parameters

e r s
Set the four TCP/IP window sizing–related parameters to values greater than or equal to the values
t U
shown in the slide. These define the read (rmem) and write (wmem) window sizes for a TCP/IP

I n
packet. Defaults are defined, and because TCP/IP communications occur with other machines, the

l
maximum value.
c e
sizes are allowed to adjust upward to attain compatibility. They are not adjusted beyond the specified

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 12
Shell Limits

Processes Files

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Shell Limits

e A
Oracle-Related Limits
c l
Two limits must be set in order for an Oracle database to function properly. These apply to the

r a
oracle Linux user. There is little to be gained by not setting each of these to a conservatively high
value.
O ly
• nofile: The maximum number of files the user can have open at one time. The oracle user

& On
opens initialization files, data files, redo log files, and so on, so this should be set high enough to
l
files in a single database.
n a e
have those files open simultaneously. This is set very close to the maximum number of database

t e r U s
• nproc: The maximum number of processes a given user can run at once. The oracle Linux
user owns and starts all the background processes, server processes, and possibly the parallel

I n
query and dispatcher processes. This number must be set high enough to accommodate that. The
typical increase in process count comes from the number of sessions in the database. So you just

l e
need to set this parameter high enough to manage the highest number of sessions, plus some for

c
other processes.

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 13
Shell Limits (continued)
Soft Limit Versus Hard Limit
For each of these settings, there is a soft limit and a hard limit. The hard limit can be changed only by
the root user. The soft limit serves as the limit for the resource at any given time; the user may not
exceed that. But the soft limit can be changed by the user, up to the value of the hard limit. The
purpose of a limit is to prevent runaway situations, where resources are being used up beyond what
was intended by the processes running in the user space. So allowing the soft limit to be adjusted by
the user, but never exceeding the root-defined hard limit, provides flexibility along with control.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 14
Setting Shell Limits

root can set hard and /etc/security.conf


soft shell limits for each oracle soft nproc 2047
user. oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
/etc/pam.d/login
session required /lib/security/pam_limits.so
session required pam_limits.so

The user can set hard and $ whoami


soft shell limits for its oracle
session within the bounds $ ulimit -u 16384 -n 65536
already set by root.
m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Setting Shell Limits

e A
c l
The root user can define the hard and soft limits for each user in a configuration file. The hard
limits can be changed only by root; the user cannot set either the hard limit or the soft limit above

r a
the hard limit. To make these changes, perform the following steps:
1. Add the following to the /etc/security/limits.conf file:
oraclesoft nproc
O ly 2047
oraclehard
oraclesoft
nproc

l
nofile & On 16384
1024
oraclehard

n a e
nofile 65536
2. Add or edit the following lines in the /etc/pam.d/login file:
session
session
t e r U s
required
required
/lib/security/pam_limits.so
pam_limits.so

I n
pam_limits.so is a Pluggable Authentication Module (PAM). It is used to set system resource

c l e
limits. For more information, see the man pages for pam.
After an OS user has started a shell, the user can use the ulimit command to set the hard limit and

r a
soft limit for this specific shell. The hard limit cannot be increased after it is set, and the soft limit
cannot be increased above the hard limit. For the example shown in the slide, the ulimit command

Ohas no effect; it is setting the hard limit and soft limit to the same value they have already been set to.

Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 15


Setting Shell Limits (continued)
If it were to issue the ulimit –Sn 50 command (which sets the soft limit for number of open
files to 50), then any attempt to open more than that would result in an error. The user could still set
it higher (for example, ulimit –Sn 100), which would result only in errors when the number of
open file requests exceeds 100. However, this cannot be set higher than the hard limit.
Note: A process inherits these settings from the shell from which it is started at the time it is started,
so if you change the settings, any processes would have to be restarted for them to take effect. So, for
example, the Oracle database would have to be shut down and restarted.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 16
Managing Packages

Patches for Enterprise Linux are managed with the


Red Hat Package Manager (rpm) utility. This utility
is used to install, upgrade, remove, and query
packages.
• To determine whether or not a package is installed:
# rpm –q <package name>

• To install a package:
# rpm –ivh <package name>

• To remove a package:
# rpm –e <package name>
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Managing Packages

e A
c l
The recommended method for installing operating system patches and additional functionality is to
apply packages from the distribution vendor. Apply packages with rpm, a command-line utility with

r a
several options for querying, verifying, installing, upgrading, and removing packages.

O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 17
Managing Packages (continued)
The rpm utility accepts several command-line arguments including:
• -q: Queries the system for a package. A special argument, -qa, lists all installed packages. This
list can then be filtered by piping to a grep command. For example:
#rpm -qa |grep gcc
gcc-2.96-108.1

• -i: Installs the named package. The optional –h argument shows hash marks on the screen to
indicate progress. The optional –v argument generates verbose output. For example:
#rpm -ivh my_new_package-1.0-14.i386.rpm
Preparing... ####################################### [100%]
1:my_new_package ####################################### [100%]

• -e: Erases/removes the selected package. Optional arguments –h and –v can also be used. For
example:
# rpm -ev IBMJava2-JRE

• -U: Upgrades the current package. It removes the current package and replaces it with a
different version.
Note: The replacement happens without removing any existing configuration files. This is used
when upgrading kernel packages because you cannot remove the existing kernel before
installing a new one.
rpm -Uh kernel-2.4.9-e.27.i686.rpm
Preparing... ####################################### [100%]
m y
1:kernel-2.4.9-e27
e
####################################### [100%]

d
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 18
Required Software

Check that the required packages are installed:


# rpm -q binutils
binutils-2.15.92.0.2-15

You may have to query all of the packages and grep for
part of the name if you are unsure of the exact name:

# rpm -q compat-libstdc++
package compat-libstdc++ is not installed
# rpm -qa | grep compat-libstdc++
compat-libstdc++-296-2.96-132.7.2
compat-libstdc++-33-3.2.3-47.3
# rpm -q compat-libstdc++-296
compat-libstdc++-296-2.96-132.7.2
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Required Software

e A
c l
The Oracle Database Installation Guide lists the required packages and version numbers for your
Linux distribution. You can determine whether your Linux installation meets those package

r a
requirements by using the rpm command. The –q option queries the repository of installed packages
looking for the exact package name you supply. You must supply the package name exactly as it
O ly
appears in the repository; if it is wrong, it is reported as not installed.

l & On
The first example in the slide shows a query of the binutils package. The result shows that it is
indeed installed, and the version number is 2.15.92.0.2-15.

n a e
The second example shows a query for the compat-libstdc++ package. Initially, you see that it

t e r U s
is not installed. Then, when you query all packages, and then grep for the package name or portion
thereof, you can see that there must be more to the package name than compat-libstdc++. If

I n
you query for compat-libstdc++-296, you see that it is installed as that package name.

c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 19
Required Software (continued)
The following are the required packages and versions for Oracle Database 10gR2 on Enterprise
Linux:
binutils-2.15.92.0.2-13.EL4
compat-db-4.1.25-9
compat-libstdc++-296-2.96-132.7.2
control-center-2.8.0-12
gcc-3.4.3-22.1.EL4
gcc-c++-3.4.3-22.1.EL44
glibc-2.3.4-2.9
glibc-common-2.3.4-2.9
gnome-libs-1.4.1.2.90-44.1
libstdc++-3.4.3-22.1
libstdc++-devel-3.4.3-22.1
make-3.80-5
pdksh-5.2.14-30
sysstat-5.0.5-1
setarch-1.6-1
Note: This list shows the required RPMs at the time of printing. To ensure that this has not changed,
refer to the Oracle Database Installation Guide for your Linux distribution.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 20
Linux Patches

Apply the patches recommended by the distribution


vendor:
• Unbreakable Linux Network (ULN) supplies patches
automatically.
• Other distribution vendors have patch channels.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Linux Patches

e A
c l
Linux distribution vendors do not supply megapatches like other UNIX vendors, but supply patches
for components. The latest version of all the patches are tested to work together. Each distribution

r a
vendor has a subscription service and a method for distributing patches. Enterprise Linux is
supported by Unbreakable Linux Network. The latest patches should be applied; especially the kernel
patches and the security patches. O ly
& On
Note: Oracle Enterprise Manager Database Control and Grid Control provide an interface for finding
l
10g Release 2.
n a e
and applying patches for the OS and for the database. For details, see Oracle Database 2 Day DBA

t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 21
Configuring the X Window System

Install and configure the X Window System with the


distribution installation. Before the installation:
• Determine the monitor model number
• Determine the graphics card model number or chipset

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Configuring the X Window System

e A
c l
Oracle Universal Installer (OUI) is a Java-based product, and Java calls the X Window System on
UNIX and Linux operating systems. So the X Window System must be enabled. This is usually

r a
accomplished during the installation of the Linux distribution.

O ly
If the X Window System configuration needs to be changed after the installation, there are several
files, such as /etc/X11/XF86Config, where the X Window System configuration information is
kept.
l & On
n a e
You must know the monitor model number, the graphics card model, the video memory size, and the
chipset before configuring these items. With this information, you are able to configure your system
correctly.

t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 22
Testing the X Window System

Test the X Window System with an X client:


• Set the DISPLAY variable:
– Get the host name of the X server.
– Set and export:
— DISPLAY=hostname:0.0
— Export DISPLAY
• Check xhosts:
— xhost +hostname
• Run xclock:
— xclock

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Testing the X Window System

e A
c l
The X server is the machine where you are viewing the screen. The X client is a process (running
somewhere) that sends the display to where you will be viewing it. In the case of the OUI, X server is

r a
the machine in which you view the output, and X client is the machine where the installer runs the
database server. To make sure that the installer runs in this configuration, first verify that the X
O ly
server has connectivity to the database server, and use telnet to make a connection. If telnet

l & On
does not work, check the hardware, the wiring, and the host resolution. The host names are translated
into IP addresses by either a domain name server (DNS) or through the /etc/hosts file. The
a e
ping, host, and dig utilities can provide good diagnostic information for solving connection
n
problems.

t e r U s
After a telnet connection is established to the database server where the Oracle software will be

I n
installed, you must set and export the DISPLAY variable. This variable directs the Oracle Installer
where to display the install screens. The DISPLAY variable contains the host name or IP address and

l e
the display number.

c
For the X server to accept the display from another machine, xhost must be executed on the

r a
machine where the display is viewed. As the owner of the display (the logged-in user), execute
xhost +<hostname> where hostname is the name or IP address of the database server where
Othe installer is running.

Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 23


Testing the X Window System (continued)
On the X server, issue a hostname command to find the name of the X server. In the following
example, the machine jspiller-us is the X server where the installer will display the output.
Check which hosts are allowed to connect to the X server machine with xhosts. With xhost
+<hostname>, add the name of the database server to the X access control list. In this example, the
machine delphi is the database server where the installer will be running:
$ hostname
jspiller-us
$ xhost
Access control enabled, only authorized clients can connect
$ xhost +delphi
Delphi being added to access control list.
Connect to the database server, with telnet, set the DISPLAY variable and start an X client.
$ telnet delphi
$ DISPLAY=jspiller-us:0.0
$ export DISPLAY
$ xclock
The xclock client should appear on the X server screen or an error message will appear in the
telnet session.
The DISPLAY variable may also be set by using the IP address instead of the name as:
$ DISPLAY=192.168.1.2:0.0
This method is sometimes helpful when the host name resolution must be bypassed.
m y
info pages on your Linux system.
d e
For further information about the commands used in this lesson, refer to Appendix C, or the man and

c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 24
Creating Groups

Group Description Common


Name
Oracle Inventory Identifies the owner of the Oracle oinstall
software
OSDBA Identifies OS accounts that have dba
database administration privileges
(SYSDBA)
OSOPER Identifies OS accounts that have oper
limited database administration
privileges (SYSOPER)

m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Creating Groups

e A
c l
The Oracle Database installation guide names three group identifiers: the Oracle Inventory group,
OSDBA, and OSOPER. The members of the OSDBA group own the database files and have the

r a
privilege to connect to the database without a password, using AS SYSDBA through OS
authentication. The OSOPER group uses the same mechanism to connect with AS SYSOPER with a
O ly
restricted set of privileges. Each database may have its own OSDBA and OSOPER groups. The Oracle

l & On
Inventory group has privileges on the software. A DBA that is a member of both OSDBA and the
Oracle Inventory group has privileges in specific database instances and the ability to access and
a e
upgrade the software through the Oracle Inventory group.
n
t e r U s
An OSDBA group must be created to manage the database files. By default this group is dba, but this
name is arbitrary. If only one group of DBAs administers the databases on this server, then this group

n
may be the same as the Oracle Inventory group for all the databases on this server.
I
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 25
Creating Groups (continued)
When there are multiple groups of DBAs, each administering different databases on the same server,
you should create a separate Oracle Inventory group to own the Oracle software. This group is
commonly called oinstall. For each set of databases that will have a common set of DBAs,
create an additional OSDBA group. This allows each DBA to have privileges in the database of
responsibility but not in other databases.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 26
Creating and Viewing a Group

To create and view the necessary groups:


# groupadd –g 503 oinstall
# groupadd dba
# groupadd oper

[root@edrsr9p1 local]# cat /etc/group


root:x:0:root,vncuser
bin:x:1:root,bin,daemon
.
.
.
oinstall:x:503:
dba:x:504:oracle
oper:x:505:oracle

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Creating and Viewing a Group

e A
c l
The root user can execute the groupadd command to create a group. The group ID or gid must
be unique. IDs below 500 are typically reserved for system accounts. -g is optional; if the group ID

r a
is not specified, then the first available group ID above 499 will be assigned. This command places
an entry in the /etc/group file.
O ly
To verify whether the group was created, view the /etc/group file.

l & On
In the X Window System environment, there are multiple tools available to manage users and groups.

a e
Enterprise Linux provides the system-config-users GUI tool.

n
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 27
Creating the Oracle Software Owner

The user that owns the Oracle software:


• Must be created
• Has the Oracle Inventory group as its primary group
• Must be a member of an OSDBA group
• Is commonly named oracle

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Creating the Oracle Software Owner

e A
c l
The user that runs the Oracle Universal Installer to install Oracle Database is the Oracle software
owner. The ownership of the installed files is set based on that user.

r a
Do not run the installer as root; that would require root access every time Oracle software

O ly
maintenance has to be done. The name of this user is commonly oracle, but this name is arbitrary.
In the following examples, this user is named oracle. When this user is created, the primary group
& On
can be set. The primary group is set to the Oracle Inventory group. If the OSDBA group is different,
l
n a e
then the Oracle user must also be a member of that group. The primary group is the one listed in the
/etc/passwd file. Membership in other groups is set in the /etc/groups file.
$ id

t e r U s
uid=501(oracle) gid=503(oinstall)

n
groups=502(oracle),503(oinstall),504(dba),505(oper)

I
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 28
Creating the Oracle Software Owner

1
# useradd oracle

2
# usermod -g oinstall -G dba,oper,oracle oracle

3
# passwd oracle
Changing password for user oracle.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
#
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Creating the Oracle Software Owner (continued)

e A
c l
The root user can execute the useradd command to create a user. In this example, a user named
oracle is created with a primary group of oinstall. The user ID must be unique. If the user ID

r a
is not specified, then the user gets the first available ID above 99, because IDs below 99 are typically
reserved for system accounts. If the -D option is used with no other options, then useradd will
O ly
show the system defaults. These defaults may be overridden in the command line, completely

l & On
specified or changed with -D followed by the new default. On Enterprise Linux, the default home
directory is /home/<username>, which is acceptable. You do not need to override it with the
-D option.
n a e
t e r U s
The useradd command places an entry in /etc/passwd and /etc/shadow if shadow
passwords are being used. The –m option creates the user’s home directory and copies a skeleton set

I n
of login profiles from /etc/skel to the home directory. The -g option sets the primary group. If
the group is not specified, then a group with the same name as the user is created and set as the

l e
primary group. The -s option sets the user login shell. In this example, the -s option is not required

c
because for Enterprise Linux the bash shell is the default shell. For more information, refer to the

a
man pages for useradd.
r
OMost Linux distributions are shipped with a graphical user management tool. For Enterprise Linux,
use system-config-users.

Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 29


The nobody User

The nobody user:


• Is an unprivileged user
• Is used for executing external jobs
– The oracle user would be too powerful.
• Should be allowed to have only minimal privileges

# id nobody
uid=99(nobody) gid=99(nobody) groups=99(nobody)

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
The nobody User

e A
c l
The nobody user exists to satisfy the need for a minimally privileged OS user. There are times
when the database requests that jobs run at the OS level, and this is the user under which the job runs.

r a
Oracle Scheduler is one feature that can initiate external jobs. Any programs that are invoked this
way are owned by, and run under the permissions granted to, the nobody user. So this user starts out
O ly
with no privileges. The system administrator, as root, can add any necessary groups to this user as

l & On
needed, based on the tasks those external programs must perform.
Simply allowing these programs to run as the oracle user would be too liberal a policy, because

n a e
the oracle user is able to shut down the database, and perform many other privileged tasks.

t e r U s
If the nobody user does not exist, create it. It is common to use 99 as the user ID and group ID.

I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 30
Summary

In this lesson, you should have learned how to:


• Use the package manager to determine and update
package support
• Set up the operating system environment for Oracle
Database
• Create the necessary groups and users for Oracle
Database

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 31
Practice 2 Overview:
Preparing Linux for Oracle

This practice covers the following topics:


• Using the package manager to determine and update
package support
• Creating groups and users in preparation for an Oracle
database installation
• Setting up the operating system environment for
Oracle Database 10gR2

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 2 - 32
Installing Oracle on Linux

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Objectives

After completing this lesson, you should be able to:


• Describe the Linux file system security
• Install multiple versions of the Oracle Database
software on the same server
• Accommodate multiple Oracle homes on one database
server

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 2
File System Security

d rwx rwx rwx

Owner

Directory Group
indicator
World

$ ls -l
total 3
drwxr-xr-x 2 oracle oinstall 4096 Sep 17 13:02 backup
-rwxr-xr-x
-rwx------
1 oracle dba 87 Dec 22 2006 lab_01.sql
1 root root 24 Feb 15 2006 postinst.sh
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
File System Security

e A
c l
Linux file system security is based on permissions attached to each file and directory. There is a set
of ten indicators that specify this permission information. Their meanings, from left to right, as they

r a
appear in a listing produced by the ls –l command, are shown below. If the positional attribute
does not apply to the entry, then that permission or attribute is false, or denied.
O ly
1. Directory indicator: If this is a “d,” it indicates that the entry is a directory.

l & On
2. Owner permissions: This indicates whether the owner of the file is able to read it, write to it, or
execute it, respectively, from left to right.
a e
3. Group permissions: This indicates whether members of the group that owns the file are able to
n
t e r s
read it, write to it, or execute it, respectively, from left to right.
4. World permissions: This indicates whether all other users (besides the owner and the file’s
U
I n
group members) are able to read it, write to it, or execute it, respectively, from left to right.
Note: Execute permission applies to binary programs, shell script files, and directories. It has no

l e
meaning for other file types. In the case of a directory, if a user has the execute privilege on a

c
directory, that means they can cd to it, list the contents of it, and search it.

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 3
File Security Attributes

-rwxr-xr-x 1 oracle dba 87 Dec 2 2006 lab_01.sql

-rwx------ 1 root root 24 Feb 1 2006 postins.sh

drwxr-xr-x 2 oracle oinstall 4096 Sep 17 13:02 backup

Owner Group

m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
File Security Attributes

e A
c l
Each file or directory entry has an owner and a group assigned to it, shown in that order as displayed
by the ls –l command. This information, combined with the permissions indicators on the

r a
previous slide, determines who is allowed to do what with each given file or directory.

O ly
Regarding the items listed in the slide:
• The first belongs to the oracle user, and its group is dba. That, combined with the

l & On
permissions indicators means that the oracle user has read, write, and execute permissions on
this file. Also, any user in the dba group can execute or read this file, but cannot write to it,

n a e
which is also the case for all other users, based on the last three indicators.

t e r U s
• The second belongs to root, and the group is also root. Based on the permissions indicators,
only root can read, write, or execute this file. Even if there are other users in the root group, they

I n
cannot do anything with this file because the group permission indicators are all dashes, which
means that those accesses are denied.

l e
• The third entry is a directory.

c
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 4
SETUID and SETGID Bits

The SETUID and SETGID bits indicate that others are


allowed to execute a program as though they were the
owning user or group.

-r-sr-s--- 1 root oinstall 0 Jul 1 2005 oradism

oradism

SETUID SETGID

tbest xyz.conf
m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
SUID Bits

e A
c l
When the letter “s” appears in place of the “x” or dash in the permissions bit string, it has a special
meaning. It indicates that as this program is invoked, it will be run using the permissions of the user

r a
or group that owns it. Regarding the example of the oradism executable file shown in the slide,
oinstall is the group and root is the owner. An “s” appears in the executable bit position, for
O ly
the user and the group. That is, anyone can execute oradism, and when they do, every action the

l & On
oradism program attempts will be evaluated, permissions-wise, based on the fact that the
requesting user is root and the requesting group is oinstall.

n a e
For example, suppose that the tbest user is in the tbest and users groups only. There is a

t e r U s
/etc/xyz.conf file which is owned by root, and its group is root. The tbest user cannot
access that file at all. But if the oradism program accesses that file, anyone who invokes that

I n
program will succeed in accessing that file. This is because the decision to allow access to the
/etc/xyz.conf file is made based on the fact that the requestor is the root user.

c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 5
Choosing a Shell

There are many shells available for Linux:


• Oracle shell scripts are Bourne shell scripts.
• bash is the Bourne-again shell:
– It is Bourne shell compatible.
– It is POSIX compliant.
• Korn is a superset of Bourne:
– The Korn shell is required for certain actions.
• The C shell is preferred by many.
• The working-level shell is a matter of preference.
• Most shell scripts specify the shell that is required.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Choosing a Shell

e A
c l
Linux has many popular features. One of the most popular features is that the user interface can be
easily customized. There are at least four different shells in the default EL installation. The Bourne

r a
shell, one of the first shells that was available on AT&T UNIX, is the standard shell that the Oracle
database uses for scripting. The C shell was the BSD UNIX shell. The C shell has many user-friendly
O ly
features, such as command history, that are not available in the Bourne shell. But the C shell was

l & On
interpreted, and not compiled like the Bourne shell, and is consequently slower. The Korn shell is a
superset of the Bourne shell with command history, and is compiled. The Bourne-again shell, bash,
a e
was written to be Bourne shell compatible, with features of both the Korn and C shells. It is intended
n
t e r s
to be POSIX compliant. Some Oracle installation actions require a Korn shell such as the Oracle
Internet Directory configuration script, oidca.
U
I n
Most Oracle shell scripts specify the shell that is required in the first line of the script. A first line of
#!/bin/sh indicates that the script uses the Bourne shell. On Linux, /bin/sh is usually a link to

l e
the Bourne-again shell (bash).

c
To view the shell that you are currently in, use the echo $0 command.

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 6
Setting Environment Variables

The shells have specific syntaxes for setting environment


variables.
• Bourne, Korn, and bash shell syntax:
ORACLE_SID=orcl; export ORACLE_SID

• C shell syntax:
setenv ORACLE_SID orcl

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Setting Environment Variables

e A
c l
Each shell has a specific syntax for setting an environment variable. The most common syntax for
each shell and an example for the ORACLE_SID variable are shown. The environment variables are

r a
session specific and, therefore, must be set at each login. In each shell, there are specific login scripts
that are executed.
• The Bourne shell runs .profile. O ly
l & On
• The Korn shell runs .profile and .kshrc.
• The bash shell runs .bash_profile, .profile, and .bashrc.
a e
• The C shell runs .login and .cshrc.
n
t e r U s
The Oracle environment variables must be set in the last script to run in each case.
Example: For the bash shell, set ORACLE_SID in the .bashrc script.

I n
Oracle Support recommends that you create a shell script in the same format as.bashrc and source

l e
it in the shell that will be running the installer. This has the advantage that after installation the
.bashrc or .login script does not need to be edited for ordinary use with the oraenv script. For
c
r a
example, create a file instenv with the environment variables, do a chmod 755 so that it can be
executed, and then execute '. ./instenv' to run the script without forking a new shell.

O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 7
User File Creation Mask

Every file that a user creates has a set of permissions


controlled by a mask.
• View the mask with umask -S.
• Set the mask with umask -S u=rwx,g=rx,o=rx.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
User File Creation Mask

e A
c l
Every file that is created by a user receives a default set of permissions. The permissions determine
who can read, write, and execute a file. The example above indicates that the files that are created

r a
have permissions set as follows: read, write, execute for the owner (u); read and execute permissions
for the group (g); and read and execute permissions for the other (o). For EL, by default, umask is
O ly
set to u=rwx,g=rx,o=rx. But if it is not set to this value, it can be changed. In the .bashrc

l & On
script for the oracle user, place a line as shown below:
umask -S u=rwx,g=rx,o=rx

n a e
The umask can optionally be specified as an octal value, which specifies which permission bits

t e r U s
should be off. For example, 022 is the equivalent of the above example. The two bits that are on in
the octal value represent the only two permissions that are not allowed: write for group and write for
other.
I n
The umask must be verified before running the Oracle Universal Installer (OUI) and set for the

l e
oracle user in the .bashrc file.

c
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 8
Setting Oracle Environment Variables

For the oracle user, you must set the following shell
variables before the installer is run:
• DISPLAY (required)
– Location of the X Window System server
• PATH (required)
– Location of the OS linker and compiler
– Location of the Oracle database executables

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Setting Oracle Environment Variables

e A
c l
Only two shell variables need to be initialized before the installer is run: the DISPLAY variable and
the PATH variable. Other variables can be initialized to facilitate the installation. The DISPLAY

r a
variable must be set to the location of the X Window System server. If X-based terminal windows are
being used, then the DISPLAY is usually set properly in login scripts. Before installation, set the
O ly
PATH variable manually or with a script in the shell where the Oracle Installer is invoked to include

l & On
the $ORACLE_HOME/bin directory. If the '$ORACLE_HOME' string is used instead of a full path
to set the PATH variable, then the ORACLE_HOME variable must be set before its use. Usually, base
a e
PATH is set to /usr/bin:/bin:/usr/bin/X11R6:/usr/local/bin by default. If it is not,
n
t e r
then set it in the .bashrc file.

U s
After the installation, the PATH variable for any database user on Linux can be set by using the

n
supplied oraenv script. It adds $ORACLE_HOME/bin to the end of the existing PATH variable.
I
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 9
Optimal Flexible Architecture

Optimal Flexible Architecture (OFA) was introduced to


optimize the relationship between the database files and
the host operating system. You can use OFA to:
• Distribute files across multiple mount points:
– Balance I/O for performance
– Increase reliability
• Handle large and growing directories
• Administer multiple releases

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Optimal Flexible Architecture

e A
c l
Optimal Flexible Architecture (OFA) is a method for configuring the Oracle database and other
databases. OFA makes use of the operating system (OS) and disk subsystems capabilities to create an

r a
easy-to-administer configuration that allows maximum flexibility for growing and high performance
databases. The methods described here are the basics of OFA.
O ly
For details about the goals and implementation of OFA, refer to the Oracle Database Administrator’s
& On
Guide 10g Release 2 and the Oracle Database Installation Guide 10g Release 2 (10.2) for Linux x86-
l
64.

n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 10
OFA Characteristics

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
OFA Characteristics

e A
c l
The OFA characteristics translate into specific recommendations for the management of database
files, and the structure of the host file systems and directory structure. They are listed here:

r a
• File system organization: The file system is organized to enable easy administration and to
facilitate adding data into existing databases, adding users, creating databases, and adding
hardware. O ly
bottlenecks.
l & On
• Distributed I/O loads: I/O loads are distributed across enough disk drives to prevent performance

a e
• Hardware support: In most cases, you do not require new hardware to implement the Optimal
n
t e r s
Flexible Architecture standard.
• Safeguards Against Drive Failures: By distributing applications across more than one drive,
U
I n
drive failures affect as few applications as possible.
• Distribution of Oracle home directories: The collection of home directories, and further, the

c l e
contents of each individual home directory can be distributed across disk drives.
• Integrity of login home directories: You can add, move, or delete login home directories without

r a having to revise programs that refer to them.

O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 11
OFA Characteristics (continued)
• Independence of UNIX directory subtrees: Categories of files are separated into independent
UNIX directory subtrees so that files in one category are minimally affected by operations on
files in other categories.
• Supports concurrent execution of application software: You can run multiple versions of Oracle
software simultaneously, enabling you to test and use a new release before retiring the previous
release. Transferring to a new release after an upgrade is simple for the administrator and
transparent for the user.
• Separate administrative information for each database: The ability to separate administrative
information for each database ensures a reasonable structure for the organization and storage of
administrative data.
• Consistent database file naming: Database files are named so that:
- Database files are easy to distinguish from other files
- Files belonging to one database are easy to distinguish from files that belong to another
database
- Control files, redo log files, and data files can be identified as such
- The association of data file to tablespace is clearly indicated
• Separation of tablespace contents: Tablespace contents are separated to minimize tablespace free
space fragmentation, minimize I/O request contention, and maximize administrative flexibility.
• I/O loads tuned across all drives: I/O loads are tuned across all drives, including drives storing
Oracle data in either Automatic Storage Management disk groups or in raw devices.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 12
Mount Points

To be OFA compliant, the database requires two mount


points:
• Mount points are listed in /etc/fstab.
• Name mount point /pm or /pm/q/db.
– p is a string.
– m is a unique identifier (2 to 4 digit number).
– q indicates Oracle database files (default oradata).
– db is the database name.
• Examples:
– /u01
– /u02/oradata/orcl
– /sales01
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Mount Points

e A
c l
A database that is fully OFA compliant has at least two mount points: one for the software and at
least one for database files. The Oracle Installer requests two directories. The installer does not know

r a
if you are supplying mount points or directories. The naming of the database software directory was
performed when you created the ORACLE_HOME environment variable.
O ly
Although there are many correct names that you can use, it is usually a good idea to avoid names that
& On
map to hardware. For example, if you choose a name that corresponds to a particular disk controller,
l
n a e
then a later upgrade may result in a name that is deceptive. It is much easier to separately track
hardware to logical name mappings.

t e r U s
You should not use names that suggest that a mount point is devoted to one application’s data unless
it is true. For example, you do not want to neglect your Oracle database files just because they were

I n
stored under a mount point called /backup01.

l e
In the original OFA, the concept of a mount point almost always referred to a single physical disk,
that is, each disk had one mount point. In today’s environment, disks can be very large, and they are
c
r a
partitioned to useful sizes. Each partition requires a mount point.
Note: The usage of Automatic Storage Management (ASM) eliminates many of the concerns about

Omount points. ASM is covered in detail in the lesson titled “Automatic Storage Management and
Automatic Storage Management Library Driver.”

Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 13


ORACLE_HOME and ORACLE_BASE

These are directories to implement an OFA-compliant


installation.
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
ORACLE_HOME and ORACLE_BASE

e A
What Is ORACLE_HOME Used For?

c l
The ORACLE_HOME directory is used by any user who wants to use the particular database. It

r a
identifies the directory that has the proper release distribution and binaries for the database. It also

O ly
identifies the default location of the parameter file that launches the database. The ORACLE_HOME
variable does not have to be preset as an environment variable, it can be set during the installation

l & On
process. The directory does not have to exist but the directory structure above it must exist and be
owned by the user named oracle. The ORACLE_HOME variable is typically in the following

n a e
ORACLE_BASE directory: ORACLE_HOME=$ORACLE_BASE/product/10.2.0.
What Is ORACLE_BASE Used For?

t e r U s
The ORACLE_BASE directory is typically a higher-level directory than ORACLE_HOME. It can be

I n
used by shell scripts that you create. Typically, your data files and administration files are located

l e
below this point. This allows shell scripts to be created that are not dependent on the particular tree
structure, and those scripts continue to work on other machines or reconfigured machines and
c
a
possibly on other releases of the database.

r
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 14
Creating the Oracle Directories

ORACLE_BASE /u01/app/oracle

product flash_recovery_area oradata

<version>

ORACLE_HOME /u01/app/oracle/product/10.2.0/db_1

m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Creating the Oracle Directories

e A
c l
The ORACLE_BASE directory must be created by root. The ownership of the directory must be
assigned to the oracle user and the oinstall group. Following the examples in previous slides,

r a
use the command chown oracle:oinstall /u01/app/oracle. Repeat this procedure for
the directories that are designated to hold database files. The ORACLE_HOME directory is
O ly
successfully created by the OUI as long as the permissions on the ORACLE_BASE directory are
correct.
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 15
Installing New Releases

• Provide a separate tree for each release. This tree is


deleted after an upgrade (when it is no longer in use).
• Place releases in a directory named h/product/v,
where:
– h is the ORACLE_BASE directory
– v is the version identifier or release number
Example:
— /u05/app/oracle/product/10.2.0
— /u02/app/oracle/product/9.2.0
• Maintain the /etc/oratab file, which lists the existing
ORACLE_HOME directories.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Installing New Releases

e A
c l
Each new release gets its own directory. As new releases are added, the old release directories can be
removed. Therefore, the release directory should contain only files that are specific to that release.

r a
You must store only the files that are installed by the OUI in the ORACLE_HOME directory.

O ly
Installing a new release often results in multiple databases running under different releases. Each
instance on a machine specifies the release that it uses in the /etc/oratab file. For example:

l & On
prod:/u02/app/oracle/product/9.2.0:Y

a e
dev:/u05/app/oracle/product/10.2.0:N

r n
When a database is upgraded to use a different release, change the oratab file so that users find the

s
proper ORACLE_HOME directory. For example, to move prod to 10.2.0:

t e U
prod:/u05/app/oracle/product/10.2.0:Y

n
I
When the 9.2.0 database is removed, the directory is no longer needed and can be removed.

e
c l
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 16
Managing Multiple Versions

Set the user environment when several versions of the


database software exist on the same machine.
• Use generic login scripts.
• Use Oracle-supplied scripts to set the environment.

PATH=/usr/bin:/bin:/usr/bin/X11/:/usr/local/bin
ORACLE_SID=orcl

ORAENV_ASK=NO
. oraenv
ORAENV_ASK=

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Managing Multiple Versions

e A
c l
You may want to update from your installed version of the Oracle Database to the current release.
This requires that you can run multiple releases simultaneously. Often, a small group of users or

r a
developers use the new release initially. Later, remaining users switch to using the new release after
your applications have been determined to be stable there. You should have a plan to allow easy
O ly
configuration for multiple database users. Simply installing to ORACLE_HOME is not sufficient.

& On
An upgrade from one version of the Oracle Database to another can be very difficult if not planned
l
n a e
properly. This is especially true during the period when multiple versions of the database software
are on the system, and possibly several databases on the same machine are running from different

t e r U s
ORACLE_HOME directories. One common problem involves setting the user environment to access a
particular database. Another problem has to do with providing proper support libraries for

I n
executables. For example, you can execute a program such as SQL*Plus from a different directory,
but without the proper version of supporting software libraries defined in ORACLE_HOME, the

l e
program will usually fail. These problems and the solution on the following page apply only to users

c
that have OS logins on the database server machine.

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 17
Managing Multiple Versions (continued)
The solution is to embed a call in each user’s login script to a separate file that determines the
environment for the user’s preferred database. This makes the switching over of all users to a
different ORACLE_HOME much simpler. The login script that is used depends on the user login shell.
For the bash shell, the login script would be .bashrc. In the slide, setting ORACLE_SID and
ORAENV_ASK=NO in .bashrc sets a default environment for this user, without requiring user
interaction. Other variations can be set to suit your environment.
Generic Login Script
Each user should have a login script that includes only the environment variables that are specific to
that user, such as the instance SID that the user accesses. A call to the Oracle-supplied oraenv
script from the login script finds and sets the proper ORACLE_HOME and other site-specific, required
environment variables.
oraenv
The oraenv script is provided with the database software and is relocated by the root.sh script at
installation. The default location is /usr/local/bin. If the ORAENV_ASK variable is not set,
then the oraenv script prompts the user for ORACLE_SID that the user wants to set, and presents a
default of ORACLE_SID in the user’s environment. This is a convenient way for users to change
their environments or access multiple databases. If ORAENV_ASK is set to NO, then oraenv does
not prompt the user, but sets ORACLE_HOME and other variables unless ORACLE_SID is set to a
value not specified in the /etc/oratab file. In that case, the user is asked to provide
ORACLE_HOME for the SID. If ORAENV_ASK is set to anything other than NO (including a blank),
then the user will be prompted. Korn, Bourne, and bash shell users can use the oraenv script;
m y
d e
coraenv is provided for C shell users. The oraenv script should be customized for each site. If
the site requirements change, the DBA can modify oraenv and alter all the users’ environments

c a
without changing every login script. The oraenv script calls another script, dbhome, which looks
up the ORACLE_HOME associated with the ORACLE_SID in the /etc/oratab file. An example
of calling oraenv from a login script is:
e A
PATH=/usr/local/bin:/$PATH
ORACLE_SID=orcl
c l
export PATH ORACLE_SID
ORAENV_ASK=NO
r a
. oraenv
O ly
ORAENV_ASK=

l & On
Note: The '.' command sources the oraenv script, causing it to run in the current shell. This

a e
allows the oraenv script to set environment variables in this shell. Without the source command,

n
t e r
the parent forks a new shell, the script executes and exits, returning to the calling shell.

U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 18
Setting Oracle Environment Variables

Additional optional environment variables:


• ORACLE_BASE: The root of the Oracle software
directory structure
• ORACLE_SID: The initial instance name
• ORA_NLS10: The location of the character set files
• TMPDIR and TMP: An optional location for temporary
space if required
• ORACLE_HOSTNAME: The name of the host on which to
install the software; used for servers with multiple
network cards
• ORACLE_DOC: The location of Oracle documentation
• LANG: System language
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Setting Oracle Environment Variables

e A
c l
In an OFA-compliant installation, there will be a root directory for all the Oracle software and
database files. This often has the form of /<mount_point>/app/oracle and is

r a
$ORACLE_BASE. The ORACLE_BASE variable is set to reduce typing errors during the installation.
This directory must exist and be owned by oracle with group dba before the installer is started.
O ly
You can set the ORACLE_SID in the Database Creation Wizard.

& On
ORA_NLS10 is required to be set only if the .nlb message files and character set files are placed in
l
n a e
a directory other than the default directory. The default directory is
$ORACLE_HOME/ocommon/nls/admin/data.

t e r U s
The OUI can use up to 400 MB of space in the /tmp directory, and the OS commands that are run
by the installer can use an additional 100 MB of space. If there is not enough space in /tmp, then

I n
use the TMPDIR variable to direct the OS commands to use an alternative directory, and the TMP
variable to redirect the commands that would normally use the /tmp directory.

l e
ORACLE_DOC is an optional environment variable that is used to specify the installation location of
c
a
the Oracle online documentation.

r
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 19
Setting Oracle Environment Variables (continued)
LANG is a mandatory system environment variable that may optionally be changed for the Oracle
user. Normally, the LANG variable will be set to something like en_US.utf8 when you install your
operating system. For the oracle user, the character set (utf8) should be omitted so that the
environment variable is just en_US. Failure to set this variable for the oracle user will limit
Oracle Enterprise Manager functionality, including the abilities to:
• Store preferred credentials
• Run jobs
• Access reports
LD_LIBRARY_PATH specifies the path to C libraries. For the oracle user, that path normally
includes the system default (/usr/lib and /usr/X11R6/lib), as well as the following:
• $ORACLE_HOME/jdk/jre/lib/i386
• $ORACLE_HOME/jdk/jre/lib/i386/lib
• $ORACLE_HOME/rdbms/lib
• $ORACLE_HOME/lib

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 20
Mounting the CD-ROM

To mount the CD-ROM with the Oracle software, perform


the following steps:
1. Insert CD into the CD drive on the server.
2. Click the CD-ROM icon or start the User Mount tool.
Do not make your working directory the CD
mount point.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Mounting the CD-ROM

e A
c l
Log in as the Oracle software owner. Insert the CD-ROM marked Disk 1. Start the User Mount tool
or click the CD-ROM icon. If a file navigator is displayed, close the navigator. During the

r a
installation, the second and third CD-ROMs will have to be mounted. The current CD-ROM cannot
be unmounted or ejected if any process, including the navigator, is accessing it. Depending on your
O ly
access privileges, another terminal session logged in as root may be needed to mount and unmount

l & On
the CD-ROM. The commands to mount and unmount a CD-ROM are:
# mount -t iso9660 /dev/cdrom /media/cdrom

a e
# umount /media/cdrom

n
t e r
If /etc/fstab has the default settings for mounting /dev/cdrom, then the mount command
can be simplified to the following:
U s
n
# mount /media/cdrom
Staging the CDs

e I
c l
On machines that have sufficient disk space, the CD-ROMs can be copied to disk. This allows faster
installations and network installations.

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 21
Starting the Installer

• Start the OUI from the user’s home directory.


• At the prompt, issue the runInstaller command.

$ cd
$ pwd
/home/oracle
$ /media/cdrom/database/runInstaller

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Starting the Installer

e A
c l
The cd command with no arguments changes your working directory to your $HOME directory.
Using the oracle user created previously, this would be /home/oracle. Do not run the

r a
runInstaller command from the CD-ROM mount point. If you do, you will not be able to eject
and insert the CDs when requested by the Oracle Universal Installer (OUI).
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 22
Oracle Universal Installer

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Oracle Universal Installer

e A
supports.
c l
The Oracle Universal Installer is Java based, so it is the same across all platforms that Oracle

r a
After the Welcome screen and before the File Location screen, you are prompted to do the following:

O ly
1. Provide the Inventory Location. This defaults to $ORACLE_BASE/oraInventory.
2. Provide the Linux Group for the Oracle Inventory user.
& On
3. Run the two specified scripts. You must go to a separate window as root and run this script.
l
n a e
Follow the instructions in the pop-up window. If the installation fails after this script is run, then
the /etc/oraInst.loc file must be removed for successful reinstallation. If there are prior

t e r U s
Oracle installations on this server, do not remove the oraInst.loc file; contact Oracle
Support. The oraInst.loc file contains a pointer to the location of the inventory and the

n
ORAINVENTORY group name. You require this file for removal or upgrading.
I
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 23
Installation Log Files

The log files for the Oracle Universal Installer are in this
directory: $ORACLE_BASE/oraInventory/logs
$ cd $ORACLE_BASE/oraInventory/logs
$ ls *.log
installActions2005-07-07_01-42-01AM.log
INFO: Configuration assistant "Oracle Database
Configuration Assistant" succeeded
INFO: Command =
/u01/app/oracle/product/10.2.0/db_1/bin/isqlplusctl
start

iSQL*Plus 10.2.0.1.0
Copyright (c) 2003, 2005, Oracle. All rights reserved.

Starting iSQL*Plus ...


m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 24
Prerequisite Check Results

The results of the installation prerequite checks are in this


file: /u01/app/oracle/oraInventory/logs/results/db
.
.
.
Checking for binutils-2.14;
found binutils-2.14.90.0.4-35. Passed
Checking for gcc-3.2;
found gcc-3.2.3-42. Passed
Checking for libaio-0.3.96;
found libaio-0.3.96-3. Passed
Check complete.
The overall result of this check is: Passed

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 25
Oracle Patch Utility

Use OPatch to:


• Apply other temporary patches
• Roll back temporary patches
• List installed Oracle components and temporary
patches
• Attach an installed ORACLE_HOME to a central inventory

$ opatch apply
...
OPatch succeeded.
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Oracle Patch Utility

e A
c l
The Perl-based OPatch allows the application and rolling back of temporary patches. OPatch is
installed as part of the Oracle 10g Database installation; it can be found under the
$ORACLE_HOME/OPatch directory.
r a
O ly
To install a patch with OPatch, you must have:
• Perl interpreter version 5.005_03 or later installed. Version 5.6 is preferred.
& On
• A Java Runtime Environment (JRE). It is automatically installed with Oracle Database 10g
l
Release 2.

n a e
• Execute privileges on the fuser utility. OPatch uses fuser to check that no Oracle database

t e r U s
processes are running before it applies a patch. fuser is usually located in /sbin for Linux
distributions and must be copied to the OPatch directory with operating system permissions

I n
changed so the Oracle user can execute it.
• Exclusive control of the Oracle Inventory directory. OPatch updates the inventory to reflect

l e
interim patches. There can be no other instance of OPatch or OUI running in order for OPatch to

c
succeed.

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 26
Oracle Patch Utility (continued)
You can use OPatch to:
List currently installed components: Use the lsinventory command to list all installed
components for your current ORACLE_HOME including any temporary patches already applied via
OPatch.
$ opatch lsinventory –oh <ORACLE_HOME> -all
The -oh <ORACLE_HOME> argument can be omitted if you want to display the inventory for the
ORACLE_HOME defined by $ORACLE_HOME.
The optional -all argument may be used in place of the -oh argument to display the contents of
ALL ORACLE_HOMEs registered with the inventory.
Apply temporary patches: Use the apply command to apply a temporary patch.
$ opatch apply <patch directory> <ORACLE_HOME>
If the <patch directory> argument is not supplied, then OPatch looks for the patch in the current
directory. If the <ORACLE_HOME> argument is not supplied, then OPatch applies the patch to
ORACLE_HOME defined by $ORACLE_HOME.
Remove temporary patches: Use the rollback command to remove a temporary patch that has
been applied by OPatch.
$ opatch rollback –id <patch id> -ph <patch directory>
By default, OPatch removes the patch from ORACLE_HOME specified by the $ORACLE_HOME
environment variable. You can add the optional flag –oh <ORACLE_HOME> if you want to remove
the patch from a different ORACLE_HOME. The patch ID and patch directory arguments are
m y
mandatory to remove a patch.

d e
Attach an installed ORACLE_HOME to a central inventory: Use the attach command to add an

c a
ORACLE_HOME to an existing inventory. This may be necessary if the Oracle Database software was
transferred from one system to another without the inventory, which is a nonstandard, unsupported
installation method.

e A
c l
$ opatch attach –name <OH name> -oh <ORACLE_HOME>
If ORACLE_HOME is not specified, then OPatch uses ORACLE_HOME defined by $ORACLE_HOME.

r a
For help on any of the OPatch commands, use the –help argument:
$ opatch –help
$ opatch attach –help O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 27
Oracle Relink Utility

To relink Oracle executables, perform the following steps:


1. Verify whether ORACLE_HOME is correctly set.
2. Set LD_LIBRARY_PATH to include $ORACLE_HOME/lib.
3. Execute the appropriate relink command to relink the
appropriate binaries:
– relink all: All Oracle executables
– relink oracle Database executables
– relink network: Listener, cman, names
– relink oemagent: Intelligent Agent
– relink utilities: SQL*Loader, tkprof, rman,
impdp, expdp, imp, exp
– relink ctx: Oracle Text
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Oracle Relink Utility

e A
c l
The Oracle Database 10g software is not distributed as a group of complete executables. Instead,
Oracle distributes individual object files, library archives of object files, and some source files which

r a
then get “linked” at the operating system level during installation to create usable executables. This
guarantees a reliable integration with functions provided by the OS system libraries.
O ly
If the operating system or Oracle object files change, then Oracle executables should be relinked to
& On
create updated executables properly integrated with the operating system.
l
• An OS upgrade has occurred
n a e
Relinking occurs automatically when a patch set is installed, but must be performed manually when:

OS patch.
t e r U s
• A change has been made to the OS system libraries. This can occur during the application of an

I n
• A new installation failed during the relinking phase.
• An individual Oracle patch has been applied. Explicit relink instructions are usually either

l e
included in README or integrated into the patch install script.
c
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 28
Oracle Relink Utility (continued)
To relink, you can use the relink utility as shown in the preceding slide, or manually relink with the
make command. Unlike OPatch, the relink utility does not return positive feedback. Unless you
receive an error message, relink succeeded.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 29
Troubleshooting

If you have problems during the installation:


• Check the kernel parameter settings
• Check the environment variables
• Check directory permissions
• Verify that the required packages are installed

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Troubleshooting

e A
preinstallation setup.
c l
There are some common problems with the installation. Many are the result of missing a step in the

r a
Kernel parameters errors, often the result of typographic errors, can cause ORA-3113 End of

O ly
File on communication channel, or an OS error indicating that there is not enough shared
memory or semaphores. These usually show up when the Database Creation Assistant tries to start an
instance.
l & On
n a e
Environment variables can lead to a variety of errors again due to incorrect typing. The directory to
be used as the ORACLE_BASE must exist and be owned by the user that is running the installer. The

environment variable.
t e r U s
C compiler and supporting utilities must be installed and the directory must be included in the PATH

I n
The OUI is very convenient to use. The error pop-up windows normally allow you to go to another

l e
window, fix the problem, and click Retry. The only errors that cannot be fixed in this manner are the
environment variables. If you discover that the problem is with environment variables, then you must
c
r a
exit the OUI, change the variable, and restart the installer. The installer inherits the environment
when it starts, and the installer environment cannot be changed while the installer is running.

O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 30
Summary

In this lesson, you should have learned how to:


• Describe the Linux file system security
• Install Multiple versions of Oracle Database software
on the same server
• Accommodate multiple Oracle homes on one database
server

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 31
Practice 3 Overview:
Installing Oracle on Linux

This practice covers the following topics:


• Working with Linux users and groups
• Installing Oracle on Linux

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 3 - 32
Managing Storage

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Objectives

After completing this lesson, you should be able to:


• Distinguish the differences between certified and
supported file systems
• Select a file system

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 4 - 2
Certified and Supported
File Systems

• Linux supports multiple file systems.


• Oracle supports some of the file systems.
• Oracle certifies three file systems:
– ext3
– Automatic Storage Management
– Oracle Cluster File System/Oracle Cluster File System 2
• Criteria for choosing a particular file system are:
– Reliability
– Performance
– Security

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Certified and Supported File Systems

e A
c l
One of the most interesting features of the Linux OS is its support for multiple file systems.
File systems can be defined and built on a partition basis; ext3, XFS, and ReiserFS file

r a
systems can coexist on the same Linux system, along with several other file systems and raw

O ly
partitions. Your choice of which one to use should be based on supportability, reliability,
security, and performance.

l & On
To be acceptable for database use, the file system must perform certain minimum functions

n a e
such as write acknowledge, write-thru cache, and file permissions. Examples of file systems
that are not normally acceptable for database use are XFS, and Virtual File Allocation Table

t e r U s
(VFAT), which lack file permissions.
There is an important distinction between supported and certified file systems. Oracle only

I n
certifies ext3, Oracle Automatic Storage Management (ASM), and Oracle Cluster File

e
System/Oracle Cluster File System 2 (OCFS/OCFS2). If it is determined that an issue is
l
caused by the file system and the file system is certified, then Oracle Support will work on the
c
issue. If you choose to run on other file systems, such as ReiserFS, and have a file system

r a
issue, you will be supported, but it will be the OS vendor providing the file system support.

O
Oracle Database 10g: Managing Oracle on Linux for DBAs 4 - 3
Disk Partitioning

Linux uses disk partitions effectively to segregate


directories and ease recovery:
• /boot
• /
• /var/log
• /tmp
• /home
• /<mount_point>/oracle

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Disk Partitioning

e A
c l
Disk partitioning is not required by Linux or by Oracle software. However, disk partitioning
can reduce the time consumed in operations such as planning for recovery, upgrades, and
backups.
r a
O ly
The larger the partition the longer a file system check (fsck) operation takes on bootup.
Much of this time can be avoided by using a journaled file system, such as ext3. Having a

l & On
small /boot partition that holds only the current kernels separates the tasks of booting the
machine and recovering a partition. A typical size of this partition is from 10 MB to 100 MB.

n a e
For Enterprise Linux, it is recommended that you have approximately 100 MB for the boot
partition.

t e r U s
The / partition should hold only a few directories that are created with the distribution

I n
installation. These directories are overwritten with a new installation or upgrade. (Keep track
of any customized configuration files that you place under this partition, because they will also

l e
be overwritten during a new installation or upgrade.)
c
The /var/log and /tmp should be separate partitions to isolate the effects of runaway

r a
processes. The /tmp partition should be at least 400 MB.

O
Oracle Database 10g: Managing Oracle on Linux for DBAs 4 - 4
Disk Partitioning (continued)
If these separate partitions become full, the process dies or stops logging. If these directories
become full when they are on the / partition, the system can crash. If /home is a separate
partition, it can be backed up and restored separately. An OS upgrade need not touch this
partition.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 4 - 5
Comparing File Systems

Linux supports multiple file systems:


• Operating system (OS) is file system independent.
• Multiple file systems can be on the same server.
– Cross-platform compatibility
– Performance
– Special requirements: Oracle Cluster File System (OCFS)

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Comparing File Systems

e A
c l
The Linux kernel is file system independent. It has a file system API. If the file system uses
the API, it can be supported. A variety of file systems are available with the standard

r a
distribution. Some are just for compatibility with other systems, such as FAT32 for MS
Windows compatibility. Others are included for historical reasons, such as minix which was
O ly
the first file system supported by Linux. The most popular file systems are ext3 and

l & On
ReiserFS. There are other file systems available from various sources. Most of these should
be considered experimental. Oracle provides Automatic Storage Management (ASM) and
a e
Oracle Cluster File System/Oracle Cluster File System 2 (OCFS/OCFS2). The OCFS is
n
t e r s
designed for use with Linux clusters running the Real Application Clusters (RAC) database.
This file system overcomes the limitations of raw devices on Linux.
U
I n
OCFS2 has been designed to be a general purpose cluster file system. With it, you can store
not only database-related files on a shared disk, but also store Oracle binaries and

l e
configuration files (shared Oracle home) making management of RAC even easier. OCFS2

c
began shipping as part of the Linux kernel in version 2.6.16.

r a
Oracle recommends using ASM for database files.

O
Oracle Database 10g: Managing Oracle on Linux for DBAs 4 - 6
File System Characteristics

Certain characteristics are better for database use:


• Write-thru-cache ability
• Write acknowledgement
• Security
• Journaling
• High Performance

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
File System Characteristics

e A
c l
In choosing a file system, performance is important, but not the primary consideration. It does
not matter how fast the file system is if the data is corrupted, lost, or compromised. To achieve

r a
this end, the Oracle database does not support database files on file systems that do not have a
write-thru-cache capability. Supported file systems must acknowledge writes. There are
O ly
security requirements as well. Oracle server and the database files require special file

l & On
permissions that are not available on certain file systems. When these file permissions are not
set correctly, the Oracle server does not function properly. Data files should be accessible only
a e
to the database owner, and all other access should be controlled by the database itself.
n
t e r U s
Journaling is a popular characteristic. The major benefit is that the changes to the file system
are recorded in a journal file similar to database redo logs. If the server crashes or shuts down

I n
without synchronizing the disks, then the journal file can be applied to the file system, thus
restoring the file system integrity very quickly. This effect can be seen on bootup. The fsck

l e
command checks journaled file systems more quickly than nonjournaled file systems.

c
Oracle Database must be able to verify that writes to a disk are completed successfully.

r a
Standard NFS, including file systems on NAS devices, may not be able to guarantee that
writes to a disk are completed successfully, and this may lead to possible data file corruption.
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 4 - 7
File System Characteristics (continued)
Oracle recommends that you do not store files on standard NFS. If you use NFS, it is
recommended you use a storage vendor and storage device listed in the Oracle Storage
Compatibility Program list. This list is available from the following Web site:
http://www.oracle.com/technology/deploy/availability/htdocs/oscp.html
If a storage device is supported, then you can use it to store Oracle software files, Oracle
database files, or both.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 4 - 8
Automatic Storage Management

• Provides a vertical integration of the file system and


volume manager for Oracle database files
• Spreads database files across available storage for
optimal performance and resource utilization
• Enables simple and nonintrusive resource allocation
• Provides automatic rebalancing
• Works in single instance and Real Application Cluster
(RAC) databases

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Automatic Storage Management

e A
c l
Automatic Storage Management (ASM) provides an integrated file system and volume
manager specifically for Oracle database files.

r a
ASM spreads database files evenly across available disks. ASM enables you to nonintrusively

O ly
add or remove storage. Disk space can be added or removed while the database is online.
Automatic Storage Management can be used with single instance or RAC.

l & On
Managing multiple file systems and hundreds or thousands of files for a large database can be

n a e
very cumbersome. With ASM, you assign large pools of disks in disk groups to ASM, then
allow ASM to manage the files stored on those disks. You need to manage only the disks, not
the files.
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 4 - 9
ext2 and ext3

The ext2 and ext3 file systems are closely related:


• ext2 can be converted to ext3.
• ext3 can be mounted as an ext2 file system.
• ext3 is a journaled file system.
• ext3 has several performance enhancements.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
ext2 and ext3

e A
c l
The differences between the ext2 and ext3 file systems are important. ext2 has, in
computer terms, a long history of improvements and reliability. ext3 starts with the same

r a
base and adds journaling and speed. In general, journaling is slower than nonjournaled file
systems, but ext3 optimizes the disk head movement to give excellent performance. In
O ly
several tests that compared ext2, ext3, ReiserFS, and raw, ext3 was the fastest.

l & On
ext3 has three journaling levels that may be set with the -o option in the mount command
or in the options section of /etc/fstab. The highest level—the one that does the most
a e
journaling is data=journal—writes the journal entries for all the data and metadata
n
t e r U s
changes. The lowest level, which does the least journaling, is data=writeback with only
metadata being written. The default is data=ordered, where metadata with increased

I n
integrity is written.
Comparing ext3 at different journaling levels has not been as thoroughly documented, but

l e
preliminary results indicate that setting data=journal is the fastest and most reliable. The

c
other levels of journaling, data=writeback (the lowest) and data=ordered (the

r a
default), would be expected to yield performance benefits at the expense of reliability, but do
not seem to be faster.
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 4 - 10
Oracle Clustered File System 2

Oracle Corporation makes OCFS2 available under the


General Public License (GPL) for use with Linux.
• OCFS2 is a general purpose cluster file system that
shares between files nodes of a cluster:
• OCFS2 can be downloaded from:
— http://oss.oracle.com
• More information about OCFS2 and other products
from Oracle’s Linux Projects Development group can
be found at Oracle’s home for Open Source projects,
http://oss.oracle.com, and the Oracle Technology
Network http://otn.oracle.com.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Oracle Clustered File System 2

e A
c l
Oracle Clustered File System 2 (OCFS2) is designed to be a general-purpose cluster file
system. It can store data files, as well as binaries and configuration files.

r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 4 - 11
Network File System

• Oracle Compatible Network Attached File Servers


– http://www.oracle.com/technology/deploy/availability/htd
ocs/vendors_nfs.html
• Oracle Storage Compatibility Program (OSCP)
– http://www.oracle.com/technology/deploy/availability/htd
ocs/oscp.html

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Network File System

e A
c l
Oracle supports only NFS protocol with network file servers. Oracle does not support CIFS
protocol because CIFS protocol cannot guarantee certain write block size and data
commitment to disk or cache.
r a
O ly
Oracle does not recommend using an NFS device unless the NFS vendor is a member of the
Oracle Storage Compatibility Program (OSCP). Members in OSCP test and verify their
& On
products compatibility with the Oracle product.
l
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 4 - 12
Summary

In this lesson, you should have learned how to:


• Distinguish between certified and supported file
systems
• Choose a file system

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 4 - 13
m y
d e
ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Automatic Storage Management
and Automatic Storage Management
Library Driver

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Objectives

After completing this lesson, you should be able to:


• Install and initialize Automatic Storage Management
Library Driver (ASMLib)
• Mark disks for ASMLib
• Create an Automatic Storage Management instance

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 5 - 2
Automatic Storage Management

• Instance

• Disks

• Disk groups

• Files

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Automatic Storage Management

e A
Instance

c l
The Automatic Storage Management (ASM) instance is a special Oracle instance that manages

r a
disks in disk groups. An ASM instance must be configured and running before a database

O ly
instance can access Automatic Storage Management files. This configuration is performed
automatically if the Database Configuration Assistant is used for database creation.
Disk Group
l & On
n a e
A disk group is a set of disk devices that ASM manages as a single unit. Each disk device can be
an individual physical disk, a multiple disk device such as a redundant array of inexpensive disks

e r s
(RAID) storage array or logical volume, or even a partition on a physical disk. However, in most
t U
cases, disk groups consist of one or more individual physical disks. To enable ASM to balance

I n
I/O and storage efficiently within the disk group, you must ensure that all devices in the disk
group have similar, if not identical, storage capacity and performance.

c l e
ASM spreads data evenly across all the devices in the disk group to optimize performance and

r a
utilization. You can add or remove disk devices from a disk group without shutting down the
database. When you add or remove disks, ASM rebalances the files across the disk group. You

Ocan create multiple disk groups to handle specific tasks, such as backup and recovery operations,
in addition to regular file storage activities.

Oracle Database 10g: Managing Oracle on Linux for DBAs 5 - 3


Automatic Storage Management
Library Driver (ASMLib)

• Simplifies configuration and management of disks


• Eliminates the need for binding raw devices
• Download RPMs from http://www.oracle.com

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Automatic Storage Management Library Driver (ASMLib)

e A
c l
The Automatic Storage Management library driver (ASMLib) simplifies the configuration and
management of the disk devices by eliminating the need to rebind raw devices used with ASM
each time the system is restarted.
r a
O ly
If you intend to use Automatic Storage Management for database storage for Linux, then Oracle
recommends that you install the ASMLib driver and associated utilities, and use them to

is known as a candidate disk.


l & On
configure candidate disks. A disk that is configured for use with Automatic Storage Management

n a e
If you do not use the Automatic Storage Management library driver, then each disk device that

t e r U s
you want to use must be bound to a raw device.

I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 5 - 4
Installing and Initializing
ASMLib

# rpm –Uvh oracleasm*


Preparing… ##################### [100%]
1: oracleasm-support ##################### [ 33%]
2: oracleasm-2.6.9-22.EL ##################### [ 67%]
3: oracleasmlib ##################### [100%]

# /etc/init.d/oracleasm configure

# /etc/init.d/oracleasm enable

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Installing and Configuring ASMLib

e A
specific to your kernel.
c l
To install ASMLib, you need to download three RPMs from http://www.oracle.com, which are

r a
After downloading, install the RPMs with the Uvh option.
rpm –Uvh oracleasm*
O ly
After the RPMs are installed, execute /etc/init.d/oracleasm with the configure
option.
l & On
n a e
/etc/init.d/oracleasm configure
You will be prompted four times.

t e r U s
• Default user to own the driver interface
• Default group to own the driver interface

I n
• Start Oracle ASM library driver on boot
• Fix permissions of Oracle ASM disks on boot

l e
The user who owns the driver interface should be the same user who owns the software
c
r a
installation, typically oracle. The group to own the driver interface should be the group used
for DBAs, typically dba. You will want ASMLib to start when the system boots and to fix

Opermissions of ASM disks.


After it is configured, to enable ASM, run the oracleasm utility with the enable option.

Oracle Database 10g: Managing Oracle on Linux for DBAs 5 - 5


Configuring Disks

Oracle recommends that you create a single whole-disk


partition on each disk that you want to use.
# /sbin/fdisk /dev/sdc
# /sbin/fdisk /dev/sdd

To ensure that the kernel is aware of the partition


changes, run the partprobe command after partitioning
all disks.
# /sbin/partprobe

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Configuring Disks

e A
c l
Oracle recommends that you create a single whole-disk partition on each disk that you want to
use. Use either fdisk or parted to create a single whole-disk partition on the disk devices that
you want to use.
/sbin/fdisk /dev/sdc r a
O ly
The kernel may be unaware of the partition changes after partitioning the disks. The partprobe

/sbin/partprobe
l & On
command searches for partitions information and informs the kernel of partition table changes.

n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 5 - 6
Marking Disks As Automatic
Storage Management Disks

# /etc/init.d/oracleasm createdisk DF1 /dev/sda1


# /etc/init.d/oracleasm createdisk DF2 /dev/sdb1
# /etc/init.d/oracleasm createdisk FRA1 /dev/sde1
# /etc/init.d/oracleasm createdisk FRA2 /dev/sdf1

# /etc/init.d/oracleasm scandisks

m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Marking Disks As Automatic Storage Management Disks

e A
c l
When using ASMLib, disks must be marked for ASM usage. In the process of marking a disk,
you must assign a name to the disk. Meaningful names can be assigned for each disk.
You may create multiple disk groups.
r a
O ly
By providing descriptive names to each disk, you will have an easier time assigning disks to disk
groups when creating the ASM instance. When choosing names for drives, consider using the

l & On
physical location of the drive in the name.

a e
Disks are marked by using the createdisk option with /etc/init.d/oracleasm:

n
r
/etc/init.d/oracleasm createdisk DF1 /dev/sda1

e s
To make the disks available, use the scandisks option:
t U
n
/etc/init.d/oracleasm scandisks

e I
c l
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 5 - 7
Creating an ASM Instance

• Use DBCA to create the ASM instance.


• Select Configure Automatic Storage Management.
• Run the $ORACLE_HOME/bin/localconfig add
command when prompted:

$ su –
# /u01/app/oracle/product/10.2.0/db_1/bin/localconfig add

• Default parameters for the initialization parameter file


are sufficient for a single instance database.
• Create two disk groups:
– Database
– Flash recovery area
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Creating an ASM Instance

e A
c l
An ASM instance manages ASM disk groups. Before starting or creating a database instance,
which uses ASM to manage its disks, the ASM instance must be running.

r a
When you choose Automatic Storage Management as a database storage mechanism in the

O ly
Database Configuration Assistant (DBCA), an ASM instance is created and started. You then
assign disks to disk groups within DBCA.

l & On
If you create multiple single-instance databases on a node, a single ASM instance can handle all

n a e
the disk groups for the databases on the node.
Note: Screenshots for using DBCA to create an ASM instance can be found in the lab solutions

e r
for this lesson in Appendix B.
t U s
I n
Oracle recommends that you use ASM for database files and the flash recovery area. Separate
disk groups may be created for each.

c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 5 - 8
ASM and ASMLib Installation
and Configuration Summary

• Download and install the ASMLib RPMs.


• Run oracleasm configure.
• Run oracleasm enable.
• Create a single whole-disk partition on each disk.
• Run partprobe to ensure that the kernel is aware of
the new partitions.
• Mark disks as Automatic Storage Management disks.
• Run oracleasm scandisks to make the disks
available.
• Create the ASM instance using the Database
Configuration Assistant.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 5 - 9
ASM Installation: Best Practices

• Install ASM in a separate ORACLE_HOME from the


ORACLE_HOME database:
– This provides higher availability and manageability.
– It allows independent upgrades of the database and
ASM.
– Deinstallation of the database software can be performed
without impacting the ASM instance
• Create one ASM instance per node.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
ASM Installation: Best Practices

e A
c l
Install Automatic Storage Management in a separate ORACLE_HOME from the ORACLE_HOME(s)
database. Creating the ASM Instance from the same ORACLE_HOME as the databases creates a

r a
single point of failure. A separate ORACLE_HOME allows independent upgrades of the ASM and
the database. The database or ASM can be upgraded without upgrading the other. The
O ly
ORACLE_HOMEs database can be deinstalled without affecting the ASM instance.

databases on the node.


l & On
Create only one ASM instance per node. The ASM instance will manage storage for all

n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 5 - 10
Disk Group: Best Practices

• Create two disk groups:


– Database area
– Flash recovery area
• Create disk groups using large numbers of similar type
disks:
– Same size characteristics
– Same performance characteristics

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Disk Group: Best Practices

e A
c l
Create two disk groups: one for the database area and the other for the flash recovery area.
However, more disk groups can be created; using two will be easier to manage.

r a
Automatic Storage Management performs load balancing. Using disks with the same size and

O ly
performance characteristics will assist ASM to properly balance the files across the disks.

l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 5 - 11
Summary

In this lesson, you should have learned how to:


• Install and initialize ASMLib
• Mark disks for ASMLib
• Create an ASM instance

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 5 - 12
Practice 5 Overview:
Installing and Configuring ASMLib and ASM

This practice covers the following topics:


• Installing Oracle ASMLib RPMs
• Configuring ASMLib
• Configuring disks
• Marking disks for ASM
• Creating an ASM instance

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 5 - 13
m y
d e
ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Creating the Database

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Objectives

After completing this lesson, you should be able to:


• Create an Oracle database that uses ASM
• Identify the location of various Oracle files
• Implement OS authentication

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 6 - 2
Creating a Database

$ dbca

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Creating a Database

e A
c l
You can use DBCA to create a database, either in silent mode or via a graphical interface. Using the
graphical interface, you answer about 12 questions, and then the creation process starts. Some of the

r a
questions are regarding the name of the database, passwords for users, and the storage mechanism to
use.
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 6 - 3
Choosing the Storage Mechanism

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Choosing the Storage Mechanism

e A
c l
You have three options for your database’s storage: File System, Automatic Storage Management
(ASM), and Raw Devices. These options are explained in detail in the lesson titled “Managing

r a
Storage.” If you choose Automatic Storage Management, then there must be an ASM instance
running at the time.
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 6 - 4
Specifying the ASM Disk Groups

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Specifying the ASM Disk Groups

e A
c l
If you choose ASM for the storage mechanism, then you are presented with a list of existing ASM
disk groups. Select the disk groups that you plan to use for this database. In the example in the slide,

r a
there are two disk groups displayed: DF and FRA. In this case, for example, you may intend to use
DF for the data files and FRA for the flash recovery area for this database, so both are selected.
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 6 - 5
Assigning ASM Disk Groups

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Assigning ASM Disk Groups

e A
c l
Now that dbca is aware of the ASM disk groups that are to be used for this database, you can assign
them to be used for database file locations and the flash recovery area. In this example, Oracle-

r a
Managed Files is being used, and the +DF disk group is to contain those files. After specifying that,
you can specify if there is a flash recovery area, and where it is to be stored. This example is
O ly
following the Oracle-recommended practice of having a separate disk group for the flash recovery
area.
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 6 - 6
dbca Log Files

The $ORACLE_HOME/cfgtoollogs/dbca/<SID> directory


contains text log files of the following, during and after the
creation of the database:
• Creation of the database objects
• Configuration of Enterprise Manager
• Importing of example schemas

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
dbca Log Files

e A
c l
To see the details of the dbca execution, you can navigate to the
$ORACLE_HOME/cfgtoollogs/dbca/<SID> directory and view the log files there, using a

r a
text editor. Here are some sample contents of the tts_example_imp.log file, which shows the
log of the import of the EXAMPLE tablespace:
O ly
$ head tts_example_imp.log

l & On
Connected to: Oracle Database 10g Enterprise Edition Release

a e
10.2.0.1.0 - Production

n
t e r
With the Partitioning, OLAP and Data Mining options

U s
Export file created by EXPORT:V10.02.01 via conventional path

I n
About to import transportable tablespace(s) metadata...
import done in US7ASCII character set and AL16UTF16 NCHAR

c l e
character set
. importing SYS's objects into SYS

r a . importing SYS's objects into SYS


. importing HR's objects into HR

O
Oracle Database 10g: Managing Oracle on Linux for DBAs 6 - 7
The Instance admin Directory

The files that serve as diagnostics are located in


$ORACLE_BASE/admin:

$ cd $ORACLE_BASE/admin
$ ls
+ASM orcl

The orcl database instance

The ASM instance

There is a subdirectory for each instance.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
The Instance admin Directory

e A
c l
In the $ORACLE_BASE/admin directory, there is a subdirectory for each instance. The slide shows
there are two instances in this case, the ASM instance, called +ASM, and the conventional database
instance, orcl.
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 6 - 8
Parameter and Dump Files

The following subdirectories are in the


$ORACLE_BASE/admin/$ORACLE_SID directory:
• adump: Audit files
• bdump: Background process trace files
• cdump: Core dump files
• udump: User process trace files
• dpdump: Default Data Pump output directory
• pfile: Oracle database initialization parameter files

m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Parameter and Dump Files

e A
c l
There is a set of diagnostic directories under each of these instance subdirectories. These can be
referred to when looking for information such as trace files and core dumps, among other things.

r a
Here is an example of the contents of two of the subdirectories:

O ly
$ ls -l *
+ASM:
total 16
drwxr-x--- 2
l & On
oracle oinstall 4096 Sep 26 05:38 bdump
drwxr-x--- 2

n a e
oracle oinstall 4096 Sep 25 08:16 cdump

r
drwxr-x--- 2 oracle oinstall 4096 Sep 26 05:13 pfile
drwxr-x---

t e 2

U s
oracle oinstall 4096 Sep 26 05:38 udump

orcl:
total 24
I n
c l e
drwxr-x---
drwxr-x---
2
2
oracle
oracle
oinstall
oinstall
4096
4096
Sep
Sep
26
26
06:05
05:39
adump
bdump

r a drwxr-x---
drwxr-x---
2
2
oracle
oracle
oinstall
oinstall
4096
4096
Sep
Sep
26
26
05:16
05:16
cdump
dpdump

O drwxr-x---
drwxr-x---
2
2
oracle
oracle
oinstall
oinstall
4096
4096
Sep
Sep
26
26
05:26
05:39
pfile
udump

Oracle Database 10g: Managing Oracle on Linux for DBAs 6 - 9


The portlist.ini File

The portlist.ini file contains all of the port number information for
Oracle-related applications, including:
• iSQL*Plus
• Enterprise Manager Console
$ cd $ORACLE_HOME/install
$ cat portlist.ini
iSQL*Plus HTTP port number =5560
Enterprise Manager Console HTTP Port (orcl) = 1158
Enterprise Manager Agent Port (orcl) = 3938

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
The portlist.ini File

e A
c l
The portlist.ini file is in the $ORACLE_HOME/install directory and contains the record
of port numbers that are used for browser-based applications. For example, this portlist.ini

r a
file indicates that 1158 is the port number for Enterprise Manager Console for the orcl instance.

O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 6 - 10
URL Deployment Information

$ cd $ORACLE_HOME/install
$ cat readme.txt
The following J2EE Applications have been deployed and
are accessible at the URLs listed below.

iSQL*Plus URL:
http://EDRSR9P1:5560/isqlplus

iSQL*Plus DBA URL:


http://EDRSR9P1:5560/isqlplus/dba

Enterprise Manager 10g Database Control URL:


http://EDRSR9P1:1158/em

y
http://EDRSR9P1:1158/em
http://EDRSR9P1:1158/em

em
Copyright © 2007, Oracle. All rights reserved.
a d
URL Deployment Information A c
l e
The readme.txt file in the $ORACLE_HOME/install directory lists the URLs for any J2EE
applications that have been deployed.
c
r a
To start the Enterprise Manager Database Control application, enter the following command as the

O ly
owner of the Oracle software installation (for example, oracle):
$ emctl start dbconsole

l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 6 - 11
Miscellaneous Files

Show the record of installations on this system:


$ cat /etc/oraInst.loc
inventory_loc=/u01/app/oracle/oraInventory
inst_group=oinstall

Set up the Oracle environment:


$ . oraenv
ORACLE_SID = [orcl] ? <Enter>

Show the current ORACLE_HOME directory setting:


$ dbhome
/u01/app/oracle/product/10.2.0/db_1
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Miscellaneous Files

e A
c l
The /etc/oraInst.loc file contains a pointer to the Oracle software inventory directory. It also
specifies the Linux group name that owns the Oracle software. This directory gets created

r a
automatically when using the Oracle Universal Installer (OUI), but it must be created and populated
manually if you are performing a silent installation, and it does not already exist. If Oracle products
O ly
have already been installed on the system, then it exists already.

l & On
The oraenv script, located in the $ORACLE_HOME/bin directory, sets up your Oracle
environment for you based on the value of ORACLE_SID. This is useful to run if you need to switch

n a e
from one database to another on the same system.

t e r U s
The dbhome script reports the current Oracle home directory.

I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 6 - 12
Background Processes

$ ps -eo pid -o command | grep _orcl | grep ora_


3900 ora_pmon_orcl
3902 ora_psp0_orcl
3904 ora_mman_orcl
3906 ora_dbw0_orcl
3908 ora_lgwr_orcl
3910 ora_ckpt_orcl
3912 ora_smon_orcl
3948 ora_q001_orcl
14072 ora_o000_orcl
21647 ora_j000_orcl
.
.
.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Background Processes

e A
c l
There are several processes that make up the executable part of an Oracle instance. You can list these
in Linux by issuing the ps command. Just listing all processes will be too much information, if you

r a
want to see only the processes that belong to a single instance. So, you can use grep to filter the
information out. All the database instance process names start with the string ora_ and end with the
O ly
string _<SID>. So, if you are interested in the orcl instances processed, grepping as shown in the
slide shows you that.
l & On
The ASM instance process names all start with _asm and end with the string _<SID>. So, the

n a e
following command shows you the processes for the +ASM instance:

t e r
6985 asm_pmon_+ASM
U s
$ ps -eo pid -o command | grep _+ASM | grep asm_

I n
6987 asm_psp0_+ASM
6989 asm_mman_+ASM

c l e
6991 asm_dbw0_+ASM
6993 asm_lgwr_+ASM

r a .
.

O .

Oracle Database 10g: Managing Oracle on Linux for DBAs 6 - 13


Background Processes

SQL> select spid, program from v$process


2 where program like '%(DBW0)' or
3 program like '%(LGWR)';

SPID PROGRAM
------ ----------------------
3908 oracle@EDRSR9P1 (LGWR)
3906 oracle@EDRSR9P1 (DBW0)

$ ps -eo pid -o command | grep _orcl | \


> grep -e lgwr -e dbw0
3906 ora_dbw0_orcl
3908 ora_lgwr_orcl

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Background Processes (continued)

e A
c l
After the instance is run, you can map the process IDs from the v$process view to the process IDs
listed by OS commands. The SPID column of the v$process view contains the OS process ID, or

r a
in Linux, this is referred to as the PID.

O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 6 - 14
Server Processes

$ sqlplus hr/hr@orcl
SQL>

$ sqlplus hr/hr
SQL>

$ ps kpid -eo pid -o args | grep oracleorcl


4422 oracleorcl (LOCAL=NO)
5112 oracleorcl
(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
5120 oracleorcl (LOCAL=NO)
24673 oracleorcl (LOCAL=NO)
24675 oracleorcl (LOCAL=NO)
24677 oracleorcl (LOCAL=NO)
25270 oracleorcl (LOCAL=NO)
25293 oracleorcl (LOCAL=NO)
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Server Processes

e A
c l
In an instance that is running in dedicated server mode, there is a one-to-one correspondence of
session to server process. A server process is the process that gets started that is dedicated to

r a
accessing the data files on behalf of a database session, with the purpose of executing commands and
returning results.
O ly
On Linux, all the server processes are named with this pattern: “oracle<SID>”. So, in this case,
& On
where the instance name is orcl, all the server process names are oracleorcl. You can see
l
disconnected.
n a e
server processes appear and disappear from the Linux process list, as sessions are created and

t e r U s
In the example in the slide, there are two sessions. One was started with a service name specifier,
which resulted in process 4422 being spawned. Note that the argument says LOCAL=NO. That is

I n
because it came through the listener. Then another SQL*Plus session was established, this time
without using a service name. The server process for that session is 5112, and the argument indicates

l e
that LOCAL=YES.
c
r a
Note: For shared server mode, there are other processes involved, called dispatchers, and there is no
longer a one-to-one correspondence of session to server process. For more information about shared

Oserver mode, refer to the Oracle Database Administrator’s Guide.

Oracle Database 10g: Managing Oracle on Linux for DBAs 6 - 15


Process Hierarchy

PID PPID COMMAND


1 0 init [5]
6474 1 gnome-terminal
17664 6474 bash
18556 17664 sqlplus as sysdba
18557 18556 oracleorcl
(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Process Hierarchy

e A
c l
When one process starts another process, the first process is referred to as the parent, and the
spawned process is referred to as the child process. This can be observed in Oracle Database

r a
processes if you list the parent process IDs in Linux.

O ly
The example in the slide shows the session details for a particular session that was created using
SQL*Plus. So, the database records the client process ID as 18556, which is the SQL*Plus process.
& On
This process started the dedicated server process, identified by a process ID of 18557. So, in the ps
l
n a e
listing, the SQL*Plus process is the parent of the server process. You can continue to follow the
process hierarchy until you get to the init process. The SQL*Plus program was invoked from inside

t e r U s
the bash shell (running in the Gnome windowing system), which was invoked by the init process,
which started the operating system at boot time.

I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 6 - 16
Implementing OS Authentication for DBAs

OS authentication is the provisioning of access to the


database based on the OS username rather than a
database username, and is implemented by doing the
following:
1. Create the needed OS accounts for users.
2. Define the OSDBA and OSOPER operating system
groups.
3. Assign those groups to the users you want
authenticated.
4. Set REMOTE_LOGIN_PASSWORDFILE parameter to NONE.

Now, as one of those users, you can log in, including AS


SYSDBA or AS SYSOPER in the connect string.
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Implementing OS Authentication for DBAs

e A
c l
Provisioning of access is the process of authenticating a user to the database, that is, allowing access
to it. Operating system authentication is a type of access provisioning that imposes the operating

r a
system credentials onto the database, allowing the database to discern access based on that, rather
than the database requiring username and password information. By default, the database is
O ly
configured to allow certain users to connect without a password. The database considers the OS to be

l & On
trusted to provide the authentication service. The configuration shown is for privileged users and is
configured by default when using the Oracle Universal Installer. A privileged user is granted the
SYSDBA or SYSOPER privilege.
n a e
t e r U s
Any OS user that is a member of the OSDBA group, named dba by default, can connect to the
database with “/ as SYSDBA” included in the connect string.

I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 6 - 17
Summary

In this lesson, you should have learned how to:


• Create an Oracle database that uses ASM
• Identify the location of various Oracle files
• Implement OS authentication

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 6 - 18
Practice 6 Overview:
Creating a Database

This practice covers the following topics:


• Creating a database that uses ASM storage
• Interrogating the installation

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 6 - 19
m y
d e
ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Customizing Oracle on Linux

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Objectives

After completing this lesson, you should be able to:


• Create automated startup/shutdown scripts
• Automate tasks using scheduling tools
• Configure Linux startup and shutdown sequence

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 2
Controlling Oracle Database

After a server restart, all Oracle processes will be stopped


by default. In order for the database server to be used,
they must be started in one of the following ways:
• Manually
• Automatically

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Controlling Oracle Database

e A
c l
By default, the database instance and its related services do not start when the Linux server is
started. Depending on your needs you will want to start all or some of the following services:
• Database Listener
• ASM Instance r a
• Database Instance O ly
• DB Console
• iSQL*Plus
l & On
n a e
These can be started manually through standard commands:


lsnrctl start

t e r s
sqlplus “/ as sysdba” and then execute the startup command
U

• n
emctl start dbconsole

I
isqlplusctl start

l e
Or, they can be started automatically. The next few pages discuss how to start the Oracle

c
database and related services automatically.

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 3
Linux Startup Sequence

Kernel

BIOS

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Linux Startup Sequence

e A
basically in the same way.
c l
Although there are distribution-specific differences, most servers running Linux will start up

r a
The first step is to initialize the Built-In Operations System (BIOS). BIOS resides in a ROM

O ly
chip, usually on the system motherboard. BIOS initializes the hardware on the motherboard and
much of the hardware that is attached to the motherboard in preparation for loading the actual

l & On
operating system. BIOS will also look for a bootable device, searching in the order defined
within the BIOS program. When it finds a bootable device, it checks the Master Boot Record

n a e
(MBR) of that disk for a boot loader. As soon as the boot loader is found, BIOS loads the code

t e r U
GRand Unified Bootloader (GRUB). s
into memory and passes control of the system over to the boot loader. Enterprise Linux uses the

I n
There are other boot loaders available such as the Linux Loader (LILO), but none as flexible as
GRUB, which can load Linux, Windows, and more. The boot loader displays a menu of boot

l e
options from the MBR. (In a dual boot system, this is where you are offered the chance to select
c
which operating system [OS] will be used.) It then uses the settings found in the MBR to load

r a
the selected operating system kernel.

O
Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 4
Linux Startup Sequence (continued)
After the kernel is loaded, it checks /sbin and starts the init process. This is process number
one. The init process reads /etc/inittab, which contains instructions telling the kernel to
run a basic setup script that describes actions such as how to set the system clock, where the
swap file is located, and what the global environment variables are.
In Enterprise Linux, that basic setup script is /etc/rc.d/rc.sysinit.
Here is where you become concerned as the administrator. After the basic setup script is run, the
init process continues reading /etc/inittab and makes its decisions on what to do next
based on which of the seven runlevels you have booted to. The runlevel you select will
determine who can log on, how many users can be logged on, and what services are available.
The runlevels are described in detail later in the lesson.
In Enterprise Linux, there are a series of directories under /etc/rc.d with names such as
rc0.d, rc1.d…rc6.d. For example, if you were to boot to runlevel 5 (the default), then the
init process would run scripts located in rc5.d. On most systems, you will find that the
scripts are not actually in these directories, rather there are links to the scripts.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 5
Linux Startup Sequence

rc0.d Power off

init /etc/rc.d/rc.sysinit
rc1.d
• Runlevels 1 through 5 are
available on boot. rc2.d
• Runlevel 0 is the system
halt state, entered from rc3.d
runlevels 1–5 before
shutdown. rc4.d
• Runlevel 6 initiates a
system restart. rc5.d

rc6.d
m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Linux Startup Sequence

e A
c l
Each runlevel is associated with its own subdirectory. Within any given level’s subdirectory, you
will see scripts with names like these. These files are from rc5.d:
K02NetworkManager
K05saslauthd
K74nscd
K74ntpd
r a S10network
S12syslog
S56rawdevices
S56xinetd
K10dc_server
K10psacct O ly
K87auditd
K89netplugd
S13irqbalance
S13portmap
S80sendmail
S85gpm
K12dc_client
K12FreeWnn
l & On
K90bluetooth
K94diskdump
S14nfslock
S15mdmonitor
S90canna
S90crond
K20nfs

n a e
S01sysstat S25netfs S95anacron

r
K24irda S05kudzu S26apmd S95atd
K35smb
K35vncserver
t e U s
S08arptables_jf
S08iptables
S28autofs
S55sshd
S97messagebus
S99local

I n
The scripts are executed in alphabetical sequence as the runlevel is entered. In this case, as
runlevel 5 is entered, the script S01sysstat is executed, then S05kudzu, and so on until all

l e
scripts have completed. Scripts beginning with a “K” (for “kill”) are intended to stop services,
c
scripts beginning with an “S” (for “start”) are intended to start services.

r a
Linux allows movement between runlevels through the init command. From runlevels 1–5,

Oyou can move to any other runlevel, including the two special runlevels 0 and 6. Runlevel 6
initiates a system reset. Runlevel 0 enters the system halt state (all services stopped) and is used
to properly shut the system down before the power is turned off.
Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 6
Linux Runlevels

Runlevels determine which services are available.


• Linux runlevels:
– 0 = halt
– 1 = single user
– 3 = multiuser, network
– 5 = multiuser, X
• The default runlevel is usually 5 but can be changed.
• Servers usually use runlevel 3.
• Runlevels can also be changed with the init
command.

# init 3
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Linux Runlevels

e A
c l
Linux uses runlevels to determine which services to start or stop. For example, at certain
runlevels the graphic user interface might not be started. The meaning and services started at the

r a
different runlevels is distribution dependent, but for Enterprise Linux it is as follows:
• Runlevel 0: Halt. It is used to shut down the system.
O ly
• Runlevel 1: Single-user (maintenance) mode. Only root may log in.

l & On
• Runlevel 2: Multiuser mode, text-based console only
• Runlevel 3: Multiuser mode with networking
• Runlevel 4: For custom use
n a e
t e r s
• Runlevel 5: The default mode; multiuser with networking and active X session
• Runlevel 6: Reboot. This shuts everything down and then starts it back.
U
I n
Booting to a Nondefault Runlevel
The GRand Unified Bootloader (GRUB) provides a way to specify the runlevel on startup from
l e
the OS selection menu. For Enterprise Linux, you press [E] then scroll down to select the kernel,
c
press [E] again, press the spacebar, enter the runlevel you want to boot to, then press [B].

r a
Your current and previous runlevel can be found with the runlevel command.

O
Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 7
Database Startup and Shutdown

Create a dbora service script to automate startup and


shutdown.
• Create a script named dbora.
• Place it in the /etc/rc.d/init.d directory.
• Use chkconfig to set the runlevels.

Startup Database Shutdown


m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Database Startup and Shutdown

e A
c l
Most servers are not shut down often, and the system administrator may not be familiar with the
commands for doing a proper shutdown of the database. Because of this, it is a good idea to

r a
provide a script to shut down the database in each of the runlevel directories. This ensures that
the database does a proper shutdown without DBA involvement. If a server crashes, you want
O ly
the database to be open as soon as possible after the machine is started. By placing startup

automatically.
l & On
scripts in each of the proper runlevel directories, the database and related services can be started

Create a Script Named dbora


n a e
t e r U s
The name of this script is arbitrary. Naming it dbora can be convenient because the name of
the script is echoed to the console during the boot process. This script can start all the database-

I n
related processes as is shown in the example, or the script may be broken into multiple scripts
that start and stop the processes separately. In this example, the order in which the processes are

l e
started is important. Start the listener first, next the ASM instance, then the database, and finally
c
DB Console (because it connects to a repository in the database on startup).

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 8
Database Startup and Shutdown (continued)
The stop commands are in sequence and the database is stopped in the end. Any process that is
not stopped here is stopped by the killall command later during the shutdown process.
Enterprise Linux uses a subsystem lock file at /var/lock/subsys/<service_name>.
The stop script runs only if the lock file exists.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 9
Administrative Scripts

Oracle provides a set of administrative scripts.


• Start up and shut down databases by using:
– dbstart
– dbshut

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Administrative Scripts

e A
c l
Oracle provides the dbstart and dbshut scripts that must be modified for your site. These
scripts read the oratab file, determine which databases participate in automated startup or

r a
shutdown, and start up or shut down these databases.
The oratab file is created by root.sh and updated by the Database Configuration Assistant
(DBCA) when creating a database. O ly
l & On
A colon, “:”, is used as the field terminator. A new line terminates the entry. Lines beginning
with a pound sign, “#”, are comments.
Entries are of the form:
n a e
t e r U s
$ORACLE_SID:$ORACLE_HOME:<N|Y>
The first and second fields are the system identifier and home directory of the database,

I n
respectively. The third field indicates to the dbstart utility whether the database should be
brought up at system boot time, indicated by Y or N, meaning yes or no, respectively.

l e
Example of the entries in /etc/oratab :
c +ASM:/u01/app/oracle/product/10.2.0/db_1:Y

r a orcl:/u01/app/oracle/product/10.2.0/db_1:Y

OASM and database instances created without using DBCA will not appear in the oratab file.
Entries will need to be made manually in the file for those instances.

Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 10


Administrative Scripts (continued)
dbstart
dbstart first starts the listener, then scans oratab twice. Databases that use ASM for
managing storage require the ASM instance to be started before the database instance. On the
first scan, dbstart looks for ASM instances with a “Y” in the third field. Values of
$ORACLE_SID which start with a “+” denote an ASM instance. When found the instances are
started. On the second scan, the script looks for database instances with a “Y” in the third field.
The dbstart script that is provided with 10.2.0.1.0 contains an error. The Metalink note
336299.1 documents this issue. To solve this problem, perform the following steps:
1. Edit $ORACLE_HOME/bin/dbstart
2. Go to line 78.
3. Replace the line with:
ORACLE_HOME_LISTNER=$ORACLE_HOME
4. Save the file and exit the editor.
5. Execute dbstart.
The script can be customized to start other utilities, such as DB Control.
dbshut
The dbshut performs shutdown immediate. This mode terminates all connections and
then shuts down the database. The dbshut script can be modified to shut down DB Console
before shutting down the database. This would allow for a faster shutdown of the database.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 11
Managing Services with chkconfig

# chkconfig: 2345 99 10 rc0.d


# description: starts and
stops oracle instances
rc1.d
• Create a startup script,
S99dbora, in runlevels 2 rc2.d
through 5.
rc3.d

• Create a kill script, rc4.d


K10dbora, in runlevels 0, 1,
and 6. rc5.d

rc6.d
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Managing Services with chkconfig

e A
c l
System administrators must create a link in each runlevel directory for each service that should
be available at that runlevel. A manual creation of these links is time consuming and prone to

r a
errors. A tool called chkconfig is provided in Linux distributions modeled after a tool on
IRIX, which provides a simple way to add and delete services to runlevels. You can also use the
O ly
graphical tool system-config-services to manage services.

l & On
A service script named dbora can have the following comment lines. These comment lines
specify the runlevels and the order numbers for the start and kill.

n a e
# chkconfig: 2345 99 10

t e r U s
# description: starts and stops oracle instances
This says that the links to this script should be named S99dbora and K10dbora. The start

I n
scripts will be present at the runlevels 2, 3, 4, and 5. The kill scripts will be present at the
runlevels 0, 1, and 6.

l e
With these comment lines in place, the chkconfig --add dbora command
c
r a
adds the links to the script into the appropriate directories. chkconfig --del dbora
removes the links and chkconfig --list dbora shows the runlevels and the state of the

Odbora service at each runlevel.

Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 12


Automating Jobs

Automate the following jobs to leverage your time:


• Backups
• Database startup and shutdown
• Gathering database statistics
• Monitoring database health
• Monitoring processes: listener, agent, HTTP server

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Automating Jobs

e A
c l
Much of your work as a DBA must be done outside normal working hours, or at least during off-
peak hours. In many companies, you are asked to support more databases and more hours of the

r a
day or night. Automating routine jobs is a way of reducing the work load. These routine jobs
include:
O ly
• Doing backups and maintaining backup scripts

l & On
• Starting up and shutting down the database
• Gathering statistics on the database and OS
a e
• Monitoring the health of the database and related processes
n
t e r U s
Ensure that the database starts up when the machine boots, and more importantly make sure that
the database does a proper shutdown before the machine is shut down. Monitor the database and

n
related processes so that you are aware of a problem before the users start contacting you.
I
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 13
OS Scheduling Tools

Linux offers the standard UNIX tools for scheduling:


• cron and anacron
• at and batch
• Task Scheduler

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
OS Scheduling Tools

e A
c l
Linux offers several scheduling tools that usually are a variation of the standard cron and at
tools, or a GUI for one of these tools. Task Scheduler is one of these user interfaces that makes
cron and at easier to use.
r a
cron
O ly
The system cron daemon is started as part of the boot process. Security for cron is handled by
& On
the system administrator by using the /etc/cron.allow and /etc/cron.deny files.
l
n a e
Only users listed in the /etc/cron.allow file are allowed to use cron, users listed in the
/etc/cron.deny file cannot use cron. If neither of these files exist, only the superuser is

t e r U s
allowed to use cron. The cron daemon checks the system-level schedule in the
/etc/crontab file and user-level schedules in the /var/spool/cron directory. In

I n
Enterprise Linux, there is also a set of directories /etc/cron.hourly,
/etc/cron.daily, /etc/cron.weekly, and /etc/cron.monthly that hold

l e
executable scripts. If the system administrator puts an executable script into one of these
c
directories, then cron runs the script at the appropriate interval.

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 14
OS Scheduling Tools (continued)
cron (continued)
The format of an entry in the crontab file is <minute> <hour> <day> <month>
<weekday> <cmd>. If any of these fields has a “*”, then the meaning is “every.” A crontab
entry to run a backup script might look like the following:
14 22 * * 1-5 su - oracle -c /usr/local/bin/backup.cmd >/dev/null 2>&1
This command runs 14 minutes after 10 p.m. every weekday of every month, Monday through
Friday. The command says, log in as the oracle owner and execute backup.cmd, sending
the standard out to /dev/null, the bit bucket, and standard error to the same place.
anacron
It is an interesting variation of cron that does not require the system to be running
continuously. The anacron daemon periodically checks the /etc/anacrontab file, and
verifies whether the task has been executed within the time specified in the Period field of the
configuration file. If not, anacron executes the command specified after waiting for the
number of minutes specified in the Delay field.
at and batch
The at command executes a command once at a specified time, as opposed to cron that
executes recurring commands. The atd daemon runs the at commands and the batch
commands. The batch commands wait until the system load average drops below 0.8, and then
executes the given commands.
m y
Task Scheduler

d e
There are GUI task schedulers available that are front ends for cron in both the Gnome and the
K(ommon) Desktop Environment (KDE).
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 15
Job Capabilities of DB Console

DB Console provides a way to schedule jobs against the


database or node. You can schedule:
• SQL scripts
• PL/SQL blocks
• Stored procedures
• RMAN scripts
• PERL scripts
• OS commands

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Job Capabilities of DB Console

e A
c l
Using DB Console, you can schedule a job to run at a particular time or interval. Each job can be
run against the database instance or the node. A job can be SQL scripts, OS commands, RMAN

r a
scripts, PERL scripts, a PL/SQL block, or a stored procedure. DB Console uses
dbms_scheduler from the database providing a convenient way to centralize your recurring
O ly
jobs. You can use the Job Wizard to create, register, execute, and save jobs.

l & On
Using Oracle Enterprise Manager Grid Control to manage your node and database provides even
greater flexibility in the types of jobs that can be created.

n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 16
Database Backups

Database backups are essential. The options for backing


up your database are:
• User-managed backup with OS tools
• User-managed backup with third-party tools
• Server-managed backup with RMAN

Database Backup
m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Database Backups

e A
c l
Backups are required by most businesses. The method and the frequency are often dictated by
business requirements. The method should be chosen based on availability requirements,

r a
convenience, performance, and mean time to recover (MTTR).
User-Managed Backups with OS Tools
O ly
Backups can be created by using standard OS tools, such as tar, cpio, and cp. It is the user’s

l & On
responsibility to understand the limitations of these tools.

a e
User-Managed Backups with Third-Party Tools

n
t e r s
There are several third-party backup solutions. The most important consideration is whether the
tool you choose coordinates with the Oracle database. The database must be shut down, or the
U
I n
tablespaces put into backup mode before the back up takes place. Many vendors provide an
Oracle database agent module to provide this functionality.

l e
Server-Managed Backups with RMAN

c
Oracle Corporation provides an integrated tool called Recovery Manager (RMAN) to perform

r a
backups or use the DB Console interface to RMAN. This tool works with the database instance
to make reliable backups.
ONote: Use the full pathname to invoke RMAN: $ORACLE_HOME/bin/rman. By doing this,
you avoid any path problems. There is a different Linux utility named rman.
Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 17
Backing Up with RMAN

Recovery Manager is the recommended solution, because


it:
• Provides tight integration with the Oracle database
• Understands raw partitions
• Can be scripted and scheduled
• Allows finer-grained recovery options
• Is required to back up an ASM-based database

RMAN> BACKUP DATABASE;


m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Backing Up with RMAN

e A
c l
The Recovery Manager tool is bundled with every installation of the Oracle database. It uses the
instance to facilitate the backup. RMAN handles raw partitions in the same manner that the

r a
database instance does. RMAN can be scripted and scheduled from OS schedulers or as an
Enterprise Manager Job. A full database backup can be simple (such as the command shown in
O ly
the slide) or complex, depending on your requirement. Recovery Manager has a full range of

l & On
commands that allow detailed control of the backup.
You should use the available tools to make the backups self-scripting so that the backup scripts
have zero maintenance.
n a e
t e r U s
Automatic Storage Management requires RMAN for taking backups.
RMAN backups are covered in the Oracle Database 10g: Administration Workshop II and the

I n
Oracle Database 10g: Backup and Recovery course and in the Backup and Recovery Basics and
Backup and Recovery Advanced User’s Guide.

c l e
Oracle Secure Backup is also available for backups. Oracle Secure Backup delivers tape data

r a
protection for the Oracle database and file systems in distributed Linux and Network Attached
Storage (NAS) environments. Safeguarding data and access to the backup domain, Oracle

OSecure Backup leverages the proven security technologies of secure sockets layer (SSL) and
encryption.

Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 18


Server Parameter File

With an Oracle 10g database, you can use a server


parameter file SPFILE or the initialization parameter file
PFILE:
• An SPFILE is recommended.
• SPFILE is maintained by the server.
• The STARTUP command always uses the
same SPFILE.
• The default location for the SPFILE with ASM is
<diskgroup>/<sid>/.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Initialization Parameter Files

e A
parameter files:
c l
When you start the instance, an initialization parameter file is read. There are two types of

r a
• Server parameter file: This is the preferred type of initialization parameter file. It is a
binary file that can be written to and read by the database server and must not be edited
O ly
manually. It resides in the server that the Oracle database is executing on, and is persistent

l & On
across shutdown and startup. This is often referred to as an SPFILE. The default name of
this file, which is automatically sought at startup, is spfile<SID>.ora located in
a e
$ORACLE_HOME/dbs. For a database using ASM, the default name of the SPFILE is
n
t e r
spfile<sid>.ora with the file located in <diskgroup>/<sid>/ (for example,
+DF/orcl/spfileorcl.ora)
U s
I n
• Text initialization parameter file: This type of initialization parameter file can be read by
the database server, but it is not written to by the server. The initialization parameter

c l e
settings must be set and changed manually by using a text editor so that they are persistent
across shutdown and startup. The default name of this file, which is automatically sought at

r a startup if an SPFILE is not found, is init<SID>.ora.


It is recommended that you create a server parameter file (SPFILE) as a dynamic means of
Omaintaining initialization parameters. By using a server parameter file, you can store and
manage your initialization parameters persistently in a server-side disk file.

Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 19


Summary

In this lesson, you should have learned how to:


• Create automated startup/shutdown scripts
• Automate tasks using scheduling tools
• Configure Linux startup and shutdown sequence

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 20
Practice 7 Overview:
Automating Tasks

This practice covers the following topics:


• Automating the startup and shutdown of
the database
• Adding starting and stopping DB Control to dbstart
and dbshut

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Practice 7 Overview: Automating Tasks

e A
l
For detailed instructions on performing this practice, see Practice 7 in Appendix A.

c
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 7 - 21
m y
d e
ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Managing Memory

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Objectives

After completing this lesson, you should be able to:


• List the memory models available in Linux kernels
• Implement hugepages
• Describe /proc/meminfo contents
• List the implications of Linux memory configuration on
Oracle Database
• Identify the issues regarding 32-bit OS versus 64-bit
OS

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 2
Swap Space

The swap space makes more memory available to the


system even when physical memory is limited.

Physical Swap space


memory (virtual memory)

Total available memory


m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Swap Space

e A
c l
Often there are demands for more memory than what is actually installed on the machine. To
mitigate the effects of this limitation, swap space is set up. Swap space is an area of disk that is set

r a
aside to hold some of the contents of physical memory, or RAM, at certain times. As Linux switches
from running one process to another, it may need to allocate some memory in RAM to support the
O ly
new process. If there is not enough RAM available, instead of failing the process, Linux copies the

l & On
contents of some of the RAM to the swap space. This process of copying memory contents from
RAM to disk and back again is why this disk area is referred to as swap space; Linux continually
a e
swaps the contents of physical RAM and disk, as needed. The result is that there is effectively more
n
t e r U s
memory available for processes to use.

I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 3
Swap Cache

The swap cache tracks the state of swapped pages and


reduces the swap I/O activity.

Swap
RAM Swap space
cache

m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Swap Cache

e A
c l
A closer look at the RAM/swap space interaction reveals the swap cache mechanism. The swap
cache is an area of RAM that is set aside to track the pages that are swapped out to disk, and, whether

r a
they have been written to since that time. The purpose of this is to short-circuit any unnecessary I/O.
Consider the page out operation, where a page is swapped out to disk, and then later, is needed back
O ly
in memory. If, while it was swapped out onto disk, the in-memory page was not reused for anything

l & On
else, then there is no need to read the page back in from disk; it is already in memory. Likewise, if a
page is swapped in, and then swapped out, the swap out operation may not require that the page be
a e
written to disk again. If the page had not been modified at all while it was swapped in, then its
n
t e r s
contents still match what is already stored on disk, and thus, there is no need to write it to disk again.
The details of the processes that write a page out and read a page in follow.
U
Page Out Operation
I n
If a page residing in memory is not used, it ages. The older a page, the more likely it is to be

l e
overwritten. The swap looks for the oldest pages in each process every few seconds. If there is a

c
demand for free pages, swap overwrites the old pages. These pages are moved to the swap cache in

r a
memory if they are dirty, or discarded if they are not dirty. If a page is needed again before being
moved from the cache to disk, then it is reloaded from the cache. Otherwise, it gets flushed from the
Ocache to the disk after a period of time.

Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 4


Swap Cache (continued)
Page In Operation
If the process tries to access a page that is not mapped into physical memory, a page fault occurs. A
page fault causes the process to suspend. The page is read from a disk or a swap cache. The page is
loaded into a free page of memory. This page is mapped to the Translation Lookaside Buffer (TLB).
Then the process is placed on the run queue. To bring a page into memory, a free page must exist.
The swap process works to keep a pool of free pages available for these page in operations.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 5
Sizing Swap Space

Swap space should be sized based on the amount of RAM


installed.

1 GB 1.5 GB
RAM Swap
4 GB 4 GB
RAM
= Swap
7.5 GB
10 GB Swap
Total = 2.5 GB RAM

Total = 8 GB

Total = 17.5 GB
m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Sizing Swap Space

e A
c l
The amount of swap space to allocate depends on the amount of RAM installed on the machine. The
following conditions show the RAM size followed by the reasonable swap space size, respectively:
• <= 2 GB: 150% of the RAM size
r a
• Between 2 GB and 8 GB: Equal to the RAM size
• > 8 GB: 75% of the RAM size O ly
& On
Some examples are shown in the slide. You can use the free command to see the size of the swap
l
/proc/swaps.
n a e
space, and also to see how much of it is being used. You can also view the contents of

t e r U s
Note: Diagram sizes are not to scale.

I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 6
/proc/meminfo

The most useful high-level statistics found in the


/proc/meminfo file are:
• MemTotal: Total usable physical RAM
• MemFree: RAM that is currently free
• Cached: Memory in the page cache
• SwapCached: Memory that was swapped back in after
being swapped out

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
/proc/meminfo

e A
following information can be found there:
c l
The /proc/meminfo virtual file shows the current state of memory for the Linux kernel. The

r a
• MemTotal: The total physical memory in the system. All of your server's physical memory
should be reported here at all times.
O ly
• MemFree: Total amount of memory that is currently free

SwapCache.
l & On
• Cached: Memory in the pagecache (diskcache) minus SwapCached. This does not include

a e
• SwapCached: Memory that once was swapped out and has been swapped back in, but is still in

n
t e r s
the swap file. This is a performance feature because if memory is needed it does not need to be
swapped out again; it is already in the swap file. This saves I/O.
U
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 7
Evaluating Free Memory

As reported by top, the situation seems dire because it


appears that almost all memory is being used:
Mem: 16124948K used, 42724K free

But the free command shows that 13 GB of this memory


is cache, which is available to processes as needed:
shared buffers cached
1710184 351312 13330324

total
16167672
used
16129820
free
37852
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
top and free

e A
c l
Some of the used memory that the top command reports is actually being used for cache. That
means that it is available to be reassigned if another process requires it. The slide illustrates how the

r a
top command memory information can be misleading. It appears that only 42 MB of memory is
free. But the free command reports that 13 GB is currently being used for cache. By the nature of
O ly
caching, that memory buffer is useful, but not all of it is always necessary. If another process starts

l & On
up, or an existing one requests more memory than is reported in the free category of the top
command, then some of this cache memory can be allocated to those memory requests, and that will
a e
be reflected in a higher used value, and a lower cached value. So, there is more memory available
n
t e r U s
for use by processes than appears as reported by the top command.

I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 8
Memory Terminology

Some terminology:
• Page table: A data structure that maps virtual
addresses to physical addresses
• Translation Lookaside Buffer (TLB): Cache in the CPU
that contains part of the page table, for performance
• Hugetlb: An entry in the TLB that point to a hugepage
• Hugetlbfs: An in-memory file system introduced in the
2.6 Linux kernel
• Page Address Extentions (PAE): A technique for
adding 4 bits onto the memory address value, allowing
a 32-bit machine to address 64 GB instead of 4 GB

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 9
Page Address Extensions (PAE)

2^32 = 4,294,967,296

4 GB

2^36 = 68,719,476,736 Very Large Memory


(VLM)
64 GB

m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Page Address Extensions (PAE)

e A
c l
A 64-bit Linux system can address 16 exabytes; an extension of the addressing system is not
necessary. But a 32-bit system can address only 4 GB of memory, because 2 raised to the thirty-
second power is roughly 4 billion.
r a
O ly
In order to get above 4 GB virtual memory on IA-32 architecture, a technique known as Page
Address Extensions (PAE) is used. It is a method that translates 32-bit (2**32 = 4 GB) linear
& On
addresses to 36-bit (2**36 = 64 GB) physical addresses. In the Linux kernel, the support is provided
l
n a e
through a compile time option that produces two separate kernels: the SMP kernel which supports
only up to 4 GB VM and the enterprise kernel that can go up to 64 GB VM (also called Very Large

t e r U s
Memory [VLM]). The enterprise kernel is able to use up to 64 GB pagecache without any
modifications. This means applications such as Oracle can make use of the large memory and scale

n
up to a large number of users without loss of performance or reliability.
I
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 10
Hugepages

4 MB
4 KB

4 KB 4 MB

4 KB 4 MB

Page table
Page table

m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Hugepages

e A
c l
The regular page size in Linux is 4 KB. That means each entry in the page table can point to a 4 KB
size page. A smaller page size like this not only limits the amount of memory that can be addressed,

r a
but it also causes more overhead in the management of the page table entries because there are more
entries required.
O ly
If you increase the page size to 4 MB, this provides for a lot more addressable memory, without the
& On
extra overhead, because the number of page table entries can remain the same. This is referred to as
l
n
they remain in physical memory. a e
hugepages. Also, hugepages are not swapped out, and thus provide for better performance because

t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 11
Implementing Hugepages on 32-Bit Linux

To implement the hughpages feature:


• Configure Linux to mount ramfs at boot time
• Increase locked memory limit
• Configure instance parameters for VLM
• Set the hugepages kernel parameter
Note: Using this feature removes the ability to configure
automatic shared memory management. You must
configure DB_CACHE_SIZE instead.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Implementing Hugepages on 32-Bit Linux

e A
1. Log on as root.
c l
To configure hugepages, perform the following steps:

r a
2. Configure Linux to mount ramfs over /dev/shm at every boot. Edit /etc/rc.local and
add the following:
umount /dev/shm
O ly
l & On
mount -t ramfs ramfs /dev/shm
chown oracle:oinstall /dev/shm

a e
where oracle is the Oracle owner and oinstall is the group for Oracle owner account.
n
3. Reboot the server.
4. Log on as root.
t e r U s
5. Check whether /dev/shm is mounted with the type ramfs:

I n
# mount | grep shm
6. Check the permissions of /dev/shm:

c l e
# ls -ld /dev/shm
7. Increase max locked memory limit. Edit /etc/security/limits.conf and add:

O ra *
*
soft
hard
memlock
memlock
3145728
3145728

Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 12


Implementing Hugepages on 32-Bit Linux (continued)
8. Log in as the oracle Linux user.
9. Check max locked memory limit:
$ ulimit –l
3145728
10. Configure instance parameters for VLM:
a. Convert the DB_CACHE_SIZE, DB_xK_CACHE_SIZE parameters to
DB_BLOCK_BUFFERS.
b. Add the USE_INDIRECT_DATA_BUFFERS=TRUE parameter.
c. Configure SGA size according to needs.
d. Remove SGA_TARGET if set.
11. Start up the instance.
12. Examine the memory allocation:
$ ls -l /dev/shm
$ ipcs -m
13. Configure hugepages.
a. Get Hugepagesize from:
$ grep Hugepagesize /proc/meminfo
b. Compute nr_hugepages = max(ipcs -m) / (Hugepagesize * 1024) +
1.
c. Set kernel parameter:
# sysctl -w vm.nr_hugepages=<value from above>
d. Set parameter for every boot. Edit /etc/sysctl.conf for
m y
vm.nr_hugepages=<value from above>
14. Check the available hugepages:
d e
$ grep Huge /proc/meminfo
15. Restart the instance.
c a
16. Check available hugepages (1 or 2 pages free)
$ grep Huge /proc/meminfo
e A
c l
Note: If the setting of nr_hugepages is not effective, you may need to reboot the server.

r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 13
Implementing a Large SGA

There are two methods to implement a large SGA under


Linux:
• Alter the Linux memory map so the SGA can use more
than 1.7 GB (up to about 2.7 GB).
• Relocate the Database Buffer Cache so it uses a
memory-based file system (up to 60 GB).
These methods can be combined, enabling very large
SGAs. The theoretical limit for a Linux SGA is 62 GB;
practical limitations are closer to 20 GB.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Implementing a Large SGA

e A
c l
There are two Linux memory limitations that affect the maximum size of the SGA. One of those is a
process limitation and the other is a kernel limitation.
Kernel Limitations
r a
O ly
A 32-bit processor cannot access more than 232 bytes (4 GB) of RAM without assistance. That
assistance comes in the form of PAE that breaks up the memory into chunks that can be handled by

l & On
the 32-bit processor. Those chunks are accessed through an extra layer of memory address
translation.

n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 14
Standard Linux Memory Map

4.0 GB

OS Disk Buffer
Kernel use and Page cache
2.98 GB

Process memory Oracle SGA

1.25 GB
Shared libraries lib*.so
1.0 GB mapped_base

Application code Oracle Executables,


user processes
128 MB
Kernel (not paged)
m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Standard Linux Memory Map

e A
c l
With 4 GB of RAM, the Linux kernel will normally divide it up as shown in the slide. The kernel
takes up a fairly small amount of RAM at the base of the memory map (the diagram in the slide is not

r a
to scale). The kernel will also reserve the top portion of the memory map for disk buffer caching and
memory page table maintenance. The area in between is left for applications, such as Oracle
Database. O ly
& On
The application area is divided into three sections: a section for application code, a section for
l
n a e
application memory, and a section for shared libraries. With Oracle, user processes and background
processes, such as PMON, SMON, and DBWn, reside in the application code area, whereas the SGA

t e r U s
resides in the application memory area. The starting point in the memory map for shared libraries and
process memory is controlled by mapped_base. As you can see, process memory can occupy the

I n
section from about 1.25 GB to 2.98 GB, giving the SGA a maximum size of around 1.7 GB. The only
way to accommodate the SGA is to take away space from other application area sections.

c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 15
Modified Linux Memory Map

4.0 GB

OS Disk Buffer
Kernel use and Page cache
2.98 GB

Process memory Oracle SGA

336 MB
Shared libraries lib*.so mapped_base
256 MB
Oracle Executables,
Application code
128 MB
Kernel (not paged)
user processes

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Modified Linux Memory Map

e A
c l
It is possible to modify the Linux memory map and allocate more memory to the SGA. The kernel
will still take up about 128 MB at the base of the map as well as the upper 1 GB, but the three

r a
application areas can be redistributed by changing the mapped_base.

O ly
As you can see in the slide, lowering mapped_base expands the area available to the SGA at the
expense of room for shared libraries and application code. The theoretical limit for the SGA using
this method is approximately 2.7 GB.
l & On
n a e
From a practical standpoint, you have to worry about shrinking the space for application code too
much because it does little good to have a large SGA if your users cannot create sessions to access it.

t e r U s
Ensure that you leave enough room below mapped_base for your applications to run.
You can check the memory mappings by looking at a /proc/<pid>/maps file for any process

I n
ID. The lowest address for the ld*.so shared library files is where shared libraries are mapped.

c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 16
Altering the Linux Memory Map

To alter the Linux Memory Map and implement an SGA


between 1.7 GB and 2.7 GB, perform the following steps:
1. Modify shmmax.
2. Modify a shell for starting the database instance by
lowering mapped_base.
3. Relocate the SGA:
a. Modify ksms.s.
b. Relink the database executables.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Altering the Linux Memory Map to Accommodate a Larger SGA

e A
c l
This procedure is used for setting an SGA larger than 1.7 GB and smaller than 2.7 GB on a machine
with 4 GB or less of real memory. Remember that you need to leave room for application code, so

r a
even as this example maximizes the SGA in real life, you would probably set the mapped_base
higher. This is not especially difficult, but you have to be careful. If you perform these steps
O ly
incorrectly, you will receive unexpected error messages (ORA-3113, attach errors, or server
processes just dying, and so on).
l & On
Lowering mapped_base and Relocating the SGA Method
Advantages:
n a e
t e r U s
• You can increase the SGA from the default of 1.7 GB up to 2.7 GB.
• It works with any 8.1.7, 9.0.1 or 9.2.x, and 10.1 and 10.2 database.

I n
• The entire SGA (shared pool, buffer cache, and so on) can be increased in size.
Disadvantages:
l e
• Local startup/shutdown of the database is allowed only from a modified Linux shell.
c
r a
• It requires a thorough understanding to be implemented correctly.
• Less virtual memory remains available for the PGA, so activities such as sorting need to be

O tuned differently.

Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 17


Altering the Linux Memory Map to Accommodate a Larger SGA (continued)
Modifying shmmax
The shmmax parameter can be changed dynamically, but unless you want to repeat the change every
time you reboot the server, you should enter the change in the /etc/sysctl.conf file. The
previous rule of thumb of limiting shmmax to half of real memory does not apply here. It is assumed
that the amount of SGA needed has already been determined. The amount of process memory needed
is also known. The sum of the SGA, the process memory, and the kernel and OS caches must be
sized to be allocated without excessive paging.
Lowering mapped_base
The mapped_base is an address in virtual memory where the mmap starts looking for a chunk of
memory to allocate to the shared memory. The larger memory addresses are considered lower in
memory. By starting the search at a lower address, a larger shared memory allocation up to 2.7 GB is
possible. The mapped_base parameter is set on a per process basis, so it cannot be set during boot
up, or for the entire system.
Lowering the mapped base is a requirement for every shell that spawns an Oracle server process on
the server. This includes any shell that is used to connect locally to the database and the shell used to
start the listener. (This way, listener-spawned processes inherit a lowered mapped_base.) This step
will have to be performed every time you start the instance. This means you will not be able to start
the instance using Oracle Enterprise Manager or other tools. The mapped_base parameter is
inherited by any process spawned by a shell that has mapped_base lowered.
Start a shell as the oracle user. In the shell, find the process ID by using ps or echo $$.
m y
# echo 268435456 > /proc/<your process ID>/mapped_base
d e
Start another shell as the root user and lower the mapped_base with the following command:

where 268435456 is decimal for 0 x 10000000.


c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 18
Relocating the SGA

Execute the following commands as the Oracle software


owner:

$ cd $ORACLE_HOME/rdbms/lib
$ cp ksms.s ksms.s_orig /* if ksms.s exists,
back it up first.*/
$ genksms -s 0x15000000 > ksms.s

$ make -f ins_rdbms.mk ksms.o


$ make -f ins_rdbms.mk ioracle

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Relocating the SGA

e A
c l
In this procedure, the ksms.s library is modified, and the database executable is relinked to use a
lowered address for the SGA. The address of 0X15000000 is safe, and lower addresses may be usable

r a
down to about 0x12000000, but these lower addresses must be thoroughly tested. Other Oracle-
supplied executables may use addresses below 0X15000000 and can be incompatible with these
changes. O ly
& On
After these changes have been made, an SGA of approximately 2.7 GB can be allocated.
l
Reversing the Change

n a e
following:
t e r
If things go wrong and you want to return to your original values, then you can do one of the

U s
• If ksms.s existed before you began this process:

I n
$ cp ksms.s_orig ksms.s

c l e
• If ksms.s did not exist, use the following command to return to the default installed value:
$ genksms > ksms.s

r a After you restore or regenerate ksms.s:


$ make -f ins_rdbms.mk ksms.o

O $ make -f ins_rdbms.mk ioracle

Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 19


Relocating the Database Buffer Cache

These steps relocate the database buffer cache so that


instead of occupying a portion of the application area
within memory, it resides in a virtual file system. To do
this, perform the following steps:
1. Set shmmax to hold the entire SGA.
2. Enable hugepages for performance boost.
3. Enable shared memory file system.
4. Set the initialization parameters and restart the
5. instance. (Dynamic SGA parameters are not available.)

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Relocating the Database Buffer Cache

e A
c l
It is possible to relocate the position of the database buffer cache so that it does not occupy space
with the rest of the SGA in the application area of the memory map. This not only allows for much

r a
larger database buffer caches, but also frees up memory within the 2.7 GB limit for other areas of the
SGA such as the shared or Java pools.
Setting shmmax to Hold the Entire SGA O ly
l & On
From any root Linux shell, set the shmmax kernel parameter to half the size of physical

a e
RAM available on your system. The value for shmmax cannot exceed 4294967295, or 4 GB:

n
t e r s
# echo 4000000000 > /proc/sys/kernel/shmmax
Again, set it at boot up by setting kernel.shmmax in /etc/sysctl.conf.
U
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 20
Relocating the Database Buffer Cache (continued)
Ensuring that hugepages Are Enabled
Ensure that hugepages are enabled, as described earlier in this lesson.
Implementing a Large SGA
Mounting a Shared Memory File System (SHMFS)
As root, mount a shared memory file system and mount it at every boot up by changing the
/etc/fstab file:
# mount -t shm shmfs -o size=8g /dev/shm
Add the following line to the /etc/fstab file:
none /dev/shm tmpfs size=8g 0 0
This creates an shmfs file system on /dev/shm of 8 GB size. The size parameter accepts the
“k”and “m” multipliers as well. When the database instance is started with the extended buffer cache
feature enabled, a file is created in /dev/shm that corresponds to the SGA database buffer cache.
Configure the Instance to Use the Shared Memory File System
Set the following initialization parameters, assuming an 8 KB block size and 3.8 GB cache:
USE_INDIRECT_BUFFERS = TRUE
DB_BLOCK_BUFFERS = 475000
Note: Multiple database buffer cache block sizes and the dynamic SGA buffer cache parameters
cannot be used with INDIRECT_BUFFERS. The database buffer cache size must be set with
DB_BLOCK_BUFFERS.
m y
Verify that the following initialization parameters are not set:
d e
DB_CACHE_SIZE
DB_2K_CACHE_SIZE
c a
DB_4K_CACHE_SIZE
e A
DB_8K_CACHE_SIZE
c l
DB_16K_CACHE_SIZE
DB_32K_CACHE_SIZE r a
O ly
Start up the Oracle database instance. If you are using this method in conjunction with altering the

l & On
Linux memory map, then do not forget to reset mapped_base before starting the instance. The
memory allocated to DB_BLOCK_BUFFERS will now be consumed from the shared file system
a e
located at (in this example) /dev/shm leaving up to 2.7 GB for other SGA areas.
n
t e r U s
Note: It is possible to make your buffer cache too large to the point where it defeats any performance
gains. For details, see the Oracle Database Performance Tuning Guide.

I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 21
hugemem Kernel

The hugemem kernel:


• Can address up to 64 GB of RAM
• Is required in order to address more than 16 GB of
RAM
• Supports multiple processors
• Makes use of Physical Address Extension (PAE)
• Allows up to 4 GB to be used per process
• Provides for a 3.6 GB SGA without implementing VLM

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
hugemem Kernel

e A
c l
The hugemem kernel is provided by the kernel-hugemem package. It is a kernel that was
developed to take advantage of memory greater than 16 GB. It can even provide some benefit on

r a
systems with as little as 6 GB of memory. There is no definite RAM size that defines where the
cutoff of benefit is, but if you have processes that can take advantage of up to 4 GB of address space,
O ly
then this kernel may provide some advantage. That is because the hugemem kernel not only

l & On
provides for addressing up to 64 GB of memory, but it also provides up to 4 GB of memory per
process. So even if you have only 12 GB, but you have a process that requires a large amount of
a e
memory for itself, then the hugemen kernel can be beneficial.
n
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 22
Summary

In this lesson, you should have learned how to:


• List the memory models available in Linux kernels
• Implement hugepages
• Describe /proc/meminfo contents
• List implications of Linux memory configuration on
Oracle Database
• Identify issues regarding 32-bit OS versus 64-bit OS

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 23
Practice 8 Overview:
Managing Memory

This practice covers the following topics:


• Understanding the contents of /proc/meminfo
• Viewing shared memory segment information

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 8 - 24
Using Linux Measurement Tools

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Objectives

After completing this lesson, you should be able to:


• Use Linux monitoring tools
• Interpret memory measurements
• Interpret I/O measurements

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 2
Basic Tuning Methodology

Tune the database


for the hardware.

Tune the hardware


for the database.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Basic Tuning Methodology

e A
c l
When you tune your system, you have to work in a cycle. In most cases, you start with a given
hardware configuration where you deploy your Oracle database. First, you work with this

r a
hardware and tune it for best performance.

O ly
Be ready to reevaluate your hardware configuration as system requirements change. When
evaluating new hardware, your primary considerations should be based on memory, storage I/O

order.
l & On
capability, and CPU power. For most systems, the requirements should be evaluated in that

n a e
Over time, your system requirements change and you need to modify your hardware. For this,

t e r U s
you may need to tune your database. This process continues for the life of your system.

I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 3
Standard Measurement Tools

Linux has measurement tools that are common to


UNIX platforms:
• Top Resource Consumers: top
• System Activity Reporter: sar
• Virtual Memory Statistics: vmstat
• I/O Statistics: iostat
• System Log files: /var/log/messages

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Standard Measurement Tools

e A
c l
Linux, like every operating system (OS), has tools available for measuring system performance.
The Open Source community has developed a series of tools that measure almost everything that

r a
you want to measure. Many of those are traditional tools adopted from the UNIX environment.
The tools mentioned here are the ones that are available across most UNIX and Linux
O ly
environments. However, this is not an all-inclusive list. These tools are either installed by

Top Resource Consumers: top


l & On
default with your distribution or freely available via the World Wide Web.

n a e
The real-time monitoring tool top is available on almost every flavor of UNIX/Linux. It shows

t e r U s
the CPU load averages, memory usage, I/O waits, and a detailed listing of the top processes
sorted by some resource, and CPU utilization, by default. Use top to begin your tuning and then

I n
drill down with other tools.
top is particularly useful for diagnosing CPU and I/O issues, though not as reliable for Oracle

l e
memory issues. Although top’s aggregate memory statistics are dependable, individual process
c
memory numbers should not be relied upon. Memory statistics for a process show all allocated

r a
memory, including shared memory. Because Oracle processes share the System Global Area

O(SGA), it shows up multiple times. The same shared memory segment will show up as belonging
to PMON, SMON, CKPT, and the other Oracle processes.

Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 4


Standard Measurement Tools (continued)
System Activity Reporter: sar
sar provides a variety of ways to look at the system activity including memory, I/O, and CPU
usage. In addition to viewing snapshots of system activity, sar collects regular samples of
statistics to a file that can be queried for particular activity at particular times. If you are already
familiar with sar from some other UNIX variant, check the man pages to verify the options
because they are different on Linux. It is usually executed with three arguments:
$ sar <options> <interval> <count>
The <options> flag determines what the output of sar will be. The report can include
statistics on memory use, I/O, system processes, interrupts, network and so on.
In addition to providing real-time metrics, sar samples the /proc file system at 10-minute
intervals and records the data in /var/log/sa as a sa# file where # is the day of the month.
A full month’s worth of statistics are retained so that the administrator can use sar to view past
statistics as well as current. For example, to view the CPU statistics for the 23rd of the month:
sar –u 2 4 –f /var/log/sa/sa23
Virtual Memory Statistics: vmstat
Probably the best tool for monitoring memory usage, the vmstat program reports information
about processes, memory, paging, block I/O, traps, and CPU activity. It is usually executed with
two arguments:
$ vmstat <interval> <count>
with <interval> being the number of seconds between statistics samplings and <count>
m y
being the number of samples to take. Unlike sar, the vmstat report allows very little
d e
customization. (You can give a –n option before the interval to suppress the report page header.)
I/O Statistics: iostat
c a
e A
Disk activity, disk queue lengths, and hot spots are all important pieces of information for tuning
the I/O related to the database. The iostat program provides these statistics, overlapping and

c l
extending the disk statistics available from sar.

a
System Log Files: /var/log/message ../syslog
r
O ly
The operating system maintains various log files that can be of use in monitoring and tuning the
system.

l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 5
Linux Tools

Linux also has tools that are specific to this operating


system:
• X-based tools: xosview
• The /proc virtual file system
• Free and used memory: free

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Linux Tools

e A
Graphical Measurement Tools

c l
For Linux systems running the X Window System (X), there are a variety of graphical tools that

r a
can be installed to monitor performance. They have the advantage of being easy to interpret.
X-Operating System View: xosview
O ly
l & On
The xosview tool shows CPU, disk, memory, and network activity. SuSE and UnitedLinux
install xosview by default. The package for xosview is distributed with Enterprise Linux,

a e
but is not part of the default installation.

n
t e r s
Note: Remember that X-based tools tend to influence the output by their own load on the CPU;
because of this, they may not be the most accurate measurements of CPU usage.
U
I n
Virtual Process File System: /proc
The /proc file system is a virtual file system that provides a look into the background

l e
workings of the operating system. You can think of it as the Linux equivalent to Oracle’s v$

c
views. The /proc file system exists in many UNIX variants, whereas its contents are greatly

r a
expanded under Linux.
Free Memory: free
OThe free command displays the total amount of free and used physical and swap memory in
the system, as well as the shared memory and buffers used by the kernel.
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 6
Linux Tools (continued)
Process Tree: pstree
This tool displays the relationship between processes in a tree structure, with parents to the left
and children to the right:
$ pstree
init-+-2*[Xvnc]
|-apmd
|-oafd
|-26*[oracle]
|-perl-+-emagent---emagent---4*[emagent]
`-java---java---52*[java]
Because the init process is system process number 1, it will always appear to the left. In this
snippet from the pstree output, you can see that there are two Xvnc processes running, 26
Oracle process running, and that the perl process has started two children, each of which has
started several other processes.
Resource Limits: ulimit
This tool shows the resources available to your shell. This tool is shell dependent; with the C
shell you would use limit –h instead.
/> bash
# ulimit –a (the –a flag shows all current limits)
core file size
data seg size
(blocks, -c) 0
(kbytes, -d) unlimited
m y
file size
max locked memory
(blocks, -f) unlimited
(kbytes, -l) 4
d e
max memory size
open files
(kbytes, -m) unlimited
(-n) 1024
c a
pipe size (512 bytes, -p) 8

e A
l
stack size (kbytes, -s) 10240
cpu time
max user processes
a c
(seconds, -t) unlimited
(-u) 7168
virtual memory
And many more
r
(kbytes, -v) unlimited

O ly
l & On
If it is measurable, chances are that there is a Linux package already written to measure it. Many
more utilities may be available depending on your distribution and which packages you have

a e
installed. Consult your distribution-specific documentation for more information. Also, Oracle
n
t e r
provides Oracle Enterprise Manager DB Control, which provides a great deal of performance-
s
monitoring information about the systems it is monitoring.
U
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 7
Common Areas to Tune

CPU I/O

Memory

Network
m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Common Areas to Tune

e A
c l
System performance depends on how efficiently system resources are used. In most systems, the
key resources that affect performance are CPU, memory, disk I/O, and network.
Central Processing Unit (CPU)
r a
O ly
The CPU is the heart of your system. If CPU performance is poor it does not matter what else
you tune, your system will be slower than it could be.
Memory
l & On
a e
Memory is a common system bottleneck. It is usually divided into two generic categories: real
n
t
Disk Input/Output (I/O)
e r
and virtual (swap). Any running process consumes some memory.

U s
I n
Although other device I/O can affect performance, disk I/O is usually the most critical type of
I/O. How fast and reliably can you move data to and from a disk? This is often the slowest factor

l e
in a system, and can be one of the most difficult to tune.
Network
c
r a
The network is the gateway into your system. Few modern systems are self-contained within a

Osingle server. Most depend on external connections either from clients or middle-tier machines.

Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 8


Monitoring and Tuning CPU

Tools for monitoring and tuning CPU include:


• top
• pstree
• vmstat
• mpstat –p All
• sar -u
• xosview
• xload

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Monitoring and Tuning CPU

e A
c l
Before you start tuning the CPU, you must identify if the CPU is a bottleneck for system
performance. For this step, you normally use high-level tools such as top, pstree, or one of

r a
the many graphical utilities available for Linux, such as xosview and xload. If CPU is a
problem for your system, then you drill down to find the source of that bottleneck with fine-
O ly
grained tools such as sar or vmstat.
/proc Virtual File System
l & On
n a e
All the tools mentioned in the slide use the /proc virtual file system as a source of
performance information. The raw data contained within /proc exposes a wealth of

• /proc/cpuinfo
t e r U s
information about CPU resources. Interesting files include:

• /proc/stat
• /proc/loadavg I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 9
Is the CPU a Bottleneck?

Is the CPU a bottleneck?


• How many CPUs does the machine have?
• What is the load average?
• What is the load factor?
– <1: CPU probably not a bottleneck
– Between 1 and 2: Running at capacity
– >2: CPU may be a bottleneck, investigate
• Partial output from top:
09:11:01 up 59 min, 12 users, load avg: 4.32, 5.03, 4.72
320 processes: 307 sleeping, 12 running, 1 zombie, 0
stopped
cpu states: 69.8% user 4.6% system 1.5% nice 0.0% iowait
23.9% idle
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Is the CPU a Bottleneck?

e A
c l
To answer this, you have to know a few things about your system:
• How many CPUs does your machine have? You can find this by checking

r a
/proc/cpuinfo or with commands such as mpstat.
• What is the average load on your system? There are many ways to find this, but the easiest
O ly
is to use top. The output from top shows you the load average for the past 10 minutes

l & On
with three samples (now, 5 minutes ago, and 10 minutes ago).
load average: 4.32, 5.03, 4.72

a e
• What is the load factor for your system? The load average does not mean a lot taken by
n
t e r s
itself. It gives only the number of processes receiving service from the CPUs at any given
time. These numbers would be a matter for concern on a uniprocessor box (or even a two-
U
I n
processor box), but would not be something to worry about on a four or more processor box.
Load factor is a more relevant metric. To calculate the load factor, divide the load average

c l e
by the number of CPUs:
load average = load factor

r a #CPUs

O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 10
Is CPU a Bottleneck? (continued)
• If your load factor is:
- <1, you have CPU capacity to spare and it is unlikely that you are CPU bound
- Between 1 and 2, your system is running at capacity
- >2, CPU may be a bottleneck in your system, and you should investigate further using
other tools such as sar or vmstat
Full Output from the top Command
09:11:01 up 59 min, 12 users, load average: 4.32, 5.03, 4.72
320 processes: 307 sleeping, 12 running, 1 zombie, 0 stopped
CPU states: 69.8% user 4.6% system 1.5% nice 0.0% iowait 23.9% idle
Mem: 385112k av, 378740k used, 6372k free, 0k shrd, 37812k buff
287620k actv, 0k in_d, 6384k in_c
Swap: 779144k av, 303648k used, 475496k free 90592k cached

PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND
1973 root 25 0 23480 9872 956 R 59.4 2.5 4:28 0 X
2487 oracle 15 0 29596 24M 1576 S 2.5 6.6 1:41 0 jre
2816 susan 15 0 21768 19M 1036 S 2.3 5.1 0:15 0 jre
2126 oracle 16 0 1080 1048 420 S 2.1 0.2 0:56 0 top
3218 root 16 0 1504 1504 860 R 2.1 0.3 0:02 0 top
3028
2061
oracle
oracle
25
15
10
0
2820
5852
2636 2052 R N
2168 1100 S
1.5 0.6
0.9 0.5
0:06
0:08
0 sproingies
0 rhn-applet-gui

m y
e
1675 root 15 0 1800 728 540 S 0.7 0.1 0:12 0 snmpd
2602
1426
oracle
root
15
15
0
0
8284
200
6452 1552 S
164 116 R
0.7 1.6
0.5 0.0
0:30
0:08
0 dbsnmp

a
0 syslogd
d
2329
15
3008
root
root
root
15
15
15
0
0
0
25876
0
12612
9M
0
824 R
0 SW
11M 7864 S
0.5 2.6
0.3 0.0
0.3 3.0
6:52
0:09
0:04
c
0 X

A
0 kjournald
0 rhn-applet-gui
2212
2262
root 15
rlowenth 15
0
0
26124
5836
10M

c l e
812 R
2144 1084 S
0.1 2.7
0.1 0.5
9:01
0:12
0 X
0 rhn-applet-gui.

r a
Many people do not realize that top is an interactive utility. From within top, you can enter
“?” to see a list of options. One more useful interactive command is “u” which allows you to
O ly
identify a single user for the top display output. For example, if you enter “u” and then type in

l & On
“oracle” then your list of processes would include only processes started by oracle. The
top displays’ default refresh rate is every two seconds, but you can change that interval with the
a e
“s” command. When top is run by root, you can kill processes directly from within top by
n
using the “k” command.

t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 11
CPU Measurements

Identify the following CPU statistics and interpret them:


• CPU idle time
• CPU time spent executing user code
• CPU time spent executing system code
• Processes waiting for CPU time (run-queue)

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
CPU Measurements

e A
c l
Although there are dozens of different CPU measurements that you can look at, the ones listed in
the slide are the most important. These have the same meaning but slightly different labels

r a
depending on the tool that is used to view them.
CPU Idle Time
O ly
This indicates the amount of time that CPU is in an idle state. Idle time is labeled %idle in
& On
sar, id (under the CPU heading) in vmstat, and idle in top. If you are experiencing
l
n a e
performance problems, and CPU shows high idle time, then the system is not CPU bound.
CPU Time Spent Executing User and System Codes

e r s
These statistics have to be considered together. Together they represent the useful work that is
t U
I n
being done by the CPU. User time indicates the time that is spent in executing code in the user
space. System time measures the time that is spent in executing system calls. Every application

c l e
has a characteristic ratio of user to system. With an Oracle database, you should expect a ratio of
approximately 60% user code to 40% system code. If the user code percent is significantly

r a
higher, then there may be inefficiencies in the application code. If the system code percentage is
significantly higher, look for system activity, such as high rates of disk I/O or memory swap.

O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 12
CPU Measurements (continued)
run-queue size
The run queue size indicates the number of processes that are ready to run. Processes that are
blocked (waiting on I/O or for other reasons) are not counted in the run queue. All the processes
in the run queue are waiting for a time slice of the CPU. If the run queue size is more than one,
performance could probably be increased by adding additional CPUs.
Obtaining CPU Measurements
There are several ways to obtain the key CPU metrics. Each of these tools gives a slightly
different view of the same information about the CPU activity.
# vmstat <interval> <count>
# mpstat -P <CPU> <interval> <count>
# sar -u <interval> <count>
# sar -q <interval> <count>
# iostat -c <interval> <count>
vmstat, mpstat, and iostat get their information directly from the /proc file system.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 13
Measuring CPU Activity with vmstat

# vmstat <interval> <count>

# vmstat 2 5
procs system cpu
r b w … in cs us sy id
0 0 0 … 11 42 3 1 96
1 0 0 … 106 141 0 1 99
0 0 0 … 109 134 0 0 100
1 0 0 … 103 146 7 1 92
0 0 0 … 107 125 0 0
Note: Memory and IO statistics removed for readability
100

m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Measuring CPU Activity with vmstat

e A
c l
The output of vmstat shows the key CPU metrics measured over the specified interval and
time period. In the partial listing in the slide:

r a
• cpu / us = CPU time spent executing user code
• cpu / sy = CPU time spent executing system code
• cpu / id = Idle CPU time
O ly
Other CPU metrics shown are:
l & On
• procs / r = Processes waiting for CPU (run-queue size)

a e
• procs / b = Processes in uninterruptible sleep

n
t e r U s
• procs / w = Processes swapped out, but runnable
• system / in = Interrupts per second

I n
• system / cs = Context switches per second

A full example of the vmstat command follows:

l e
# vmstat 2 2
procs
c memory swap io system cpu

r a
r b w swpd free buff cache si so bi bo in cs us sy id

O
0 0 0 78748 48720 97540 453688 0 0 4 60 11 42 3 1 96
1 0 0 78748 48716 97540 453688 0 0 0 8 106 141 0 1 99

Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 14


Measuring CPU Activity with mpstat
Unlike the vmstat command, the mpstat command allows you to drill down into CPU
statistics by processor. In a multiprocessor system, this can give you a more detailed picture of
what your CPUs are doing other than vmstat. Unfortunately, mpstat will not show you the
run-queue size. A full example of the mpstat command is as follows:
$ mpstat -P ALL 1 1
Linux 2.4.9-e.3enterprise (delphi) 04/01/2003
08:09:21 AM cpu %user %nice %system %idle intr/s
08:09:22 AM all 19.50 0.00 31.50 49.00 111.00
08:09:22 AM 0 27.00 0.00 42.00 31.00 111.00
08:09:22 AM 1 12.00 0.00 21.00 67.00 111.00
Measuring CPU Activity with sar
You can also use the System Activity Reporter (sar) command to retrieve information about
CPU performance. Like the mpstat command, the sar command returns information about
the division of work within the system.
$ sar -u 2 5
Linux 2.4.9-e.3enterprise (delphi) 04/01/2003

08:12:14 AM cpu %user %nice %system %idle


m y
08:12:16 AM all 30.50 0.00 1.75
d e 67.75
08:12:18 AM all 39.75 0.00 1.00
c a 59.25

A
08:12:20 AM all 36.25 0.00 1.75 62.00
08:12:22 AM all 23.75 0.00
e
1.50 74.75
08:12:24 AM all
c l
33.25 0.00 1.50 65.25
Average: all
r a32.70 0.00 1.50 65.80

O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 15
Measuring CPU Activity with sar (continued)
To monitor the processor queue, including the run-queue (displayed with sar as runq-sz),
you can use the sar –q command.
#sar -q 2 5
Linux 2.4.9-e.3enterprise (delphi) 04/01/2003

08:12:30 AM runq-sz plist-sz ldavg-1 ldavg-5


08:12:32 AM 1 79 1.17 0.98
08:12:34 AM 1 79 1.17 0.98
08:12:36 AM 2 79 1.16 0.98
08:12:38 AM 1 79 1.16 0.98
08:12:40 AM 1 79 1.16 0.98
Average: 1 79 1.16 0.98
Also shown with sar -q are:
plist-sz: Process list size showing the number of processes running in memory
ldavg: The load average for the last minute and the last five minutes
Measuring CPU Activity with iostat

m
Although it is normally used to measure data flow to and from disk devices, iostat also
y
produces basic CPU statistics.
d e
$ iostat -c 2 3
Linux 2.4.9-e.3enterprise (delphi) 04/01/2003
c a
e A
avg-cpu: %user
3.50
%nice
0.05
c l
%sys
0.83
%idle
95.61

r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 16
Interpreting CPU Measurements

When interpreting CPU measurements, observe cases


where the system has:
• High idle time with poor response time
• Too much time spent executing user code
• Too much time spent executing system code
• Run-queue size more than double the number of CPUs
• Extremely high context requests per second

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Interpreting CPU Measurements

e A
c l
The key to understanding the CPU measurements is that CPU is consumed on behalf of the
application. Therefore, if an Oracle instance and processes are consuming all the CPU resources,

r a
check the database application and tune the SQL. Some key points to consider when interpreting
CPU measurements are:
O ly
• High idle time with poor response time indicates that the processes are getting blocked. This

l & On
means I/O, network, and swapping should be checked.
• If the %user to %system ratio on the Oracle server processes is much greater than the
a e
60:40 ratio expected, then it indicates that the application code must be tuned. If the ratio is
n
t e r
much lower, that is, %system is larger, then look for I/O or virtual memory problems.
s
• On a properly sized system, the run-queue size should seldom be more than the number of
U
I n
CPUs. If the run-queue size is greater than two times the number of CPUs available, then
check sar -wW or vmstat for swapping and switching activity. A large run-queue size

c l e
indicates a CPU bottleneck. This could indicate an undersized system or possibly
insufficient memory.

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 17
Interpreting CPU Measurements (continued)
• Each process takes virtual memory. When more process memory is required than is
available in real memory, paging takes place. As more processes are added, more memory
is required, and more CPU overhead is required to process the paging and context switching
requests. This can continue until the CPU spends most of its time paging and switching.
This situation is called thrashing.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 18
Reducing CPU Bottlenecks

If you determine that CPU is the limiting factor in your


system:
• Increase CPU resources
• Decrease CPU demand
• Schedule CPU demand more efficiently

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Reducing CPU Bottlenecks

e A
c l
CPU is usually a finite resource. Sometimes it is possible to increase CPU resources (upgrade
the processor or add additional processors), but it is usually difficult or expensive unless you are

r a
working in a grid system. Therefore, you usually concentrate on either using existing resources
more efficiently or offloading unnecessary work to other systems.
Using Your CPU More Efficiently O ly
l & On
There are some basic things you can do to make your CPU more efficient:

n a e
• Schedule non-time-critical jobs to run during times when CPU is less loaded. For example,
database backups, index rebuilds, optimizer statistics collection, and batch jobs could run at

t e r U s
night rather than during the day.
• Employ a resource management system (such as Oracle Resource Manager) to ensure that

I n
your most important jobs are serviced first, and that too many batch jobs cannot be started
simultaneously. The use of system process priority manipulation to assign resources to more

l e
important processes is not recommended for Oracle processes because Oracle has its own
c
built-in process management system.

r a
• Reduce the demand on your CPU by eliminating unnecessary work or offloading work to a
different server.
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 19
Monitoring and Tuning Memory

Tools for monitoring and tuning memory include:


• top
• free
• vmstat
• sar -B
• xosview
• System Monitor

Gnome System Monitor


m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Monitoring and Tuning Memory

e A
c l
In addition to the tools listed in the slide, a great deal of information about system memory use
can be obtained from the /proc virtual file system.

r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 20
Measuring Memory Usage

Measure memory utilization and paging. Significant


memory statistics include:
• Total memory
• Context switches
• Pages in and out
• Inactive pages
• Demand rate

Page out

Page in
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Measuring Memory Usage

e A
c l
The instance uses SGA memory to increase performance. Linux uses the buffer cache and page
cache memory to increase performance. A well-tuned memory reduces the I/Os by caching

r a
frequently used pages. Poorly tuned or insufficient memory often shows up first as an I/O
bottleneck with high activity on the swap partition.
Total Memory O ly
& On
Use free, top, or cat /proc/meminfo to find the total memory on your system. Physical
l
Context Switches
n a e
memory is labeled mem in these tools.

e r s
Context switches can be seen in vmstat under the system group of columns. They are in the
t U
column labeled cs. A context switch takes place each time the CPU starts working on a

I n
different process. In a context switch, the TLB is reloaded for the new process, and other

c l e
housekeeping details are taken care of.

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 21
Measuring Memory Usage (continued)
Pages Out
Pages out and pages in are measured in 1 KB blocks, even though the memory page size is 4
KB. Pages out are seldom zero, and should not be a cause for concern as some “page out”
activity is normal. The swap process frequently moves a few pages out to swap to be sure that
free pages are always available for page in operations. As more pages of real memory are
needed, the number of pages moved to swap increases.
Pages In
The number of pages in is a good measure of RAM shortage. A page in operation occurs when a
memory page is pulled from virtual memory back to RAM. As processes access pages that are
not mapped or have been paged out, a page in is registered. Ideally, the average pages in over
time is near zero. This means that all the processes fit in real memory. As more processes start
and require memory, the pages in increase. This is a key measurement when adjusting the SGA
size for the database. If the pages in increases significantly after an increase in SGA size, it may
indicate that the SGA is too large.
Inactive Pages
This is also known as free or freeable memory. Inactive “clean” pages can be immediately
replaced by other memory pages. Inactive “dirty” pages are free but must be written to disk
before they can be used.
Demand Rate
m y
d e
This is also known as “Inactive Page Target.” This is one of the most important memory
statistic. It is shown as the inatarpg column with sar -B. The value shown is the average

c a
number of pages per second, within the last minute, the system needed to make “free” to meet
memory demands. This value may also be seen as inact_target in /proc/meminfo. This
A
is the goal the kernel tries to reach to make sure that there are enough inactive pages available.

e
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 22
Measuring Total Memory

#top

#free

#cat /proc/meminfo

m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Measuring Total Memory

e A
c l
The top command gives an excellent overview of the system activity. In the header portion, the
Mem line shows total physical memory, memory used, free memory, shared memory, amount of

r a
memory in the buffer cache, and amount of memory in the page cache in kilobytes. Remember
that individual process memory reported with top is meaningless for Oracle processes because
O ly
shared memory is reported for each process.
#top

l & On
9:12pm up 15:44, 4 users, load average: 1.02, 0.65, 0.33

a e
235 processes: 231 sleeping, 4 running, 0 zombie, 0 stopped

n
r
cpu states: 40.2% user, 59.7% system, 0.0% nice, 0.0% idle

t e
Mem: 512284K av, 508348K used,

U s3936K free, 5200K shrd, 67428K buff


Swap:522072K av, 115088K used, 406984K free 242740K cached

PID USER
I n
PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND
1017
20866
1212
root

c l
root
e
oracle
15
15
16
0 5944 5544 4360 S
0 86360 67M 54228 S
0 1188 1188 832 R
0.7 1.0
0.5 13.4
0.3 0.2
2:10
0:10
0:00
Xvnc
java
top

r a1
2
root
root
15
15
0
0
508 460
0 0
460 S
0 SW
0.0 0.0
0.0 0.0
0:04
0:00
init
keventd

O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 23
Measuring Total Memory (continued)
The free command also shows total memory and swap usage. The -/+ buffers/cache
line indicates the adjustment to free and used memory by the kernel’s disk buffers and page
cache (how much a process could get if it requested it—the kernel will dump its own page cache
and disk buffers to support running processes):
#free
total used free shared buffers cached
Mem: 512284 506880 5404 5200 68196 239984
-/+ buffers/cache: 198700 313584
Swap: 522072 114884 407188

All the utilities that collect statistics gather information from the /proc file system. The virtual
meminfo “file” gives an instantaneous snapshot of memory usage.

# cat /proc/meminfo
total: used: free: shared: buffers: cached:
Mem: 1054806016 1029685248 25120768 0 136949760 617668608
Swap: 534601728 22032384 512569344
MemTotal: 1030084 kB
MemFree: 24532 kB
MemShared: 0 kB
Buffers: 133740 kB
Cached:
SwapCached:
585920 kB
17272 kB

m y
e
Active: 674312 kB

d
ActiveAnon: 214892 kB
ActiveCache: 459420 kB
Inact_dirty: 0 kB
Inact_laundry: 159476 kB
c a
Inact_clean:
Inact_target:
14016 kB
169560 kB

e A
HighTotal:
HighFree:
130524 kB
2032 kB
c l
LowTotal:
LowFree:
899560 kB
22500 kB
r a
SwapTotal:
SwapFree:
522072 kB
500556 kB O ly
HugePages_Total:
HugePages_Free:
0
0
l & On
Hugepagesize: 4096 kB

n a e
t e r U s
A few key statistics from the meminfo output are:
• Mem: The current state of physical RAM in the system, including a full breakdown of total,

I n
used, free, shared, buffered, and cached memory utilization in bytes
• MemFree: The amount of physical RAM left unused by the system. It is usually very low.

l e
• Active: The total amount of buffer or page cache memory that is in active use

c
• Inact_dirty: Buffers that might need writing to disk or swap. It should be relatively

r alow.
• Inact_target: Demand rate. This is the goal the kernel tries to reach to make sure that

O there are enough inactive pages available.


• SwapFree: The total amount of swap free. It should not stay below 20% of SwapTotal.

Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 24


Measuring Memory with sar

#sar -B <frequency> <count>

#sar -R <frequency> <count>

#sar -B 2 3

#sar -R 2 3

m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
sar

e A
c l
The System Activity Reporter (sar) has many options.
The -B option shows pages in and pages out per second (pgpgin/s, pgpgout/s); the

r a
number of active pages (activepg); and the inactive dirty, inactive clean, and inactive target

O ly
pages (inadtypg, inaclnpg, inatarpg). The inactive target is the demand rate.
# sar -B 2 3
Linux 2.4.9-e.3 (EDD1R28P1)

l & On 02/26/2003

08:19:03 PM

n a e
pgpgin/s pgpgout/s activepg inadtypg inaclnpg inatarpg

r
08:19:05 PM 1994.00 126.00 85630 18848 4802 32733
08:19:07
08:19:09
PM
PM
t e
940.00
U s
2934.00 11680.00
420.00
85968
88629
23722
4175
3605
20266
32733
32733
Average:

I n
1898.80 5554.40 87859 12015 12492 32733

c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 25
sar (continued)
The -R option shows the number of pages freed per second, the number of additional shared
memory pages, buffer pages, and cache pages used, frmpg/s, shmpg/s, bufpg/s, and
campg/s. Negative values indicate fewer pages used.
# sar -R 2 3
Linux 2.4.9-e.3 (EDD1R28P1) 02/26/2003

08:18:47 PM frmpg/s shmpg/s bufpg/s campg/s


08:18:49 PM 0.50 0.00 0.00 -109.50
08:18:51 PM 3.50 0.00 -1.50 140.50
08:18:53 PM -4.00 0.00 -4.00 -93.00
Average: 0.10 0.00 -1.10 -61.30

vmstat
The vmstat command has two parameters: frequency and count. Frequency is the number of
seconds between samples, and count is the number of samples to take.
In this example, vmstat samples every two seconds for a total of five samples. The first output
line of vmstat shows all the activity since the last reboot. The following example shows a
loaded system, but with little swapping. Pages in are represented by “si” and pages out are
shown with “so.”
Note: The first line of output includes all activity since the last vmstat report.

# vmstat 2 5
m y
procs
r b w swpd free buff
memory
cache si
swap
so bi
io
bo in
system
cs us
d e
sy
cpu
id
1 0 0
1 0 0
1 0 0
296004
296004
296004
3092
3076
3076
73268
73268
73268
61324
61324
61324
0
0
0
3
0
0
11
0
0
51
2
32
135
109
109
588

c
372
199 a
10
66
59
4
34
41
86
0
0
1 0 0
1 0 0
296004
296004
3072
3076
73268
73268
61316
61300

e
0
0
0
0
0
2
24
10
110
107 A331
373
40
51
60
49
0
0

c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 26
Interpreting Memory Measurements

When interpreting memory measurements, observe cases


where the system has:
• High swap memory usage
• Kernel file cache that continue to be allocated despite
low system memory
• High page ins/page outs
• Low inactive pages

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Interpreting Memory Measurements

e A
c l
Remember that a single measurement is meaningless. The key to using memory statistics is
measurement over a period of time. You can use the average demand rate (when the system

r a
performance is acceptable) as a baseline to compare with when the system performs poorly.
This, along with the pages in over the same time periods, may indicate memory problems.
High Swap Memory Usage O ly
l & On
Indicates memory demand is too high for the available RAM. If this is consistently high, then
consider adding RAM.

n a e
Kernel File Cache Continues to Be Allocated Despite Low System Memory

e r s
This may be an indication of kernel problems. (Earlier Linux kernels did not release file cache
t U
quickly enough.)

I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 27
Interpreting Memory Measurements (continued)
High Page Ins
This can indicate that the SGA is too large for available memory, or that the SGA needs to be
“locked” into RAM. If you are using a supported enterprise distribution, then use the hugepages
feature. If using a nonenterprise kernel, then set lock_sga=true to lock the SGA into RAM.
Note that this requires the oracle user to have the CAP_IPC_LOCK privilege granted through
and advanced permissions management system such as the Linux Intrusion Detection System
(LIDS).
Low Inactive Pages
This indicates that you do not have enough memory. The best solution is to increase RAM.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 28
Reducing Memory Bottlenecks

If you determine that memory is the limiting factor in your


system, then:
• Increase memory resources
• Decrease memory demand

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Reducing Memory Bottlenecks

e A
c l
All the solutions are in the form of Use less memory or Get more memory.
• Identify nonessential memory consumption and eliminate it. Look for running non-Oracle

r a
processes and eliminate those you can do without.
• Use Linux hugepages.
O ly
• Reducing the SGA is not usually acceptable, but check the installation and configuration.

l & On
Are you using the Java Virtual Machine (JVM)? If not, reduce JAVA_POOL_SIZE to zero.
Can your buffer cache be reduced without affecting performance? Although the SGA would
a e
not complain about excessive pool sizes (within reason), your server certainly will.
n
r s
• Reduce the number of user processes. Without restricting the number of users, the number

e
of user processes can be reduced by using shared servers if the workload supports them.
t U
• Reduce the amount of process memory with PGA_AGGREGATE_TARGET.

I n
• Add memory to your server.

c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 29
Monitoring and Tuning I/O

You should monitor the I/O across all devices to balance


which device gives the best overall performance. Tools for
monitoring I/O include:
• /proc file system
• sar -d
• iostat –d -p
• vmstat
• xosview

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Monitoring and Tuning I/O

e A
c l
Which tools you use to tune disk I/O really depend on your storage system. Tools such as sar
and iostat are common, but tend to show I/O measurements from the operating system’s

r a
point of view rather than from a hardware standpoint. If your hardware includes large storage
arrays from vendors, such as EMC, Network Appliance, HP/Compaq, and Veritas, then you will
O ly
normally use monitoring tools provided by your vendor. If you are using the Just a Bunch Of

l & On
Disks (JBOD) technology, then the information provided by operating system tools, such as sar
and iostat, should be sufficient.

n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 30
Is I/O a Bottleneck?

Is I/O a bottleneck?
• Take and retain baseline I/O measurements.
• Individual measurements (snapshots) are usually of
little value. I/O monitoring should be done over time.
• I/O issues with the swap partition should be treated as
memory problems first.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Is I/O a Problem?

e A
c l
With databases, disk I/O is a primary concern. Disk I/O is the single largest performance cost.
Most I/O measurements are meaningless without a baseline, so ensure that you capture and

r a
retain that. When you notice performance degradation, look for high queue and wait statistics to
determine whether I/O is the culprit.
O ly
Remember that virtual memory is maintained on disk, and will also show up as I/O. If you spot

address it as an I/O issue.


l & On
high I/O statistics on the swap partition, you should troubleshoot it as a memory issue first, then

n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 31
I/O Measurements

I/O measurements concentrate on volume and speed:


• Read I/O operations
• Write I/O operations
• Request queue size
• Transfer rate
• Wait time
• Service time

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
I/O Measurements

e A
with which that data is handled.
c l
I/O measurements usually concentrate on either the volume of data being handled or the speed

Volume
r a
O ly
Obviously, the more work that is being done the longer it will take to do that work. When you
measure volume, look at read and write volume separately. Also, if your tools allow you to view

l & On
it, monitor sequential operations as compared with random access. It is usually quicker to write

n a e
1 MB of sequential data than to write 20 KB in multiple locations on the disk because of the
time required for disk head positioning.
Speed
t e r U s
I n
When monitoring speed, look for transfer rate (bytes per second), wait time (how much time was
spent waiting for I/O to respond), and service time (how long does each I/O operation take from

c l
standpoint.e
start to finish). Of these three, the wait time is the most important from a database performance

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 32
Measuring I/O with iostat

I/O measurements concentrate on volume and speed:


• Read I/O operations
• I/O statistics by device
iostat -d <interval> <count>
#iostat -d 2 2
Linux 2.6.9-22.EL (HOSTNAME) 10/27/2006
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
hda 4.85 49.16 84.01 60104671 102704241

• I/O activity by partition

y
iostat –d -p <interval> <count>

e m
Copyright © 2007, Oracle. All rights reserved.
a d
Measuring I/O with iostat
A c
l e
The iostat command is used for monitoring system I/O device loading by observing the time

c
the devices are active in relation to their average transfer rates. The first report provides statistics

r a
concerning the time since the system was booted. Subsequent reports cover the time since the
previous report.
O ly
To view I/O statistics by device, use (the –d option suppresses CPU statistics):

& On
iostat -d <interval> <count>

l
n a e
Transfer rate is shown by the tps, Blk_read/s and Blk_wrtn/s columns. Volume
measurements for read and write operations can be seen in the blk_wrtn and blk_read
columns.

t e r U s
To see I/O activity by partition, use:

I n
iostat –d -p <interval> <count>

l e
The iostat -p command presents the I/O statistics by partition with the same statistics that
can be seen from V$FILESTAT on database files.
c
r a
To display extended statistics by device, use (the -d –x option, -x and –p are mutually
exclusive and cannot be used together):

O iostat –d –x <interval> <count>

Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 33


Measuring I/O with iostat (continued)
Speed measurements are shown in three ways: merged requests as rrqm/s and wrqm/s (how
many operations were performed), requests as r/s and w/s (how many requests were made of
the I/O system), and sectors handled per second as rsec/s and wsec/s.
Volume statistics are shown including average requests size avgrq-sz.await gives the
average wait time for requests. avgqu-sz is a key metric that shows the length of the request
queue (this is the I/O equivalent of CPU load). Service time, another key metric, appears as
svctm. %util is the percentage of time the CPU spends handling I/O requests.
The output of the following command has been reformatted to fit the page.
# iostat –d -x 2 2
Linux 2.6.9-22.EL (EDRSR24P1) 10/27/2006

Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s rkB/s wkB/s


hda 0.26 8.09 2.44 2.39 48.99 83.83 24.50 41.92
<would normally appear on same line as above>
Device: avgrq-sz avgqu-sz await svctm %util
hda 27.51 0.34 70.08 2.89 1.40

#iostat -d -p 2 2
Linux 2.6.9-22.EL (EDRSR24P1) 10/27/2006

m y
Device: tps Blk_read/s Blk_wrtn/s Blk_read

d e
Blk_wrtn

a
hda 4.84 49.08 83.93 59993375 102593945
hda1
hda2
0.02
0.00
0.01
0.00
0.00
0.00
A c
15083
1595
5179
70

e
hda3 0.59 2.30 2.40 2806293 2932664
hda5 12.60 46.77

c l 81.52 57168926 99656032

performance.
r a
As you can see in the above example, hda5 is the only partition that is really affecting system

O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 34
Measuring I/O with sar
sar –b shows transfer rate as tps. The transfers are broken down into read/write with
rtps/wtps showing the number of requests per second and bread/s and bwrtn/s
showing the number of data blocks per second.
sar –d shows transfer rates and blocks per second per device.
# sar -d 2 2
02:57:44 PM DEV tps blks/s
02:57:46 PM dev3-0 6.50 96.00

02:57:46 PM DEV tps blks/s


02:57:48 PM dev3-0 1.50 112.00

Average: DEV tps blks/s


Average: dev3-0 4.00 104.00
Remember that sar can show history information for up to one month in the past, so this tool
allows you to easily compare current rates with historical figures.
Measuring I/O with vmstat
vmstat provides information on overall I/O throughput.
• bo: Blocks sent to the storage array (write)
m y
• bi: Blocks received from the storage array (read)

d e
# vmstat 3 3
procs memory swap io
c
system a cpu
r b w swpd
1 0 0 424800
free
12540
buff
84636
cache
376516

e
si so
0 0
bi
10
bo
58
in
3A cs us
31 12
sy id
5 24
2 0 0 424800
3 0 0 424800
12536
12536
84636
84636
c l
376516
376516
0
0
0
0
0
0
11
56
107 451
110 451
1
1
0 99
0 99

r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 35
Interpreting I/O Measurements

Look for changes from baseline measurements, especially


in queue size or wait times:
• High volume or queue size across multiple devices
• High volume or queue size for one device
• High wait times without corresponding high queue
sizes

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Interpreting I/O Measurements

e A
c l
Like memory measurements, the key to using I/O statistics is measurement over a period of
time. Take periodic measurements of I/O volume and speed so that when performance degrades,

r a
you can identify probable problem devices.

O ly
High Request Volume or Queue Size Overall
This indicates that the I/O devices are unable to handle the rate of I/O requests. This means that

l & On
there are either not enough channels to I/O devices or that existing channels are too slow.

a e
High Request Volume or Queue Size for One Device

n
High Wait Times
t e r U s
It indicates that I/O may not be properly balanced across available devices.

I n
If wait times are high and queue size is not, verify whether asynchronous I/O is being used if the
storage arrays supports it. If not, ensure that I/O slaves are in use. This may also be indicative of

l e
hardware problems.
c
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 36
Reducing I/O Bottlenecks

To reduce I/O as a bottleneck:


• Reduce the volume of I/O through application and
memory tuning
• Increase I/O throughput by parallelizing I/O
– Multiple disk controllers
– Multiple disks
– Multiple data bus adapters
• Select your hardware carefully, and build your storage
arrays with performance in mind
• Separate redo, data, and index files

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Reducing I/O Bottlenecks

e A
c l
A good rule of thumb is to tune the application and memory to reduce or eliminate I/O as much
as possible. When this is accomplished, balance the remaining I/O across all the available drives

I/O performance can be. r a


and controllers. In general, the more disks and controllers you are working with, the greater your

O ly
Carefully consider how your storage arrays are built. If you mix drives with different

l & On
performance characteristics, keep the fastest drives on a different bus than the slowest drives.
The controller bus speed is limited to the speed of the slowest device. More data channels means
a e
more data bandwidth. Consider adding additional Host Bus Adapters (HBAs).
n
t e r U s
If you are using Redundant Arrays of Inexpensive Disks (RAID), choose hardware-based RAID
over software-managed RAID. Software-managed RAID consumes CPU and memory resources

I n
and seldom performs as well as hardware-based RAID. Additionally, RAID 5 generally
performs well for read operations, but poorly for write due to the parity calculations required.

l e
Try to minimize the number of stripe columns in RAID 5. More columns means more

c
calculations to generate the parity bit.

r a
Remember to place files with different requirements on different disks. For example, your redo

Olog members should be placed on separate disks (away from data and control files) and should
be on your fastest disks, bus, and controllers.

Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 37


Summary

In this lesson, you should have learned how to:


• Use Linux monitoring tools
• Interpret memory measurements
• Interpret I/O measurements

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 38
Practice 9 Overview:
Using Linux Measurement Tools

This practice covers using:


• sar to measure CPU loads
• vmstat to measure memory usage
• iostat to measure disk I/O loads

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Practice 9 Overview: Using Linux Measurement Tools

e A
l
For detailed instructions on performing this practice, see Practice 9 in Appendix A.

c
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 9 - 39
m y
d e
ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Tuning Oracle on Linux

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Objectives

After completing this lesson, you should be able to do the


following:
• Tune supported file systems
• Configure initialization parameters
• Implement asynchronous input/output (I/O)
• Implement advanced memory management techniques

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 10 - 2
Basic Oracle Database Optimizations

• Use locally managed tablespaces (default).


• Use a larger database buffer cache (within reason).
• Use an appropriately sized database block.
• Use a larger redo log buffer.
• Use multiple database writer processes on Symmetric
Multiprocessing (SMP) machines.
• Use Automatic Shared Memory Management.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Basic Oracle Database Optimizations

e A
Locally Managed Tablespaces c l
Oracle Database has a set of well-known (but often overlooked) features that enhance performance.

r a
Locally Managed Tablespaces (LMT) are the default in Oracle Database 10g. Starting with Oracle9i

O ly
Release 2, even the system tablespace may be locally managed. LMT reduces I/O by managing the
extent allocation within a file with a bitmap in that data file instead of updating tables in the data
& On
dictionary. This decreases the I/O requirements for the system tablespace. Performance increases of
l
Larger Database Buffer Cache
n a e
2% to 15% have been documented using LMT, depending on the application.

t e r U s
The database instance caches the most recently used blocks in the database buffer cache. The larger
the cache, the more data blocks can be cached. Because a disk access takes much longer than a

I n
memory access, each database block that can be cached and reused improves performance. Size the
cache according to the db_cache_advice feature in Oracle Enterprise Manager. Do not make the

l e
cache so large that paging increases or (in extreme cases) it takes longer to search for a block in
c
memory than it would have to just read the block from disk. Performance gains depend on the

r a
amount of reuse in the data blocks.

O
Oracle Database 10g: Managing Oracle on Linux for DBAs 10 - 3
Sizing Database Blocks

The DB_BLOCK_SIZE parameter should be set according to


the type of application:
• 8 KB block size gives good overall performance.
• Smaller blocks give better concurrency with
OLTP applications.
• Larger blocks reduce the amount of overhead for data
warehouse/decision support system (DW/DSS)
applications.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Sizing Database Blocks

e A
c l
The size of the database block has a large impact on the performance of the application. Tests have
shown that the best block size is usually 8 KB. The database block must always be the same size or a

r a
multiple of the memory page size. On Linux, the page size is 4 KB but (as discussed in the lesson
titled “Linux Measurement Tools”) can be increased to 2 or 4 MB using hugepages.
O ly
The database block should also be the same size or a multiple of the file system block size. The block
& On
size on the ext3 file system is 4 KB. Other file systems may use other block sizes.
l
OLTP Applications

n a e
e r
An online transaction processing (OLTP) application is characterized by a large number of
s
concurrent users and relatively small transactions. As the blocks get larger, the probability of two or
t U
more users requesting access to the same block simultaneously also increases. This leads to “buffer

I n
busy” waits, because only one process can access a block at a time. Smaller blocks reduce the

l e
number of rows in the block, which then reduces the likelihood of concurrent access. If your
application has these characteristics, then consider setting DB_BLOCK_SIZE to 4 KB.
c
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 10 - 4
Sizing Database Blocks (continued)
DSS/DW Applications
Data warehouse–type applications are characterized by large data sets and frequent full table scans.
Because the data sets are so large that the database buffer cache cannot hold the full set, the set must
be read from disk. In this case, use the largest block size available (16 KB on 32-bit Linux). This
reduces the percentage of space used by block headers, and increases the number of rows per block,
thus reducing the number of I/Os by packing more data into the same number of bytes.
Effect of Block Size on Indexes
In databases with large tables and small database blocks, consider a very large OLTP application
such as credit card processing. The indexes may get quite large. Index lookups are always done
serially: first the root block is accessed, and then the first-level branch block is accessed. This
process continues to the n-1 level branch, finally reaching the leaf block, which is the nth level. This
lookup may require n I/Os for an n-level index, if the blocks needed are not already in the cache.
Ideally, the index is no more than three levels deep, meaning n should be three or less.
In the following example, a 20-level index is chosen to simplify the mathematics. Realistically, an
index would seldom get that large.
To illustrate the effect of the block size on an index, assume a 2 KB block size and a 20-level index.
If this index were in a database with 4 KB block size, then each leaf would hold at least twice as
many index row entries, so that half as many leaf blocks would be used. The first-level branch blocks
would hold twice as many leaf pointers, but there would be only half as many leaf blocks, so the
number of first-level branch blocks would be reduced to 1/4 of the original index.
m y
d e
Continuing with this exponential reduction in branches would reduce the number of levels to five.
The first index required 20 reads for an index lookup, and the rebuilt index requires five reads. This
significantly improves the performance of index lookups.
c a
Because of this, you may want to use a larger block size if the application has very large indexes, or
consider using partitioned indexes.

e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 10 - 5
LOG_BUFFER and Redo Log File

Increasing the size of the redo log components can help


the performance of high data manipulation language (DML)
applications.
• Examine performance reports for waits on the redo log
components.
• Tune the redo log file and archive log file
transfers first.
• Increase the size of the LOG_BUFFER parameter.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
LOG_BUFFER and Redo Log File

e A
c l
Every DML statement produces some amount of redo information. This data must be written to the
redo log files on commit. The server process does not report Commit complete to the user until

r a
the redo information has been written to the redo log file. When the current log file is full, a log file
switch occurs.
O ly
If the LGWR process cannot write to the log files fast enough to clear space in the log buffer for other
& On
processes that are attempting to execute DML statements, then various wait statistics are
l
n a e
incremented. For example, if there is no space in the log buffer at the time an attempt is made to
write to it, there will be a log buffer space wait event. Increasing the size of the LOG_BUFFER

t e r U s
can reduce or eliminate these waits. The minimum LOG_BUFFER size is 64 KB. An optimal setting
for LOG_BUFFER varies with application. High-volume DML applications can benefit from a LOG

n
BUFFER set to something higher than the default value.
I
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 10 - 6
LOG_BUFFER and Redo Log File (continued)
Sizing redo log files is dependent on the speed at which redo is generated. If the switch is delayed for
any reason, the processes trying to write into the LOG_BUFFER have to wait, and a wait event log
file completion is recorded. You want to eliminate these waits and at the same time, do not
want to size the files so large that they become unmanageable. Redo log files in the range of tens to
hundreds of megabytes are considered reasonable. A tentative guideline is to size them such that the
log file switch occurs every 20 to 30 minutes. For details, refer to the Oracle Database 10g:
Performance Tuning course and the Oracle Database 10g Performance Tuning Guide.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 10 - 7
Advanced Features of Oracle Server

There are a few advanced initialization parameters that


affect performance on Linux:
• DB_WRITER_PROCESSES
• DBWR_IO_SLAVES
• PRE_PAGE_SGA

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Advanced Features of Oracle Server

e A
c l
The parameters listed here are considered advanced parameters. Very few initialization parameters
depend on the OS. The parameters listed in the slide are the ones that are most affected by the OS.

r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 10 - 8
Multiple DBWR Processes

DB_WRITER_PROCESSES:
• These processes are set to no more than CPU_COUNT,
up to 20.
• Multiple DBWR processes write from LRU to disk.
• These processes can use asynchronous I/O.
• These processes are best used in OLTP environments.

LRU lists

DBWR processes
m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Multiple DBWR Processes

e A
c l
In high-volume OLTP databases, the standard configuration of the DBWR process may not be able to
write changed data blocks back to the disk fast enough to maintain the pool of free buffers for new

r a
blocks coming into the database buffer cache. The usual first step is to increase the
DB_CACHE_SIZE, but this may not be enough.
O ly
The next step is to increase the number of DB_WRITER_PROCESSES. This starts the specified
& On
number of DBWR processes. This can be up to 20 as of Oracle9i, Release 2. Each DBWR process
l
n a e
handles one or more LRU lists moving dirty buffers to the disk for those lists. If asynchronous I/O is
turned on, then all the DBWR processes make use of it.

t e r U s
The default value for DB_WRITER_PROCESSES is (CPU_COUNT+7)/8. For example, with between
one and eight CPUs, DB_WRITER_PROCESSES is set to one. If your CPU_COUNT = 20, then

I n
DB_WRITER_PROCESSES is set to three. The value of DB_WRITER_PROCESSES must be
adjusted incrementally. When increasing the number of DB_WRITER_PROCESSES, consider the

l e
number of disk controllers that are available and monitor the disk I/O queues. Too many
c
DB_WRITERS_PROCESSES can cause contention for the controller channel.

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 10 - 9
DB Writer Slaves

DBWR_IO_SLAVES:
• Used to simulate asynchronous I/O
• One DBWR, multiple writers to disk

Buffer
cache DBWR
I/O slaves

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
DB Writer Slaves

e A
asynchronous I/O with the DBWR_IO_SLAVES.
c l
On systems without asynchronous I/O capability, the database instance provides a way to simulate

r a
Set this parameter to no more than two times the number of disks that the database is spread across.

O ly
When increasing DBWR_IO_SLAVES, consider the number of disk controllers and monitor the disk
I/O queues for contention. Also, when increasing the number of slaves, add only a few at a time,
& On
because each of these processes has an overhead cost. If you add too many at once, the overhead of
l
n a e
all the processes may outweigh the benefit of the additional processes. Each slave must have a
communication area for I/O buffers. This area is taken from the large pool if it is configured, or from

t e r U s
the shared pool if the large pool does not exist. Turning on DBWR_IO_SLAVES forces
DB_WRITER_PROCESSES to one, and sets the number of slave processes used by the ARCH and

I n
LGWR processes to four. Even though I/O slaves are generally used to simulate asynchronous I/O, the
slaves use asynchronous I/O if it is turned on.

l e
Note: The use of multiple DBWR processes and I/O slaves are mutually exclusive.
c
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 10 - 10
Changing SGA Behavior

• Normally, unused memory allocated to the System


Global Area (SGA) is not mapped to the physical
memory until it is used, and infrequently used pages
are paged out.
• To touch all the SGA at startup, use PRE_PAGE_SGA:
– The SGA is mapped to physical memory.
– The SGA could slow connection processing.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Changing SGA Behavior

e A
c l
The normal behavior is that shared memory up to SGA_MAX_SIZE is allocated and set up in virtual
memory at startup. Unused pages in the SGA are not mapped to physical memory until they are used,

r a
and pages in the SGA that are not frequently used may be paged out.

O ly
The PRE_PAGE_SGA initialization parameter causes each server process that starts to touch every
page of the SGA. This has the advantage of mapping all the SGA pages to physical memory, so that
& On
when they are required later, they will be already mapped. The disadvantage is that with large
l
n a e
number of pages, each server process that starts touches all the pages, thus increasing the connection
time. If some pages are swapped out, those pages have to be swapped in for the touch. This in turn

t e r U s
may force other more active pages to swap, further reducing performance. Set PRE_PAGE_SGA =
true only when there is sufficient real memory to hold the entire SGA.

I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 10 - 11
Automatic Shared Memory Management

• Automatically adapts to workload changes


• Maximizes memory utilization
• Helps eliminate out-of-memory errors

Buffer cache
Buffer cache
Example:
Large pool
Large pool

Shared pool Shared pool


Java pool Java pool
Streams pool Streams pool

Online users Batch jobs


m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Automatic Shared Memory Management

e A
c l
Automatic Shared Memory Management (ASMM) is another key self-management enhancement in
the Oracle database. This functionality automates the management of the most important shared

r a
memory structures used by an Oracle database instance, and relieves you of having to configure these
components manually. Besides making more effective use of available memory and thereby reducing
O ly
the cost incurred for acquiring additional hardware memory resources, the ASMM feature

adaptive memory management scheme.


l & On
significantly simplifies Oracle database administration by introducing a more dynamic, flexible, and

n a e
For example, in a system that runs large online transactional processing (OLTP) jobs during the day

t e r U s
(requiring a large buffer cache) and runs parallel batch jobs at night (requiring a large value for the
large pool), you would have to simultaneously configure both the buffer cache and the large pool to

I n
accommodate your peak requirements.
With ASMM, when the OLTP job runs, the buffer cache grabs most of the memory to allow for good

l e
I/O performance. When the data analysis and reporting batch job starts up later, the memory is
c
automatically migrated to the large pool so that it can be used by parallel query operations without

r a
producing memory overflow errors.

O
Oracle Database 10g: Managing Oracle on Linux for DBAs 10 - 12
Basic Linux Optimizations

Basic changes to the Linux default setup can give some


performance improvements.
• Use the latest supported kernel.
• Turn off last time-read updates for the database files.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Basic Linux Optimizations

e A
c l
Apply the latest supported kernel patches through the .rpm files provided by the distribution vendor.
This ensures that you are using the most efficient kernel available.

r a
By default, the last time-read attribute (atime) is updated every time a file is read. For database

O ly
files, this is not an important statistic and you can turn it off to reduce the number of I/Os. This
parameter can be set for a file with chattr +A <filename> or for a directory with chattr -

l & On
R +A <directory name>. To make this change persistent across reboots, change it for a file
system by changing the /etc/fstab file and adding the noatime option to the fourth column.

n a e
r
/dev/hdb7 /u3/app/oracle/ ext3 rw,noatime 1 1

t e U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 10 - 13
Choosing a Kernel

Choose the appropriate kernel for best performance:


• If you have more than 4 GB of physical memory, then
use the enterprise or hugemem kernel.
• If you have more than one CPU, then use the smp
kernel.
• Otherwise, use the uniprocessor kernel.

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Choosing a Kernel

e A
c l
The Linux installers tend to make good choices about which kernel to install, and install the kernel
that uses your hardware and gives a good performance. If you have to choose which kernel to use,
follow these guidelines.
r a
O ly
For machines with more than 4 GB of physical memory, an enterprise kernel is required. The
enterprise kernel includes the Physical Address Extensions (PAE) that are required to address
& On
more than 4 GB of physical memory. This includes a three-level memory page table, so if you have
l
required.
n a e
less than 4 GB of physical RAM, then the three-level page table is an extra overhead that is not

t e r U s
For multiprocessor machines, the installer chooses an smp kernel. The smp kernel has the required
extensions to handle scheduling processes on more than one CPU.

I n
The uniprocessor kernel handles up to 4 GB of physical memory on a single processor. An example

c l e
of the uniprocessor name is 2.4.9-e.3. (Note that there is no special designator.)
An enterprise or smp kernel may be used on a uniprocessor machine, but has extra overhead

a
associated with the unused features.
r
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 10 - 14
Summary

In this lesson, you should have learned how to:


• Evaluate file systems
• Tune supported file systems
• Configure initialization parameters
• Implement asynchronous input/output (I/O)
• Implement advanced memory management techniques

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 10 - 15
Practice 10 Overview:
Tuning Performance

This practice covers the following topics:


• Adjusting the block size of database objects
• Identifying poorly performing sessions at the operating
system level

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 10 - 16
Debugging Oracle on Linux

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Objectives

After completing this lesson, you should be able to:


• Install and configure OS Watcher
• Use Oracle Support’s Remote Diagnostics Agent
• Trace programs and processes with strace
• Gather required information for resolving ORA-600 and
ORA-7445 errrors

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 11 - 2
OS Watcher

OS Watcher (OSW) is a set of scripts that continually run in


the background, collecting information about:
• Processes
• I/O
• Memory
• Network

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
OS Watcher

e A
c l
OS Watcher (OSW) is a collection of shell scripts intended to collect and archive operating
system and network metrics to aid support of generic performance issues. OSW operates as a set

r a
of background processes on the server and gathers OS data on a regular basis, invoking such
utilities as vmstat, netstat and iostat.
O ly
Note: For more details, refer to the OS Watcher user’s guide in MetaLink note 301137.1. The
& On
MetaLink note contains the link for downloading OS Watcher.
l
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 11 - 3
Installing OSW

$ tar -xf osw.tar


$ cd osw
$ ls -gG
total 56
drwxr-xr-x 11 4096 Sep 30 13:50 archive
-rwxr-xr-x 1 1731 Mar 29 2005 Exampleprivate.net
-rwxr-xr-x 1 4451 Apr 5 2005 OSWatcherFM.sh
-rwxr-xr-x 1 10231 Aug 2 2005 OSWatcher.sh
-rwxr-xr-x 1 334 Mar 28 2005 oswnet.sh
-rwxr-xr-x 1 401 Mar 21 2005 oswsub.sh
-rw-r--r-- 1 3029 Mar 22 2005 README
-rwxr-xr-x 1 1101 Mar 18 2005 startOSW.sh
-rwxr-xr-x 1 560 Dec 16 2004 stopOSW.sh
-rwxr-xr-x 1 57 Jun 14 2005 tarupfiles.sh
-rwxr-xr-x 1 409 Mar 18 2005 topaix.sh

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Installing OSWatcher

e A
c l
Installation is very simple. Untar the osw.tar file, which creates the directory structure under
the current directory. The parent directory of all the extracted files is called osw. At that point,
the software is installed.
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 11 - 4
Configuring OSW

Configure OSW by changing the command that it runs,


which are stored in the OSWatcher.sh file:

#########################################################
# CONFIGURATION Determine Host Platform
#########################################################
case $PLATFORM in
Linux)
IOSTAT='iostat -x 1 3'
VMSTAT='vmstat 1 3'
TOP='eval top -b -n 1 | head -50'
PSELF='ps -elf'

y
MPSTAT='mpstat 1 3'
MEMINFO='cat /proc/meminfo'
SLABINFO='cat /proc/slabinfo'

e m
Copyright © 2007, Oracle. All rights reserved.
a d
Configuring OSW
A c
l e
OSWatcher can be configured by editing the CONFIGURATION section of the

c
OSWatcher.sh script. Here, the commands, along with their arguments, are listed. You can

r a
edit these here to cause the behavior and output of the commands to change. The default setting
for the Linux platform is shown in the slide.
O ly
For example, the output from iostat with the –x option, as shown above, shows the statistics

l & On
of the hard drive but not the partitions. You could change the –x option to –p /dev/hda and
the output would show the individual partitions.

n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 11 - 5
Running OSW

$ ./startOSW.sh 30 24
Testing for discovery of OS Utilities... Snapshot
VMSTAT found on your system. interval
IOSTAT found on your system. in seconds
MPSTAT found on your system.
NETSTAT found on your system.
TOP found on your system. Hours
Discovery completed. to run
Starting OSWatcher V1.3.2 on Sat Sep ...
With SnapshotInterval = 30
With ArchiveInterval = 24
Starting Data Collection...
osw:Sat Sep 30 13:50:30 PDT 2006
osw:Sat Sep 30 13:51:01 PDT 2006 $ ./stopOSW.sh
osw:Sat Sep 30 13:51:31 PDT 2006
Terminated
m y
d e
Copyright © 2007, Oracle. All rights reserved.

c a
Running OSW

e A
c l
To run OSW, simply invoke the startOSW.sh script:
startOSW.sh <snapshot_interval> <hours>

r a
where the snapshot_interval is the number of seconds there should be between each data sample,

O ly
and hours is the number of hours for which to collect data. Even if the number of hours has not
been reached, you can run the stopOSW.sh script to stop it at any time.
& On
In the example in the slide, data is being sampled every 30 seconds, and the script will run for 24
l
n a e
hours. But, after three samples have been taken (90 seconds have passed) the stopOSW.sh
script is run to stop the data collection.

t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 11 - 6
Viewing OSW Output

The archive subdirectory contains the output of an OSW


execution, categorized into directories related to each
command that runs.

$ ls
oswiostat oswmpstat oswprvtnet oswslabinfo oswvmstat
oswmeminfo oswnetstat oswps oswtop
$ head -4 oswmeminfo/EDRSR9P1_meminfo_09.30.06.1300.dat
zzz ***Sat Sep 30 13:50:31 PDT 2006
MemTotal: 1035320 kB
MemFree: 451920 kB
Buffers: 1020 kB

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Viewing OSW Output

e A
c l
The only directory immediately under the osw installation directory is called archive. That is
where all output is stored. In that directory is a subdirectory for each command that is being

r a
repeatedly run during the session. The subdirectory names are made up by prepending the string
“osw” to the command name. They are:
• oswiostat
O ly
• oswmeminfo
• oswmpstat
l & On
• oswnetstat

n a e
• oswprvtnet
• oswps

t e r U s
• oswslabinfo
• oswtop
I n
l e
• Oswvmstat

c
Under each of those directories are the files that contain the collected data. The names of those

a
files follow this pattern for organizational purposes:
r
O
<hostname>_<command>_<timestamp>.dat

Oracle Database 10g: Managing Oracle on Linux for DBAs 11 - 7


Remote Diagnostics Agent

The Remote Diagnostics Agent (RDA) is a tool you can run


on your database server that gathers information relevant
to:
• Performance issues
• Installation/configuration issues
• ORA-600, ORA-7445, and ORA-3113 errors
• Upgrade, migration, and linking issues

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Remote Diagnostics Agent (RDA)

e A
c l
The Remote Diagnostics Agent is a tool that you can use to gather comprehensive information
about your database server, including Linux parameters, database settings, and network

r a
information, and so on. This information is compiled into HTML, and so is easily browseable by
category.
O ly
The output is written in the form of HTML files, which are also collected into a single ZIP file.

l & On
This makes it easy to send the information to Oracle Support for analysis. It is also a good way
for you to see a summary of your entire system.

n a e
Note: See MetaLink Note 314422.1 for details on downloading, installing, and running the
RDA.

t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 11 - 8
Installing the RDA

$ gunzip rda_4.5-060912.tar.gz
$ tar -xf rda_4.5-060912.tar
$ cd rda
$ ls -gG
total 112
-r--r--r-- 1 4087 Jul 6 01:58 DISCLAIM.txt
drwxr-xr-x 2 4096 Sep 30 12:07 hcve
drwxr-xr-x 2 4096 Sep 30 12:07 modules
drwxr-xr-x 4 4096 Sep 30 12:07 RDA
-r-xr-xr-x 1 3415 Apr 25 05:50 rda.cmd
-r-xr-xr-x 1 40066 Sep 8 08:03 rda.pl
-r-xr-xr-x 1 3442 Apr 25 05:50 rda.sh
-r--r--r-- 1 13103 Aug 4 06:41 README_Unix.txt
-r--r--r-- 1 14539 Aug 4 06:41 README_VMS.txt
-r--r--r-- 1 13101 Aug 4 06:41 README_Windows.txt

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Installing the RDA

e A
c l
Installation is very simple. Extract the gzip file using gunzip, and then untar the extracted tar
file, which creates the directory structure under the current directory. The parent directory of all

r a
the extracted files is called rda. At that point, the software is installed; there is no need to run
an installation script.
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 11 - 9
Running the RDA

Prompts with
several questions Gathers
data
$ ./rda.sh –S

.
.
$ ./rda.sh -v
Collecting diagnostic data ...
---------------------------------------------------------
RDA Data Collection Started 22-Sep-2006 11:59:37 AM
---------------------------------------------------------
Processing Initialization module ...
Processing CFG module ...

y
Processing Sampling module ...
Processing OCM module ...
Processing OS module ...

em
Copyright © 2007, Oracle. All rights reserved.
a d
Running the RDA
A c
l e
There are two steps involved in running the RDA:

c
1. Setup: Run the rda.sh script with the –S parameter to perform the setup. This prompts

r a
you for information about your installation including Oracle home directories, ASM
instance information, and location of certain files such as the initialization file.
O ly
2. Gather data: This step actually collects the data about your system. As each area (referred

l & On
to as module) is interrogated, the name is output on the command line.
Note: Root cannot connect to a database as “/ as sysdba.” When running rda.sh as the root

n a e
OS user, choose a different schema for connecting to the database.

t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 11 - 10
Viewing the RDA Output

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Viewing the RDA Output

e A
c l
Run a browser, and open the file that is referenced at the end of the data collection run. That
displays the main page, an example of which is shown in the slide. There are frames to easily

r a
navigate to the various categories of information.

O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 11 - 11
Navigating the RDA Output

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Navigating the RDA Output

e A
c l
In the example in the slide, you see that you can choose to look at the Operating System Setup,
and then choose Miscellaneous Linux Information.

r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 11 - 12
strace

• Diagnostic utility
• Records system calls
• Trace a specified command
• Trace an existing process
$ strace –aef –Ttt –o /tmp/date.out date

$ strace –p 1287 –o /tmp/ora_pmon_orcl.out

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
strace

e A
c l
Strace is a utility that intercepts and records the system calls, which are called by a process, and
the signals, which are received by a process. The name of each system call, its arguments and its

r a
return value are printed on standard error or to the file specified with the -o option.

O ly
strace can trace running background processes or be used when executing a program.
Using a simple shell script, you can see a sample of the output from strace. Script

l & On
helloworld.sh invokes a bash shell, echoes “Hello World!,” and then exits.
helloworld.sh shell script:

n a e
#!/bin/bash

e r
echo “Hello World!”
exit 0
t U s
I n
The shell script is executed using strace:

c l e
strace –o /tmp/helloworld.out ./helloworld.sh

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 11 - 13
strace (continued)
The full output of the trace is 102 lines. The listing below contains the last few lines of the trace.
.
.
.
open("./helloworld.sh", O_RDONLY|O_LARGEFILE) = 3
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbffb28c8) = -1 ENOTTY
(Inappropriate ioctl for device)
_llseek(3, 0, [0], SEEK_CUR) = 0
read(3, "#!/bin/bash\necho \"Hello World!\"\n"..., 80) = 39
_llseek(3, 0, [0], SEEK_SET) = 0
getrlimit(RLIMIT_NOFILE, {rlim_cur=64*1024, rlim_max=64*1024}) = 0
dup2(3, 255) = 255
close(3) = 0
fcntl64(255, F_SETFD, FD_CLOEXEC) = 0
fcntl64(255, F_GETFL) = 0x8000 (flags
O_RDONLY|O_LARGEFILE)
fstat64(255, {st_mode=S_IFREG|0755, st_size=39, ...}) = 0
_llseek(255, 0, [0], SEEK_CUR) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
read(255, "#!/bin/bash\necho \"Hello World!\"\n"..., 39) = 39
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 5), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0xb7de3000

y
write(1, "Hello World!\n", 13) = 13
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
munmap(0xb7de3000, 4096)
exit_group(0)
= 0
= ?
e m
a d
A c
c l e
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 11 - 14
ORA-600 Errors

Alert log entry:

Tue Oct 3 05:13:08 2006


Errors in file
/u01/app/oracle/admin/orcl/udump/orcl_ora_18464.trc:
ORA-00600: internal error code, arguments: [kcfrbd_3],
[1], [3932239], [1], [62720], [62721], [], []

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
ORA-600

e A
c l
ORA-600 errors are raised from the kernel code of the Oracle Database software when an
internal inconsistency is detected or an unexpected condition is met. This situation is not

r a
necessarily a bug, it might be caused by problems with the operating system, lack of resources,
hardware failures, or other conditions.
O ly
With the ORA-600 error comes a list of arguments in square brackets. The first of these

l & On
arguments tells us from where in the code the error was caught and thus is the key information in
identifying the problem. This argument is either a number or a character string. The remaining

n a e
arguments are used to supply further information such as values of internal variables.

t e r U s
When an ORA-600 error is raised a trace file is generated in either USER_DUMP_DEST or
BACKGROUND_DUMP_DEST depending on whether the error was caught in a user or a

I n
background process. The error is also written in the alert log with the name of the trace file. The
trace file contains vital information about what led to the error condition.

c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 11 - 15
ORA-7445 Errors

Alert log entry:

Tue Oct 3 05:26:06 2006


Errors in file
/u01/app/oracle/admin/orcl/udump/orcl_ora_18732.trc:
ORA-07445: exception encountered: core dump [0046A7A2]
[SIGSEGV] [unknown code] [0x4A49] [] []

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
ORA-7445 Error

e A
c l
An ORA-7445 error is raised by an Oracle server process when it has received a fatal signal
from the operating system. The error may be raised in either a foreground or background

r a
process. The process will normally write an error to the alert log, write a trace file in either
USER_DUMP_DEST or BACKGROUND_DUMP_DEST, and create a core dump in
CORE_DUMP_DEST.
O ly
l & On
There are many “illegal” operations the operating system can trap; a common example is a
process writing to an invalid memory location. To protect the system, the offending process will

n a e
be sent a fatal signal. Typically, the signals seen are SIGBUS (signal 10, bus error) and

t e r U s
SIGSEGV (signal 11, segmentation violation).
There are other Linux signals and exceptions that may happen; however, those are likely caused

I n
by an OS program rather than a problem in the Oracle database.
Examples of other signals are SIGINT, SIGKILL, and SIGSYS.

c l e
An ORA-7445 is a generic error, and can occur from anywhere in the Oracle code. The precise

a
location of the error is identified by the trace file it produces.
r
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 11 - 16
Resolving
ORA-600/ORA-7445 Errors

File a service request with Oracle Support providing:


• The database alert log located in
BACKGROUND_DUMP_DEST
• The trace file mentioned in the alert log
• Recent changes to the system environment
– Hardware modifications
– Operating system upgrades
– Restore of data files
– Power failures
• Data generated by RDA

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
Resolving ORA-600/ORA-7445 Errors

e A
c l
Unless you are able to identify the cause and possible fix for an ORA-600 error using the
references mentioned below, it should be considered as a potentially serious issue and reported
to Oracle Support for identification.
r a
O ly
Every ORA-600 and ORA-7445 error generates a trace file. The name and location of the trace
file is also written to alert.log. To help Oracle Support determine what caused the error,

l & On
you should open a service request and supply the following information:
• The database alert log located in BACKGROUND_DUMP_DEST

n a e
• The trace file mentioned in the alert log

t e r
- Hardware modifications
U s
• Recent changes to the system environment:

I n
- Operating system upgrades
- Restore of data files

l e
- Power failures

c
• Data generated by the Remote Diagnostic Agent

r a
The trace file generated contains a call stack trace. A call stack trace or stack trace is the list of
routine calls, with the most recently called routine at the top of the list. The stack trace in the
Otrace file is a small portion of the trace starting with the header “Call Stack Trace.”

Oracle Database 10g: Managing Oracle on Linux for DBAs 11 - 17


Resolving ORA-600/ORA-7445 Errors (continued)
Trace file stack trace:
----- Call Stack Trace -----
calling call entry argument values in hex
location type point (? means dubious value)
------------------- ---- --------------- ----------------------------
ksedst()+27 call ksedst1() 0 ? 1 ?
ksedmp()+557 call ksedst() 0 ? 0 ? 0 ? 0 ? 0 ? 0 ?
ksfdmp()+19 call ksedmp() 3 ? BFFFADD0 ? AC05C15 ?
CBC2A40 ? 3 ? CB740C0 ?
kgerinv()+177 call 00000000 CBC2A40 ? 3 ?
kgesinv()+52 call kgerinv() CBC2A40 ? B72A0020 ?
C50DAE0 ? 5 ? BFFFAE34 ?
ksesin()+46 call kgesinv() CBC2A40 ? B72A0020 ?
C50DAE0 ? 5 ? BFFFAE34 ?
C50DAE0 ? 5 ? BFFFAE34 ?
kcfrbd()+444 call ksesin() C50DAE0 ? 5 ? 0 ? 1 ? 0 ? 0 ?
kco_blkchk()+815 call kcfrbd() 2 ? BFFFAED4 ? 1 ? 3C004F ?
1 ? 0 ?
kcb_blkchk()+247 call kco_blkchk() 291A37A4 ? 24580000 ? 0 ?
2000 ? 0 ?
kcb_apply()+870 call kcb_blkchk() 291A37A4 ? 247EE40C ? 0 ?
ktichg_noundo()+770 call kcb_apply() BFFFB014 ? BFFFB02C ? 0 ? 1 ?
29166220 ? 0 ? 292C95D0 ? 0 ?
ktbchgro()+351 call ktichg_noundo() 29166220 ? 0 ? 1 ? BFFFB02C ?

y
BFFFB014 ? 291A37A4 ?
ktsfbfmt()+808 call ktbchgro() 0 ? 1 ? CC0F4A4 ? 291A37A4 ?

e m
Copy the call stack trace from the trace file into the service request filed with Oracle Support.
Doing so will assist Support in resolving the issue.

a d
A c
c l e
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 11 - 18
Summary

In this lesson, you should have learned how to:


• Use OS Watcher
• Use the Oracle Support’s Remote Diagnostics Agent
• Trace programs and processes with strace
• Gather information for resolving ORA-600 and
ORA-7445 errors

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 11 - 19
Practice 11 Overview:
Debugging Oracle on Linux

This practice covers the following topics:


• Installing and configuring OS Watcher
• Gathering OS and database information using RDA
• Tracing programs and processes using strace
• Forcing ORA-600 and ORA-7445 errors, and then
gathering the needed information for Oracle Support

m y
d e
Copyright © 2007, Oracle. All rights reserved.

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs 11 - 20
Appendix A
Practices

m y
d e
ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Practice for Lesson 1

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 2
Practice 1-1: Working with the Linux Kernel
This practice enables you to gather some information about the Linux operating system
you are using. This includes the kernel version, users and groups, and disk partitions. You
will also write a simple shell script.
1) Determine the complete version number of your Linux kernel, and record it here:
2) Determine if your kernel is tainted.
3) Find out what groups the user you are logged in as belongs to. What is the primary
group?
4) What other users are in this group?
5) Display information about disk storage on your database server. How much disk
space do you have free in the root partition?
6) Using the /proc file system, display the list of partitions.
7) Change your prompt string to include the full directory path instead of just the last
subdirectory name. Test this by changing to the /stage/labs directory.

Question: Why does the prompt still end with a hash sign when you have specified it
to be a dollar sign? You may need to check the bash man page to answer this.

Note: Your prompt will look different from those shown here because of the specific
machine name being shown.
m y
8) Write a shell script called showargs.sh that displays each space-delimited
parameter passed to it, on a separate line. For example:
d e
./showargs.sh abc 123 xyz
c a
abc

e A
123
c l
xyz

r a
9) Determine why the showargs.sh script did not run, correct that, and run it
successfully with test input.
O ly
l & On
10) Determine how long the system has been up, using the virtual file system. Compare
your result to the value returned by the uptime command.

n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 3
Practice 1-2: Setting Up locatedb
There are times during these practices when you may need to locate a file. In this
practice, you will set up the data structure that supports that search.
1) Run the locate command to find all rpm files.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 4
Practice for Lesson 2: Preparing Linux for Oracle

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 5
Practice 2-1: Installing Linux Packages
In this practice, you will determine whether all the packages required by Oracle Database
10g R2 are installed, and install them if needed.
Note: Scripts for this practice are in the /stage/labs directory.
1) Use the rpm command to determine whether the correct packages are installed to
support Oracle Database 10g R2. Use the lab_02_01_01.sh script to check for
missing packages.
2) Install any missing RPMs. The necessary RPM files can be found in the labs
directory also. Then verify that all the required packages are installed.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 6
Practice 2-2: Creating the oracle User
Now you will create the oracle user and set up its environment. All lab files are in the
/stage/labs directory.
1) Verify that there is no oracle user already on the system.
2) Create the oracle user by running the lab_02_02_02.sh script:
3) Now that the oracle user exists, copy the script files into their proper place in the
oracle home directory. References to script files will be to the new labs directory
from this point on. Do this for the labs and solutions directories only, which are
currently in the /stage directory.
4) Verify that the nobody user exists.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 7
Practice 2-3: Configuring Kernel Parameters
You now need to view and modify kernel parameters to meet the requirements of an
Oracle database installation.
1) As the root user, view the kernel memory parameters. What are their names and
values? Are they adequate for the Oracle database installation?
Name Value Adequate?
__________ ____________ __Y/N_
__________ ____________ __Y/N_
__________ ____________ __Y/N_
2) Update any of the kernel parameters that are not set correctly.
3) Change the kernel parameters for the semaphore, file handle, and network settings.
The correct settings should be:

Semaphores: 250 32000 100 128


File Handles: 65536
Local port range: 1024 65000
net.core.rmem_default: 1048576
net.core.rmem_max: 1048576
net.core.wmem_default: 262144
net.core.wmem_max: 262144
m y
4) Set the shell limits according to the following:
d e
Number of processes: soft = 2047, hard = 16384
Number of open file handles: soft = 1024, hard = 65536
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 8
Practice 2-4: Creating Oracle Directories
Set up the needed directories and environment variables for the Oracle software
installation.
1) Determine a mount point that has enough space, and create the directory that will
serve as ORACLE_BASE. This should be named /u01/app/oracle.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 9
Practice 2-5: Setting Up the Host Name
When you run Oracle Universal Installer, an error may occur if name resolution is not set
up. To avoid this error, before you begin installation, you must ensure that host names are
resolved only through the /etc/hosts file.
1) Verify that the /etc/hosts file is used for name resolution.
2) Verify that the host name has been set correctly. If it does not include the domain
name, run the hostname.sh script to correct it.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 10
Practice for Lesson 3: Installing Oracle on Linux

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 11
Practice 3-1: Installing Oracle Database on Linux
Install Oracle Database. The database software is staged in the /stage/database
directory.
1) Exit all windows of the current session, and log out of the root session.
2) Log in to the machine as the oracle user. The password is oracle.
3) Open a new terminal window, and run the installer program that is in the
/stage/database directory. Perform the installation, selecting the Basic option.
Use oracle for any passwords. Use the default settings for everything except for
these options:
Set the UNIX DBA Group to oinstall
Do not create the starter database
4) In the End of Installation window, click Exit to quit the installation.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 12
Practice 3-2: Configuring the Listener
Configure and start the listener.
1) Run the Network Configuration Assistant (netca) to configure the listener. Use the
default settings on every screen.
2) Verify that the listener has been started.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 13
Practice for Lesson 4
There is no practice for lesson 4.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 14
Practice for Lesson 5: Automatic Storage Management

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 15
Practice 5-1: Installing and Configuring ASMLib
In this practice, you install and configure ASMLib, and then create an ASM instance.
1) As root, install the three RPMs required for ASMLib. The RPMs are located in
/home/oracle/labs.
2) Configure ASM by executing the /etc/init.d/oracleasm configure
command. Use the following settings:
Owning user: oracle
Owning group: dba
Start on boot: y
Fix permissions: y
3) Use the fdisk command to create a single partition on the disks to be used with
ASM.
When prompted within fdisk, enter these values:
Command (new partition): n
Primary partition: p
Partition number: 1
First cylinder: 1
Last cylinder: 130
Last command (write): w
4) Repeat the step above, creating partitions for each of the following devices:

m y
/dev/sdk
/dev/sdl
d e
/dev/sdm
/dev/sdn
c a
/dev/sdo
/dev/sdp
e A
/dev/sdq

c l
5) Run the partprobe command. This informs the kernel of partition table changes.

r a
In this case, running partprobe ensures that the kernel is aware the disks have
been partitioned.
O ly
6) Enable ASMLib.

l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 16
Practice 5-1: Installing and Configuring ASMLib (continued)
7) Create the ASM disk for storing the database’s data files and flash recovery area files.
Use the oracleasm utility to do this. Map the ASM disk names to devices:
8) Make the ASM disks available using the scandisks option of the oracleasm
utility.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 17
Practice 5-2: Creating an ASM Instance
Now that the ASM disks are set up, you can create the ASM instance that uses them. In
this practice, you will create an ASM instance, and define the ASM disk groups that it is
to use for data, and for the flash recovery area.
1) Use DBCA to configure Automatic Storage Management.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 18
Practice for Lesson 6: Creating the Database

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 19
Practice 6-1: Creating a Database
Create a database to be used in the instance already installed. The database will use the
ASM you already configured, for data file and flash recovery area storage.
1) Use the Database Creation Assistant to create a database with these attributes:
It is a general-purpose database.
It has a Global Database Name of orcl.us.oracle.com.
The SID is orcl.
It is configurable using Database Control.
All initial accounts should have the password of oracle.
The database should use ASM as its storage mechanism.
The flash recovery area should be 4 GB in size.
The database should be in ARCHIVELOG mode.
It should use Oracle Managed Files (OMF).
It should have the sample schemas installed.
2) When DBCA finishes, it will display the information about the database that was just
created. Make note of this information here:
SID: __________
m y
Sever Parameter File name: _____________________________
Database Control URL: ________________________________
d e
SID: ___orcl_______
c a
Sever Parameter File name: _+DF/orcl/spfileorcl.ora
e A
l
Database Control URL: http://edt3r12p1:1158/em______________
c
a
3) Unlock the HR account, and set its password to hr.
r
4) Click Exit to exit DBCA.
O ly
5) Set the ORACLE_SID environment variable so that it is set for every terminal session

l & On
that the oracle user starts. Set it to orcl.

n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 20
Practice 6-2: Backing Up Your Database
It is good to have a backup of the database you are working with. Take a backup of the
database that has just been created.
1) Back up the database.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 21
Practice for Lesson 7: Customizing Oracle on Linux

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 22
Practice 7-1: Configuring Automatic Startup and Shutdown of
the Database
For dealing with reboots, either planned or unplanned, it is good to have your database
start up automatically. This provides higher database availability and reduces the chance
of error. In this practice, you will configure the database to start and stop when the OS
boots and shuts down. In addition, you will edit the dbstart and dbshut scripts to
include starting and stopping DB Control. Lastly, in this practice, you will view a demo
of the installation of Enterprise Linux.
Note: If you do not want to manually edit the dbstart dbshut files, then fully edited
and correct versions of these files are located in /home/oracle/solutions. The
files are named dbstart_edited, and dbshut_edited.
1) By editing the /etc/oratab file, configure the ASM and orcl instances to be
automatically started and stopped when the operating system is started and stopped.
2) View the /home/oracle/labs/dbora script to see what it does. What scripts
does it invoke?
________________ ________________
3) Copy the dbora script from the /home/oracle/labs directory to a directory
such that it will be invoked during startup and shutdown of the OS.
4) Set the permissions for the dbora script to 750, and set the group to dba.
5) Establish links in the dbora script such that it will be invoked during the OS startup
m y
and shutdown in runlevels 3 and 5. The shutdown, or “kill” scripts, should be
executed first, and startup scripts should be executed last. d e
c a
6) Edit /u01/app/oracle/product/10.2.0/db_1/bin/dbstart to fix the

e A
file.
c l
known issue with starting the listener. Make the following changes, and then save the

r a
On line 78, change the value for ORACLE_HOME_LISTNER to this value:

O ly
Correct automatic ASM startup by editing line 59. Remove the –s option
from the LOGMSG value. The resulting line should look like this:

l & On
Change line 255 to look like this:

n a e
Change line 88. Remove the first word of the line, export. Then insert a line

t e r U s
under 88 that looks like this:

I n
7) Test stopping the database instances using dbora.

c l e
r a
8) While the databases are being shut down, check whether they are still running. Check
for pmon_orcl and pmon_+ASM processes.

O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 23
Practice 7-1: Configuring Automatic Startup and Shutdown of the Database
(continued)

When the commands return no results, the instances have been shut down.

9) Test starting the database with dbora. First shut down the listener to set up the
environment, as it would be at normal boot-up time.
10) Test that these scripts will be called and will function properly during a reboot.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 24
Practice 7-2: Configuring Automatic Startup and Shutdown of
DB Control (optional)
Note: If you have already copied the dbstart_edited and dbshut_edited files
as described in practice 7-1, then you do not need to do this practice.
You need to configure DB Console to start and stop when the database starts up and shuts
down. If DB Control has been configured for an instance, then there exists a directory
under $ORACLE_HOME with the format FullyQualifiedHostname_SID. For
example:
textbox.us.oracle.com_orcl
If DB Control is available in this version of the database, then the executable emctl
exists under the $ORACLE_HOME/bin directory.
1) Configure DB Control to start with the database. It is best to start DB Control after
the database has successfully started. So position the commands in the dbstart
script to be after a test for a successful start of the database. Add the following text to
the dbstart script. Insert it at line 221, which is following these three lines:
Line 218: if test $? -eq 0 ; then
Line 219: echo ""
Line 220: echo "$0: ${INST} \"${ORACLE_SID}\" warm started."

Note: You can either edit this file manually (the text above is in a file named
lab_07_02_01.txt) or simply copy the dbstart_edited file from the
m y
solutions directory to $ORACLE_HOME/bin/dbstart. The copy command to
use, as the oracle user, is:
d e
c a
A
2) Configure DB Control to stop when the database is shut down. Do this by editing the
e
l
dbshut script, adding the following text at line 101, which is following these lines:
c
Line 95: SQLDBA=svrmgrl
r a
Line 94: if [ -f $ORACLE_HOME/bin/svrmgrl ] ; then

O ly
Line 96: VERSION="internal"
Line 97: else
Line 98:
Line 99: fi

l & On
SQLDBA="sqlplus /nolog"

a e
Line 100: fi

r n s
Note: You can either edit this file manually (the text above is in a file named

n e
lab_07_02_02.txt) or simply copy the dbshut_edited file from the
t U
solutions directory to $ORACLE_HOME/bin/dbshut. The copy command to
I
use, as the oracle user, is:

e
c l
3) Test the automatic shutdown of DB Control by issuing a dbora stop command.

r a
4) Test the automatic startup of DB Control by issuing a dbora start command.

O 5) Test the automatic restart by rebooting the system.

Oracle Database 10g: Managing Oracle on Linux for DBAs A - 25


Practice 7-3: Installing Linux
In this practice, you will run a viewlet of the process of installing Enterprise Linux.
1) Launch the viewlet using the install_el4u4_launcher.html file.
2) Answer the following questions:
a. Why was a graphical environment not installed by default?
__________________________________________________________________
b. What is the mount point for the swap partition?
________________________
c. Are sar and iostat installed by default?
________________________
d. Is creating a root user optional?
________________________

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 26
Practice for Lesson 8: Managing Memory

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 27
Practice 8-1: Managing Memory
In this practice you will inspect your system’s memory parameters. You will look at
statistics and behavior regarding physical memory, and swap space.
1) View the current memory settings and status for the kernel. How much total memory
is on your system?
Note: You may see different memory related values from those shown here,
depending on the type of machine you are on.
2) According to the top command, how much memory is currently in use?

3) How much of this used memory is being used for cache, which means that it is
available to be used for noncache uses such as new process starting up, or new
requests for memory allocation?
4) How much swap space is there, and how much is in use?
5) What is the device name that is being used for the swap space?
m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 28
Practice 8-2: Managing Shared Memory
Now you will view the state and behavior of shared memory segments on your system,
and how they relate to an Oracle database instance.
1) Display the list of shared memory segments belonging to the oracle user on your
system.
2) Note the largest shared memory segment. What is it being used for? Prove your
answer.
Note: The numbers you see will most likely be different from those shown here.
3) What does the next highest oracle shared memory segment belong to?
4) What is the meaning of the nattch column? Prove it by demonstrating how it
changes.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 29
Practice for Lesson 9

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 30
Practice 9-1: Gather Statistics Using iostat, sar, and vmstat
In this practice, you will measure CPU, virtual memory, and I/O usage on your system. A
table of commands is provided for your reference.

Diagnostic Measures Notes

sar -uq 5 3 runq-sz, ldavg, On the system the averages


%user,%sys, %idle provide a baseline

sar -d 5 3 rps, sect/s Overall activity by device

vmstat 5 3 Free, si Swapping information also


includes disk and CPU. First
line is all activity since last
report. Pick a representative line
other than the first to record.

iostat -p /dev/hda 5 3 avgqu-sz, await, Disk activity by partition. hda5


svctm is the / partition. Note hda is
sum of hda* lines. First output
section is all activity since last
report. Pick a representative
section other than the first to
record.
m y
d e
Record your measurements in the following table.
c a
e A
Measurement Quiet
c l Database
Activity
I/O
Activity
sar -uq AVERAGE runq-sz
r a
sar -uq AVERAGE ldavg O ly
sar -uq AVERAGE
l & On
sar -uq AVERAGE %user
n a e
sar -uq AVERAGE %sys

t e r U s
n
sar -uq AVERAGE %idle
I
c l e
sar -d AVERAGE dev3-0 tps

sar -d AVERAGE dev3-0 rd_sec/s

r a
sar -d AVERAGE dev3-0 wr_sec/s

O vmstat memory free

Oracle Database 10g: Managing Oracle on Linux for DBAs A - 31


Practice 9-1: Gather Statistics Using iostat, sar, and vmstat (continued)

vmstat swap si

iostat -p hda5 tps

iostat -p hda5 Blk_read/s

iostat -p hda5 Blk_wrtn/s

1) Use the sar command to measure system stats including:


Run queue size
Load average
Percent CPU utilization for user processes
Percent CPU utilization for system (kernel) processes
Percent CPU is idle
Take three measurements at an interval of five seconds. Record the results in the
Quiet column of the previous table.
2) Use the sar command to report on device statistics. Use the same repeat interval and
count as above. Record the results in the Quiet column of the previous table.
3) Use the vmstat command to measure virtual memory statistics, using the same
m y
virtual memory and the amount of virtual memory swapped in (si).
d e
interval as above. In the Quiet column of the table above, record the amount of free

results in the Quiet column of the table above. c a


4) Use the iostat command to report I/O statistics for the root partition. Record the

e A
c l
5) Run the $ORACLE_HOME/rdbms/admin/catproc.sql script to put a load on
the system.
r a
6) While the catproc.sql script is running, take measurements on your system again
O ly
(as earlier), but this time, you can simply use the script that runs the commands you

& On
ran before. The script is monitor.sh.
l
n a e
7) While the catproc.sql script is still running, run the following dd command to
generate I/O activity. Then run the monitor.sh script again and record the results

t e r U s
in the I/O Activity column of the chart mentioned earlier.
Note: In order to determine the if parameter for the dd command, use the df

I n
command to find out the device name of the root partition.

l e
8) Stop the dd command by pressing [Ctrl] + [C]. Do not interrupt the catproc.sql

c
script run. It should complete in order for the database objects to end up in a

r aconsistent state.

O 9) Review the results recorded in the chart. Note the differences when the
catproc.sql script ran, and when the dd command executed.

Oracle Database 10g: Managing Oracle on Linux for DBAs A - 32


Practice 9-2: Using Graphical Monitoring Tools
This practice enables you to install and use xosview to monitor CPU, memory, and disk
I/O.
1) Attempt to run xosview. This will fail because xosview is not installed by default.
2) Install xosview as root, using the xosview-1.8.2-1.i386.rpm file.
3) Run xosview by entering the xosview command, as root.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 33
Practice for Lesson 10: Tuning Performance

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 34
Practice 10-1: Adjusting the SGA Size
Often increasing the size of the Shared Global Area (SGA) improves performance by
allowing more data to be resident in memory rather than having to be read from disk
frequently. In this practice, you will increase the size of the SGA.
1) Adjust the SGA size to at least 400 MB.
Note: If it is already greater than 400 MB, do not change anything.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 35
Practice 10-2: Adjusting Block Sizes
You can select different block sizes for each tablespace, and that can affect performance.
This practice illustrates the difference in performance different block sizes can have,
depending on the type of activity on the tablespace.
1) Set the cache size to 128 MB for tablespaces with 2 KB block size.
2) Set the cache size to 128 MB for the 16 KB block size.
3) Create the TS2 tablespace in ASM, which has a 2 KB block size, is NOLOGGING,
and is 128 MB in size.
4) Create the TS16 tablespace in ASM, which has a 16 KB block size, is NOLOGGING,
and is 128 MB in size.
5) Run the lab_10_02_05.sql script to create and populate the T2 and T16 tables,
which are created in the TS2 and TS16 tablespaces, respectively.
6) Using SQL*Plus, turn on timing, and repeatedly select count(*) from each of
these tables using a WHERE clause that forces each row to be read. Compare the times
between each of the tables. Which is faster?
7) Turn on SQL tracing for this HR session.
8) Rerun each of the two statements once, putting in a comment to force a reparse of
each statement.
9) Use EM to view the statistics for each of these two statement executions.
m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 36
Practice 10-3: Identifying Sessions in Linux
At times you need to correlate database sessions to specific processes running at the
operating system level. In this practice, you will identify a resource-consuming operating
system process, determine which database session it belongs to, and take action to correct
it.
1) Run the lab_10_03_01.sh script to generate some HR sessions that do some
work in the database.
2) Run the top command to see the oracle session that is consuming many system
resources. Find the session associated with that process, and kill it.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 37
Practice for Lesson 11: Diagnosing Oracle on Linux

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 38
Practice 11-1: Install and Configure OS Watcher
OS Watcher is a utility that collects statistics about the operating system. It is useful for
gathering historical data for comparison and for providing OS information about your
system to Oracle Support Services. You will now install and configure OS Watcher, and
then run it, reviewing the results from the generated reports.
1) Install OS Watcher. Create a directory for OS Watcher named osw under the
/home/oracle directory. Extract the tar OSW.tar file, located in
/home/oracle/labs directory, into the new directory.
2) Use startOSW.sh to start the tool. Provide parameters such that data is sampled
every 10 seconds, and the last 10 hours of data is logged to archive files. Make the
tool run as a background process.
3) Verify that the script is running by checking the Linux process listing.
4) View the iostat report that has been created by OSW so far. The output is being
written to the archive directory where OSW has been installed.
5) View the OSW generated output for other types of data you see in the archive
directory.
6) Stop OSW.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 39
Practice 11-2: Install and Configure RDA
The Remote Diagnostic Agent (RDA) collects information about your machine, operating
system, and database that can be useful for diagnosing problems. In this practice, you will
install it, run it, and view the output.
1) Install RDA. The file containing the software is
/home/oracle/labs/rda_4.5-060912.tar.gz. Extract it into the
/oracle/home directory.
2) Configure RDA by running the rda.pl script in the rda directory. For each
question, press [Enter] to accept the default, except for the following questions:
Is INIT.ORA for the database to be analyzed located on this machine?
(Y/N)
Press [Enter] to accept the default (Y): n
Enter an Oracle User ID (user ID only) to view DBA_ and V$ tables. If
RDA is run under the Oracle software owner’s ID, enter a “/” here, and
select Y at the SYSDBA prompt to avoid being prompted for the database
password at run time.
Press [Enter] to accept the default (system):/
Is “/” a sysdba user (will connect as sysdba) (Y/N)?
Press [Enter] to accept the default (N): y
Is ASM (Automatic Storage Management) in use (Y/N)?
m y
Press [Enter] to accept the default (N): y
Is the ASM INIT.ORA located on this machine (Y/N)?
d e
Press [Enter] to accept the default (Y): n
c a
Press [Enter] to accept the default (N): y
e A
Is the Database Control for 10G in use on this node (Y/N)?

c l
3) After the last question is answered, the RDA runs. This takes several minutes. After it

file in the browser.


r a
is finished, note the URL for the HTML file to open and to view the results. Open this

O ly
4) Under Overview > System Information what are the values for Total Physical
Memory and Swap: In Use?
________________________
l & On __________________________

n a e
5) Under Operating System Setup > Disk Drives, which drive partition contains swap?

e r
________________________
t U s
I n
6) Under ASM > File/Space Related Information > Files Stored in Diskgroup, what is
the fully qualified location of the SYSTEM tablespace?

c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 40
Practice 11-3: Using strace
In this practice, you will look at the output of the strace command. First you look at
the output of a simple shell script. Then you use strace on a running process and send
the output to a file.
1) View the contents of the helloworld.sh test script.
2) Execute the helloworld.sh script.
3) Execute the helloworld.sh script using strace. After tracing the script, review
the output.
4) Trace the PMON process execution using strace. Send the output of the trace to the
/tmp/orcl_pmon.out file. Run the lab_11_03_04_a.sh script to find the
process ID of PMON.
5) View the output file by using the tail command. Do not cancel this tail
command. It is used in the next practice.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 41
Practice 11-4: Diagnosing ORA-600 and ORA-7445 Errors
In this practice, you investigate ORA-600 and ORA-7445 errors, which frequently
require diagnosis at the operating system level.
1) Force an ORA-600 error. Use the lab_11_04_01.sh script to generate the error.
2) Force an ORA-7445 error. Do this by issuing a kill –11 command for the PID of
the PMON process.
3) In Practice 11-3, you started a strace of the PMON process, with the output being
sent to a file, which is being viewed using the tail command. Look at the terminal
window that contains the tail of the strace. All of the strace was written to the
output file, but it takes longer to scroll to the screen. In the window with the tail of
the strace output, press [Ctrl] + [C] to stop the tail output.
4) Now that both an ORA-600 and ORA-7445 have been generated, look at the alert
log file for the instance.
5) Note that each of the entries for the ORA-600 and ORA-7445 errors point to a trace
file.
6) By killing the PMON process, you caused the database instance to crash. Restart it.
7) Run the RDA script to have it collect data about the trace files that were just
generated.
8) After rda.pl finishes running, open the following URL in a browser:
m y
e
9) Click RDBMS Log/Trace Files. Note the Last Errors section. These are the trace files
d
c a
for both the ORA-600 and ORA-7445 errors. To find the file names of the specific
trace files for each error, click Alert.log, and then locate the errors, noting the trace
file names.

e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs A - 42
Appendix B
Practice Solutions

m y
d e
ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Practice Solutions for Lesson 1

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 2
Solutions for Practice 1-1: Working with the Linux Kernel
This practice enables you to gather some information about the Linux operating system
you are using. This includes the kernel version, users and groups, and disk partitions. You
will also write a simple shell script.
1) Determine the complete version number of your Linux kernel, and record it here:
Answer:
1. Start a terminal session by right-clicking in the desktop area, and selecting Open
Terminal. Then enter the following at the OS prompt:
# uname -r
2.6.9-42.0.0.0.1.EL

Note: If you are using an SMP machine, the displayed version is:
2.6.9-42.0.0.0.1.Elsmp

2) Determine if your kernel is tainted.


Answer:
1. Enter the following at the OS prompt:
# cat /proc/sys/kernel/tainted
0

3) Find out what groups the user you are logged in as belongs to. What is the primary
group?
m y
Answer:
d e
which is root.
c a
1. Enter the following at the OS prompt, to see the group list for the current user,

# id

e A
uid=0(root) gid=0(root)

c l
groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(w
heel)
r a
O ly
The primary group is root because it is listed as gid=, and not just in the
groups= list.

l & On
4) What other users are in this group?
Answer:
n a e
t e r U s
1. Enter the following at the OS prompt:
# grep root: /etc/group

I n
root:x:0:root,vncuser

c l e
There are two users in the root group. They are root and vncuser.
5) Display information about disk storage on your database server. How much disk

r aspace do you have free in the root partition?

O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 3
Solutions for Practice 1-1: Working with the Linux Kernel (continued)
Answer:
1. Enter the following at the OS prompt:
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda5 25G 12G 12G 51% /
/dev/hda2 23M 4.0M 18M 19% /boot
none 506M 0 506M 0% /dev/shm
/dev/hda1 11G 5.8G 5.0G 54% /mnt/cdrive

The root partition is always mounted on “/”. The available space on this system
is approximately 12 GB.
Note: Depending on your system, you may see different output from that shown.
6) Using the /proc file system, display the list of partitions.
Answer:
1. Enter the following at the OS prompt:
# cat /proc/partitions
major minor #blocks name

3 0 39082680 hda
3
3
1
2
11269566
24097
hda1
hda2
m y
3
3
3
4
2048287
1
hda3
hda4
d e
3
7
5
0
25736098
1048576
hda5
loop0
c a
A
7 1 1048576 loop1
7 2 1048576 loop2
7
7
3
4
1048576
1048576
c l e
loop3
loop4

a
7 5 1048576 loop5

#
7
7
6
7
1048576
r
O ly
1048576
loop6
loop7

& On
Note: Depending on your system, you may see different output from that shown.
l
n a e
7) Change your prompt string to include the full directory path instead of just the last
subdirectory name. Test this by changing to the /stage/labs directory.

t e r U s
Question: Why does the prompt still end with a hash sign when you have specified it

I n
to be a dollar sign? You may need to check the bash man page to answer this.

l e
Note: Your prompt will look different from those shown here because of the specific
c
machine name being shown.

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 4
Solutions for Practice 1-1: Working with the Linux Kernel (continued)
Answer:
1. Enter the following at the OS prompt to see the current setting:
[root@EDT3R12P1 ~]# echo $PS1
[\u@\h \W]\$

2. Note that the directory specifier is \W, which represents the last subdirectory of
the current directory. Change that to \w, to represent the entire current directory
path name. Note that in order to make the last character a hash sign, you must
enter two backslashes before the dollar ($) sign. The two backslashes will be
reduced to one resulting in the final string having \$, which means display the
dollar sign, unless the user is root, in which case display the hash sign. Make
this change by entering the following:
[root@stctestbox03 ~]# PS1="[\u@\h \w]\\$ "

3. Test this by changing the directory to /stage/labs as shown in the following


box. Note that the prompt now displays the full current working directory.
[root@EDT3R12P1 ~]# cd /stage/labs
[root@EDT3R12P1 /stage/labs]#

4. To answer the question, enter the following on the command line to see the bash
man page:
# man bash
m y
d e
5. When the man page appears, search for the PS1 string by entering the following:
/PS1
c a
A
6. When the string is found, keep entering [N] until you see the following:

e
c l
r a
O ly
7. Note that you are directed to see the section on PROMPTING. So, enter the

& On
following to find that section (case is important):
l
/PROMPTING

n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 5
Solutions for Practice 1-1: Working with the Linux Kernel (continued)
8. The following screen is displayed:

m y
d e
9. Enter [j] repeatedly to scroll down to the section describing the \$ string. Note

c a
that the description for the \$ string is that it will cause a dollar sign to be
displayed unless the user ID is 0 (root) in which case the hash sign is displayed.

e A
c l
r a
Answer: The prompt still ends with a hash sign because the \$ string indicates
O ly
that hash is to be used if the user is root.

l & On
10. Enter [q] to quit the man page display.

a e
8) Write a shell script called showargs.sh that displays each space-delimited
n
t e r
parameter passed to it, on a separate line. For example:

U s
./showargs.sh abc 123 xyz
abc
I n
c l e
123
xyz

r aAnswer:

O 1. Use an editor to create and edit the /tmp/showargs.sh file.

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 6


Solutions for Practice 1-1: Working with the Linux Kernel (continued)
# gedit /tmp/showargs.sh &

2. Enter the following lines into the file:


for fname in $*;
do
echo $fname
done

3. Save the file.


4. At the OS prompt, enter the following to run the script with some test arguments:
# cd /tmp
# ./showargs.sh a b c
bash: ./showargs.sh: Permission denied

5. Note that the script does not run.


9) Determine why the showargs.sh script did not run, correct that, and run it
successfully with test input.
Answer:
1. The error is that permission was denied. So, check the permissions on the file by
entering the following command while in the /tmp directory:
# ls -l showargs.sh
-rw-r--r-- 1 root root 43 Oct 9 03:30 showargs.sh
m y
d e
2. Note that none of the execute permissions are enabled for this file. Enable them
and verify that by entering the following commands:
c a
# chmod +x showargs.sh
# ls -l showargs.sh

e A
-rwxr-xr-x 1 root root 43 Oct

c l 9 03:30 showargs.sh

3. Reattempt executing the script by entering the following:


# ./showargs.sh a b c
r a
a
b O ly
c
l & On
n a e
10) Determine how long the system has been up, using the virtual file system. Compare
your result to the value returned by the uptime command.
Answer:
t e r U s
I n
1. At the OS prompt, enter the following to display the /proc/uptime contents.
Your results will vary from those shown.

c l e
# cat /proc/uptime

r a 1595093.32 1404257.62

O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 7
Solutions for Practice 1-1: Working with the Linux Kernel (continued)
2. At the OS prompt, enter the following to run the uptime command:
$ uptime
18:33:36 up 18 days, 11:04, 5 users, load average:
0.20, 0.75, 1.09

3. The returned number of seconds of uptime is 1595093.32. Dividing that by


(60*60*24), which is the number of seconds in a day, results in approximately
18.46 days, which comes to about 18 days and 11 hours.
Note: Your numbers will most certainly vary from those given here.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 8
Solutions for Practice 1-2: Setting Up locatedb
There are times during these practices when you may need to locate a file. In this
practice, you will set up the data structure that supports that search.
1) Run the locate command to find all rpm files.
Answer:
1. Enter the following at the OS prompt:
# locate rpm
warning: locate: could not open database:
/var/lib/slocate/slocate.db: No such file or directory
warning: You need to run the 'updatedb' command (as root)
to create the database
.
Please have a look at /etc/updatedb.conf to enable the
daily cron job.
#

2. Note that the locate command is not able to perform the search because the
locate DB cannot be initialized. Initialize it by entering the following command.
This will take about two minutes to run.
# updatedb

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 9
Practice Solutions for Lesson 2: Preparing Linux for
Oracle

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 10
Solutions for Practice 2-1: Installing Linux Packages
In this practice, you will determine whether all the packages required by Oracle Database
10g R2 are installed, and install them if needed.
Note: Scripts for this practice are in the /stage/labs directory.
1) Use the rpm command to determine whether the correct packages are installed to
support Oracle Database 10g R2. Use the lab_02_01_01.sh script to check for
missing packages.
Answer:
1. Run the following script to determine whether the RPMs that Oracle Database
needs are installed:
# cd /stage/labs
# ./lab_02_01_01.sh
binutils-2.15.92.0.2-21
compat-db-4.1.25-9
compat-libstdc++-296-2.96-132.7.2
control-center-2.8.0-12.rhel4.5
gcc-3.4.6-3.1
gcc-c++-3.4.6-3.1
glibc-2.3.4-2.25

y
glibc-common-2.3.4-2.25
gnome-libs-1.4.1.2.90-44.2
libstdc++-3.4.6-3.1
libstdc++-devel-3.4.6-3.1
e m
make-3.80-6.EL4
pdksh-5.2.14-30.3
a d
package sysstat is not installed
xscreensaver-4.18-5.rhel4.12
package setarch is not installed A c
#

Note the two missing packages.


c l e
r a
2) Install any missing RPMs. The necessary RPM files can be found in the labs

O ly
directory also. Then verify that all the required packages are installed.
Answer:
l & On
a e
1. Enter the following at the OS prompt to install the sysstat package:

n
r s
# rpm -iv sysstat-5.0.5-11.rhel4.i386.rpm

e
warning: sysstat-5.0.5-11.rhel4.i386.rpm: V3 DSA

t U
signature: NOKEY, key ID b38a8516

I n
Preparing packages for installation...
sysstat-5.0.5-11.rhel4

l e
2. Note that, although the package is installed successfully, there is a warning about
c a missing key. Check the key on the rpm file by entering the following:

r a # rpm --checksig sysstat-5.0.5-11.rhel4.i386.rpm

O sysstat-5.0.5-11.rhel4.i386.rpm: (SHA1) DSA sha1 md5 (GPG)


NOT OK (MISSING KEYS: GPG#b38a8516)

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 11


Solutions for Practice 2-1: Installing Linux Packages (continued)
3. Locate the key file that needs to be imported by entering the following:
# locate GPG
/usr/share/rhn/BETA-RPM-GPG-KEY
/usr/share/rhn/RPM-GPG-KEY
/usr/share/rhn/RPM-GPG-KEY-fedora
/usr/share/rhn/RPM-GPG-KEY-fedora-test
/usr/share/rhn/RPM-GPG-KEY-oracle
/usr/share/doc/enterprise-release-4/RPM-GPG-KEY-enterprise
/usr/share/doc/enterprise-release-4/RPM-GPG-KEY
/usr/share/doc/rpm-4.3.3/RPM-GPG-KEY
/usr/share/doc/rpm-4.3.3/BETA-GPG-KEY
#

Note the oracle key file.


4. Import the oracle key file by entering the following:
# rpm --import /usr/share/rhn/RPM-GPG-KEY-oracle

5. Recheck the key by entering the following:


# rpm --checksig sysstat-5.0.5-11.rhel4.i386.rpm
sysstat-5.0.5-11.rhel4.i386.rpm: (sha1) dsa sha1 md5 gpg
OK

6. Enter the following at the OS prompt to install the setarch package:


m y
# rpm -iv setarch-1.6-1.i386.rpm
Preparing packages for installation...
d e
setarch-1.6-1

c a
7. Rerun the labs_02_01_01.sh script to verify that all the needed packages are
A
now installed. Do this by entering the following at the OS prompt:
e
# ./lab_02_01_01.sh
c l
a
binutils-2.15.92.0.2-21
compat-db-4.1.25-9
r
O ly
compat-libstdc++-296-2.96-132.7.2
control-center-2.8.0-12.rhel4.5
gcc-3.4.6-3.1
gcc-c++-3.4.6-3.1
l & On
glibc-2.3.4-2.25

n a e
glibc-common-2.3.4-2.25

t e r
libstdc++-3.4.6-3.1
U s
gnome-libs-1.4.1.2.90-44.2

I n
libstdc++-devel-3.4.6-3.1
make-3.80-6.EL4

e
pdksh-5.2.14-30.3

c l sysstat-5.0.5-11.rhel4
xscreensaver-4.18-5.rhel4.12

r a setarch-1.6-1
#

O Note that now there are no missing packages.

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 12


Solutions for Practice 2-2: Creating the oracle User
Now you will create the oracle user and set up its environment. All lab files are in the
/stage/labs directory.
1) Verify that there is no oracle user already on the system.
Answer:
1. Attempt to change the user to oracle by entering the following at the OS
prompt:
# su - oracle
su: user oracle does not exist

Note that the attempt fails with the error that the oracle user does not exist.
2) Create the oracle user by running the lab_02_02_02.sh script:
# ./lab_02_02_02.sh
Creating user and groups...
Changing password for user oracle.
passwd: all authentication tokens updated successfully.
#

3) Now that the oracle user exists, copy the script files into their proper place in the
oracle home directory. References to script files will be to the new labs directory
from this point on. Do this for the labs and solutions directories only, which are
m y
currently in the /stage directory.
Answer:
d e
c
1. As root, enter the following at the OS prompt to copy the directories:a
# cp -R /stage/labs ~oracle

e A
c l
# cp -R /stage/solutions ~oracle

2. Enter the following at the OS prompt to change the owner of the directories and
files to oracle:
r a
O ly
# chown -R oracle ~oracle/labs

& On
# chown -R oracle ~oracle/solutions

directories: l
3. Enter the following at the OS prompt to change the group for these files and
a e
r n s
# chgrp -R oinstall ~oracle/labs

t e U
# chgrp -R oinstall ~oracle/solutions

n
I
4) Verify that the nobody user exists.

e
c l
Answer:
1. Enter the following at the OS prompt:

r a $ id nobody

O uid=99(nobody) gid=99(nobody) groups=99(nobody)


$

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 13


Solutions for Practice 2-3: Configuring Kernel Parameters
You now need to view and modify kernel parameters to meet the requirements of an
Oracle database installation.
1) As the root user, view the kernel memory parameters. What are their names and
values? Are they adequate for the Oracle database installation?
Name Value Adequate?
__________ ____________ __Y/N_
__________ ____________ __Y/N_
__________ ____________ __Y/N_
Answer:
1. If still logged in as the oracle user, enter the following to exit that session and
go back to the root session:
$ exit

2. As the root user, enter the following at the OS prompt to go to the virtual
directory where the shared memory parameters can be viewed:
# cd /proc/sys/kernel

parameters:
m y
3. Enter the following to list the virtual files that are related to shared memory kernel

# ls -l shm*
d e
-rw-r--r-- 1 root root 0 Nov 27 01:13 shmall
-rw-r--r-- 1 root root 0 Nov 27 01:13 shmmax
c a
-rw-r--r-- 1 root root 0 Nov 27 01:13 shmmni

e
4. View the contents of each of these files using the cat command:A
# cat shmall
c l
2097152
# cat shmmax r a
33554432
O ly
# cat shmmni
4096
l & On
a e
5. Note that all these settings are sufficient except for shmmax.
n
t e r U s
2) Update any of the kernel parameters that are not set correctly.
Answer:
I n
c l e
1. Edit the /etc/sysctl.conf file and enter a line defining the value for
shmmax as 2147483648. Save the file when finished editing.

Ora # Shared Memory size, to support Oracle DB.


kernel.shmmax = 2147483648

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 14


Solutions for Practice 2-3: Configuring Kernel Parameters (continued)
2. Enter the following at the OS prompt to set the new value for shmmax:

# /sbin/sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
kernel.shmmax = 2147483648
#

3. Verify that the new value is reflected in the /proc/sys/kernel/shmmax file


by entering the following:
# cat /proc/sys/kernel/shmmax
2147483648
#
3) Change the kernel parameters for the semaphore, file handle, and network settings.
The correct settings should be:

Semaphores: 250 32000 100 128


File Handles: 65536
Local port range: 1024 65000
net.core.rmem_default: 1048576
m y
net.core.rmem_max: 1048576
net.core.wmem_default: 262144
d e
net.core.wmem_max:
Answer:
262144

c a
A
1. Enter the following at the OS prompt to see what the current settings are for the
e
l
semaphores. Save the file when done.
c
# cat /proc/sys/kernel/sem
250 32000 32
r a
128

O ly
2. Note that the third number for semopn is too low. It must be set to 100. Enter

& On
the following line in the /etc/sysctl.conf file to make that change:

l
a e
kernel.sem = 250 32000 100 128

n
t e r
3. To make that change persistent, enter the following at the OS prompt:
# /sbin/sysctl -p
U s
I n
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1

c l e
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0

r a kernel.core_uses_pid = 1
kernel.shmmax = 2147483648

O kernel.sem = 250 32000 100 128


#

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 15


Solutions for Practice 2-3: Configuring Kernel Parameters (continued)
4. Enter the following at the OS prompt to see what the values for the file handle
limit are:
# cat /proc/sys/fs/file-max
102714

5. Edit the /etc/sysctl.conf file, and then enter the following line:
fs.file-max = 65536

6. Enter the following at the OS prompt to see the current settings for the local port
range:
# cat /proc/sys/net/ipv4/ip_local_port_range
32768 61000

Note that it is not correct.


7. Edit the /etc/sysctl.conf file and enter the following line:
net.ipv4.ip_local_port_range = 1024 65000

8. Enter the following to check the current values for the TCP/IP window size
parameters:
# cat /proc/sys/net/core/rmem_default
110592
# cat /proc/sys/net/core/rmem_max
m y
131071
# cat /proc/sys/net/core/wmem_default
d e
110592
# cat /proc/sys/net/core/wmem_max
c a
A
131071
#

l
Note that all these are too small.
c e
a
9. Edit the /etc/sysctl.conf file and enter the following lines:
r
O ly
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576

l & On
net.core.wmem_default = 262144
net.core.wmem_max = 262144

a e
10. Now that all the correct entries have been made in the /etc/sysctl.conf
n
t e r U s
file, make sure that the file has been saved, and then issue the following OS
command to make them effectively permanent:

I n
# sysctl -p
net.ipv4.ip_forward = 0

c l e
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0

r a kernel.sysrq = 0
kernel.core_uses_pid = 1

O kernel.shmmax = 2147483648
kernel.sem = 250 32000 100 128

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 16


Solutions for Practice 2-3: Configuring Kernel Parameters (continued)
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144
#

4) Set the shell limits according to the following:


Number of processes: soft = 2047, hard = 16384
Number of open file handles: soft = 1024, hard = 65536
Answer:
1. Edit the /etc/security/limits.conf file, and make the following
entries, and then save the file:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

2. Add the following lines to the /etc/pam.d/login file, and then save it:
session
session
required
required
/lib/security/pam_limits.so
pam_limits.so
m y
3. Add the following lines to the /etc/profile file, and then save it:
d e
ulimit -u 16384 -n 65536

ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 17
Solutions for Practice 2-4: Creating Oracle Directories
Set up the needed directories and environment variables for the Oracle software
installation.
1) Determine a mount point that has enough space, and create the directory that will
serve as ORACLE_BASE. This should be named /u01/app/oracle.
Answer:
1. Enter this at the OS prompt to see the disk space available:
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda5 25G 12G 12G 51% /
/dev/hda2 23M 4.0M 18M 19% /boot
none 506M 0 506M 0% /dev/shm
/dev/hda1 11G 5.8G 5.0G 54% /mnt/cdrive

Note: Depending on your system, you may see different output from that shown.
2. As the root user, enter the following to create the Oracle base directory and set
the permissions appropriately:
# mkdir -p /u01/app/oracle
# chown –R oracle:oinstall /u01/app/oracle
# chmod 775 /u01/app/oracle

3. Add the following lines to the ~oracle/.bash_profile file to set the


m y
ORACLE_BASE and ORACLE_HOME directories, and to adjust the PATH variable
to include the Oracle binaries, after they are installed:
d e
export ORACLE_BASE=/u01/app/oracle
c a
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export PATH=$PATH:$ORACLE_HOME/bin

e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 18
Solutions for Practice 2-5: Setting Up the Host Name
When you run Oracle Universal Installer, an error may occur if name resolution is not set
up. To avoid this error, before you begin installation, you must ensure that host names are
resolved only through the /etc/hosts file.
1) Verify that the /etc/hosts file is used for name resolution.
Answer:
1. You can verify this by checking the hosts file entry in the nsswitch.conf file
as follows:
# grep hosts /etc/nsswitch.conf
#hosts: db files ldap nis dns
hosts: files dns

Note that there is a files entry, which means that host names are resolved only
through the /etc/hosts file.
2) Verify that the host name has been set correctly. If it does not include the domain
name, run the hostname.sh script to correct it.
Answer:
1. You can verify this by entering the hostname command as follows:
# hostname
EDT3R12P1
m y
e
Note that the host name is in uppercase, and is not fully qualified. This will cause
d
a warning during the installation, so this needs to be fixed.
2. Run the ~oracle/labs/hostname.sh script to correct the host name
c a
setting by entering the following command:

e A
# ~oracle/labs/hostname.sh

c l
again:
r a
3. Verify that the host name is corrected by entering the hostname command

# hostname
O ly
& On
edt3r12p1.us.oracle.com

l
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 19
Practice Solutions for Lesson 3: Installing Oracle on
Linux

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 20
Solutions for Practice 3-1: Installing Oracle Database on Linux
Install Oracle Database. The database software is staged in the /stage/database
directory.
1) Exit all windows of the current session, and log out of the root session.
Answer:
1. Type the following in any OS terminal windows.
# exit

2. Click “X” in the upper right corner of any remaining windows.


2) Log in to the machine as the oracle user. The password is oracle.
3) Open a new terminal window, and run the installer program that is in the
/stage/database directory. Perform the installation, selecting the Basic option.
Use oracle for any passwords. Use the default settings for everything except for
these options:
Set the UNIX DBA Group to oinstall
Do not create the starter database
Answer:
1. Choose the menu item in Applications > System Tools > Terminal. Then enter the
following at the OS prompt:
m y
$ cd /stage/database
d e
a
$ ./runInstaller

A
deselect the Create Starter Database option, and then click Next.c
2. On the Installation Method page, change the UNIX DBA Group to oinstall,

l e
3. On the “Specify inventory directory and credentials” page, make sure that the

c
inventory directory is set to $ORACLE_BASE/oraInventory, and that the

r a
operating system group name is oinstall. Then click Next.

O ly
4. After the prerequisite checks are run, make sure that they have all passed, and
then click Next.

l & On
5. On the Summary page, click Install. The install activity begins now.

a e
6. When the Execute Configuration Scripts page appears, run each of the two scripts
n
$ su -
t e r U s
shown, as root. Enter the following to log in as root, and run the scripts:

I n
Password:oracle
# /u01/app/oracle/oraInventory/orainstRoot.sh

c l eChanging permissions of /u01/app/oracle/oraInventory to 770.


Changing groupname of /u01/app/oracle/oraInventory to oinstall.

r a The execution of the script is complete


# /u01/app/oracle/product/10.2.0/db_1/root.sh

O Running Oracle10 root.sh script...

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 21


Solutions for Practice 3-1: Installing Oracle Database on Linux (continued)
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/10.2.0/db_1

Enter the full pathname of the local bin directory:


[/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...

Creating /etc/oratab file...


Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
#
7. Click OK after running the scripts.
4) In the End of Installation window, click Exit to quit the installation.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 22
Solutions for Practice 3-2: Configuring the Listener
Configure and start the listener.
1) Run the Network Configuration Assistant (netca) to configure the listener. Use the
default settings on every screen.
Answer:
1. Enter the following at the OS prompt, as the oracle user:
$ netca

2. Click Next on each of the netca wizard screens, until you see Finish. Click
Finish.
2) Verify that the listener has been started.
Answer:
1. Enter the following at the OS prompt:
$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 11-


DEC-2006 10:39:32

Copyright (c) 1991, 2005, Oracle.

Connecting to
All rights reserved.

m y
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=edt3r12p1)(PORT=
1521)))
d e
STATUS of the LISTENER
------------------------
c a
Alias
Version
LISTENER

e
TNSLSNR for Linux: Version A
10.2.0.1.0 - Production
Start Date
c l
11-DEC-2006 10:33:53
Uptime
r a
0 days 0 hr. 5 min. 39 sec

O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 23
Practice Solutions for Lesson 4
There is no practice for lesson 4.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 24
Practice Solutions for Lesson 5: Automatic Storage
Management

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 25
Solutions for Practice 5-1: Installing and Configuring ASMLib
In this practice, you install and configure ASMLib, and then create an ASM instance.
1) As root, install the three RPMs required for ASMLib. The RPMs are located in
/home/oracle/labs.
Answer:
1. Five RPMs exist in /home/oracle/labs for Oracle ASMLib. Three need to
be installed: oracleasm, oracleasmlib, and oracleasm-support. RPM oracleasm is
dependent on the kernel version, containing the kernel version in the name of the
RPM. List the RPMs, in /home/oracle/labs, for Oracle ASMLib.
$ ls /home/oracle/labs/oracleasm*

2. Use the uname -r command to determine the kernel version.


$ uname -r

3. Install the three RPMs. Note, in the example a kernel version is not given. Use the
kernel version from the uname -r command.
$ su –
Password:
# cd /home/oracle/labs
# rpm -Uvh oracleasm-<kernel version>-2.0.3-2.i686.rpm \
> oracleasmlib-*.rpm \
m y
e
> oracleasm-support*.rpm

d
Preparing...

a
########################################### [100%]

c
1:oracleasm-support
########################################### [ 33%]
2:oracleasm-2.6.9-

e
42.0.0.########################################### [ 67%] A
3:oracleasmlib
c l
a
########################################### [100%]
#
r
O ly
2) Configure ASM by executing the /etc/init.d/oracleasm configure
command. Use the following settings:
Owning user:
l & On
oracle
Owning group:
n a e
dba
Start on boot:

t e r
Fix permissions:
U
y
ys
Answer:
I n
1. As root, enter the following at the OS prompt:

c l e[root@edt3r12p1 labs]# /etc/init.d/oracleasm configure

r a Configuring the Oracle ASM library driver.

O This will configure the on-boot properties of the Oracle ASM


library

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 26


Solutions for Practice 5-1: Installing and Configuring ASMLib (continued)
driver. The following questions will determine whether the
driver is
loaded on boot and what permissions it will have. The current
values
will be shown in brackets ('[]'). Hitting <ENTER> without
typing an
answer will keep that current value. Ctrl-C will abort.

Default user to own the driver interface []: oracle


Default group to own the driver interface []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Fix permissions of Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: [ OK ]
Creating /dev/oracleasm mount point: [ OK ]
Loading module "oracleasm": [ OK ]
Mounting ASMlib driver filesystem: [ OK ]
Scanning system for ASM disks: [ OK ]
#

3) Use the fdisk command to create a single partition on the disks to be used with
ASM.
When prompted within fdisk, enter these values:

y
Command (new partition): n
Primary partition: p
Partition number:
First cylinder:
1
1
e m
Last cylinder:
Last command (write):
130
w
a d
Answer:
A c
l e
1. Enter the following at the OS prompt:

c
# /sbin/fdisk /dev/sdj

r a
Device contains neither a valid DOS partition table, nor

O ly
Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in
memory only,

l & On
until you decide to write them. After that, of course, the
previous

n a e
content won't be recoverable.

t e r U s
Warning: invalid flag 0x0000 of partition table 4 will be

n
corrected by w(rite)

I
c l e
Command (m for help): n
Command action
e extended

r a p
p primary partition (1-4)

O Partition number (1-4): 1


First cylinder (1-130, default 1): <press ENTER>

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 27


Solutions for Practice 5-1: Installing and Configuring ASMLib (continued)
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-130, default
130): <press ENTER>
Using default value 130

Command (m for help): w


The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error


22: Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
#
4) Repeat the step above, creating partitions for each of the following devices:
/dev/sdk
/dev/sdl
/dev/sdm
/dev/sdn

y
/dev/sdo
/dev/sdp
/dev/sdq

e m
Answer:

a d
1. Enter the following commands at the OS prompt, and respond with the exact same
values for the /dev/sdj set up.
Note: The responses are not shown here.
A c
#
#
/sbin/fdisk
/sbin/fdisk
/dev/sdk
/dev/sdl
c l e
#
#
/sbin/fdisk
/sbin/fdisk
r a
/dev/sdm
/dev/sdn
# /sbin/fdisk
O ly
/dev/sdo

& On
# /sbin/fdisk /dev/sdp

l
# /sbin/fdisk /dev/sdq

n a e
5) Run the partprobe command. This informs the kernel of partition table changes.

e r s
In this case, running partprobe ensures that the kernel is aware the disks have
t
been partitioned.
U
Answer:
I n
l e
1. Enter the following at the OS prompt:
c
r a # partprobe

6) Enable ASMLib.
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 28
Solutions for Practice 5-1: Installing and Configuring ASMLib (continued)
Answer:
1. Enter the following at the OS prompt:
# /etc/init.d/oracleasm enable
Writing Oracle ASM library driver configuration: [ OK ]
Scanning system for ASM disks: [ OK ]

7) Create the ASM disk for storing the database’s data files and flash recovery area files.
Use the oracleasm utility to do this. Map the ASM disk names to devices:
DF1 /dev/sdj1
DF2 /dev/sdk1
DF3 /dev/sdl1
DF4 /dev/sdm1
FRA1 /dev/sdn1
FRA2 /dev/sdo1
FRA3 /dev/sdp1
FRA4 /dev/sdq1
Answer:
1. Enter the following at the OS prompt:
# /etc/init.d/oracleasm createdisk DF1 /dev/sdj1
Marking disk "/dev/sdj1" as an ASM
# /etc/init.d/oracleasm createdisk
disk: .
DF2 /dev/sdk1
[ OK ]

m y
Marking disk "/dev/sdk1" as an ASM
# /etc/init.d/oracleasm createdisk
disk:
DF3 /dev/sdl1
[

d eOK ]

a
Marking disk "/dev/sdl1" as an ASM disk: [ OK ]
# /etc/init.d/oracleasm createdisk
Marking disk "/dev/sdm1" as an ASM
# /etc/init.d/oracleasm createdisk
DF4 /dev/sdm1
disk:

A
FRA1 /dev/sdn1c [ OK ]

c l e
Marking disk "/dev/sdn1" as an ASM
# /etc/init.d/oracleasm createdisk
disk:
FRA2 /dev/sdo1
[ OK ]

a
Marking disk "/dev/sdo1" as an ASM disk: [ OK ]

r
# /etc/init.d/oracleasm createdisk

O ly
Marking disk "/dev/sdp1" as an ASM
# /etc/init.d/oracleasm createdisk
FRA3 /dev/sdp1
disk:
FRA4 /dev/sdq1
[ OK ]

l & On
Marking disk "/dev/sdq1" as an ASM disk:

8) Make the ASM disks available using the scandisks option of the oracleasm
[ OK ]

utility.
n a e
Answer:

t e r U s
1. Enter the following at the OS prompt:

I n
# /etc/init.d/oracleasm scandisks

c l eScanning system for ASM disks: [ OK ]

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 29
Solutions for Practice 5-2: Creating an ASM Instance
Now that the ASM disks are set up, you can create the ASM instance that uses them. In
this practice, you will create an ASM instance, and define the ASM disk groups that it is
to use for data, and for the flash recovery area.
1) Use DBCA to configure Automatic Storage Management.
Answer:
1. Exit from the root session by entering the following at the OS prompt:
# exit

2. As the oracle user, enter the following to start the database configuration
assistant:
$ dbca

3. On the Welcome screen, click Next.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
4. On the Operations screen, select Configure Automatic Storage Management, and

n
then click Next.
I
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 30
Solutions for Practice 5-2: Creating an ASM Instance (continued)

5. STOP. On the Warning screen, do not click OK yet. Note that it says that you
m y
e
need to start the Oracle Cluster Synchronization Service (CSS) before proceeding.
d
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
6. While the warning screen is still displayed, go to a terminal window as the root
user. You may need to start a new terminal and log in as root. Then enter the

c l e
following command:
# /u01/app/oracle/product/10.2.0/db_1/bin/localconfig add

r a /etc/oracle does not exist. Creating it now.


Successfully accumulated necessary OCR keys.

O Creating OCR keys for user 'root', privgrp 'root'..


Operation successful.

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 31


Solutions for Practice 5-2: Creating an ASM Instance (continued)
Configuration for local CSS has been initialized

Adding to inittab
Startup will be queued to init within 90 seconds.
Checking the status of new Oracle init process...
Expecting the CRS daemons to be up within 600 seconds.
CSS is active on these nodes.
edt3r12p1
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)
# exit

7. Return to the CSS warning window and click OK.

8. On the Operations page, click Next.


m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 32
Solutions for Practice 5-2: Creating an ASM Instance (continued)
9. On the Create ASM Instance page, enter oracle (twice) as the SYS password
for the new instance. Then click Next.

m y
d e
the ASM instance. Click OK.
c a
10. The Database Configuration Assistant dialog box says that you are about to create

e A
c l
r a
O ly
l & On
n a e
t e r U s
11. On the ASM Disk Groups page, note that there are no groups created yet. Click
Create New to create one.

I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 33
Solutions for Practice 5-2: Creating an ASM Instance (continued)

12. On the Create Disk Group page, name the group DF, change Redundancy to
m y
click OK.
d e
External, and select the four data file disks (DF1, DF2, DF3, and DF4). Then

c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 34
Solutions for Practice 5-2: Creating an ASM Instance (continued)

m y
d e
13. Note that the DF disk group is now listed. Click Create New again to create the
disk group for the flash recovery area.
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 35
Solutions for Practice 5-2: Creating an ASM Instance (continued)

m
14. Name the disk group FRA, change the Redundancy to External, and select all four
y
of the remaining disks. Then click OK.
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 36
Solutions for Practice 5-2: Creating an ASM Instance (continued)

m y
d e
15. After the FRA disk group is created, the ASM Disk Groups page appears again,
showing both disk groups. Click Finish.
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 37
Solutions for Practice 5-2: Creating an ASM Instance (continued)

16. Click No when asked if you want to perform another operation.


m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 38
Practice Solutions for Lesson 6: Creating the
Database

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 39
Solutions for Practice 6-1: Creating a Database
Create a database to be used in the instance already installed. The database will use the
ASM you already configured, for data file and flash recovery area storage.
1) Use the Database Creation Assistant to create a database with these attributes:
It is a general-purpose database.
It has a Global Database Name of orcl.us.oracle.com.
The SID is orcl.
It is configurable using Database Control.
All initial accounts should have the password of oracle.
The database should use ASM as its storage mechanism.
The flash recovery area should be 4 GB in size.
The database should be in ARCHIVELOG mode.
It should use Oracle Managed Files (OMF).
It should have the sample schemas installed.
Answer:
1. Enter the following at the OS prompt, as the oracle user:
$ dbca
m y
2. Click Next on the Welcome page.
d e
3. Select the Create a Database option, and click Next.
c a
4. Select General Purpose for the template to use, and click Next.

e A
5. On the Database Identification page, enter the following for the Global Database
Name, and then click Next.
c l
orcl.us.oracle.com
r a
O ly
6. Click Next on the Management Options page.

l & On
7. Enter oracle for both password fields on the Database Credentials page.
8. On the Storage Options page, select Automatic Storage Management, and click
Next.
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 40
Solutions for Practice 6-1: Creating a Database (continued)

9. Enter oracle as the password in the ASM Credentials window, and then click
m y
OK.
d e
c a
e A
c l
r a
O ly
10. Select the DF disk group to be used for storage in this database, and then click
Next.

l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 41
Solutions for Practice 6-1: Creating a Database (continued)

11. On the Database File Locations page, leave the settings as the defaults, which
m y
means that the Database Area is the +DF disk group. Then click Next.
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 42
Solutions for Practice 6-1: Creating a Database (continued)
12. On the Recovery Configuration page, click Browse to select the FRA disk group
to serve as the Flash Recovery Area. Also, set the Flash Recovery Area Size to
4040, which is all of the free space in +FRA. Then select the Enable Archiving
option, and click Next.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 43
Solutions for Practice 6-1: Creating a Database (continued)

13. Select the Sample Schemas option on the Database content page, and then click
m y
Next.
d e
14. On the Initialization Parameters page, click Next.
15. On the Database Storage page, click Next. c a
16. On the Creation Options page, click Finish.
e A
c l
17. Review the information on the Confirmation page, and then click OK.

r a
At this point, DBCA begins creating the database. This will take several minutes
to complete.
O ly
2) When DBCA finishes, it will display the information about the database that was just
& On
created. Make note of this information here:
l
SID: __________

n a e
t e r U s
Sever Parameter File name: _____________________________
Database Control URL: ________________________________
Answer:
I n
l e
1. The information displayed on the final DBCA page is similar to:

c SID: ___orcl_______

r a Sever Parameter File name: _+DF/orcl/spfileorcl.ora

O Database Control URL: http://edt3r12p1:1158/em______________

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 44


Solutions for Practice 6-1: Creating a Database (continued)
3) Unlock the HR account, and set its password to hr.
Answer:
1. Click Password Management.
2. On the Password Management page, deselect the Lock Account column for the
HR username. Enter hr for the New Password and the Confirm Password fields.
Then click OK.
4) Click Exit to exit DBCA.
5) Set the ORACLE_SID environment variable so that it is set for every terminal session
that the oracle user starts. Set it to orcl.
Answer:
1. Edit the .bash_profile file, and then add the following line:
export ORACLE_SID=orcl

2. Exit from all open terminal shells, and log out of the machine.
3. Log in as the oracle user again.
4. Start a terminal shell, and check the ORACLE_SID variable by entering the
following:
$ echo $ORACLE_SID
m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 45
Solutions for Practice 6-2: Backing Up Your Database
It is good to have a backup of the database you are working with. Take a backup of the
database that has just been created.
1) Back up the database.
Answer:
1. Enter the following as the oracle user, at the OS prompt:
$ rman target /

2. Enter the following at the RMAN prompt:


RMAN> backup database;
.
.
.
RMAN> exit

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 46
Practice Solutions for Lesson 7: Customizing Oracle
on Linux

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 47
Solutions for Practice 7-1: Configuring Automatic Startup and
Shutdown of the Database
For dealing with reboots, either planned or unplanned, it is good to have your database
start up automatically. This provides higher database availability and reduces the chance
of error. In this practice, you will configure the database to start and stop when the OS
boots and shuts down. In addition, you will edit the dbstart and dbshut scripts to
include starting and stopping DB Control. Lastly, in this practice, you will view a demo
of the installation of Enterprise Linux.
Note: If you do not want to manually edit the dbstart dbshut files, then fully edited
and correct versions of these files are located in /home/oracle/solutions. The
files are named dbstart_edited, and dbshut_edited.
1) By editing the /etc/oratab file, configure the ASM and orcl instances to be
automatically started and stopped when the operating system is started and stopped.
Answer:
1. As the oracle user, edit the /etc/oratab file, changing the third field,
delimited by a colon, from N to Y. The resulting lines should look like this:
+ASM:/u01/app/oracle/product/10.2.0/db_1:Y
orcl:/u01/app/oracle/product/10.2.0/db_1:Y

2) View the /home/oracle/labs/dbora script to see what it does. What scripts


does it invoke?
m y
________________
Answer:
________________

d e
1. The /home/oracle/labs/dbora script invokes dbstart and dbshut.
c a
A
3) Copy the dbora script from the /home/oracle/labs directory to a directory
e
Answer:
c l
such that it will be invoked during startup and shutdown of the OS.

r a
1. As the root user, enter the following command at the OS prompt:

O ly
# cp /home/oracle/labs/dbora /etc/rc.d/init.d

l & On
4) Set the permissions for the dbora script to 750, and set the group to dba.
Answer:
n a e
t e r U s
1. As root, enter the following command at the OS prompt:

I n
# chmod 750 /etc/rc.d/init.d/dbora
# chgrp dba /etc/rc.d/init.d/dbora

l e
5) Establish links in the dbora script such that it will be invoked during the OS startup

c
and shutdown in runlevels 3 and 5. The shutdown, or “kill” scripts, should be

r aexecuted first, and startup scripts should be executed last.

O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 48
Solutions for Practice 7-1: Configuring Automatic Startup and Shutdown of
the Database (continued)
Answer:
1. As root, enter the following commands:
# ln -s /etc/rc.d/init.d/dbora /etc/rc3.d/S99dbora
# ln -s /etc/rc.d/init.d/dbora /etc/rc3.d/K01dbora
# ln -s /etc/rc.d/init.d/dbora /etc/rc5.d/S99dbora
# ln -s /etc/rc.d/init.d/dbora /etc/rc5.d/K01dbora

Note that the startup scripts start with S99 forcing them to run last. The kill
scripts start with K01 forcing them to run first.
6) Edit /u01/app/oracle/product/10.2.0/db_1/bin/dbstart to fix the
known issue with starting the listener. Make the following changes, and then save the
file.
On line 78, change the value for ORACLE_HOME_LISTNER to this value:
/u01/app/oracle/product/10.2.0/db_1

Correct automatic ASM startup by editing line 59. Remove the –s option
from the LOGMSG value. The resulting line should look like this:
LOGMSG="logger -puser.alert"

Change line 255 to look like this:


m y
COUNT=`expr $COUNT + 1`
d e
c a
Change line 88. Remove the first word of the line, export. Then insert a line
under 88 that looks like this:
export VER10LIST
e A
c l
r a
7) Test stopping the database instances using dbora.
Answer:
O ly
& On
1. Enter the following as the root user:
l
a e
# /etc/rc.d/init.d/dbora stop

n
e r s
Note that shutdown is in progress even though the dbora command returns
t U
I n
immediately. This is because, within the script, dbshut is called with an
ampersand following it, causing it to run in the background.

l e
8) While the databases are being shut down, check whether they are still running. Check

c
for pmon_orcl and pmon_+ASM processes.

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 49
Solutions for Practice 7-1: Configuring Automatic Startup and Shutdown of
the Database (continued)
Answer:
1. Run the following two commands until the only result returned is the grep
command itself.
# ps -ef | grep pmon_orcl
# ps -ef | grep pmon_+ASM

When the commands return no results, the instances have been shut down.

9) Test starting the database with dbora. First shut down the listener to set up the
environment, as it would be at normal boot-up time.
Answer:
1. Enter the following, as the oracle user, to stop the listener:
$ lsnrctl stop

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 11-


DEC-2006 14:27:30

Copyright (c) 1991, 2005, Oracle. All rights reserved.

Connecting to
m y
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=edt3r12p1)(PORT=
1521)))
d e
The command completed successfully
$
c a
2. Run the dbstart script by entering the following as root:

e A
# /etc/rc.d/init.d/dbora start

c l
r a
3. Check for the instances to be started by looking for the pmon processes to appear
in the process listing. Do that by entering the following commands:

O ly
# ps -ef | grep pmon_orcl

l & On
# ps -ef | grep pmon_+ASM

10) Test that these scripts will be called and will function properly during a reboot.
Answer:
n a e
t e r s
1. Enter the following at the OS prompt, as the root user:
U
I
# reboot
n
c l e
The system reboots. As the system reinitializes, check for the pmon processes
using the ps commands used previously.

r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 50
Solutions for Practice 7-2: Configuring Automatic Startup and
Shutdown of DB Control (optional)
Note: If you have already copied the dbstart_edited and dbshut_edited files
as described in practice 7-1, then you do not need to do this practice.
You need to configure DB Console to start and stop when the database starts up and shuts
down. If DB Control has been configured for an instance, then there exists a directory
under $ORACLE_HOME with the format FullyQualifiedHostname_SID. For
example:
textbox.us.oracle.com_orcl
If DB Control is available in this version of the database, then the executable emctl
exists under the $ORACLE_HOME/bin directory.
1) Configure DB Control to start with the database. It is best to start DB Control after
the database has successfully started. So position the commands in the dbstart
script to be after a test for a successful start of the database. Add the following text to
the dbstart script. Insert it at line 221, which is following these three lines:
Line 218: if test $? -eq 0 ; then
Line 219: echo ""
Line 220: echo "$0: ${INST} \"${ORACLE_SID}\" warm started."

--- Beginning of text to add ---


HOSTNAME_SID=${ORACLE_HOME}/`hostname --long`_${ORACLE_SID}
m y
if [ -d ${HOSTNAME_SID} ] && [ -f ${ORACLE_HOME}/bin/emctl ];then
d e
echo "$0: Starting DB Control"
${ORACLE_HOME}/bin/emctl start dbconsole
c a
fi

e A
if test $? -eq 0 ; then

c l
a
echo ""

else
r
echo "$0: DB Console for \"${ORACLE_SID}\" started."

O ly
$LOGMSG ""

l & On
$LOGMSG "Error: DB Control for \"${ORACLE_SID}\" NOT started."
fi
n a e
e r
--- End of text to add ---

t U s
I n
Note: You can either edit this file manually (the text above is in a file named

l e
lab_07_02_01.txt) or simply copy the dbstart_edited file from the
solutions directory to $ORACLE_HOME/bin/dbstart. The copy command to
c
r ause, as the oracle user, is:

O $ cp ~/solutions/dbstart_edited $ORACLE_HOME/bin/dbstart

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 51


Solutions for Practice 7-2: Configuring Automatic Startup and Shutdown of
DB Control (optional) (continued)
2) Configure DB Control to stop when the database is shut down. Do this by editing the
dbshut script, adding the following text at line 101, which is following these lines:
Line 94: if [ -f $ORACLE_HOME/bin/svrmgrl ] ; then
Line 95: SQLDBA=svrmgrl
Line 96: VERSION="internal"
Line 97: else
Line 98: SQLDBA="sqlplus /nolog"
Line 99: fi
Line 100: fi

--- Beginning of text to add ---


HOSTNAME_SID=${ORACLE_HOME}/`hostname --long`_${ORACLE_SID}
echo ${HOSTNAME_SID}
if [ -d ${HOSTNAME_SID} ] && [ -f ${ORACLE_HOME}/bin/emctl ]; then
echo "$0: Stop DB Console"
${ORACLE_HOME}/bin/emctl stop dbconsole
fi
if test $? -eq 0 ; then
echo ""
echo "$0: DB Console for \"${ORACLE_SID}\" stopped."
m y
else
$LOGMSG ""
d e
$LOGMSG "Error: DB Console for
c a
\"${ORACLE_SID}\" NOT stopped."
fi

e A
l
--- End of text to add ---

a c
Note: You can either edit this file manually (the text above is in a file named
lab_07_02_02.txt) or simply copy the dbshut_edited file from the

use, as the oracle user, is:


r
solutions directory to $ORACLE_HOME/bin/dbshut. The copy command to
O ly
l & On
$ cp ~/solutions/dbshut_edited $ORACLE_HOME/bin/dbshut

n a e
t e r U s
3) Test the automatic shutdown of DB Control by issuing a dbora stop command.
Answer:

I n
1. As root, enter the following at the OS prompt:

c l e # /etc/init.d/dbora stop

Ora 2. Check the status of the DB Control, the listener, and the database instance by
entering the following. Note that you must become the oracle user by exiting
the root session. Also, stop the listener.

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 52


Solutions for Practice 7-2: Configuring Automatic Startup and Shutdown of
DB Control (optional) (continued)
# exit
$ emctl status dbconsole
$ ps -ef|grep -i smon
$ lsnrctl status

3. Note that DB Control and the database are stopped, but the listener is still
running. It is not stopped by dbora. Enter the following to stop it:
$ lsnrctl stop

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 12-


DEC-2006 06:24:11

Copyright (c) 1991, 2005, Oracle. All rights reserved.

Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=edt3r12p1)(PORT=
1521)))
The command completed successfully
$

4) Test the automatic startup of DB Control by issuing a dbora start command.


Answer:
1. Open two terminal windows. One is logged in as oracle and the other as root.
m y
d e
2. In the oracle user’s window, enter the following to view the startup log in real
time.
$ touch /u01/app/oracle/product/10.2.0/db_1/startup.log
c a
$ tail -f /u01/app/oracle/product/10.2.0/db_1/startup.log

e A
l
3. In the root user’s window, enter the following to start the test:
c
# /etc/init.d/dbora start

r a
O ly
4. In the oracle user’s window, check that the database, listener, and DB Control
have started. Press [Ctrl] + [C] to break the tail command first. Then enter the
following:
l & On
$ lsnrctl status
$ tnsping orcl
n a e
t e r U s
$ emctl status dbconsole

5) Test the automatic restart by rebooting the system.


Answer: I n
l e
1. Enter the following in the root user’s window:
c
r a # reboot

O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 53
Solutions for Practice 7-2: Configuring Automatic Startup and Shutdown of
DB Control (optional) (continued)
2. After the system reboots, enter the following to check whether DB Control has
restarted:
$ emctl status dbconsole

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 54
Solutions for Practice 7-3: Installing Linux
In this practice, you will run a viewlet of the process of installing Enterprise Linux.
1) Launch the viewlet using the install_el4u4_launcher.html file.
Answer:
1. While in the ~oracle/labs directory, enter the following at the OS prompt:
$ htmlview install_el4u4_launcher.html

2. When the browser window appears, click the link that appears on the page.
3. The viewlet begins running. Use the navigation buttons at the bottom of the
screen to pause, restart, and so on.
2) Answer the following questions:
a. Why was a graphical environment not installed by default?
__________________________________________________________________
b. What is the mount point for the swap partition?
________________________
c. Are sar and iostat installed by default?
________________________
d. Is creating a root user optional?
m y
________________________
d e
c a
Answer:

e
1. Following are the answers to the questions listed: A
c l
a. The graphical environment was not installed by default because you chose a
Server type installation.
r a
b. You do not specify the mount point for a swap partition. It is not actually a file
O ly
system, and thus is not mounted.

l & On
c. No, sar and iostat are not installed by default. You have to select those

a e
from the System Tools list of packages.

n
t e r
d. No, you must have a root user. The installation process creates the user, and
s
asks you for the password.
U
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 55
Practice Solutions for Lesson 8: Managing Memory

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 56
Solutions for Practice 8-1: Managing Memory
In this practice you will inspect your system’s memory parameters. You will look at
statistics and behavior regarding physical memory, and swap space.

1) View the current memory settings and status for the kernel. How much total memory
is on your system?
Note: You may see different memory related values from those shown here,
depending on the type of machine you are on.
Answer:

1. Enter the following at the OS prompt, as root.


# cat /proc/meminfo
MemTotal: 1035208 kB
MemFree: 15680 kB
Buffers: 34100 kB
Cached: 603772 kB
SwapCached: 60 kB
Active: 596128 kB
Inactive: 371704 kB
HighTotal: 130524 kB
HighFree: 1736 kB
LowTotal:
LowFree:
904684
13944
kB
kB
m y
SwapTotal:
SwapFree:
2048276
2048208
kB
kB
d e
Dirty:
Writeback:
1592
0
kB
kB
c a
A
Mapped: 539544 kB
Slab: 19520 kB
CommitLimit: 2565880
Committed_AS: 1647784
c l e
kB
kB
PageTables:
VmallocTotal:
12164
106488
r a kB
kB

O ly
VmallocUsed: 6184 kB
VmallocChunk: 99316 kB
HugePages_Total:
HugePages_Free:
l & On
0
0
Hugepagesize:

n a e
4096 kB

t e r U s
2. Note that there is about 1 GB total memory on this system.

n
2) According to the top command, how much memory is currently in use?
I
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 57
Solutions for Practice 8-1: Managing Memory (continued)
Answer:
1. Enter the following at the OS prompt:
# top

2. Note that top reports, in this case, 1017792 KB of memory is currently being
used.
3) How much of this used memory is being used for cache, which means that it is
available to be used for noncache uses such as new process starting up, or new
requests for memory allocation?
Answer:
1. Run the free command, as shown below:
# free
total used free shared buffers cached
m y
Mem: 1035208 1021648 13560
-/+ buffers/cache: 382904 652304
0 34168 604576

d e
Swap:
#
2048276 112 2048164
c a
A
2. Note that, in this case, approximately 604 MB of the memory in use is being used
e
for cache.

c l
Answer:
r a
4) How much swap space is there, and how much is in use?

O ly
1. According to the free output, there is about 2 GB of swap space allocated, and

l & On
112 KB is being used right now.
5) What is the device name that is being used for the swap space?
Answer:
n a e
allocation:
t e r U s
1. Enter the following command to see the information about the swap space

I
Filenamen
# cat /proc/swaps
Type Size Used Priority

c l e
/dev/hda3 partition 2048276 1036 -1

Note: The swap space is allocated on /dev/hda3. Depending on the type of

r a device on your machine, you may see a different value here, such as
/dev/sda3.
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 58
Solutions for Practice 8-2: Managing Shared Memory
Now you will view the state and behavior of shared memory segments on your system,
and how they relate to an Oracle database instance.
1) Display the list of shared memory segments belonging to the oracle user on your
system.
Answer:
1. Enter the following at the OS prompt:
$ ipcs -m

------ Shared Memory Segments --------


key shmid owner perms bytes nattch
status
0x00000000 65536 vncuser 644 151552 2 dest
0x00000000 98305 vncuser 644 122880 2 dest
0x00000000 131074 vncuser 644 790528 2 dest
0x351b2710 458763 oracle 640 88080384 12
0x00000000 589836 oracle 644 151552 2 dest
0x00000000 622605 oracle 644 122880 2 dest
0x00000000 655374 oracle 644 790528 2 dest
0x00000000 688143 oracle 600 196608 2 dest

y
0x00000000 720912 oracle 600 196608 2 dest
0x00000000 753681 oracle 600 196608 2 dest
0x00000000 786450
0x00000000 819219
oracle
oracle
600
600
196608
196608
2
2
e m
dest
dest
0x00000000 851988
0x00000000 884757
oracle
oracle
600
600
196608
196608
2

a
2 d dest
dest
0x00000000 917526 oracle
0x00000000 3571735 oracle
0xbe3bb918 3768344 oracle
600
600
640
196608
196608
A
423624704
c 2
2
29
dest
dest

0x00000000 2129945 oracle


0x00000000 2654237 oracle
c l e 600
600
196608
196608
2
2
dest
dest

[oracle@EDRSR9P1 labs]$
r a
O ly
2) Note the largest shared memory segment. What is it being used for? Prove your
answer.

l & On
Note: The numbers you see will most likely be different from those shown here.
Answer:
n a e
e r s
1. Shut down the Oracle database instance by entering the following:
t U
I n
$ sqlplus / as sysdba
SQL> shutdown

l e
2. Rerun the ipcs –m command as above. Note that the largest shared memory
c
r a segment is gone from the list. It belonged to the Oracle database.
$ ipcs -m

O ------ Shared Memory Segments --------


key shmid owner perms bytes nattch status

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 59


Solutions for Practice 8-2: Managing Shared Memory (continued)
0x00000000 65536 vncuser 644 151552 2 dest
0x00000000 98305 vncuser 644 122880 2 dest
0x00000000 131074 vncuser 644 790528 2 dest
0x351b2710 458763 oracle 640 88080384 11
0x00000000 589836 oracle 644 151552 2 dest
0x00000000 622605 oracle 644 122880 2 dest
0x00000000 655374 oracle 644 790528 2 dest
0x00000000 688143 oracle 600 196608 2 dest
0x00000000 720912 oracle 600 196608 2 dest
0x00000000 753681 oracle 600 196608 2 dest
0x00000000 786450 oracle 600 196608 2 dest
0x00000000 819219 oracle 600 196608 2 dest
0x00000000 851988 oracle 600 196608 2 dest
0x00000000 884757 oracle 600 196608 2 dest
0x00000000 917526 oracle 600 196608 2 dest
0x00000000 3571735 oracle 600 196608 2 dest
0x00000000 2129945 oracle 600 196608 2 dest

3. Restart your database instance, and rerun the ipcs command to see the shared
memory segment reappear in the list.
3) What does the next highest oracle shared memory segment belong to?
Answer:
1. It belongs to the ASM instance.
4) What is the meaning of the nattch column? Prove it by demonstrating how it m y
changes.
d e
Answer:
c a
A
1. The nattch column is the number of processes that are attached to this shared
memory segment. You can prove this by creating and disconnecting from
e
c l
database sessions and observing the number as it changes accordingly. Enter the
following to get a baseline number for the orcl instance shared memory

r a
segment. Only the largest segment is shown here.
$ ipcs –m
O ly
l & On
------ Shared Memory Segments --------

a e
key shmid owner perms bytes nattch status

n
0xbe3bb918 983064 oracle 640 289406976 27

t e r U s
2. Note that there are 27 processes attached to this segment. In a separate oracle
terminal window, enter the following to establish another database session:

I n
$ sqlplus / as sysdba

l e
3. Rerun the ipcs command to see if the nattch number has increased. Note that
c it has increased by one.

r a $ ipcs –m

O ------ Shared Memory Segments --------

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 60


Solutions for Practice 8-2: Managing Shared Memory (continued)
key shmid owner perms bytes nattch status
0xbe3bb918 983064 oracle 640 289406976 28

4. Exit the SQL*Plus session and note that the number of processes attached to the
segment returns to the original value.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 61
Practice Solutions for Lesson 9

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 62
Solutions for Practice 9-1: Gather Statistics Using iostat, sar,
and vmstat
In this practice, you will measure CPU, virtual memory, and I/O usage on your system. A
table of commands is provided for your reference.

Diagnostic Measures Notes

sar -uq 5 3 runq-sz, ldavg, On the system the averages


%user,%sys, %idle provide a baseline

sar -d 5 3 rps, sect/s Overall activity by device

vmstat 5 3 Free, si Swapping information also


includes disk and CPU. First
line is all activity since last
report. Pick a representative line
other than the first to record.

iostat -p /dev/hda 5 3 avgqu-sz, await, Disk activity by partition. hda5


svctm is the / partition. Note hda is
sum of hda* lines. First output

report. Pick a representative


section other than the first tom y
section is all activity since last

record.
d e
c a
Record your measurements in the following table.

e A
Measurement
c
Quietl Database I/O

r a Activity Activity
sar -uq AVERAGE runq-sz
O ly
sar -uq AVERAGE ldavg
l & On
sar -uq AVERAGE

n a e
sar -uq AVERAGE %user

t e r U s
I n
sar -uq AVERAGE %sys

sar -uq AVERAGE %idle

c l e
sar -d AVERAGE dev3-0 tps

r a
sar -d AVERAGE dev3-0 rd_sec/s

O sar -d AVERAGE dev3-0 wr_sec/s

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 63


Solutions for Practice 9-1: Gather Statistics Using iostat, sar, and vmstat
(continued)

vmstat memory free

vmstat swap si

iostat -p hda5 tps

iostat -p hda5 Blk_read/s

iostat -p hda5 Blk_wrtn/s

1) Use the sar command to measure system stats including:


Run queue size
Load average
Percent CPU utilization for user processes
Percent CPU utilization for system (kernel) processes
Percent CPU is idle
Take three measurements at an interval of five seconds. Record the results in the
Quiet column of the previous table.
Answer:
m y
1. The numeric arguments to sar indicate the time interval and the number of
d e
samples, respectively. So, you use 5 and 3 for that. The –u option reports on all

c a
CPU utilization, and the –q option reports on the run queue size. So, enter the
following command, as the root user.

e A
Note: The numbers shown here may differ for your system, depending on the type
of machine you are using.
c l
$ sar -uq 5 3
r a
Linux 2.6.9-42.0.0.0.1.EL (edt3r12p1.us.oracle.com)
12/12/2006
O ly
09:35:09 AM
l & On
CPU %user %nice %system %iowait %idle

a e
09:35:14 AM all 1.80 3.79 1.00 0.00 93.41

r n
09:35:09 AM runq-sz
s plist-sz ldavg-1 ldavg-5 ldavg-15
09:35:14 AM

n t e 0

U
214 0.20 0.13 0.10

e I
09:35:14 AM
09:35:19 AM
CPU
all
%user
11.78
%nice %system
3.59 2.59
%iowait
0.00
%idle
82.04

c l 09:35:14 AM runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15

r a 09:35:19 AM 3 215 0.18 0.13 0.09

O 09:35:19 AM
09:35:24 AM
CPU
all
%user
15.60
%nice %system
3.00 2.80
%iowait
0.20
%idle
78.40

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 64


Solutions for Practice 9-1: Gather Statistics Using iostat, sar, and vmstat
(continued)

09:35:19 AM runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15


09:35:24 AM 0 215 0.17 0.13 0.09

Average: CPU %user %nice %system %iowait %idle


Average: all 9.72 3.46 2.13 0.07 84.62

Average: runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15


Average: 1 215 0.18 0.13 0.09
[oracle@edt3r12p1 postpilot]$

2) Use the sar command to report on device statistics. Use the same repeat interval and
count as above. Record the results in the Quiet column of the previous table.
Answer:
1. Enter the following command at the OS prompt:
$ sar -d 5 3
Linux 2.6.9-42.0.0.0.1.EL (edt3r12p1.us.oracle.com)
12/12/2006

10:07:07 AM DEV tps rd_sec/s wr_sec/s


10:07:12
10:07:12
10:07:12
AM
AM
AM
dev1-0
dev1-1
dev1-2
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
m y
10:07:12
10:07:12
AM
AM
dev1-3
dev1-4
0.00
0.00
0.00
0.00
0.00
0.00
d e
10:07:12
10:07:12
AM
AM
dev1-5
dev1-6
0.00
0.00
0.00
0.00
c
0.00
0.00a
10:07:12
10:07:12
AM
AM
dev1-7
dev1-8
e
0.00
0.00
0.00
0.00 A 0.00
0.00
10:07:12
10:07:12
AM
AM
dev1-9
dev1-10
c l 0.00
0.00
0.00
0.00
0.00
0.00
10:07:12
10:07:12
AM
AM
r
dev1-11
dev1-12a 0.00
0.00
0.00
0.00
0.00
0.00
10:07:12
10:07:12
AM
AM O ly
dev1-13
dev1-14
0.00
0.00
0.00
0.00
0.00
0.00
10:07:12
10:07:12
AM
AM
l & On
dev1-15
dev3-0
0.00
1.80
0.00
0.00
0.00
67.20
10:07:12 AM

n a e
dev22-0 0.00 0.00 0.00
10:07:12
10:07:12
10:07:12
t
AM

e
AM
AM
r U s
dev2-0
dev9-0
dev7-0
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00

I
10:07:12
10:07:12n AM
AM
dev7-1
dev7-2
0.00
0.00
0.00
0.00
0.00
0.00

c l e
10:07:12
10:07:12
AM
AM
dev7-3
dev7-4
0.00
0.00
0.00
0.00
0.00
0.00

r a 10:07:12
10:07:12
AM
AM
dev7-5
dev7-6
0.00
0.00
0.00
0.00
0.00
0.00

O 10:07:12
.
AM dev7-7 0.00 0.00 0.00

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 65


Solutions for Practice 9-1: Gather Statistics Using iostat, sar, and vmstat
(continued)
.
.

3) Use the vmstat command to measure virtual memory statistics, using the same
interval as above. In the Quiet column of the table above, record the amount of free
virtual memory and the amount of virtual memory swapped in (si).
Answer:
1. Enter the following command:
$ vmstat 5 3
procs -----------memory---------- ---swap-- -----io---- --
system-- ----cpu----
r b swpd free buff cache si so bi bo
in cs us sy id wa
3 0 1780 18184 40352 587688 0 0 56 54
1110 694 8 2 90 1
0 0 1780 16816 40356 587712 0 0 2 58
1103 947 8 2 90 0
0 0 1780 16716 40356 587712 0 0 0 29
1106 912 5 1 94 0
$

4) Use the iostat command to report I/O statistics for the root partition. Record the
results in the Quiet column of the table above.
m y
Answer:
d e
1. Enter the following at the OS prompt:
c a
$ iostat -p /dev/hda 5 3
Linux 2.6.9-42.0.0.0.1.EL (edt3r12p1.us.oracle.com)

e A
12/12/2006

c l
avg-cpu: %user
4.46
r a
%nice
3.42
%sys %iowait
1.61 0.57
%idle
89.93

Device: tps O ly
Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
hda
hda5
5.19
11.63
l & On 75.07
74.67
68.76 1286721 1178645
68.29 1279844 1170544
hda4 0.00

n a e 0.00 0.00 4 0

r
hda3 0.08 0.11 0.22 1915 3784
hda2
hda1
t e
0.09
0.31
U s 0.10
0.13
0.00
0.25
1697
2211
23
4294
.
.
I n
c l e
.

r a
5) Run the $ORACLE_HOME/rdbms/admin/catproc.sql script to put a load on

O the system.

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 66


Solutions for Practice 9-1: Gather Statistics Using iostat, sar, and vmstat
(continued)
Answer:
1. As the oracle user, enter the following at the command prompt:
$ cd $ORACLE_HOME/rdbms/admin
$ sqlplus / as sysdba
SQL> @catproc.sql

6) While the catproc.sql script is running, take measurements on your system again
(as earlier), but this time, you can simply use the script that runs the commands you
ran before. The script is monitor.sh.
Answer:
1. Enter the following in a command window, while in the ~oracle/labs
directory:
$ ./monitor.sh

2. Record the results in the Database activity column of the chart given previously.
7) While the catproc.sql script is still running, run the following dd command to
generate I/O activity. Then run the monitor.sh script again and record the results
in the I/O Activity column of the chart mentioned earlier.
# dd if=<root partition> of=/dev/null conv=ebcdic bs=1024000

m y
Note: In order to determine the if parameter for the dd command, use the df
command to find out the device name of the root partition.
d e
Answer:
c a
A
1. Enter the following to determine the filesystem of the root partition:

e
# df -h
Filesystem
c l
Size Used Avail Use% Mounted on
/dev/hda5
/dev/hda2
r a 25G
23M
14G 9.8G 58% /
4.0M 18M 19% /boot
none
/dev/hda1 O ly 506M
11G
0 506M 0% /dev/shm
6.1G 4.8G 56% /mnt/cdrive

l & On
2. Enter the following to generate the load. Provide the correct if parameter value

a e
based on the output of the above command.

n
t e r U s
# dd if=/dev/hda5 of=/dev/null conv=ebcdic bs=1024000

8) Stop the dd command by pressing [Ctrl] + [C]. Do not interrupt the catproc.sql

I n
script run. It should complete in order for the database objects to end up in a
consistent state.

c l e
9) Review the results recorded in the chart. Note the differences when the

r acatproc.sql script ran, and when the dd command executed.

O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 67
Solutions for Practice 9-2: Using Graphical Monitoring Tools
This practice enables you to install and use xosview to monitor CPU, memory, and disk
I/O.
1) Attempt to run xosview. This will fail because xosview is not installed by default.
Answer:
1. Enter the following at the OS prompt:
# xosview
-bash: xosview: command not found
#

2) Install xosview as root, using the xosview-1.8.2-1.i386.rpm file.


Answer:
1. As the root user, enter the following at the OS prompt:
# cd /home/oracle/labs
# rpm -ivh xosview-1.8.2-1.i386.rpm
warning: xosview-1.8.2-1.i386.rpm: V3 DSA signature:
NOKEY, key ID 4f2a6fd2
Preparing...
########################################### [100%]
1:xosview
########################################### [100%]
m y
#

3) Run xosview by entering the xosview command, as root.


d e
Answer:
c a
1. Enter the following, as root, at the command line:

e A
# xosview

c l
a
2. Note the graphic that appears, showing various statistics.
r
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 68
Solutions for Practice 9-2: Using Graphical Monitoring Tools (continued)

Remember that xosview is just one of many GUI performance monitoring tools for
the Linux operating system. Although GUI tools do not provide any information that
could not have been obtained through viewing the /proc virtual file system, they
can make monitoring your system much easier.
m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 69
Practice Solutions for Lesson 10: Tuning Performance

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 70
Solutions for Practice 10-1: Adjusting the SGA Size
Often increasing the size of the Shared Global Area (SGA) improves performance by
allowing more data to be resident in memory rather than having to be read from disk
frequently. In this practice, you will increase the size of the SGA.
1) Adjust the SGA size to at least 400 MB.
Note: If it is already greater than 400 MB, do not change anything.
Answer:
1. Start the browser by clicking the Web browser icon at the top of the screen.

2. Navigate to the following URL:


http://<machine name>:1158/em
3. Log in to Enterprise Manager as the SYS user with the password, oracle.
Connect as SYSDBA.
m y
4. Click Memory Parameters on the Administration tabbed page.
d e
c a
5. If the value for Maximum SGA Size is less than 400 MB, enter 400 for it, and
then click Apply. If it is already at least 400 MB, you can skip this step and the
remainder of this practice (10-1).

e A
l
6. Click Yes to confirm that the database is to be restarted.
c
r a
7. Enter oracle and oracle for the Host Username and Password, respectively.
Click OK, and then click Yes to proceed with the restart.

O ly
8. Click Refresh after a minute until the database is restarted. Then log in as SYS

& On
again, and check the maximum SGA size setting, to verify that it is now 400 MB.

l
a e
9. Enter 400 for the Total SGA size, and click Apply.

n
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 71
Solutions for Practice 10-2: Adjusting Block Sizes
You can select different block sizes for each tablespace, and that can affect performance.
This practice illustrates the difference in performance different block sizes can have,
depending on the type of activity on the tablespace.
1) Set the cache size to 128 MB for tablespaces with 2 KB block size.
Answer:
1. In Enterprise Manager (EM), click All Initialization Parameters on the
Administration tabbed page.
2. On the Initialization Parameters page, enter 2k in the Name field, and click Go.
3. For the db_2k_cache_size variable, enter 128M for the value, and then click
Apply.
2) Set the cache size to 128 MB for the 16 KB block size.
Answer:
1. Perform the same steps as for the 2k setting, except making the change to the
db_16k_cache_size variable.
3) Create the TS2 tablespace in ASM, which has a 2 KB block size, is NOLOGGING,
and is 128 MB in size.
Answer:

m y
1. Click Tablespaces on the Administration tabbed page.
2. On the Tablespaces page, click Create.
d e
c
3. Enter TS2 for the Name, and then click Add in the Datafiles section. a
4. Set the File Size to 128 MB, and then click Continue.

e A
5. Click the Storage tab.
6. Set the Block Size to 2048. c l
7. Click OK.
r a
O ly
Note: You can optionally run this statement in SQL*Plus:

l & On
CREATE SMALLFILE TABLESPACE "TS2" DATAFILE'+DF' SIZE 128M

n a e
LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT
AUTO BLOCKSIZE 2048

t e r U s
I n
4) Create the TS16 tablespace in ASM, which has a 16 KB block size, is NOLOGGING,
and is 128 MB in size.

l e
Answer:
c
r a1. Perform the same steps as you did for the TS2 tablespace, except naming it
TS16, and setting the block size to 16384.

O Note: You can optionally run this statement in SQL*Plus:

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 72


Solutions for Practice 10-2: Adjusting Block Sizes (continued)
CREATE SMALLFILE TABLESPACE "TS16" DATAFILE'+DF' SIZE 128M
LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT
AUTO BLOCKSIZE 16384

5) Run the lab_10_02_05.sql script to create and populate the T2 and T16 tables,
which are created in the TS2 and TS16 tablespaces, respectively.
Answer:
1. Enter the following at the OS prompt, as the oracle user:
$ sqlplus /nolog @lab_10_02_05.sql

6) Using SQL*Plus, turn on timing, and repeatedly select count(*) from each of
these tables using a WHERE clause that forces each row to be read. Compare the times
between each of the tables. Which is faster?
Answer:
1. Enter the following:
$ sqlplus hr/hr
SQL> set timing on
SQL> select count (*) from t2 where last_name like '%a%';

COUNT(*)
----------
668976
m y
Elapsed: 00:00:00.59
d e
SQL> select count (*) from t16 where last_name like '%a%';

c a
COUNT(*)
----------
e A
668976

c l
Elapsed: 00:00:00.36
SQL>
r a
O ly
7) Turn on SQL tracing for this HR session.
Answer:
l & On
a e
1. In EM, click Search Sessions on the Performance tabbed page.
n
click Go.
t e r U s
2. Change the search criteria filter to DB User, and enter HR for the value. Then

I n
3. In the Results list, click the SID value for the returned HR session.

l e
4. Click Enable SQL Trace at the top of the Session Details page.

c
5. Click OK to confirm it.

r a
8) Rerun each of the two statements once, putting in a comment to force a reparse of

O each statement.

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 73


Solutions for Practice 10-2: Adjusting Block Sizes (continued)
Answer:
1. Edit and rerun each of the statements to look similar to the following. It is
important to put a comment in to make the statement get reparsed. Run each of
the statements only once.

SQL> select /* 1 */ count (*) from t2 where last_name like '%a%';

COUNT(*)
----------
668976

Elapsed: 00:00:00.59
SQL> select /* 1 */ count (*) from t16 where last_name like '%a%';

COUNT(*)
----------
668976

Elapsed: 00:00:00.36

9) Use EM to view the statistics for each of these two statement executions.
Answer:
1. In EM, on the Session Details page, click the Activity tab.
m y
section labeled Detail for Selected 5 Minute Interval.
d e
2. Click the SQL ID that corresponds to one of the statements you just ran, in the

c a
3. On the SQL Details page, click the Statistics tab, and note the time-related
statistics.

e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 74
Solutions for Practice 10-2: Adjusting Block Sizes (continued)

4. Navigate to the session details page for the HR session.


m y
5. Click the General tab on the Session Details page.
d e
6. Click Previous SQL to see the other SQL statement.

c
7. Scroll down to see the data statistics for this statement execution. a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 75
Solutions for Practice 10-2: Adjusting Block Sizes (continued)

m y
fewer Buffer Gets.
d e
Note that the query against the T16 table takes up less CPU time, and performs far

c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 76
Solutions for Practice 10-3: Identifying Sessions in Linux
At times you need to correlate database sessions to specific processes running at the
operating system level. In this practice, you will identify a resource-consuming operating
system process, determine which database session it belongs to, and take action to correct
it.
1) Run the lab_10_03_01.sh script to generate some HR sessions that do some
work in the database.
2) Run the top command to see the oracle session that is consuming many system
resources. Find the session associated with that process, and kill it.
Answer:
1. Enter the following at the OS prompt to run the top command, and note the
highest resource-consuming process that is an oracle process. Watch it for
several seconds to clearly identify the oracle process that is consistently
appearing at the top of the list.
Note: The numbers you see will probably differ from those shown here.
$ top

top - 16:21:02 up 18 days, 8:52, 5 users, load average: 4.68,


2.50, 1.2Tasks: 167 total,
2 zombie
1 running, 164 sleeping, 0 stopped,

Cpu(s): 70.4% us, 15.3% sy, 0.7% ni, 0.0% id, 9.4% wa, 4.2% hi,
m y
0.0%
Mem: 1035320k total, 1028928k used, 6392k free, 1588k
d e
buffers
Swap: 2048276k total, 315516k used, 1732760k free,
c
656712k a
cached

e A
PID USER
3593 oracle
PR NI
17 0
c l
VIRT
497m
RES
79m
SHR S %CPU %MEM
75m S 50.6 7.9
TIME+ COMMAND
1:06.33 oracle
3377 root
.
0 -20

r a 0 0 0 D 7.0 0.0 8:01.79 loop1

.
. O ly
l & On
2. In Enterprise Manager, navigate to the Performance tabbed page.

a e
3. Click Top Activity in the Additional Monitoring Links region.
n
listed.
t e r U s
4. In the Top Sessions region, click the session ID for the most active HR session

I n
5. Click the General tab to verify that the OS Process ID for the Server process (to

c l e
the left of the page) matches that reported in the top output.
6. Click Kill Session, select “Kill immediate,” and then click Yes to go through with

r a the kill operation.

O 7. Note that the session is now expired, according to Enterprise Manager.

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 77


Solutions for Practice 10-3: Identifying Sessions in Linux (continued)
8. View the top output again, and ensure that the process in question is no longer
there.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 78
Practice Solutions for Lesson 11: Diagnosing Oracle
on Linux

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 79
Solutions for Practice 11-1: Install and Configure OS Watcher
OS Watcher is a utility that collects statistics about the operating system. It is useful for
gathering historical data for comparison and for providing OS information about your
system to Oracle Support Services. You will now install and configure OS Watcher, and
then run it, reviewing the results from the generated reports.
1) Install OS Watcher. Create a directory for OS Watcher named osw under the
/home/oracle directory. Extract the tar OSW.tar file, located in
/home/oracle/labs directory, into the new directory.
Answer:
1. Enter the following at the OS prompt, as the oracle user:
$ mkdir -p /home/oracle/osw
$ cd /home/oracle/osw
$ tar xvf /home/oracle/labs/OSW.tar
./
./oswnet.sh
./README
./Exampleprivate.net
./tarupfiles.sh
./OSWatcher.sh
./startOSW.sh
./stopOSW.sh
./OSWatcherFM.sh
./OSWg.jar
m y
./topaix.sh
./OSWgREADME
d e
./oswsub.sh
$
c a
A
2) Use startOSW.sh to start the tool. Provide parameters such that data is sampled
e
tool run as a background process.
c l
every 10 seconds, and the last 10 hours of data is logged to archive files. Make the

Answer:
r a
O ly
1. Enter the following at the OS prompt:

& On
$ nohup ./startOSW.sh 60 10 &

l
Answer:
n a e
3) Verify that the script is running by checking the Linux process listing.

e r s
1. Enter the following at the OS prompt, to list processes and search for OSW:
t U
oracle
I n
$ ps -ef | grep -i osw
6431 1 0 13:10 pts/4 00:00:00

c l e/usr/bin/ksh ./OSWatcher.sh 60 10
oracle 6454 6431 0 13:11 pts/4 00:00:00

ra
/usr/bin/ksh ./OSWatcherFM.sh 10
oracle 6621 4953 0 13:12 pts/4 00:00:00 grep -i

O osw
$

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 80


Solutions for Practice 11-1: Install and Configure OS Watcher (continued)

4) View the iostat report that has been created by OSW so far. The output is being
written to the archive directory where OSW has been installed.
Answer:
1. Enter the following to change to the archive directory and list the contents:
$ cd archive
$ ls -l
total 36
drwxr-xr-x 2 oracle oinstall 4096 Dec 13 13:11 oswiostat
drwxr-xr-x 2 oracle oinstall 4096 Dec 13 13:11 oswmeminfo
drwxr-xr-x 2 oracle oinstall 4096 Dec 13 13:11 oswmpstat
drwxr-xr-x 2 oracle oinstall 4096 Dec 13 13:11 oswnetstat
drwxr-xr-x 2 oracle oinstall 4096 Dec 13 13:10 oswprvtnet
drwxr-xr-x 2 oracle oinstall 4096 Dec 13 13:11 oswps
drwxr-xr-x 2 oracle oinstall 4096 Dec 13 13:11 oswslabinfo
drwxr-xr-x 2 oracle oinstall 4096 Dec 13 13:11 oswtop
drwxr-xr-x 2 oracle oinstall 4096 Dec 13 13:11 oswvmstat
$

2. Note the oswiostat directory. Enter the following to change to that directory
and view the collected data:
$ cd oswiostat
$ ls
m y
edt3r12p1.us.oracle.com_iostat_12.13.06.1300.dat
$ cat edt3r12p1.us.oracle.com_iostat_12.13.06.1300.dat
d e
c a
5) View the OSW generated output for other types of data you see in the archive
directory.
6) Stop OSW.
e A
Answer:
c l
r a
1. Enter the following at the OS prompt:
$ cd /home/oracle/osw
O ly
& On
$ ./stopOSW.sh

l
a e
r n s
n t e U
e I
c l
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 81
Solutions for Practice 11-2: Install and Configure RDA
The Remote Diagnostic Agent (RDA) collects information about your machine, operating
system, and database that can be useful for diagnosing problems. In this practice, you will
install it, run it, and view the output.
1) Install RDA. The file containing the software is
/home/oracle/labs/rda_4.5-060912.tar.gz. Extract it into the
/oracle/home directory.
Answer:
1. Enter the following at the OS prompt to extract the tar file, which, in effect,
installs RDA:
$ cd /home/oracle
$ tar xzf /home/oracle/labs/rda_4.5-060912.tar.gz

2. Note the new rda directory created under the current directory:
$ ls -l rda
total 112
-r--r--r-- 1 oracle oinstall 4087 Jul 6 04:58
DISCLAIM.txt
drwxr-xr-x 2 oracle oinstall 4096 Dec 13 13:33 hcve

y
drwxr-xr-x 2 oracle oinstall 4096 Dec 13 13:33 modules
drwxr-xr-x 4 oracle oinstall 4096 Dec 13 13:33 RDA
-r-xr-xr-x 1 oracle
-r-xr-xr-x 1 oracle
oinstall 3415 Apr
oinstall 40066 Sep
25
8
2006
11:03
rda.cmd

e
rda.pl m
-r-xr-xr-x 1 oracle
-r--r--r-- 1 oracle
oinstall 3442 Apr
oinstall 13103 Aug
25
4
2006
09:41 d
rda.sh

a
README_Unix.txt
-r--r--r-- 1 oracle
README_VMS.txt
oinstall 14539 Aug
A c
4 09:41

-r--r--r-- 1 oracle
README_Windows.txt
c l e
oinstall 13101 Aug 4 09:41

r a
2) Configure RDA by running the rda.pl script in the rda directory. For each
O ly
question, press [Enter] to accept the default, except for the following questions:

& On
Is INIT.ORA for the database to be analyzed located on this machine?
l
(Y/N)

n a e
Press [Enter] to accept the default (Y): n

e r s
Enter an Oracle User ID (user ID only) to view DBA_ and V$ tables. If
t U
RDA is run under the Oracle software owner’s ID, enter a “/” here, and

I n
select Y at the SYSDBA prompt to avoid being prompted for the database
password at run time.

c l e Press [Enter] to accept the default (system):/

r a Is “/” a sysdba user (will connect as sysdba) (Y/N)?


Press [Enter] to accept the default (N): y

O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 82
Solutions for Practice 11-2: Install and Configure RDA (continued)

Is ASM (Automatic Storage Management) in use (Y/N)?


Press [Enter] to accept the default (N): y
Is the ASM INIT.ORA located on this machine (Y/N)?
Press [Enter] to accept the default (Y): n
Is the Database Control for 10G in use on this node (Y/N)?
Press [Enter] to accept the default (N): y
3) After the last question is answered, the RDA runs. This takes several minutes. After it
is finished, note the URL for the HTML file to open and to view the results. Open this
file in the browser.
Answer:
1. In the browser, start a new tab by pressing [Ctrl] + [t], and then open the indicated
HTML file by entering the following URL:
file:///home/oracle/rda/output/RDA__start.htm
2. View the main page:

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
4) Under Overview > System Information what are the values for Total Physical

I n
Memory and Swap: In Use?

c l e
________________________ __________________________
5) Under Operating System Setup > Disk Drives, which drive partition contains swap?

r a________________________

O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 83
Solutions for Practice 11-2: Install and Configure RDA (continued)

6) Under ASM > File/Space Related Information > Files Stored in Diskgroup, what is
the fully qualified location of the SYSTEM tablespace?

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 84
Solutions for Practice 11-3: Using strace
In this practice, you will look at the output of the strace command. First you look at
the output of a simple shell script. Then you use strace on a running process and send
the output to a file.
1) View the contents of the helloworld.sh test script.
Answer:
1. Enter the following at the OS prompt, as the oracle user:
$ cd
$ cd labs
$ cat helloworld.sh
#!/bin/bash
echo "Hello World!"
exit

2) Execute the helloworld.sh script.


Answer:
1. Enter the following at the OS prompt:
$ ./helloworld.sh

y
Hello World!
$

e m
the output.
a d
3) Execute the helloworld.sh script using strace. After tracing the script, review

Answer:
1. Enter the following at the OS prompt: A c
$ strace ./helloworld.sh
c l e
$ strace ./helloworld.sh

r a
execve("./helloworld.sh", ["./helloworld.sh"], [/* 32 vars
*/]) = 0
O ly
uname({sys="Linux", node="edt3r12p1.us.oracle.com", ...})
= 0
brk(0)
l & On = 0x867f000

n a e
access("/etc/ld.so.preload", R_OK)
such file or directory)
= -1 ENOENT (No

.
t e r U s
open("/etc/ld.so.cache", O_RDONLY) = 3

.
.
I n
c l e
read(255, "#!/bin/bash \necho \"Hello World!\""..., 39) =
39
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0

r a fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 4),


...}) = 0

O mmap2(NULL, 4096, PROT_READ|PROT_WRITE,


MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7d49000

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 85


Solutions for Practice 11-3: Using strace (continued)

write(1, "Hello World!\n", 13Hello World!


) = 13
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
exit_group(0) = ?
Process 14548 detached
$

4) Trace the PMON process execution using strace. Send the output of the trace to the
/tmp/orcl_pmon.out file. Run the lab_11_03_04_a.sh script to find the
process ID of PMON.
Answer:
1. Enter the following at the OS prompt. Note that your PID is different from that
shown.
$ ./lab_11_03_04_a.sh
2841
$

2. Use the PID to run strace, by entering the following, substituting the
appropriate PID for your PMON process:

m y
$ strace -p 2841 -o /tmp/orcl_pmon.out &
[1] 14960
d e
[oracle@edt3r12p1 labs]$ Process 2841 attached - interrupt
to quit
c a
e
command. It is used in the next practice. A
5) View the output file by using the tail command. Do not cancel this tail

Answer:
c l
r a
1. Enter the following command at the OS prompt:

O ly
$ tail -f /tmp/orcl_pmon.out
.
.
l & On
.

n a e
read(19, "8655 (oracle) S 1 8655 8655 0 -1"..., 999) = 197
close(19)

t e r
kill(8659, SIG_0)
U s = 0
= 0

n
open("/proc/8659/stat", O_RDONLY) = 19

e I
read(19, "8659 (oracle) S 1 8659 8659 0 -1"..., 999) = 187
close(19) = 0

c l times(NULL)
times(NULL)
= 439078492
= 439078492

r a times(NULL) = 439078492
gettimeofday({1160845334, 130251}, NULL) = 0

O gettimeofday({1160845334, 130315}, NULL) = 0


poll(

Oracle Database 10g: Managing Oracle on Linux for DBAs B - 86


Solutions for Practice 11-4: Diagnosing ORA-600 and ORA-7445
Errors
In this practice, you investigate ORA-600 and ORA-7445 errors, which frequently
require diagnosis at the operating system level.
1) Force an ORA-600 error. Use the lab_11_04_01.sh script to generate the error.
Answer:
1. Enter the following at the OS prompt:
$ ./lab_11_04_01.sh

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Dec 13


16:01:47 2006

Copyright (c) 1982, 2005, Oracle. All rights reserved.

SQL> Connected.
SQL>
Table created.

SQL>
Session altered.

SQL>
1 row created.
m y
SQL> ERROR:
d e
ORA-00603: ORACLE server session terminated by fatal error

c a
e
Disconnected from Oracle Database 10g Enterprise Edition A
c l
Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options (with
complications)
$
r a
O ly
2) Force an ORA-7445 error. Do this by issuing a kill –11 command for the PID of
the PMON process.
l & On
Answer:

n a e
t e r s
1. Enter the following at the OS prompt, filling in the appropriate PID for your
system. You can run the lab_11_03_04_a.sh script again to find it out, if
U
needed.
I n
e
$ kill –11 2841

c l
3) In Practice 11-3, you started a strace of the PMON process, with the output being

r asent to a file, which is being viewed using the tail command. Look at the terminal
window that contains the tail of the strace. All of the strace was written to the

O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 87
Solutions for Practice 11-4: Diagnosing ORA-600 and ORA-7445 Errors
(continued)
output file, but it takes longer to scroll to the screen. In the window with the tail of
the strace output, press [Ctrl] + [C] to stop the tail output.
4) Now that both an ORA-600 and ORA-7445 have been generated, look at the alert
log file for the instance.
Answer:
1. Enter the following at the OS command prompt:
$ cd $ORACLE_BASE/admin/orcl/bdump
$ tail -15 alert_orcl.log
Errors in file
/u01/app/oracle/admin/orcl/udump/orcl_ora_16084.trc:
ORA-00603: ORACLE server session terminated by fatal error
ORA-00600: internal error code, arguments:
[kcoapl_blkchk], [4], [515], [2], [], [], [], []
Wed Dec 13 16:01:58 2006
Corrupt Block Found
TSN = 4, TSNAME = USERS
RFN = 4, BLK = 515, RDBA = 16777731
OBJN = 53303, OBJD = 53303, OBJECT = T, SUBOBJECT
=
SEGMENT OWNER = HR, SEGMENT TYPE = Table Segment
Wed Dec 13 16:41:58 2006
Errors in file
m y
/u01/app/oracle/admin/orcl/bdump/orcl_pmon_2841.trc:
ORA-07445: exception encountered: core dump [007BD7A2]
d e
[SIGSEGV] [unknown code] [0x42EC] [] []
Wed Dec 13 16:42:57 2006
c a
DBW0: terminating instance due to error 472

e
Instance terminated by DBW0, pid = 2847 A
[oracle@edt3r12p1 bdump]$

c l
file.
r a
5) Note that each of the entries for the ORA-600 and ORA-7445 errors point to a trace

O ly
6) By killing the PMON process, you caused the database instance to crash. Restart it.
Answer:
l & On
a e
1. Enter the following at the OS prompt:
n
t
SQL> startup
e r
$ sqlplus / as sysdba

U s
n
SQL> exit

I
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 88
Solutions for Practice 11-4: Diagnosing ORA-600 and ORA-7445 Errors
(continued)
7) Run the RDA script to have it collect data about the trace files that were just
generated.
Answer:
1. Enter the following at the OS prompt:
$ cd /home/oracle/rda
$ ./rda.pl
----------------------------------------------------------
---------------------
RDA Data Collection Started 13-Dec-2006 04:56:52 PM
----------------------------------------------------------
---------------------
Processing Initialization module ...
Processing CFG module ...
Processing Sampling module ...
.
.
.

8) After rda.pl finishes running, open the following URL in a browser:


file:///home/oracle/rda/output/RDA__start.htm
9) Click RDBMS Log/Trace Files. Note the Last Errors section. These are the trace files
m y
d e
for both the ORA-600 and ORA-7445 errors. To find the file names of the specific
trace files for each error, click Alert.log, and then locate the errors, noting the trace
file names.
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs B - 89
m y
d e
ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
___________________

Appendix C
Basic Linux and
vi Commands
___________________

m y
d e
ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
vi Commands

The Visual Interpreter/Editor (vi) is the most widely used text editor available for the UNIX environment.
Although almost everybody curses its unwieldy command syntax, it is still the only editor almost certain
to be included with every version of the UNIX and Linux operating system. The following is a partial list
of available vi commands.

vi has two modes. Command line (where anything typed is taken as an editing command) and input mode
(where everything typed will be treated as part of the file being edited. To enter input mode, type a, A, i,
I, o, O, c, C, s, S, r, or R. To return to command-line mode, use the <ESC> key. To access the vi editor
from SQL*Plus, enter the following command:

SQL> define _editor=vi

To edit a file from the SQL*Plus prompt, type edit <filename> and press [Enter]. To edit a file
from the Linux command prompt, type vi <filename> and press [Enter].

To MOVE the cursor:

h - move left j - move down k - move up l - move right

w - one word forward b - one word backward e - end of current word

W, B, or E - same as lowercase but ignores punctuation

m y
0 (zero) - Move to the beginning of current line $ - move to the end of current line

d e
G - go to last line of file

L - go to last line on screen


H - go to top line on the screen

M - go to bottom line on the screen


c a
e
/<string> - search forward to the next occurrence of <string> A
c l
?<string> - search backward to the next occurrence of <string>

n - repeat previous search


r a N - repeat previous search in opposite direction

<ctrl> f - scroll forward one page O ly <ctrl> b - scroll backward one page

To UNDO previous changes:


l & On
n
u - undo the most recent change a e U - undo the most recently deleted text

t e r U s
:e! - re-edit current file without saving any changes made since last change

To ENTER NEW text:


I n
l e
a - append text after the current cursor position.

c
r aA - append text to the end of a line (jumps to end of line and begin appending).

O c - change object C - change from current cursor position to end of the line

Oracle Database 10g: Managing Oracle on Linux for DBAs C - 2


i - insert text before the current cursor position. I - insert text at the beginning of a line.
o - insert a blank line BELOW the current cursor position.

O - insert a blank line ABOVE the current cursor position.

r - replace character at current cursor position R - replace all characters until <ESC> is pressed

s - substitute text for character under cursor

:s/A/B/opt substitutes string B for string A. %s/A/B/opt is global replace

options include: g (change all occurences on current line) c (confirm prior to each change)

p (print changed lines) S - Substitute entire line to the end

. <period> - repeat last change n. <integer><period> repeat last change n times

To leave the input mode, press <ESC>

To DELETE existing text:

x - delete the character directly under the current cursor location.

dd - delete the entire line where the cursor is located.

dnd (where n is some integer) delete n lines from current cursor position

m y
dw - delete current word D - delete to end of current line

d e
J - delete return at end of current line. Join this line and the next

<int> J - join the next <int> lines


c a
e A
COPY, CUT, and PASTE: vi uses a single buffer where the last changed or deleted text is stored. This text may be
manipulated with the following commands:

c l
Y - yank a copy of the current line
r a y <integer> - yank a copy of next <int> lines

yw - yank a copy of the current word


O ly yb - yank a copy of the previous word

l & On
p - put buffer contents after cursor P - put buffer contents before cursor

a e
Also, see the s and S commands under the input section

n
t e r U s
To SAVE edited changes to an operating system file:

I n
zz - terminate edit mode. :w filename - save changes to the filename specified.

c l e
:wq - write all changes and quit the edit mode

To QUIT without saving changes:

r aZZ - terminate edit mode. :q! - terminate the file without saving changes.

O
Oracle Database 10g: Managing Oracle on Linux for DBAs C - 3
Basic Linux Commands

This appendix is meant to serve only as a quick reference while you are in class. For more details about
these commands, consult the man pages, your Linux documentation, or other Linux command reference
books.

Files and Linux Commands Description/Comments


Directories
Command man <command> Finds the manual entry for this
manual <command>.
man –k <string> Shows all the manual entries that
contain this <string>.
man man Displays the manual page for man.
Command info <command> Shows the information system
information entry for this command. Using
info info shows a tutorial of the
info documentation system.
Print to cat <file> Prints the named file to the
standard out terminal screen.
List users cat /etc/password
Change cd <directory> Changes the working directory to
working
directory
specified directory.
cd with no parameters changes to
m y
Copy a file cp <source_file>
$HOME.
d
Copies a source file to ae
<destination_file>

c
destination file.
a
View a file
A
Views a file a page at a time. This
less <file>
is a GNU version of more or pg.
View a file more <file>

c l e Views a file a page at a time (BSD


version)
List directory ls <directory>
r a Options –l provides long listing,

O ly -R recursive, -a shows hidden

l & On files, -t sorts by time, -r reverses


sort. The default directory is the

Create a
n a e current working directory.
Makes a directory default into the
r
mkdir <directory>
directory
t e U s current working directory; full
path may be specified.
Move or
rename a file I n
mv <old_file> <new_file> Changes the name of a file or
moves it to a different directory.

c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs C - 4
Process List ps Shows the processes report.
ps -ef Shows all processes on the system
with a full listing. Many options
exist. See the man page for details.
Print working pwd Prints to stdout the current
directory working directory.
Remove or rm <file> Removes a file. Removing a file
erase a file on Linux is permanent. Options
are: –r recursive, and –f force
(including subdirectories) are very
dangerous. Often the rm
command is aliased with rm –i
The option –i asks “Are you
sure?”
Create an empty touch <file> Creates a file.
file
Name of the hostname Returns the name of the machine
machine
The IP address host <machine_name> Queries the Domain Name Server,
m y
of the machine
e
and returns the IP address of the
machine name.
d
Remote shell rsh <host> <command> Executes a <command> on

c a
<host>. rsh is not secure. Use

Remote shell
e
ssh instead.
A
Invokes a secure shell, which has
l
ssh <host>

a c features to replace rsh, rcp,


ftp, and telnet.
Remote shell telnet <host> r
O ly
Starts a terminal session on
<host>. telnet is not secure;

Search a file for grep


l
<option>& On
<pattern> <file>
use ssh instead.
Searches a <file> or stream for a
a pattern
n a e regular expression defined by

t e r U s
<pattern> and show the line that
contains that pattern. A common
option is –i for case insensitive.

I n grep can accept input from a file

c l e
Source a script . <script_file>
or stdin through a pipe as in:
netstat –a| grep ESTABLISHED
In the bash shell, this command ‘.’

r a forces the script to run in the shell.

O Normal behavior is for the script


to run in a child shell.

Oracle Database 10g: Managing Oracle on Linux for DBAs C - 5


An interpreter awk This is a macro language for
reformatting or interpreting input.
For each line of input, a variety of
actions can be taken. May be
referred to as nawk – for “new
awk.”
Sort a file sort Sorts a file. Takes input from stdin
or a filename argument. There are
many options to sort by a
particular column, field, and so on.
See the man page.
Command line sed sed is a command-line editor,
editor with many possible commands and
options that are very good for
editing from a shell script.
Visual editor vi <file> Terminal-based editor available on
every UNIX system, Linux
provides vim, an improved vi,
that is a superset of vi.
m y
Gnu editor emacs <file>

d e
A GPL editor with extensive
customizable features available on
most UNIX and Linux
distributions
c a
WSIWIG editor gedit <file>

e A
A full-screen editor, requiring X.

WSIWIG kate <file>


c l Available under Gnome.
A full-screen editor, requires X.

Terminal output stdout r a Available under KDE.


Standard out (stdout), is not a
O ly command but a concept. Most

l & On Linux commands write to


stdout by default unless

n a e redirected.
Terminal input stdin
(keyboard)
t e r U s Standard in (stdin), is not a
command but a concept. Most

I n Linux commands read from


stdin by default unless

c
Alias l e alias <command> <alias>
redirected.
Makes a substitution. When a user

r a types <command>, <alias> is


substituted. A common alias is

O alias ‘rm’ ‘rm –i’.

Oracle Database 10g: Managing Oracle on Linux for DBAs C - 6


Aliases are often set in the
.bashrc file.
Show shell set Prints all the variables that are
variables currently defined in the shell.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs C - 7
Show printenv or env Prints all the environment
environment variables. An environment
variables variable has been “exported” so
that it will be inherited by child
processes.
File Creation umask –S u=rwx,g=rx,o=rx Sets the default permissions for all
mask files created by this shell or its
children. The –S option uses the
symbolic notation, the numeric
notation is obsolete.
Clock xclock An X client that shows a clock on
the screen. Often used to test the X
windows system.
X access xhost Shows the current access control
control xhost +<Xclient> in place.
Add an X client that is allowed to
access the local DISPLAY. If no
<Xclient> is given, all are
allowed.

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs C - 8
System Linux Commands Description/Comments
Administration
Root file system / The root directory for the system
directory tree
Home Directory /home Typically the directory in which
all user home directories are
placed (for example,
/home/oracle)
Tmp directory /tmp A temporary storage area. Do not
put anything here you want to
keep. System Administrators often
have a cron job to remove
everything periodically.
Boot directory /boot A small partition to hold the kernel
images and boot loader
instructions.
Log directory /var/log The location of most system log

Sample /etc/inittab
files.

m y
Configuration files are located per
configuration
files
d e
the application. Any configuration
file that you change after

the backup. c a
installation should be included in

Password files /etc/passwd

e A
The /etc/passwd file holds

l
/etc/shadow
user information and must be

a c readable by others; even with


encrypted passwords this can be a
r
O ly
security hole. The /etc/shadow
file holds the encrypted passwords

Groups file /etc/group


l & On and is readable only by root.
The /etc/groups file defines

n a e the groups on a server and the

t e r U s users that are members of the


group; primary group for a user is
defined in the /etc/passwd

I n file.

file
c l e
X configuration /etc/X11/XF86Config The file that sets the X server
settings for your video card,

r a monitor, mouse, and keyboard.


Usually set up with a vendor-

O supplied tool, such as sax2.

Oracle Database 10g: Managing Oracle on Linux for DBAs C - 9


Schedule a crontab -e Use this command to edit the
command to run crontab file, to create the
at a regularly specification for the cron daemon
scheduled time to use.
Schedule a /etc/anacrontab Edit the file to specify a script to
script to run at a run at a particular frequency. (See
particular man anacrontab for details.)
frequency
Schedule a at <options> TIME Runs a job specified by <options>
command to run at a specified TIME parameter.
at a single
specified time
Schedule a batch <options> <TIME> Run a command when the load
command average drops below .8, optionally
after a set TIME.
Mount a file mount <opt> <dev> <mount_point> Mount a file system on device
system <dev> at <mount_point> with the

Unmount a file umount <dev>


options specified by <dev>.
Unmount the file system or device.
m y
system umount <mount_point>

Maximum # of 65535
d e
user ID
Recover root {lilo} c a
This is a procedure to recover the
password control-x
linux S
e A
root password if it is lost. This
passwd root

c l requires physical access to the


machine and system console. You

r a start by rebooting the machine,


then during the LILO boot, press
{grub} O ly and hold [Ctrl] + [X] to get a
c

l & On prompt and command LILO to


kernel vmlinuz-2.4.9-13 single boot Linux to runlevel S.

n a e
ro root=/dev/hda8
initrd /initrd-2.4.9-13.img The second procedure uses the
boot

t e r
passwd root

U s grub boot loader.

I n
Create new user useradd The –D option alone shows the
defaults.

c l e –D with other options changes the


defaults options; without –D

r a override, the default (for example,

O –g) sets a primary group.

Oracle Database 10g: Managing Oracle on Linux for DBAs C - 10


Delete user userdel Remove a user and optionally all
files belonging to the user.
Modify user usermod Change the /etc/password
account information.
Create new groupadd –g sets the group ID; default is
group first free value above 500.
Delete group groupdel Remove a group from the system.
May not remove a group that is a
primary group for a user. Files
owned by deleted group must be
manually changed with chown.
Change run init <runlevel> The init command causes the
levels rcN.d scripts to be evaluated, for
the change in run level. init 6
forces a reboot.
Synchronize the sync Forces the buffer cache and page
disks
y
cache to write all dirty buffers to
disk. Used just before a reboot to
prevent disk corruption.
m
Shutdown the
Linux system
shutdown <mode> <delay>

d e
Do a graceful shutdown of the
system, shut down processes, run

c a
all shutdown scripts, and sync

e A
disks. The modes are –r, reboot
and –h, halt. The delay is a

c l required parameter is a number in


seconds or ‘now’. Option

r a shutdown warning message may


be sent as well.
Error logs dmesg
O ly View boot messages. This log is

l & On circular, and limited system errors


could overwrite boot information

n a e after a time.
Network IP
configuration
t e
scripts/
r U s
/etc/sysconfig/network- This directory holds scripts
executed as part of the boot up

Hosts IP
I n
/etc/hosts
sequence by rc.sysinit.
A list of hosts that your machine

c l e
addresses knows about. It must, at minimum,
include the name of the local

r a
Name service /etc/nsswitch.conf
machine and loopback IP.

O switch

Oracle Database 10g: Managing Oracle on Linux for DBAs C - 11


Network sysctl -a | grep net View all net parameters that are
parameters set for the kernel.
Routing routed
daemon
NIC ifconfig -a Show all the network devices
Configurations currently configured.
Secondary IP modprobe ip_alias
Address ifconfig eth0:1 IP
Login prompt /etc/issue Banner message user sees when
issued the login prompt.
YP/NIS service /sbin/ypbind Finds and attaches to an NIS
binder server for name resolution and
other services.
Module modinfo <options> <module> Display information about kernel
information modules: –l shows license, –p
parameters, –d description.
List modules
Load module
lsmod
insmod
Show currently loaded modules.
Load a loadable module.
m y
Unload module
Install Software
rmmod
rpm -ivh package
d e
Unload a loadable module.
Install -i, verbose –v, with

Uninstall c a
progress hash marks –h.

A
Erase package –e; will not
rpm -e package
software uninstall if dependencies exist.
List installed
software
rpm -qa

c l e Query -q, All –a, lists all


installed packages.
Verify installed rpm -V package
r a Compares installed files with the
software
List all files O ly
rpm -ql package
rpm database information.
List all the files that are part of a

l & On package.
Package owner rpm -qf file

n a e List the package when given the


full file name.
Machine model uname -m

t e r U s Shows CPU level (for example,


i686)
OS Level
Run Level I n uname -r Shows kernel version
Shows previous and current
e
runlevel

c
Kernell runlevel
Show settings of all settable kernel
a
sysctl -a

O rParameters
Max # File
Descriptors
sysctl fs.file-max
parameters.
Shows the value of maximum number
of file descriptor per process.

Oracle Database 10g: Managing Oracle on Linux for DBAs C - 12


Kernel /etc/sysctl.conf Compiled in kernel parameters;
parameter may be reset at bootup by setting
settings them in this file
Change Kernel echo <value> > </proc/<file> Write the new value of a kernel
Parameter parameter into the /proc file
system.
echo 2147483648 Set the value of the maximum size
>/proc/sys/kernel/shmmax of a shared memory segment.
Shared Memory sysctl kernel.shmmax Show the shmmax parameter.
Change Kernel sysctl –w <parameter>=<value> Change a kernel parameter; the –p
Parameter option reads the setting from a file
and sets them. The default file is
/etc/sysctl.conf.
Set Process ulimit <option> <value> Set limits on a shell and processes
limits started by the shell. Users can
make limits more restrictive;
generally only root can make limit
less restrictive; some options

m y
require root privilege. Options: –u

d e
sets number of processes, –n
number of file handles; many

Show process ulimit c a


others (see man bash).
Without options ulimit show the
limits

e A
current limit settings.
Interprocess
Communication
ipcs <option>

c l Options: –m the current usage of


shared memory; –s usage of
(Shared
Memory and r a semaphores; –a shows all.

Semaphores)
O ly
Remove a
shared memory & On
ipcrm shm <shmid>

l
Releases the shared memory
segment identified by <shmid>.
segment
n a e This is very dangerous. You can

t e r U s corrupt a database that is using the


segment that is released.

I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs C - 13
System Linux Commands Description/Comments
Performance
Performance top View real-time OS and process
monitor statistics.
System activity sar –<options> <interval> Options: –q shows CPU queue, –
reporter <count> u CPU utilization, –d device
activity, –n DEV network device
activity, many more (see man
page). Interval is in seconds.
Virtual Memory vmstat <interval> <count> Interval is in seconds.
statistics
Virtual Memory cat /proc/meminfo Shows instantaneous virtual
statistics memory usage.
Kernel Cache cat /proc/slabinfo Kernel slab allocator statistics:
statistics frequently allocated cache objects
such as inode, dentries, and
asynchronous IO buffers.
I/O statistics iostat <option> <interval>
<count>
Options: –d device activity, –c
CPU activity, –x extended disk
m y
e
activity statistics. The interval is in
d
Multiprocessor mpstat –P <cpu> <count>
seconds.

c a
Return CPU statistics for
Statistics <interval>

e A
particular processor or all CPUs in
an smp system.
Physical RAM 64 GB(Theoretical)
c l Maximum physical RAM requires
enterprise kernel
Swap device swapon -s
r a Shows devices currently in use for

O ly swap. The swap device is arbitrary


designated at install. It may be

l & On changed or added to. Multiple


swap devices may be created;

n a e swap size should be at least as

t e r U s large as physical memory.

I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs C - 14
Display swap free Show the current memory and
size swap usage.
Activate Swap swapon -a Turn on swap.
Free disk blocks df -k Measured in KB; use –m for MB
units.
Device listing cat /proc/devices List devices known to the system
by major and minor number.
Disk cat /proc/scsi/scsi0/sda/model View SCSI disk information.
information
cat /proc/ide/ide0/hda/model View IDE disk information.
Print network netstat <options> Print a wide variety of network
statistics statistics (see man netstat).
Graphical xosview An X-based display of recent OS
system statistics statistics.
viewer

m y
d e
c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs C - 15
Misc System Linux Commands Description/Comments
Information
NFS exported /etc/exports Database file is not supported on
simple NFS.
NFS Client /var/lib/nfs/xtab
mounted
directories
Max File 2 TB with 4KB block size (on 32 With ext3 and ext2, others vary
System kernel)

Max File Size 2 GB {512B block size} The Oracle database can create
files up to 64 GB with a 16 KB
File size can not database block size.
exceed file
system 2 TB {4KB block size} The 32-bit kernel limits file and
block devices to 2 TB.
File System dumpe2fs <device> Dump the file system properties to
Block size
y
stdout.
Filesystem table /etc/fstab Mounts these file systems at

Journal
bootup
e m
d
ext3
Filesystem
types reiserfs

c a
Disk Label fdisk -l

e A
fdisk is not available on all
distributions.
Extend File
system
resize2fs

c l Extending a file system is


applicable to only some file
a
resize_reiserfs

Backup r
O ly
tar cvf /dev/rst0 /
system types.
Create a backup of the root / file
system.
Restore
l & On
tar xvf /dev/rst0 Restore the root / file system.
Prepare boot
volumes
/sbin/lilo

n a e Must be run after changing


/etc/lilo.conf to push

Startup script
t e r
/etc/rc.d/rc
U s changes to boot loader.

Kernel
I n
/boot/vmlinuz

c l e
Kernel Bits getconf WORD_BIT POSIX call to get kernel
information. There are many other

r a variables besides WORD_BIT.

O
Oracle Database 10g: Managing Oracle on Linux for DBAs C - 16
Boot single user {lilo} Use LILO facility.
control-x
linux S

{grub}
c Use GRUB Boot Loader.
kernel vmlinuz-2.4.9-13 single
ro root=/dev/hda8
initrd /initrd-2.4.9-13.img
boot

Time zone /etc/sysconfig/clock


Management
SW Directory /var/lib/rpm Directory where rpm database is
kept.
Devices /dev This directory holds all the device
files.
CPU cat /proc/cpuinfo Shows CPU static information.
Whole Disk /dev/sda Device name
CDROM
CDROM file
/dev/cdrom
iso9660
Usually mounted at /mnt/cdrom

m y
type
Floppy drive Usually mounted at d e
a
/dev/fd0

System
information
/proc
/mnt/floppy

A c
The /proc file system is a
memory-based file system that

c l e allows access to process and


kernel settings and statistics.
Compile and
link a r a
make –f <file> <command> Use a make file <file> to
determine which parts of a large
executable O ly program need to be recompiled,

l & On and issue the commands required


to compile, link, and prepare the

n a e executable for use.

t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs C - 17
LVM Linux (UnitedLinux) Description/Comments
LVM Logical Volume Manager This is provided in Enterprise Linux.
LVM Concepts logical extents A logical volume is made up of logical
extents.
logical volume A set of logical extents taken from a volume
group and presented to the OS as a disk
volume. These extents may be striped across
multiple disks.
volume group A set of physical disk partitions created by
fdisk or the like, initialized with
pvcreate, then grouped into a physical
volume with vgcreate.
Display volume vgdisplay -v
group
Modify physical pvchange
volume
Prepare physical pvcreate
disk
List physical pvdisplay
m y
volume
Remove disk vgreduce
d e
from volume
group c a
Move logical pvmove

e A
volumes to
another physical
c l
volumes
Create volume vgcreate r a
group
O ly
Remove volume vgremove
group
l & On
Volume group vgchange
n a e
availability

t e r
Restore volume vgcfgrestore
U s
group
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs C - 18
Exports volume vgexport
group
Imports volume vgimport
group
Volume group vgscan
listing
Change logical lvchange
volume
characteristics
List logical lvdisplay
volume
Make logical lvcreate
volume
Extend logical lvextend
volume
Reduce logical lvreduce
volume
Remove logical
volume
lvremove

m y
Create striped lvcreate -i 3 -I 64

d e
volumes

c a
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs C - 19
m y
d e
ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Index

m y
d e
ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
A
Alert 2-11, 11-15, 11-16, 11-17
anacron 7-14, 7-15
Archive 10-6, 11-3, 11-4, 11-7
ASM 1-22, 3-13, 4-3, 4-6, 4-9, 5-3, 5-4, 5-5, 5-7, 5-8,
5-9, 5-10, 5-11, 5-12, 5-13, 6-2, 6-4, 6-5, 6-6, 6-8, 6-9,
6-13, 6-18, 6-19, 7-3, 7-8, 7-10, 7-11, 7-18, 7-19, 11-10
+ASM 1-22, 6-8, 6-9, 6-13, 7-10
ASM Instance 5-3, 5-7, 5-8, 5-9, 5-10, 5-12, 5-13, 6-4, 6-8,
6-13, 7-3, 7-8, 7-11, 11-10
ASMLib 5-2, 5-4, 5-5, 5-7, 5-9, 5-12, 5-13
ASMM 10-12
Audit 6-9
Automatic Shared Memory Management 8-12, 10-3, 10-12
Automatic Storage Management 1-3, 3-12, 3-13, 4-3, 4-6, 4-9,
5-1, 5-2, 5-3, 5-4, 5-7, 5-8, 5-9, 5-10, 5-11, 6-4, 7-18
B
BACKGROUND_DUMP_DEST 11-15, 11-16, 11-17
m y
Block 4-12, 7-16, 8-13, 8-21, 9-5, 10-3, 10-4, 10-5, 10-16, 11-14
d e
Buffer cache 8-14, 8-17, 8-20, 8-21, 9-21, 9-23, 9-29, 10-3, 10-5,
ca
C
10-9, 10-12

e A
Channel 3-30, 10-9
c l
chkconfig 7-8, 7-12
r a
CKPT 6-13, 9-4
Cluster 4-3, 4-6, 4-9, 4-11 O ly
CMAN 3-28
l & On
COMPATIBLE 3-6, 4-12
n a e
CORE_DUMP_DEST 11-16
t e r U s
Configuration assistant 3-24, 5-3, 5-8, 5-9, 7-10

Corruption 4-7
I n
c l e
CPU_COUNT 10-9
cron 7-14, 7-15
D
r a
O Data file 3-12, 4-7, 10-3

Oracle Database 10g: Managing Oracle on Linux for DBAs Index - 2


D
Database Control 2-21, 6-11
Database writer 10-3
DB_BLOCK_BUFFERS 8-13, 8-21
DB_BLOCK_SIZE 10-4
DB_CACHE_ADVICE 10-3
DB_CACHE_SIZE 8-12, 8-13, 8-21, 10-9
DB_WRITER_PROCESSES 10-8, 10-9, 10-10
DBA 2-21, 2-25, 2-26, 2-27, 2-28, 2-29, 3-3, 3-4, 3-18, 3-19,
5-5, 6-11, 6-17, 7-8, 7-13
DBCA 5-8, 6-3, 6-6, 6-7, 7-10
dbshut 7-10, 7-11, 7-21
dbstart 7-10, 7-11, 7-21
DBWn 8-15
DBWR_IO_SLAVES 10-8, 10-10
Dedicated server 2-12, 6-15, 6-16
disk group 5-3, 5-11, 6-6
DISPATCHERS 6-15
m y
DML 10-6
d e
E
c a
emctl 6-11, 7-3
A
Enterprise Manager 2-21, 3-20, 6-7, 6-10, 6-11, 7-16, 7-18, 8-18,
e
9-7, 10-3
c l
r a
Enterprise Manager Database Control 2-21, 6-11
Environment variable 3-7, 3-13, 3-14, 3-19, 3-20, 3-27, 3-30
EVENT 1-6, 10-6, 10-7 O ly
l & On
ext3 4-3, 4-4, 4-6, 4-10, 10-4, 10-13
ext2 4-10
n a e
F

t e r U s
Factor 1-22, 9-8, 9-10, 9-11, 9-19, 9-29
fdisk 5-6
I n
H
c l e
Flash recovery area 5-8, 5-11, 6-5, 6-6

r a
hugemem 1-9, 8-22, 10-14

O
Oracle Database 10g: Managing Oracle on Linux for DBAs Index - 3
H
hugepages 8-2, 8-11, 8-12, 8-13, 8-20, 8-21, 8-23, 9-24, 9-28,
9-29, 10-4
I
Index 9-19, 9-37, 10-5
Initialization parameters 7-19, 8-20, 8-21, 10-2, 10-8, 10-15
Instance 1-16, 1-22, 2-7, 2-9, 3-16, 3-18, 3-19, 3-26, 3-30,
4-9, 5-2, 5-3, 5-7, 5-8, 5-9, 5-10, 5-12, 5-13, 6-4, 6-8,
6-9, 6-10, 6-13, 6-14, 6-15, 7-3, 7-8, 7-11, 7-16, 7-17, 7-18,
7-19, 8-12, 8-13, 8-17, 8-18, 8-20, 8-21, 9-17, 9-21, 10-3, 10-10,
10-12, 11-10
iostat 9-4, 9-5, 9-13, 9-16, 9-30, 9-33, 9-34, 9-39, 11-3, 11-5,
11-6
IPC 9-28
iSQL*Plus 3-24, 6-10, 6-11, 7-3
isqlplusctl 3-24, 7-3
J
m y
Java pool 10-12
JAVA_POOL_SIZE 9-29
d e
job 2-30, 7-16, 7-18, 10-12
c a
K

e A
c l
kernel 1-2, 1-5, 1-6, 1-7, 1-8, 1-9, 1-10, 1-11, 1-16, 1-17,
1-28, 1-29, 2-3, 2-4, 2-5, 2-6, 2-7, 2-8, 2-10, 2-11, 2-18,

r a
2-21, 3-30, 4-6, 5-5, 5-6, 5-9, 7-4, 7-5, 7-7, 8-7, 8-9,

O ly
8-10, 8-12, 8-13, 8-14, 8-15, 8-16, 8-18, 8-20, 8-22, 9-6, 9-22,

L l & On
9-24, 9-27, 9-28, 10-13, 10-14, 11-15

Large pool 10-10, 10-12


n a e
e r s
Listener 3-28, 6-15, 7-3, 7-8, 7-11, 7-13, 8-18
t U
Lock 7-9, 9-28
LOCK_SGA 9-28 I n
l e
LOG_BUFFER 10-6, 10-7
c
M
r a
meminfo 1-16, 8-2, 8-7, 8-13, 8-23, 8-24, 9-21, 9-22, 9-23,
O 9-24, 11-5

Oracle Database 10g: Managing Oracle on Linux for DBAs Index - 4


M
Metric 9-10, 9-34
MMAN 6-13
MTTR 7-17
N
NLS 3-19
nobody 2-30
O
ocfs2 4-3, 4-6, 4-11
ofa 3-10, 3-11, 3-12, 3-13, 3-14, 3-19
OINSTALL 1-15, 2-25, 2-26, 2-27, 2-28, 2-29, 3-3, 3-4, 3-5,
3-15, 6-9, 6-12, 8-12
opatch 3-26, 3-27, 3-29
Optimizer statistics 9-19
Oracle Net 2-12
ORACLE_BASE 3-14, 3-15, 3-16, 3-19, 3-23, 3-24, 3-30, 6-8, 6-9
ORACLE_HOME 3-9, 3-13, 3-14, 3-15, 3-16, 3-17, 3-18, 3-19, 3-20,
m y
3-26, 3-27, 3-28, 5-8, 5-10, 6-7, 6-10, 6-11, 6-12, 7-10, 7-11,
7-17, 7-19, 8-19
d e
ORACLE_SID 3-7, 3-17, 3-18, 3-19, 6-9, 6-12, 7-10, 7-11
c a
oracleasm 1-11, 5-5, 5-7, 5-9

e
orcl 1-22, 3-7, 3-13, 3-17, 3-18, 6-8, 6-9, 6-10, 6-12, 6-13, A
c l
6-14, 6-15, 7-10, 7-19, 11-13, 11-15, 11-16

r a
OUI 2-22, 2-23, 3-8, 3-15, 3-16, 3-19, 3-22, 3-26, 3-30, 6-12
P
O ly
9-6, 9-7
l & On
Package 1-6, 1-14, 2-2, 2-17, 2-18, 2-19, 2-31, 2-32, 8-22,

n a e
partition 3-13, 4-3, 4-4, 4-5, 5-3, 5-6, 5-9, 9-21, 9-31,
9-33, 9-34

t e
Password 2-25, 2-29, 6-17
r U s
I n
Performance 1-3, 3-10, 3-11, 4-3, 4-6, 4-7, 4-9, 4-10, 5-3,

l e
5-11, 7-17, 8-7, 8-9, 8-10, 8-11, 8-20, 8-21, 9-3, 9-4, 9-6,

c
9-7, 9-8, 9-9, 9-12, 9-13, 9-15, 9-21, 9-27, 9-29, 9-30, 9-31,

r a 9-32, 9-34, 9-36, 9-37, 10-3, 10-4, 10-5, 10-6, 10-7, 10-8, 10-11,

O 10-12, 10-13, 10-14, 10-16, 11-3, 11-8

Oracle Database 10g: Managing Oracle on Linux for DBAs Index - 5


P
PGA 8-17, 9-29
PGA_AGGREGATE_TARGET 9-29
Pipe 1-18, 1-21, 1-25, 9-7
PMON 1-22, 6-13, 8-15, 9-4, 11-13
PRE_PAGE_SGA 10-8, 10-11
Privilege 2-25, 3-3, 6-17, 9-28
Procedure 3-15, 7-16, 8-17, 8-19
PROCESSES 1-14, 1-25, 2-6, 2-9, 2-10, 2-11, 2-12, 2-13, 2-14,
2-16, 3-26, 4-4, 6-13, 6-14, 6-15, 6-16, 7-3, 7-8, 7-13, 8-3,
8-4, 8-8, 8-15, 8-16, 8-17, 8-18, 8-22, 9-4, 9-5, 9-7, 9-10,
9-11, 9-12, 9-13, 9-14, 9-16, 9-17, 9-18, 9-19, 9-22, 9-23, 9-24,
9-29, 10-3, 10-6, 10-7, 10-8, 10-9, 10-10, 10-14, 11-2, 11-3, 11-13,
11-19, 11-20
Profile 3-7
pstree 9-7, 9-9
R
Recovery Manager 7-17, 7-18
m y
Redo 2-11, 2-13, 3-12, 4-7, 9-37, 10-3, 10-6, 10-7
d e
Redo log buffer 10-3
c a
relink 3-28, 3-29, 8-17
REMOTE_LOGIN_PASSWORDFILE 6-17
e A
Resource Manager 9-19
c l
RMAN 3-28, 7-16, 7-17, 7-18
r
rpm 1-6, 2-17, 2-18, 2-19, 5-5, 10-13
a
Rule 8-18, 9-37 O ly
runInstaller 3-22
l & On
a e
runlevel 2-5, 7-5, 7-6, 7-7, 7-8, 7-12
n
S

t e r U s
sar 9-4, 9-5, 9-9, 9-11, 9-12, 9-13, 9-15, 9-16, 9-17, 9-20,

I n
9-22, 9-25, 9-26, 9-30, 9-35, 9-39

c l e
scandisks 5-7, 5-9
Scheduler 2-30, 7-14, 7-15, 7-16

r a
Schema 11-10

O Segment 1-16, 2-6, 2-7, 2-8, 8-24, 9-4

Oracle Database 10g: Managing Oracle on Linux for DBAs Index - 6


S
semaphore 2-9, 2-10
Sequence 2-4, 7-2, 7-4, 7-5, 7-6, 7-9, 7-20
SESSIONS 2-13, 6-15, 8-16, 10-16
SGA 2-6, 2-7, 2-8, 8-13, 8-14, 8-15, 8-16, 8-17, 8-18, 8-19,
8-20, 8-21, 8-22, 9-4, 9-21, 9-22, 9-28, 9-29, 10-8, 10-11
SGA_MAX_SIZE 10-11
SGA_TARGET 8-13
Shared pool 8-17, 10-10, 10-12
Shared server 6-15
SID 3-7, 3-17, 3-18, 3-19, 6-7, 6-9, 6-12, 6-13, 6-15, 7-10,
7-11, 7-19
SMON 6-13, 8-15, 9-4
Snapshot 9-24, 11-6
SPFILE 7-19
SQL*Loader 3-28
SQL*Plus 3-17, 6-15, 6-16
Statistics 1-16, 7-13, 8-7, 9-4, 9-5, 9-12, 9-14, 9-15, 9-16,
m y
9-19, 9-21, 9-24, 9-27, 9-31, 9-33, 9-34, 9-36, 10-6, 11-5
d e
strace 11-2, 11-13, 11-14, 11-19, 11-20
Streams pool 10-12 ca
SYSDBA 1-24, 2-25, 6-16, 6-17, 7-3, 11-10
e A
SYSOPER 2-25, 6-17
c l
T
SYSTEM tablespace 10-3
r a
Tablespace 3-12, 6-7, 10-3 O ly
l & On
tainted 1-2, 1-10, 1-11, 1-17, 1-28
Trace Files 6-9
n a e
U
TRANSACTIONS 10-4

t e r U s
umask 3-8
I n
c l e
unbreakable 2-21
USE_INDIRECT_DATA_BUFFERS 8-13

r a
USER_DUMP_DEST 11-15, 11-16

O
Oracle Database 10g: Managing Oracle on Linux for DBAs Index - 7
V
V$FILESTAT 9-33
V$PROCESS 6-14
View 1-8, 1-17, 2-4, 2-23, 2-27, 3-6, 3-8, 6-7, 6-14, 8-6,
9-5, 9-6, 9-12, 9-13, 9-30, 9-32, 9-33
vmstat 9-4, 9-5, 9-9, 9-11, 9-12, 9-13, 9-14, 9-15, 9-17, 9-20,
9-21, 9-26, 9-30, 9-35, 9-39, 11-3, 11-5, 11-6
W
Wait event 10-6, 10-7
X
xload 9-9
xosview 9-6, 9-9, 9-20, 9-30

m y
d e
ca
e A
c l
r a
O ly
l & On
n a e
t e r U s
I n
c l e
r a
O
Oracle Database 10g: Managing Oracle on Linux for DBAs Index - 8

You might also like