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?
Omega002Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TintinCommented:
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.
0
yuzhCommented:
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
0
Omega002Author Commented:
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


0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Omega002Author Commented:
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.
0
Omega002Author Commented:
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.

0
yuzhCommented:
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.
0
Omega002Author Commented:
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.
0
TintinCommented:
Create an alias or function in your .profile, eg:

alias TST1='ORACLE_SID=TST1 ; ORACLE_BASE=tst1-db/u01/app/oracle;ORACLE_HOME=/tst1-db/u01/app/oracle/product/10.2.0.1/db_1; export ORACLE_SID ORACLE_BASE ORACLE_HOME'

Then you just need to type

TST1

to invoke that environment.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.