BUY THIS BOOK
Add to Cart

Print Book $9.95


Add to Cart

Print+PDF $12.93

Add to Cart

PDF $7.99

Safari Books Online

What is this?

Add to UK Cart

Print Book £6.95

What is this?

Looking to Reprint or License this content?


Unix for Oracle DBAs Pocket Reference
Unix for Oracle DBAs Pocket Reference By Donald K. Burleson
February 2001
Pages: 110

Cover | Table of Contents


Table of Contents

Chapter 1: Unix for Oracle DBAs Pocket Reference
The Unix for Oracle DBAs Pocket Reference is a quick reference describing the Unix commands most often used by Oracle database administrators. It's the result of my 20 years of accumulating Unix tips and techniques. For each of the commands included in this book, I've provided the basic syntax and a short, illustrative example. This guide also contains many short Unix scripts that should save you dozens of hours of manual effort.
I've organized the commands and examples in this book into the following major topic areas:
Understanding Unix
Gives you a little bit of the history of Unix and tells you some things that you need to know regarding case sensitivity, safety, and shells.
Building Unix Commands
Describes the process of creating complex Unix commands for Oracle.
Unix Server Environment
Describes the commands that make Unix easier for DBAs.
Process Management
Describes the basic Unix commands you use to display and manage server processes.
Server Values
Shows you how to display relevant server values in Unix.
Memory and CPU Management
Shows the main commands used to display information about memory segments, swap space, and semaphores used by an Oracle database. Also covers commands used to monitor CPU utilization.
Semaphore Management
Shows you how to monitor semaphore usage by your Oracle server and how to remove semaphore sets for an instance that has crashed.
System Log Messages
Shows you how to view operating-system log files.
Server Monitoring
Describes the details of using the server utilities vmstat, sar, and glance.
File Management
Describes commands that assist in file management tasks.
Disk Management
Shows you how to get information about the disks on your system. This section includes commands to list physical volumes, logical volumes, and mount points.
Miscellaneous Shell Scripts
Presents a number of shell scripts that I've found to be useful over the years, but that don't fit into any of the other sections.
Writing this pocket reference was especially challenging because of the dialect differences between the major implementations of Unix. For example, commands in HP-UX are often different from those in Sun Solaris. I've emphasized commands that are common to all Unix dialects. Where differences occur, I've attempted to cover the following platforms: HP-UX, IBM AIX, and Sun Solaris. You'll also find some specific dialect commands for IRIX and DEC Unix.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Introduction
The Unix for Oracle DBAs Pocket Reference is a quick reference describing the Unix commands most often used by Oracle database administrators. It's the result of my 20 years of accumulating Unix tips and techniques. For each of the commands included in this book, I've provided the basic syntax and a short, illustrative example. This guide also contains many short Unix scripts that should save you dozens of hours of manual effort.
I've organized the commands and examples in this book into the following major topic areas:
Understanding Unix
Gives you a little bit of the history of Unix and tells you some things that you need to know regarding case sensitivity, safety, and shells.
Building Unix Commands
Describes the process of creating complex Unix commands for Oracle.
Unix Server Environment
Describes the commands that make Unix easier for DBAs.
Process Management
Describes the basic Unix commands you use to display and manage server processes.
Server Values
Shows you how to display relevant server values in Unix.
Memory and CPU Management
Shows the main commands used to display information about memory segments, swap space, and semaphores used by an Oracle database. Also covers commands used to monitor CPU utilization.
Semaphore Management
Shows you how to monitor semaphore usage by your Oracle server and how to remove semaphore sets for an instance that has crashed.
System Log Messages
Shows you how to view operating-system log files.
Server Monitoring
Describes the details of using the server utilities vmstat, sar, and glance.
File Management
Describes commands that assist in file management tasks.
Disk Management
Shows you how to get information about the disks on your system. This section includes commands to list physical volumes, logical volumes, and mount points.
Miscellaneous Shell Scripts
Presents a number of shell scripts that I've found to be useful over the years, but that don't fit into any of the other sections.
Writing this pocket reference was especially challenging because of the dialect differences between the major implementations of Unix. For example, commands in HP-UX are often different from those in Sun Solaris. I've emphasized commands that are common to all Unix dialects. Where differences occur, I've attempted to cover the following platforms: HP-UX, IBM AIX, and Sun Solaris. You'll also find some specific dialect commands for IRIX and DEC Unix.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Understanding Unix
Unix is an operating system. It's been developed over the past 30 years by several different vendors. This book can't hope to be a tutorial on the use of Unix. I assume that you know enough to log into your Unix system, get a command prompt, and issue commands. Even so, there are some important things to review before you get started with this book.
The history of Unix goes back to 1969, when the first versions of Unix were developed by AT&T's Bell Labs. The operating system had a certain elegance, was freely available, and quickly caught on with vendors of mini-computer systems who needed an operating system for the hardware that they were selling.
As different vendors adopted Unix, they each began to create their own, slightly unique versions of the operating system. Today, you have HP-UX, Sun Solaris, IBM AIX, and a number of other variants to deal with.
Linux is a Unix-like operating system first put together by Linus Torvalds in 1991 because he needed an operating system for his PC and could not afford any of the commercial Unix variants of that day. Linux has gone on to achieve phenomenal growth and is widely used today as a server operating system on x86 machines. Linux is also available for the PowerPC, Sparc, IBM S/390, and Amiga.
Most commonly used Unix commands work more or less identically on all Unix and Linux platforms. The ls command, which lists files in a directory, is an example of such a command. I've never seen a Unix or Linux version that did not support ls. There are a number of command options available with ls, however, and not all options are available on all platforms.
System management commands probably represent the area where you will run into the greatest number of differences between the Unix variants on the market. These are the commands used to display information about disks, memory, and performance. Most Unix users are not bothered by this problem, but unfortunately, these commands are the ones that you as the database administrator (DBA) will most likely need to use.
Unless specified otherwise, I've used only commonly available commands and options in this book. Where platform differences exist, I've attempted to cover all the platforms listed in the introduction. Sometimes a command available on one platform does not have an analog on another. I've noted this in the text where appropriate.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Building Unix Commands
One of the most confounding things for the Unix neophyte is being confronted with a complex Unix command. The cryptic nature of Unix is such that even the most seasoned Unix professional may have trouble deciphering such a command. Hidden in that complexity, however, is a great deal of power. In order to leverage that power for your day-to-day work, it's essential for you to learn how to deal with complex commands.
In this section, we will begin by examining a cryptic Unix command in order to see how it is really composed of many simpler commands. We'll then walk through the process of creating such a command in order to perform a specific task.
Regarding the terms commands and scripts, you should note that any command may become a script if it is encapsulated into a file for execution. Hence, find . -print can be a command if executed from the prompt, or a script if placed into a file.
This section shows how a Unix programmer can string commands together into a powerful one-line command. The following one-line Unix script performs an important Oracle function—it kills all Oracle background processes when the database cannot be shut down normally:
ps -ef|grep "ora_"|grep -v grep|awk '{ print $2 }'|xargs kill -9
At first glance, this Unix command appears to be a conglomeration of cryptic letters. However, this is actually a series of commands that are joined together using the pipe operator (|). Here's a view of the command that's a bit easier to follow:
ps -ef
|
grep "ora_"
|
grep -v grep
|
awk '{ print $2 }'
|
xargs kill -9 
The pipe symbol tells Unix to use the output from one command as input to the next command. For example, you can pipe the output from ps -ef as input to grep "ora_". The output from ps -ef is a list of all processes on the server; this is passed to grep "ora_" to filter out only the Oracle processes running on the server. With that in mind, you can examine the commands one at a time and see how each successive command refines the output from the previous one.
Now that you've seen how a complex, one-line script is really composed of several simpler commands connected by the pipe operator (|), it's time to take a look at this from the opposite standpoint. I'll walk you through a couple of case studies showing how to start with a goal in mind, and build up a one-line script to accomplish that goal. I'll start by showing you how to build a one-line script to kill all the Oracle processes on your server. Then I'll show you how to build a one-line script to find files that contain a specific text string.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Unix Server Environment
This section presents handy Unix commands that will make it easier for you to navigate in your Unix environment. The first part of this section looks at commands that can be automatically executed when you sign on to Unix as the Oracle user. There is a special file in your home directory in which you can place Unix commands that you want automatically executed when you sign on to the system. If you use the Korn shell, this file is named .profile. If you use the C shell, it will be called .cshrc. If there's any doubt, your Unix system administrator will be able to tell you the name of the file in your particular environment.
Also in this section, you will see how to create a standard Unix prompt, wrap SQL in a Unix script, and write a utility to quickly change all files in a directory. In addition, you will explore submitting background jobs and sending mail from Unix, and you'll use the powerful rsh command to make a script that visits multiple databases on multiple servers.
Placing the following code snippet in your .profile file will give you a Unix prompt that identifies your current server name, database name, and working directory. Knowing this information can help prevent you from accidentally running a command against the wrong database. Note that I have my prompt go to a new line after displaying the information, so that I have a full 79 characters in which to type my Unix commands.
#***********************************************
# Standard Unix Prompt
#***********************************************
PS1="
`hostname`*\${ORACLE_SID}-\${PWD}
>"
Here is what the prompt looks like after you have executed the PS1 command shown in the previous example. Note how the prompt changes when you change directories.
corphp*PROD-/home/oracle
>pwd

/home/oracle

corphp*PROD-/home/oracle
>cd /u01/oradata/PROD

corphp*PROD-/u01/oradata/PROD
>
This section shows you how you can place a list of helpful Unix aliases in the .profile file of a Unix Oracle user.
An alias is a Unix shortcut whereby you can define a short name to use in place of a long Unix command. For example, you could create a shortcut called "log" that would execute the Unix
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Process Management
This section is designed to provide a basic overview of how you manage Oracle processes in a Unix environment. As you know, an Oracle instance is composed in part of a set of processes such as PMON, SMON, and DBWR. In addition, there are other Unix processes that you need to be aware of and manage. For example, if you are using a dedicated listener (as opposed to the multithreaded server, MTS), then each connected user will have a Unix process.
Manny DBAs call a standard listener a "dedicated" listener because it spawns a dedicated Unix process that connects to Oracle. The MTS does not create PID for each Oracle connection; instead, it routes the connection through a multithreaded dispatcher.
This section shows you how to find Oracle processes and identify the ones consuming the most CPU resources. You'll also see how options can be added to the ps -ef command to filter and sort the process list output.
The basic process management command is the ps command. It is commonly used to display active processes and their characteristics, and displays the values shown in the following example:
>ps -ef|grep ora

UID    PID   PPID  C  STIME     TTY  TIME  CMD
oracle 13168    1  0  05:33:06   -   3:15  oracleprod
oracle 26164    1  0  12:57:10   -   4:54  oracleprod 
...
The column definitions that you should be aware of are as follows:
UID
The user ID that owns the process.
PID
The process ID for the task.
PPID
The parent process. If the parent is 1, the process was created by the init process.
STIME
The start time of the process.
TIME
The amount of CPU time used by the process so far. This value will increase until the process is complete.
CMD
The Unix command that is being executed.
The next four sections show several very useful process-management commands that are based on ps.
The ps command shown in the following example can be used to display the top CPU consumers on a server:
>ps -ef|sort +6|tail

