|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Advanced Oracle Utilities: The Definitive Reference by Rampant TechPress is written by top Oracle database experts (Bert Scalzo, Donald Burleson, and Steve Callan). The following is an excerpt from the book.Oracle aliases for UNIX A UNIX alias is a short command that is replaced with a larger command to save typing. A common alias used to count the number of connected users on the oracle server is numuse: root> alias numuse=’who|wc –l’ root> numuse 463 Here is a list of common UNIX aliases that can be added to the UNIX logon file for the Oracle user. These perform common Oracle functions such as checking the Oracle alert log and transferring quickly between directories. #******************************* To illustrate the usefulness of aliases in Oracle administration, in the example below, get to the pfile directory in a single command so the contents of the init.ora file can be viewed: cheops*CPRO-/home/oracle Aliases can also be used for more sophisticated Oracle commands. For example, the following alias can be used to display all Oracle errors in the last 400 lines of the alert log: cheops*testsid-/u01/app/oracle/admin/envtest/pfile ORA-00604: error occurred at
recursive SQL level 1 A standard UNIX prompt for Oracle users The following code snippet in the oracle user login file will configure a standard UNIX prompt that identifies the current server name, the value of the current $ORACLE_SID UNIX variable, and the current working directory. This standard prompt makes it very easy to know where the DBA is when navigating UNIX, and it also ensures that the DBA knows where they are located at all times.
#***************************************************************** This standardized Oracle UNIX prompt
has the advantage of displaying the server name, the ORACLE_ cheops*CCPRO-/home/oracle Changing the Oracle environment in UNIX A typical problem on any UNIX server is quickly setting the many environment variables necessary to change the Oracle environment to a different database. Oracle provides a command script
called oraenv to reset the
Oracle environment, but it often does not work properly, and most experienced
DBAs know that the following commands must be issued to change from one
ORACLE_
export ORAENV_ASK=NO;\ Most DBAs create a UNIX alias with the same name as the
ORACLE_
***************************************************************** Next, examine how this works. First there is a FOR loop in UNIX. Decompose this command and see what it is doing: for DB in `cat /var/opt/oracle/oratab|\ The for DB in command means that the script will loop once for each value of $DB. The argument to the for DB in command is enclosed in graves (pronounced “gra-vees”), which is the back-tick character (directly above the tab key on a PC keyboard). Arguments enclosed in graves tell UNIX to execute the command enclosed in the graves and return the result set to UNIX. In this case, the command in the graves does the following:
root>cat /var/opt/oracle/oratab
test9i:/u01/app/oracle/product/8.1.7_64:Y
root>cat /var/opt/oracle/oratab|grep –v \#|grep –v \* test9i:/u01/app/oracle/product/8.1.7_64:Y
root>cat /var/opt/oracle/oratab|grep –v \#|grep –v \*|cut –d”:” –f1 test9i There is now a list of valid $ORACLE_ Now turn to the processes of dissecting complex UNIX commands. An Oracle DBA must be able to interpret complex UNIX commands.
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Copyright © 1996 - 2011 by
Burleson Enterprises. All rights reserved.
Oracle® is the registered trademark
of Oracle Corporation. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||