Link to home
Start Free TrialLog in
Avatar of Omega002
Omega002Flag for Afghanistan

asked on

Creating Oracle Profile to automatically set multiple Oracle homes and Oracle Instances on one DB Server

Is there anyone out there that has a .bash_profie or .profile that show an examples of how to code our profile to accept and set multiple oracle instances and homes on one DB Server?
Avatar of Tintin
Tintin

You can only have one ORACLE_HOME and ORACLE_SID set at a time, so if you need to change between various instances, you'll need to run oraenv and specify the new SID.
You need to set:
ORACLE_HOME
ORACLE_SID
LD_LIBRARY_PATH
and
PATH

for the user's .profile or .bash_profie eg:
ORACLE_HOME=/opt/oracle/product/9.2.0
ORACLE_SID=TYP2
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH

PATH=$PATH:$ORACLE_HOME/bin
export PATH

please read the example in:
http://www.akadia.com/services/ora_sol_install_9i.html#Setup%20ORACLE%20environment%20($HOME/.profile)%20as%20follows
and
http://www.akadia.com/services/ora_sol_install.html
and
http://publib.boulder.ibm.com/tividd/td/ITIM/SC32-1334-01/en_US/HTML/im451inst_ux_wl29.htm
Avatar of Omega002

ASKER

I have configured redhat 4.0 with multiple oracle homes and instances so I am looking for something similar for Sun Solaris. Listed below you will see a sample of what I am looking for that I use when installing multiple oracle homes on RHEL 4:
##########################################
#Contents of my .bash_profile
##########################################
PS1='$ORACLE_SID:$PWD>'
export PS1
########################
# Database Directories #
########################

for SID in $(ps -ef | grep smon | awk -F'_'  '{print $3}')
do

        SID_ENV="/`echo ${SID} | tr "[A-Z]" "[a-z]"`-db/u01/app/oracle/admin/${SID}/.orauser_$SID"
        alias $SID=". ${SID_ENV}"
        alias `echo ${SID} | tr "[A-Z]"`=". ${SID_ENV}"
       . $SID_ENV
done
#       . $SID_ENV
echo "###############################"
echo "  SIDs on $node  are:   "
echo "###############################"
ps -ef | grep smon | awk -F'_'  '{print $3}'
echo " "


# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
ORACLE_BASE=/db-01/app/oracle
ORACLE_HOME=/db-01/app/oracle/product/10.1.0
#ORACLE_SID=ORTD

PATH=$PATH:$ORACLE_HOME/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:$ORACLE_HOME/network/lib

export PATH ORACLE_BASE ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH


PATH=$PATH:$HOME/bin

export PATH
unset USERNAME

##############################
#Contents Of My .orauser_SID         #
##############################
################################
PSI03=/psi03-db/u01/app/oracle/admin/PSI03
ORATAB=/var/opt/oracle/oratab
HOME=/home/oracle
LD_LIBRARY_PATH=/usr/openv/netbackup/bin:$ORACLE_HOME/lib:/usr/openwin/lib:/usr/local/lib
PS1='$ORACLE_SID:$PWD> '

alias PSI03='. /psi03-db/u01/app/oracle/admin/PSI03/.orauser_PSI03'
alias psi03='. /psi03-db/u01/app/oracle/admin/PSI03/.orauser_PSI03'
alias bdump='cd $ORACLE_BASE/admin/$ORACLE_SID/bdump'
alias udump='cd $ORACLE_BASE/admin/$ORACLE_SID/udump'
alias cdump='cd $ORACLE_BASE/admin/$ORACLE_SID/cdump'
alias pfile='cd $ORACLE_BASE/admin/$ORACLE_SID/pfile'
alias report='cd $ORACLE_BASE/admin/$ORACLE_SID/report'
alias sql='cd $ORACLE_BASE/admin/$ORACLE_SID/sql'
alias expadmin='cd $ORACLE_BASE/admin/$ORACLE_SID/exp'
alias dbs='cd $ORACLE_HOME/dbs'
alias rdbms='cd $ORACLE_HOME/rdbms/admin'

