©2015 - 2022 Chad’s Technoworks. Disclaimer and Terms of Use

Chad’s TechnoWorks My Journal On Technology

ORACLE SHELL ENVIRONMENT SETUP


The following are examples of environment setup for my lab which I sometimes use as my template when setting up production systems.


TABLE OF PROFILE FILES OF VARIOUS SHELL    

SHELL

PROFILE FILE

Bourne

.profile

Ksh

.profile

Bash

.bash_profile

Csh

.login

Tcsh

.login

SAMPLE .PROFILE SCRIPT

# FILENAME: .profile

# DESCRIPTION: This is a sample shell profile to be deployed on the user home directory.


MAIL=/usr/mail/${LOGNAME:?}

PS1="`/bin/hostname`:${LOGNAME}> "

export PS1

alias ls='ls -F'

alias psg='ps -ef | grep '

MANPATH=/usr/dt/man:/usr/man:/usr/openwin/share/man:/usr/local/man:/usr/local/share/man:/usr/java/man

export MANPATH

LD_LIBRARY_PATH=/usr/share/lib:/usr/lib:/usr/css/lib:/usr/openwin/lib:/usr/dt/lib:/usr/local/lib:.

export LD_LIBRARY_PATH

PATH=/usr/bin:/usr/sbin:/usr/ccs/bin:/usr/ucb:/usr/openwin/bin:/usr/local/bin:/etc:/usr/sfw/bin:.

export PATH


SAMPLE ORACLE MULTI-HOME ENVIRONMENT SCRIPT

# Filename: oraenv_multihome

# Author: Chad Dimatulac

# Description:

#   This is an alternative shell environment script for use with multiple versions of Oracle database and grid.

#   In following the Optimal Flexible Architecture (OFA) standard, the ORACLE_BASE directories are set as:

#     /dsk0         = mount point

#     /dsk0/orabin  = standard directory in place of the common "/u01/app"

#     /dsk0/orabin/[10gR2,11gR2,12cR1, etc.]  = supposedly the application owner "/u01/app/oracle" but had it

#                     replaced with versions for easy identification.

#   Based on the above OFA path, oraInventory will reside at /dsk0/orabin for 11g and above, while for 10g

#   and below, oraInventory will reside at ORACLE_BASE dir if it was the first to be installed on the server.

#   The ORACLE_HOME directories follows the OFA specs: {ORACLE_BASE}/product/v/type

#     where v = version of the software. Normally 3-digit, but lately I'm adopting 4-digit since patchset

#               for 11gR2 and above need to have their own home dir.

#           type = install app type such as for database (db), client (client), Oracle Grid (grid)

#   Thus, as an example, database ORACLE_HOME will have a path: /dsk0/orabin/11gR2/product/11.2.0.3/db  

#   and grid standalone (asm) ORACLE_HOME is /dsk0/orabin/11gR2/product/11.2.0.3/grid

#   and RAC grid clusterware,asm ORACLE_HOME is /dsk0/orabin/11gR2grid

#   Note for RAC Grid Home: OFA spec is /mp/app/3-digit version/grid (i.e. /u01/app/11.2.0/grid) for reasons

#    that it has to be separate from the regular database home since root.sh will set the dir to be owned by

#    root. But if you don't want to follow OFA, just set the Grid Home other than the base install path.

#   For more details of OFA, check the following doc:

#     http://docs.oracle.com/cd/E16655_01/install.121/e17752/appendix_ofa.htm#SSDBI7910

#     http://docs.oracle.com/cd/E16655_01/install.121/e17889/apa.htm#RILIN1165

#

# Usage: . ./oraenv_multihome <app type> <ver> <sid>

#

useMsg1="Usage (ksh,bash): . ./oraenv_multihome APPTYPE VERSION <option:SID> \n"

useMsg2="where APPTYPE = db, client, grid, racgrid \n"

useMsg3="      VERSION = 10.2, 11.2, 12.1 \n"

useMsg4="      SID = your db instance name, optional only for apptype db \n"