oracle 55676     1   0 03:06:16  -  0:36 oracleprod 
oracle 24876     1   0 02:52:56  -  0:40 oracleprod 
oracle 41616     1   0 07:00:59  -  0:44 oracleprod 
oracle 43460     1   0 02:45:05  -  0:53 oracleprod 
oracle 25754     1   0 08:10:03  -  1:01 oracleprod 
oracle 17402     1   0 07:27:04  -  2:06 oracleprod 
oracle 14922     1   0 01:01:46  -  2:54 oracleprod 
oracle 13168     1   0 05:33:06  -  3:15 oracleprod 
oracle 26164     1   0 12:57:10  -  4:54 oracleprod 
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Server Values
Unix has a wealth of system configuration values that you can look at. These include kernel parameters as well as server device values that tell you about devices, such as memory and disk drives, that are installed on your server. Kernel parameters affect Unix's operation at a very fundamental level, and some of them are important to consider when you install Oracle on a Unix server.
This section shows you how to use the lsdev command to look at server device values. The lsdev command works under both HP-UX and AIX. You'll also learn how to display kernel parameter values. Under HP-UX, the kmtune command is used for that purpose. Under AIX, you use lsattr.
While all dialects of Unix share common command syntax, server commands can vary widely between dialects, and some dialects do not have commands to display server values. If you encounter that problem, you should contact your system administrator for help.
Using the lsdev command, you can display information about all the devices connected to your server. This includes disk drives, memory, CPUs, buses, and other hardware components. In the example that follows, the lsdev command is used to list all mounted devices for a server:
>lsdev
    Character     Block       Driver         Class
        0          -1         cn             pseudo
        3          -1         mm             pseudo
       16          -1         ptym           ptym
       17          -1         ptys           ptys
       27          -1         dmem           pseudo
       28          -1         diag0          diag
       46          -1         netdiag1       unknown
       52          -1         lan2           lan
