Omega002
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?
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/pr oduct/9.2. 0
ORACLE_SID=TYP2
LD_LIBRARY_PATH=$ORACLE_HO ME/lib:$LD _LIBRARY_P ATH
export ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH
PATH=$PATH:$ORACLE_HOME/bi n
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
ORACLE_HOME
ORACLE_SID
LD_LIBRARY_PATH
and
PATH
for the user's .profile or .bash_profie eg:
ORACLE_HOME=/opt/oracle/pr
ORACLE_SID=TYP2
LD_LIBRARY_PATH=$ORACLE_HO
export ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH
PATH=$PATH:$ORACLE_HOME/bi
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
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/${S ID}/.oraus er_$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/ora cle
ORACLE_HOME=/db-01/app/ora cle/produc t/10.1.0
#ORACLE_SID=ORTD
PATH=$PATH:$ORACLE_HOME/bi n
LD_LIBRARY_PATH=$LD_LIBRAR Y_PATH:$OR ACLE_HOME/ lib:$ORACL E_HOME/net work/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/or acle/admin /PSI03
ORATAB=/var/opt/oracle/ora tab
HOME=/home/oracle
LD_LIBRARY_PATH=/usr/openv /netbackup /bin:$ORAC LE_HOME/li b:/usr/ope nwin/lib:/ usr/local/ lib
PS1='$ORACLE_SID:$PWD> '
alias PSI03='. /psi03-db/u01/app/oracle/a dmin/PSI03 /.orauser_ PSI03'
alias psi03='. /psi03-db/u01/app/oracle/a dmin/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/repor t'
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
##########################
#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
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/ora
ORACLE_HOME=/db-01/app/ora
#ORACLE_SID=ORTD
PATH=$PATH:$ORACLE_HOME/bi
LD_LIBRARY_PATH=$LD_LIBRAR
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/or
ORATAB=/var/opt/oracle/ora
HOME=/home/oracle
LD_LIBRARY_PATH=/usr/openv
PS1='$ORACLE_SID:$PWD> '
alias PSI03='. /psi03-db/u01/app/oracle/a
alias psi03='. /psi03-db/u01/app/oracle/a
alias bdump='cd $ORACLE_BASE/admin/$ORACLE
alias udump='cd $ORACLE_BASE/admin/$ORACLE
alias cdump='cd $ORACLE_BASE/admin/$ORACLE
alias pfile='cd $ORACLE_BASE/admin/$ORACLE
alias report='cd $ORACLE_BASE/admin/$ORACLE
alias sql='cd $ORACLE_BASE/admin/$ORACLE
alias expadmin='cd $ORACLE_BASE/admin/$ORACLE
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
ASKER
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.
ASKER
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/VP1 D;'
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.
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/VP1
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_LIBRAR Y_PATH:$OR ACLE_HOME/ lib:$ORACL E_HOME/net work/lib
change to:
LD_LIBRARY_PATH=/path-to/l ib1:/path- to/lib2:$O RACLE_HOME /lib:$ORAC LE_HOME/li b
PATH=$PATH:$ORACLE_HOME/bi n
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.
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_LIBRAR
change to:
LD_LIBRARY_PATH=/path-to/l
PATH=$PATH:$ORACLE_HOME/bi
change to:
PATH=$ORACLE_HOME/bin:/usr
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.
ASKER
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/a pp/oracle
ORACLE_HOME=/tst1-db/u01/a pp/oracle/ product/10 .2.0.1/db_ 1
TST1 Oracle Instance
ORACLE_SID=TST2
export ORACLE_SID
ORACLE_BASE=/tst2-db/u01/a pp/oracle
ORACLE_HOME=/tst2-db/u01/a pp/oracle/ product/10 .2.0.1/db_ 1
TST3 Oracle Instance
ORACLE_SID=TST3
export ORACLE_SID
ORACLE_BASE=/tst3-db/u01/a pp/oracle
ORACLE_HOME=/tst3-db/u01/a pp/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.
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/a
ORACLE_HOME=/tst1-db/u01/a
TST1 Oracle Instance
ORACLE_SID=TST2
export ORACLE_SID
ORACLE_BASE=/tst2-db/u01/a
ORACLE_HOME=/tst2-db/u01/a
TST3 Oracle Instance
ORACLE_SID=TST3
export ORACLE_SID
ORACLE_BASE=/tst3-db/u01/a
ORACLE_HOME=/tst3-db/u01/a
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.