Pro Oracle Database 11g Administration

Pro Oracle Database 11g Administration by Darl Kuhn Page B

Book: Pro Oracle Database 11g Administration by Darl Kuhn Read Free Book Online
Authors: Darl Kuhn
Tags: Oracle DBA
Ads: Link
the database names in the oratab file):
    #!/bin/bash
    # Why: Sets Oracle environment variables.
    # Setup: 1. Put oraset file in /var/opt/oracle
    # 2. Ensure /var/opt/oracle is in $PATH
    # Usage: batch mode: . oraset
    # menu mode: . oraset

    #====================================================
OTAB=/var/opt/oracle/oratab
    if [ -z $1 ]; then
    SIDLIST=$(grep -v '#' ${OTAB} | cut -f1 -d:)
    # PS3 indicates the prompt to be used for the Bash select command.
    PS3='SID? '
    select sid in ${SIDLIST}; do
    if [ -n $sid ]; then
    HOLD_SID=$sid
    break
    fi
    done
    else
    if grep -v '#' ${OTAB} | grep -w "${1}:">/dev/null; then HOLD_SID=$1
    else
    echo "SID: $1 not found in $OTAB"
    fi
    shift
    fi

    #
export ORACLE_SID=$HOLD_SID
    export ORACLE_HOME=$(grep -v '#' $OTAB|grep -w $ORACLE_SID:|cut -f2 -d:) export ORACLE_BASE=${ORACLE_HOME%%/product*}
    export TNS_ADMIN=$ORACLE_HOME/network/admin
    export ADR_HOME=$ORACLE_BASE/diag/rdbms/$(echo $HOLD_SID|tr A-Z a-z)/$HOLD_SID
    export PATH=$ORACLE_HOME/bin:/usr/ccs/bin:/opt/SENSsshc/bin/\
    :/bin:/usr/bin:.:/var/opt/oracle
    export LD_LIBRARY_PATH=/usr/lib:$ORACLE_HOME/lib
    You can run the oraset script either from the command line or from a startup file (such as .profile,
    .bash_profile, or .bashrc). To run oraset from the command line, place the oraset file in a standard location like /var/opt/oracle and run as follows:
    $ . /var/opt/oracle/oraset
    28

    CHAPTER 2 ■ IMPLEMENTING A DATABASE
    Note that the syntax to run this from the command line requires a space between the dot (.) and the rest of the command. When you run oraset from the command line, you should be presented with a menu like this:
    1) O11R2
    2) DEV1
    In this example, you can now enter 1 or 2 to set the OS variables required for whichever database you want to use. This allows you to interactively set up OS variables regardless of the number of database installations on the server.
    You can also call the oraset file from an operating system startup file. Here is a sample entry in the
    .bashrc file:
    . /var/opt/oracle/oraset
    Now, every time you log on to the server, you’re presented with a menu of choices that you can use to indicate the database for which you want the OS variables set.
    Creating a Database
    This section explains how to manually create an Oracle database with the SQL*Plus CREATE DATABASE
    statement. Listed next are the steps required to create a database:
    1. Set the operating system variables.
    2. Configure the initialization file.
    3. Create the required directories.
    4. Create the database.
    5. Create a data dictionary.
    Each of these steps is covered in the following subsections.
    Step 1. Set the Operating System Variables
    Before you run SQL*Plus (or any other Oracle utility), you must set several OS variables:
    • ORACLE_HOME
    • PATH
    • ORACLE_SID
    • LD_LIBRARY_PATH
    The ORACLE_HOME variable defines the default directory location for the initialization file, which is ORACLE_HOME/dbs on Linux/Unix. On Windows, this directory is usually ORACLE_HOME\database. The ORACLE_HOME variable is also important because it defines the directory location of the Oracle binary files (such as sqlplus) that are in ORACLE_HOME/bin.
    The PATH variable specifies which directories are looked in by default when you type a command from the operating system prompt. In almost all situations, you require ORACLE_HOME/bin (the location of the Oracle binaries) to be included in your PATH variable.
    The ORACLE_SID variable defines the default name of the database you’re attempting to create.
    ORACLE_SID is also used as the default name for the initialization file, which is init.ora.
    29

    CHAPTER 2 ■ IMPLEMENTING A DATABASE
    The LD_LIBRARY_PATH variable is important because it specifies where to search for libraries on Linux/Unix boxes. The value of this variable is typically set to include ORACLE_HOME/lib.
    Step 2: Configure the Initialization File
    Oracle requires that you have an initialization file in place before

Similar Books

Godzilla Returns

Marc Cerasini

Past Caring

Robert Goddard

Assignment - Karachi

Edward S. Aarons

Mission: Out of Control

Susan May Warren