The Character, Block, and Class columns are not relevant to this discussion. The Driver column is the one you want to look at. It shows a list of device drivers, and hence a list of devices that are attached to the server.
Just as with HP-UX, the AIX lsdev command displays all the devices on the AIX server. However, while the command is the same, the -C flag is required under AIX. Also notice that the output is quite different from the
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Memory and CPU Management
This section is devoted to the commands that show memory and CPU consumption. As you know, an Oracle database does not exist in a vacuum. If the database server is experiencing a CPU overload or a memory-swapping problem, no amount of Oracle tuning can relieve that. Hence, it is very important that you be able to see when your server is overloaded.
The commands described in this section often differ between Unix dialects. Some dialects, such as Solaris, do not support memory-display commands. In those cases, GUI tools such as glance must be used to see memory values.
In DEC Unix, you can use the uerf command in conjunction with grep to display memory size. For example:
 uerf -r 300 | grep -i mem 
Here, the output of the uerf command is piped to grep to filter out and display the segments relating to memory. The -i option causes grep to find both uppercase and lowercase strings. With respect to the example shown here, grep -i mem looks for both MEM and mem.
In HP-UX, you can run the glance or sar utilities in order to see the amount of RAM available. The glance utility displays a screen showing CPU and memory utilization both for the system as a whole and for individual processes. The sar utility displays a complete set of system settings and also shows overall server performance. Because it consists of more than 50 screens, a discussion of sar is beyond the scope of this text. For more information on glance or sar, look to the manpages on your Unix server.
In some shops, you may need to get permission from your Unix system administrator in order to run glance or sar.
The prtconf command can be used on Solaris servers to quickly see the amount of available memory. For example:
>prtconf|grep -i mem

Memory size: 2048 Mbytes
    memory (driver not attached)
    virtual memory (driver not attached)
In IBM's AIX dialect of Unix, you can use the lsdev command followed by the lsattr command to display the amount of memory on a server. First execute lsdev to list all devices. Then pipe that output through grep to filter out everything not related to memory. That will get you the names of the memory devices that are installed. For example:
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Semaphore Management
Semaphores are signals used by Oracle to serialize the internal Oracle processes. The number of semaphores for a database is equal to the value of the PROCESSES parameter in the INIT.ORA file. For example, a database with PROCESSES=200 will have 200 semaphores allocated for Oracle.
AIX Unix does not use semaphores. In AIX, the post/wait driver is used instead, because it increases performance.
It is critical that the Unix kernel parameter semmns be set to at least double the total number of processes for all database instances on your server. If it's not set, your databases will fail to start, and you'll receive the following error:
spcre: semget error, unable to get first semaphore set.
It's often necessary to make changes to kernel parameters on a Unix system in order to accommodate the needs of the Oracle database software. You should always work with your Unix system administrator to make such changes. The general process, however, is as follows:
  1. Shut down any running Oracle instances.
  2. Locate the kernel configuration file for your operating system.
  3. Make the necessary changes using system utilities or the vi editor. System utilities for several common Unix variants are listed in Table 1-1.
  4. Reconfigure the kernel.
  5. Reboot your machine.
  6. Restart your Oracle instances.
Remember, kernel configuration requires a great deal of expertise. Always work with your system administrator.
Table 1-1: Utilities to Change Kernel Parameters
Operating System
Utility
HP-UX
SAM
SCO
SYSADMSH
AIX
SMIT
Solaris
ADMINTOOL
Reconfiguring kernel parameters can have a dramatic impact on your server. The effects of a mistake can be catastrophic. Hence, you need to make sure that you fully understand kernel configuration before attempting any such changes.
The maximum allowed number of semaphores is specified by the semmns kernel parameter. In HP-UX Version 11, the command to show semaphores is kmtune. Run kmtune, and pipe the output through grep sem to filter out everything except semaphore settings. For example:
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
System Log Messages
The commands described in this section are used to display the OS error logs. These logs can be useful for detecting transient disk I/O problems, memory failures, and other such problems.
Because each dialect of Unix was created differently, the system logs are in different locations, and different commands are used to display the messages.
Unix server log messages in HP-UX are kept in the /var/adm/syslog/syslog.log file. This file will display messages relating to any server-related problems with disk I/O, memory, or CPU. This is one of the first places to look when an Oracle database has crashed, because you must first rule out server problems before attempting to fix the database.
The following example shows the grep command being used to display lines from the server log that contain the text "error":
>grep error /var/adm/syslog/syslog.log|more