if [ $# -ge 2 ]; then

  if [ "$1" = "db" ]; then

    if [[ -n $3 ]]; then  

      if [ "$2" = "10.2" ]; then

        ORACLE_SID=$3

        export ORACLE_SID

        ORACLE_BASE=/dsk0/orabin/10gR2 ; export ORACLE_BASE

        ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db ; export ORACLE_HOME

        setenvDb=true

      else if [ "$2" = "11.2" ]; then

        ORACLE_SID=$3

        export ORACLE_SID

        ORACLE_BASE=/dsk0/orabin/11gR2 ; export ORACLE_BASE

        ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/db ; export ORACLE_HOME

        setenvDb=true

      else if [ "$2" = "12.1" ]; then

        ORACLE_SID=$3

        export ORACLE_SID

        ORACLE_BASE=/dsk0/orabin/12cR1 ; export ORACLE_BASE

        ORACLE_HOME=$ORACLE_BASE/product/12.1.0.1/db ; export ORACLE_HOME

        setenvDb=true

      else  

        echo "ERROR: Version not available."

        printf "$useMsg1 $useMsg2 $useMsg3 $useMsg4"

     exit

      fi

      fi

      fi

    else

      echo "ERROR: SID need to be defined."

      printf "$useMsg1 $useMsg2 $useMsg3 $useMsg4"

      exit

    fi

  else if [ "$1" = "client" ]; then

      if [ "$2" = "10.2" ]; then

        ORACLE_BASE=/dsk0/orabin/10gR2 ; export ORACLE_BASE

        ORACLE_HOME=$ORACLE_BASE/product/10.2.0/client ; export ORACLE_HOME

        setenvClient=true

      else if [ "$2" = "11.2" ]; then

        ORACLE_BASE=/dsk0/orabin/11gR2 ; export ORACLE_BASE

        ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/client ; export ORACLE_HOME

        setenvClient=true

      else if [ "$2" = "12.1" ]; then

        ORACLE_BASE=/dsk0/orabin/12cR1 ; export ORACLE_BASE

        ORACLE_HOME=$ORACLE_BASE/product/12.1.0.1/client ; export ORACLE_HOME

        setenvClient=true

      else  

        echo "ERROR: Version not available."

        printf "$useMsg1 $useMsg2 $useMsg3 $useMsg4"

     exit

      fi

      fi

      fi

  else if [ "$1" = "grid" ]; then

      if [ "$2" = "10.2" ]; then

        ORACLE_BASE=/dsk0/orabin/10gR2 ; export ORACLE_BASE

        GRID_HOME=$ORACLE_BASE/product/10.2.0/grid ; export GRID_HOME

        ORACLE_HOME=$GRID_HOME ; export ORACLE_HOME

        setenvGrid=true

      else if [ "$2" = "11.2" ]; then

        ORACLE_BASE=/dsk0/orabin/11gR2 ; export ORACLE_BASE

        GRID_HOME=$ORACLE_BASE/product/11.2.0.4/grid ; export GRID_HOME

        ORACLE_HOME=$GRID_HOME ; export ORACLE_HOME

        setenvGrid=true

      else if [ "$2" = "12.1" ]; then

        ORACLE_BASE=/dsk0/orabin/12cR1 ; export ORACLE_BASE

        GRID_HOME=$ORACLE_BASE/product/12.1.0.1/grid ; export GRID_HOME

        ORACLE_HOME=$GRID_HOME ; export ORACLE_HOME

        setenvGrid=true

      else  

        echo "ERROR: Version not available."

        printf "$useMsg1 $useMsg2 $useMsg3 $useMsg4"

     exit

      fi

      fi

      fi      

  else if [ "$1" = "racgrid" ]; then

      if [ "$2" = "10.2" ]; then

        ORACLE_BASE=/dsk0/orabin/10gR2 ; export ORACLE_BASE

        GRID_HOME=/dsk0/orabin/10gR2grid ; export GRID_HOME

        setenvRacGrid=true

      else if [ "$2" = "11.2" ]; then

        ORACLE_BASE=/dsk0/orabin/11gR2 ; export ORACLE_BASE

        GRID_HOME=/dsk0/orabin/11gR2grid ; export GRID_HOME

        setenvRacGrid=true

      else if [ "$2" = "12.1" ]; then

        ORACLE_BASE=/dsk0/orabin/12cR1 ; export ORACLE_BASE

        GRID_HOME=/dsk0/orabin/12cR1grid ; export GRID_HOME

        setenvRacGrid=true

      else  

        echo "ERROR: Version not available."

        printf "$useMsg1 $useMsg2 $useMsg3 $useMsg4"

     exit

      fi

      fi

      fi

      

  else

    echo "ERROR: Invalid app type."

    printf "$useMsg1 $useMsg2 $useMsg3 $useMsg4"

 exit

  fi

  fi

  fi

  fi

    TMPDIR=$ORACLE_BASE/tmp ; export TMPDIR

    if [ ! -f $TMPDIR ];

    then

      mkdir -p $TMPDIR

    fi

    TEMP=$ORACLE_BASE/tmp ; export TEMP

    EDITOR=vi ; export EDITOR    

    if ([[ -n $setenvDb ]] || [[ -n $setenvClient ]]); then

        ORAINST=$ORACLE_HOME/oraInst.loc ; export ORAINST

        LD_LIBRARY_PATH_64=$ORACLE_HOME/lib ; export LD_LIBRARY_PATH_64

        LD_LIBRARY_PATH=$ORACLE_HOME/lib32 ; export LD_LIBRARY_PATH

        NLS_LANG=AMERICAN_AMERICA.UTF8 ; export NLS_LANG

        TNS_ADMIN=$ORACLE_HOME/network/admin ; export TNS_ADMIN

        PATH=$PATH:/usr/sbin:$HOME/.env:$ORACLE_HOME/bin ; export PATH        

    fi    

    if ([[ -n $setenvGrid ]] || [[ -n $setenvRacGrid ]]); then

        ORAINST=$GRID_HOME/oraInst.loc ; export ORAINST

        ORACLE_HOME=$GRID_HOME ; export ORACLE_HOME

        LD_LIBRARY_PATH_64=$GRID_HOME/lib ; export LD_LIBRARY_PATH_64

        LD_LIBRARY_PATH=$GRID_HOME/lib32 ; export LD_LIBRARY_PATH

        TNS_ADMIN=$GRID_HOME/network/admin ; export TNS_ADMIN

        PATH=$PATH:/usr/sbin:$HOME/.env:$GRID_HOME/bin ; export PATH    

    fi

    if [[ -n $setenvRacGrid ]]; then

        ORA_CRS_HOME=$GRID_HOME ; export ORACLE_CRS_HOME

    fi    

 echo ------- DATABASE ENV -------

 if [[ -n $setenvDb ]]; then

   echo ORACLE_SID=$ORACLE_SID

 fi

 echo ORACLE_BASE=$ORACLE_BASE

 echo ORACLE_HOME=$ORACLE_HOME

 if ([[ -n $setenvGrid ]] || [[ -n $setenvRacGrid ]]); then

   echo GRID_HOME=$GRID_HOME

 fi

 if  [[ -n $setenvRacGrid ]]; then

   echo ORA_CRS_HOME=$ORA_CRS_HOME

 fi

 echo ORAINST=$ORAINST

 echo TNS_ADMIN=$TNS_ADMIN

 if ([[ -n $setenvDb ]] || [[ -n $setenvClient ]]); then

   echo NLS_LANG=$NLS_LANG

 fi

 echo LD_LIBRARY_PATH_64=$LD_LIBRARY_PATH_64

 echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH

 echo TMPDIR=$TMPDIR

 echo EDITOR=$EDITOR

 echo

else

    printf "$useMsg1 $useMsg2 $useMsg3 $useMsg4"

 false

fi

# Set Backspace For Putty and Gnome Desktop

#stty erase "^?"


#Set Backspace For Secure CRT

stty erase ^H



Information Technology