Solved

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

Posted on 2007-04-03
8
1,688 Views
Last Modified: 2013-12-21
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?
0
Comment
Question by:Omega002
  • 4
  • 2
  • 2
8 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 18847773
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
 
LVL 38

Expert Comment

by:yuzh
ID: 18847945
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
 

Author Comment

by:Omega002
ID: 18848212
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
 

Author Comment

by:Omega002
ID: 18848220
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:Omega002
ID: 18848275
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
 
LVL 38

Expert Comment

by:yuzh
ID: 18848396
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
 

Author Comment

by:Omega002
ID: 18889333
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
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 18893478
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

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now