May  1 20:30:08 sprihp01 syslog: NetWorker media: 
(warning) /dev/rmt/c5t6d0BESTn reading: I/O error
In AIX, you do not need to know the file location for the system log. Issuing the errpt command will display the error log, which shows any server-related errors. For example:
>errpt -a|more
-------------------------------------------
LABEL:          CORE_DUMP
IDENTIFIER:     C60BB505

Date/Time:       Tue May  9 10:34:47 
Sequence Number: 24908
Machine Id:      000138644C00
Node Id:         sp2k6n03
Class:           S
Type:            PERM
Resource Name:   SYSPROC
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Server Monitoring
It is critical to check your server whenever you see a performance problem. You must rule out the server as the source of a performance problem before attempting to do any Oracle tuning. The only effective way to monitor the complete behavior of an Oracle database is to monitor both the database server and the database itself.
There is a host of Unix commands that display CPU and memory consumption. Common utilities include top, sar, and vmstat.
Use the top utility to show the top sessions on a Unix server. The top command shows the relative activity for each CPU in the CPU cluster. The output from top is in two sections. The first section shows the load on each processor, while the second section lists the current top sessions in terms of CPU utilization. The following example shows the first section of top output:
Server1>top

System: corp-hp9 Thu Jul  6 09:14:23 2000
Load averages: 0.04, 0.03, 0.03
340 processes: 336 sleeping, 4 running
CPU states:
CPU   LOAD   USER   NICE    SYS   IDLE...
 0    0.06   5.0%   0.0%   0.6%  94.4%...
 1    0.06   0.0%   0.0%   0.8%  99.2%...
 2    0.06   0.8%   0.0%   0.0%  99.2%...
 3    0.06   0.0%   0.0%   0.2%  99.8%...
 4    0.00   0.0%   0.0%   0.0% 100.0%...
 5    0.00   0.2%   0.0%   0.0%  99.8%...
---   ----  -----  -----  -----  -----...
avg   0.04   1.0%   0.0%   0.2%  98.8%...

...  BLOCK  SWAIT   INTR   SSYS
...   0.0%   0.0%   0.0%   0.0%
...   0.0%   0.0%   0.0%   0.0%
...   0.0%   0.0%   0.0%   0.0%
...   0.0%   0.0%   0.0%   0.0%
...   0.0%   0.0%   0.0%   0.0%
...   0.0%   0.0%   0.0%   0.0%
...  -----  -----  -----  -----
...   0.0%   0.0%   0.0%   0.0%
At the very beginning of this section, before the tabular output begins, you see three values for the load average. The load average is an arbitrary number that describes the load on the system. The first load average value is the immediate load for the past minute. The next value represents the load average for the past 5 minutes. The third value is the load average for the past 15 minutes.
The second section of top output, which details the current top sessions in terms of CPU utilization, appears as follows:
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
File Management
Most Oracle DBAs are responsible for the management of the Oracle data files on their database servers. You must be able to determine the status of all the Oracle data files, initialization files, trace files, and log files.
As a DBA, you often need to see the most recently touched files in a filesystem. An Oracle file is touched each time that the file is read or written. Knowing when a file has been touched can offer you insight into the behavior of Oracle on your server. The ls command in the following example generates a sorted list of files, with the most recently accessed files appearing first. That output is piped through head in order to limit the display to the most recently touched files.
>ls -alt|head

-rw-r----- 1 ... 52429312 May 11 07:00 arlog272.arc
-rw-r----- 1 ... 393829   May 10 20:20 arlog21.arc.Z
-rw-r----- 1 ... 19748689 May 10 20:03 arlog27.arc.Z
-rw-r----- 1 ... 16018687 May 10 08:05 arlog26.arc.Z
Note that "touched" is different from "changed." A file is touched anytime that the file is read by a process, but a file is only changed when it has been written.
The -l option of the ls command always causes the modification date to be listed with each file, even when you use the ls -alt|head command to see the most recently touched files. The -t option causes the output to be sorted by touched date, but the modification date is still the date that is displayed. The -a option lists all files in your directory.
The following example uses a variation of the ls command that displays the most recently changed files. The -c option causes the list of files to be sorted on the date and time of the most recent change. Note that the -c option displays in reverse order, so you must pipe the ls output to tail in order to see the most recent values.
>ls -alc|tail