export ORACLE_BASE ORACLE_HOME ORACLE_SID TNS_ADMIN TOOLS PATH OH ORACLE_PATH LOGNAME MAIL ORA_NLS
export OBK_HOME ORATAB HOME LD_LIBRARY_PATH PS1 MAILTO PSI03


Using these two profile scripts, I am able to switch between Oracle Homes and Instances by typing the SID name. I am looking for something like this for Sun SOlaris 10.
Here's another example of what I am looking for that I need for a Sun SOlaris SPARC DB Server with multiple Oracle Instances.

Better yet, have one single generic .profile with aliases defined for each instance
running on the server.

Want to change env for another instance? Just type it's name. It is that simple.

We do this on all our servers, some with 20+ instances running under 7.3.4, 8.0.x,
8.1.x and 9.2.x. We use only one id for all versions of Oracle s/w.

The .profile file sources the alias' file as .local.aliases. This file has entries as
below:

#Add Database name here using the following format
alias PRMT='export ORACLE_SID=PRMT; export ORAENV_ASK="NO";. oraenv;'
alias PRMX='export ORACLE_SID=PRMX; export ORAENV_ASK="NO";. oraenv;'
alias VP1D='export ORACLE_SID=VP1D; export ORAENV_ASK="NO";. oraenv; cd
/u01/home/oracle/admin/VP1D;'
alias SDSD='export ORACLE_SID=SDSD; export ORAENV_ASK="NO";. oraenv;'
alias SDST='export ORACLE_SID=SDST; export ORAENV_ASK="NO";. oraenv;'
alias SVRP='export ORACLE_SID=SVRP; export ORAENV_ASK="NO";. oraenv;'
alias SVRT='export ORACLE_SID=SVRT; export ORAENV_ASK="NO";. oraenv;'
alias IDSU='export ORACLE_SID=IDSU; export ORAENV_ASK="NO";. oraenv;'
alias IWVT='export ORACLE_SID=IWVT; export ORAENV_ASK="NO";. oraenv;'

PRMT --> IWVT are the instances running on the server.

I suggest you to create a END file for each version of ORACLE
installation

Please notice that, you need to redefind:
LD_LIBRARY_PATH and PATH

don't use $LD_LIBRARY and $PATH inside the file, eg:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:$ORACLE_HOME/network/lib

change to:
LD_LIBRARY_PATH=/path-to/lib1:/path-to/lib2:$ORACLE_HOME/lib:$ORACLE_HOME/lib

PATH=$PATH:$ORACLE_HOME/bin

change to:
PATH=$ORACLE_HOME/bin:/usr/bin:/path-to/other-bins
etc

give the  file a good name, eg oracle10.sh oracle8.sh etc

when the use want to run v10, he/she can type in:
. /path-to/oracle10.sh

to use v8
. /path-to/oracle8.sh

etc.
Are there any other suggestions out there that would have a simple approach to using multiple oracle homes? I basically want to automate the process without going through all the steps listed below:

I have 3 oracle instance installed in 3 separate oracle homes. To set the environment I do the following:
TST1 Oracle Instance
ORACLE_SID=TST1
export ORACLE_SID
ORACLE_BASE=/tst1-db/u01/app/oracle
ORACLE_HOME=/tst1-db/u01/app/oracle/product/10.2.0.1/db_1
TST1 Oracle Instance
ORACLE_SID=TST2
export ORACLE_SID
ORACLE_BASE=/tst2-db/u01/app/oracle
ORACLE_HOME=/tst2-db/u01/app/oracle/product/10.2.0.1/db_1
TST3 Oracle Instance
ORACLE_SID=TST3
export ORACLE_SID
ORACLE_BASE=/tst3-db/u01/app/oracle
ORACLE_HOME=/tst3-db/u01/app/oracle/product/10.2.0.1/db_1



What I would like to do once I logon to this DB Server would be to type TST1 and it automatically sets the environment for this instance or type TST2 and set tthe environment for this instance when needed or typr TST3 when needed.
ASKER CERTIFIED SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial