Pro Oracle Database 11g Administration

Pro Oracle Database 11g Administration by Darl Kuhn Page A

Book: Pro Oracle Database 11g Administration by Darl Kuhn Read Free Book Online
Authors: Darl Kuhn
Tags: Oracle DBA
Ads: Link
corresponding Oracle home directories.
    The oratab file is automatically created for you when you install the Oracle software. On Linux boxes, oratab is usually placed in the /etc directory. On Solaris servers, the oratab file is placed in the
    /var/opt/oracle directory. If for some reason the oratab file isn’t automatically created, you can manually create the directory and file.
    The oratab file is used in Linux/Unix environments for the following:
    • Automating the sourcing of required OS variables
    • Automating the start and stop of Oracle databases on the server
    The oratab file has three columns with the following format:
    ::Y|N
    26

    CHAPTER 2 ■ IMPLEMENTING A DATABASE
    The Y or N indicates whether you want Oracle to automatically restart on reboot of the box; Y

indicates yes, and N indicates no. Automating the startup and shutdown of your database is covered in detail in Chapter 21, “Automating Jobs.”
    Comments in the oratab file start with a pound sign (#). Here’s a typical oratab file entry:
    # 11g prod databases
    O11R2:/oracle/app/oracle/product/11.2.0/db_1:N
    ORC11G:/oracle/app/oracle/product/11.2.0/db_1:N
    Several Oracle-supplied utilities use the oratab file:
    • oraenv uses oratab to set the operating system variables.
    • dbstart uses it to automatically start the database on server reboots (if the third field in oratab is Y).
    • dbstop uses it to automatically stop the database on server reboots (if the third field in oratab is Y).
    The oraenv tool is discussed in the next section.
    Using oraenv
    If you don’t properly set the required OS variables for an Oracle environment, then utilities such as SQL*Plus, Oracle Recovery Manager (RMAN), Data Pump, and so on won’t work correctly. The oraenv utility automates the setting of required OS variables (such as ORACLE_HOME, ORACLE_SID, and PATH) on an Oracle database server. This utility is used in Bash, Korn, and Bourne shell environments (if you’re in a C
    shell environment, there is a corresponding coraenv utility).
    The oraenv utility is located in the ORACLE_HOME/bin directory. You can run it manually like this: $ . oraenv
    Note that the syntax to run this from the command line requires a space between the dot (.) and the oraenv tool. You’re prompted for ORACLE_SID and ORACLE_HOME values:
    ORACLE_SID = [oracle] ?
    ORACLE_HOME = [/home/oracle] ?
    You can also run the oraenv utility in a non-interactive way by setting OS variables before you run it.
    This is useful for scripting when you don’t want to be prompted for input: $ export ORACLE_SID=oracle
    $ export ORAENV_ASK=NO
    $ . oraenv
    My Approach to Setting OS Variables
    I don’t use Oracle’s oraenv file to set the OS variables (see the previous section for details of Oracle’s approach). Instead, I use a script named oraset. The oraset script depends on the oratab file being in the correct directory and of the expected format:
    ::Y|N
    As mentioned in the previous section, the Oracle installer should create an oratab file for you in the correct directory. If it doesn’t, then you can manually create and populate the file. In Linux, the oratab 27

    CHAPTER 2 ■ IMPLEMENTING A DATABASE
    file is usually created in the /etc directory. On Solaris servers, the oratab file is located in
    /var/opt/oracle. Here is an example:
    O11R2:/ora01/app/oracle/product/11.2.0/db_1:N
    DEV1:/ora02/app/oracle/product/11.2.0/db_1:N
    The names of the databases on the previous lines are O11R2 and DEV1. The path of each database’s Oracle home directory is next on the line (separated from the database name by a colon [:]). The last column contains Y or N and indicates whether you want the databases to automatically be restarted when the system reboots.
    Next, use a script that reads the oratab file and sets the operating system variables. Here is an example of an oraset script that reads the oratab file and presents a menu of choices (based on

Similar Books

Godzilla Returns

Marc Cerasini

Past Caring

Robert Goddard

Assignment - Karachi

Edward S. Aarons

Mission: Out of Control

Susan May Warren