-rw-r-----   1 ... May 09 05:02 archlog263.arc.Z
-rw-r-----   1 ... May 09 05:03 archlog264.arc.Z
-rw-r-----   1 ... May 10 05:02 archlog265.arc.Z
-rw-r-----   1 ... May 10 05:02 archlog266.arc.Z
-rw-r-----   1 ... May 10 05:02 archlog267.arc.Z
-rw-r-----   1 ... May 10 05:02 archlog268.arc.Z
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Disk Management
Disks exist in Unix as physical volumes and are carved into physical partitions (PPs). These physical partitions are, in turn, assigned to logical volumes. A logical volume is a chunk of storage that consists of one or more physical partitions. The logical volumes are then mapped onto Unix mount points. Several logical volumes can be used in a mount point, and a collection of such logical volumes is referred to as a volume group. A Unix mount point is like a directory name, and is used by you, the Oracle DBA, when allocating Oracle data files.
All logical volumes can be listed in HP-UX using the df -k command. The df -k command shows each logical volume, and the corresponding mount point. For example:
ROOT>df -k

/home(/dev/vg00/lvol5): 20166 total allocated Kb
                         4945 free allocated Kb
                        15221 used allocated Kb
                           75 % allocation used
/opt (/dev/vg00/lvol6):615914 total allocated Kb
                       227403 free allocated Kb
                       388511 used allocated Kb
                           63 % allocation used
/tmp (/dev/vg00/lvol4):64215 total allocated Kb
                       20564 free allocated Kb
                       43651 used allocated Kb
                          67 % allocation used
/u01 (/dev/vg01/u01  ):17580720 total allocated Kb
                       12117048 free allocated Kb
                        5463672 used allocated Kb
                             31 % allocation used
The df -k command is most often used to see the total space in each mount point and the amount of free space within each mount point. In the previous example, you see that /u01 is defined with a size of 17 gigabytes, and has 12 gigabytes free.
The mount point name is outside the parentheses, while the logical volume name is within the parentheses. To see the logical volumes in a filesystem, you can issue the lvdisplay command followed by a logical volume name. For example:
ROOT>lvdisplay /dev/vg00/u01

--- Logical volumes ---
LV Name                     /dev/vg00/lvol3
VG Name                     /dev/vg00
LV Permission               read/write   
LV Status                   available/syncd           
Mirror copies               1            
Consistency Recovery        MWC                 
Schedule                    parallel     
LV Size (Mbytes)            140             
Current LE                  35        
Allocated PE                70          
Stripes                     0       
Stripe Size (Kbytes)        0                   
Bad block                   off          
Allocation                  strict/contiguous         
IO Timeout (Seconds)        default      
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Miscellaneous Shell Scripts
The topics in this section deal with miscellaneous Unix commands and scripts that are useful for Oracle DBAs.
It is important to have a single tnsnames.ora file on each server. This is because database servers with multiple Oracle homes will have many default locations for the tnsnames.ora file. For example, each home will have its own $ORACLE_HOME/network /admin directory. The resulting proliferation of files can cause some confusion. The ideal is to create a single tnsnames.ora file for the database server with soft links pointing from every $ORACLE_HOME/network /admin directory to the single copy.
Oracle uses the following search order for finding the tnsnames.ora file:
  1. $TNS_ADMIN
  2. /etc (or /var/opt/oracle for Solaris)
  3. $ORACLE_HOME/network /admin
Most AIX and HP-UX sites keep a single copy of the tnsnames.ora, oratab, sqlnet.ora, and listener.ora files in the /etc directory. Under Solaris, these files are kept in /var/opt/oracle.
Even though the search path will look in /etc anyway, it is good practice for you to soft-link all such configuration files to /etc. This removes the possibility of the wrong file being accessed, and shows that you have made an effort to consolidate the common Oracle files.
The following script will create a soft link to /etc for every database on the server:
# Loop through each database name 
# on the host /etc/oratab.
for db in `cat /etc/oratab|egrep ':N|:Y'|\
grep -v \*|cut -f1 -d':'`
do
  # Get the ORACLE_HOME for each database.
  home=`cat /etc/oratab|egrep ':N|:Y'|\
grep -v \*|grep ${db}|cut -f2 -d':'`
  echo " "
  echo "database is $db"
  cd $home/network/admin
  ln -s /etc/tnsnames.ora\    
        $home/network/admin/tnsnames.ora
done
Some sites require the root user to initially create the tnsnames.ora file and change the permissions to allow the Oracle Unix user to alter the file. You should have your system administrator do this prior to running this script.
Unix has a native utility called tar for rapid copying of files to tape archives. Here is an example showing tar being used to do a simple Oracle backup to tape:
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!

Return to Unix for Oracle DBAs Pocket Reference