LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


View Poll Results: what do you say?
yes it works! 2 100.00%
doesn't worked for me! 0 0%
Voters: 2. You may not vote on this poll

Reply
  Search this Thread
Old 03-06-2006, 12:51 AM   #1
prozac
Member
 
Registered: Oct 2005
Location: Australia
Distribution: slackware 12.1
Posts: 753

Rep: Reputation: 32
Talking [solved] start|stop multiple oracle databases in the same oracle server


i have this problem with one of my oracle database server. this server previously only had one database and so start|stop-ing the database at system startup|shutdown was no problem since a single script in init.d and some changes in rc.local and rc.S would solve the problem. but now this server has 3 different databases running over it and all of them are fully operational. the problem is now only the default database gets started up in the system startup and i have to start the other 2 manually using the 'startup' command after login in to each of the databases. as you can understand this becomes a real pain in the a** for me as i have to come and do the same thing everyday. i did a little research and came to know that the default database is loaded up after checking the ORACLE_SID from .bash_profile of oracle user (yes we have this user in our system). so here's what i did i thought would solve the problem only it doesn't:
(i hope the script is self explanatory)
----------------------------------------------------------------------------------------
Code:
[root@oracledb root]# cat /etc/init.d/oracle
#!/bin/sh

# oracle: script to start all databases at system startup

ORACLE_OWNER=oracle
ORACLE_HOME=/oracle/product/9.2.0
PROFILE_PATH="/oracle/.bash_profile"

if [ ! -e $PROFILE_PATH ]; then
 echo "File not there";
 exit 1;
fi

CUR_SID=`grep "ORACLE_SID=" /oracle/.bash_profile |sed s/ORACLE_SID=//`

case "$1" in

'db1' )
        sed -i -e 's/db1/'"$CUR_SID"'/g' ~oracle/.bash_profile
        ;;

'db2' )
        sed -i -e 's/db2/'"$CUR_SID"'/g' ~oracle/.bash_profile
        ;;

'db3' )
        sed -i -e 's/db3/'"$CUR_SID"'/g' ~oracle/.bash_profile
        ;;

 *)
        echo "Usage: oracle {db1|db2|db3} {start|stop|restart}"
        exit 1

esac

case "$2" in
'start' )

echo -n "Starting Oracle Databases: "

su - oracle -c dbstart

echo -n "Starting Oracle Listeners: "

su - oracle -c "lsnrctl start"

echo "Done."

;;

'stop')

echo -n "Shutting Down Oracle Listeners: "

su - oracle -c "lsnrctl stop"

        echo "Done."

echo -n "Shutting Down Oracle Databases: "

su - oracle -c dbshut

;;

  'restart')

echo -n "Restarting Oracle Databases: "

su - oracle -c dbshut

su - oracle -c dbstart

echo -n "Restarting Oracle Listeners: "

        su - oracle -c "lsnrctl stop"

  su - oracle -c "lsnrctl start"

echo "Done."


 ;;

  *)

        echo "Usage: oracle {db1|db2|db3} {start|stop|restart}"
      exit 1

esac
------------------------------------------------------------------------------------------------

these lines in /etc/rc.d/rc.local i thought would startup all databases at system startup
Quote:
/etc/init.d/oracle db1 start
/etc/init.d/oracle db2 start
/etc/init.d/oracle db3 start
it doesn't! searching google with the keywords as in the subject line turned up one promising search but alas they ask money to show me the solution
hxxp://www.experts-exchange.com/Databases/Oracle/Q_21114417.html"

i would greatly appericiate if you guys could help me out with this problem. i am not suggesting using only the above way to solve the problem. any way is good enough if it solves the problem.

Last edited by prozac; 03-20-2006 at 11:56 PM.
 
Old 03-07-2006, 12:25 AM   #2
prozac
Member
 
Registered: Oct 2005
Location: Australia
Distribution: slackware 12.1
Posts: 753

Original Poster
Rep: Reputation: 32
are u guys even giving it some thought or am i just been neglected or impatient?
 
Old 03-20-2006, 11:44 PM   #3
prozac
Member
 
Registered: Oct 2005
Location: Australia
Distribution: slackware 12.1
Posts: 753

Original Poster
Rep: Reputation: 32
i have solved the problem and since nobody bothered to answer my question i am answering it for myself (thinking about future) and to anybody for whom it might be useful:

the example i take here involves three databases say (db1,db2 & db3) all in one oracle database server (i have 9i, yours maybe different).

first find the oratab file oracle is using (mine is /etc/oratab, yours maybe different)
here's a sample:
Quote:
#

# This file is used by ORACLE utilities. It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.

# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
#*:/oracle/product/9.2.0:Y
db1:/oracle/product/9.2.0:Y
#backup:/oracle/product/9.2.0:Y
db2:/oracle/product/9.2.0:Y
db3:/oracle/product/9.2.0:Y
you see the last 5 lines, these are the important lines. it tells oracle what to start and what not to. the script is pretty much self explanatory. the first field is ORACLE_SID and the dbstart script uses it to fire up databases. an * means all (but i am not confident so i am not using it). i have three separate lines for my three databases (2nd, 4th & 5th lines). the middle part says about the ORACLE_HOME and the third field (after colon) specifies whether to auto start the database or not. since i want to fire up all three databases at system startup, i have put them as 'Y' (yes).

next go find init.ora files. it must be in your dbs directory under your $ORACLE_HOME (mine is there your's may be elsewhere). there is one init file per database and the filename convention is init($ORACLE_SID).ora
so my three databases have three init files initdb1.ora,initdb2.ora and initdb3.ora respectively. if only one is present and the other's are not (as in my case) simply copy the existing one to other two and name it respectively. from now on i have three database init files (since i made two copies of the existing one). now open the newly copied files and edit it to suit your needs. i only had to change all the occurences of db1 to db2 and db3 (in initdb2.ora & initdb3.ora) at several places and it worked for me since my $ORACLE_HOME is same for all three databases. save the file.
with root priv, fire up 'lsnrctl start' then 'dbstart' you should see all your db's starting up one after another. mine did. that's it. its pretty simple isn't it.

NOTE:
the script in the FIRST post is a WASTE OF TIME. DONOT use it. you donot have to run dbstart for each of the databases if you followed the above method. one dbstart with do for all. i will post another script shortly.

Last edited by prozac; 03-20-2006 at 11:50 PM.
 
Old 03-20-2006, 11:52 PM   #4
prozac
Member
 
Registered: Oct 2005
Location: Australia
Distribution: slackware 12.1
Posts: 753

Original Poster
Rep: Reputation: 32
ok here's the script:
Quote:
[root@oracledb root]# cat /etc/init.d/oracle

#!/bin/sh

ORACLE_OWNER=oracle
ORACLE_HOME=/oracle/product/9.2.0

case "$1" in
'start' )

echo -n "Starting Oracle Databases: "

su - oracle -c dbstart

echo "Done."

echo -n "Starting Oracle Listeners: "

su - oracle -c "lsnrctl start"

echo "Done."

;;

'stop')

echo -n "Shutting Down Oracle Listeners: "

su - oracle -c "lsnrctl stop"

echo "Done."

echo -n "Shutting Down Oracle Databases: "
su - oracle -c dbshut

echo "Done."

;;

'restart')

echo -n "Restarting Oracle Databases: "

su - oracle -c dbstop

su - oracle -c dbstart

echo "Done."

echo -n "Restarting Oracle Listeners: "

su - oracle -c "lsnrctl stop"

su - oracle -c "lsnrctl start"

echo "Done."


;;

*)

echo "Usage: oracle {start|stop|restart}"
exit 1

esac
hope this post helps somebody who's in stress (like i was )
 
1 members found this post helpful.
Old 07-18-2006, 01:42 AM   #5
aamerjavaid
Member
 
Registered: Dec 2005
Posts: 53

Rep: Reputation: 15
Auto Start Oracle

Dear prozac,

Hope You r fine.

Thanks for such a wonderfull guidence of creating 2 or more db on Linux plateform.

Currently I am working on installing Oracle 10g AS, and 10g forms and reports services on RHEL 4.

Would u pls recommend me how to autostart Oracle 10g AS, and 10g forms and reports services on RHEL 4.

Thanks.

Aamer Javaid
 
Old 07-18-2006, 01:54 AM   #6
prozac
Member
 
Registered: Oct 2005
Location: Australia
Distribution: slackware 12.1
Posts: 753

Original Poster
Rep: Reputation: 32
first install everything you need. oracle will put proper script files in /etc/init.d, you will then need to add their paths in your /etc/rc.local file for them to start automatically on each boot.
 
Old 07-19-2006, 12:11 AM   #7
aamerjavaid
Member
 
Registered: Dec 2005
Posts: 53

Rep: Reputation: 15
Auto Start Multiple Oracle Homes

Dear prozac,

Hope You r fine.

Thanks again but when I did the same.

I installed Oracle10gDB on RHEL 4. It created oratab, oraenv and one more file on Linux.

Then I installed Oracle10gAS FRServices on the same machine.
It asked me to override these files.

My Question is that what should I do to auto start both these softwares. should I override previous files or should I rename previous files or what to do?

One more thing is that How to auto start Oracle EM service that is in 10g. b-coz Management Server is not in Oracle 10g.

I am waiting for a detailed response.

Thanks.

Aamer Javaid
 
Old 07-19-2006, 12:23 AM   #8
prozac
Member
 
Registered: Oct 2005
Location: Australia
Distribution: slackware 12.1
Posts: 753

Original Poster
Rep: Reputation: 32
you have to create separate ORACLE_HOME for oracleDB and oracleAS if you intend to run both in the same machine.
I am not SOA in oracle matters and there are lots of guide in web which attempts to cover most of the FAQ's with the installations. We can not expect to cover all of them here, so i would suggest going throught them first and try as much to do as said there. Then if you are still unable to figure out somethings we can talk.
 
Old 01-23-2007, 03:01 AM   #9
prozac
Member
 
Registered: Oct 2005
Location: Australia
Distribution: slackware 12.1
Posts: 753

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by aamerjavaid
One more thing is that How to auto start Oracle EM service that is in 10g. b-coz Management Server is not in Oracle 10g.
I see the EM in oracle10g is web based. Here's a nice script to do that I found on the web:
I have tested it and it works.

Code:
#!/bin/bash
# chkconfig: 35 95 1

##ORACLE SOFTWARE INIT SCRIPT (10gR2DB, TNS Listener, EMS)

ORACLE_USER=oracle

# see how we are called:
case $1 in
    start)
    su - "$ORACLE_USER"<<EOO
    lsnrctl start
    sqlplus /nolog<<EOS
    connect / as sysdba
    startup
EOS
    emctl start dbconsole
EOO
    ;;

    stop)
    su - "$ORACLE_USER"<<EOO
    lsnrctl stop
    sqlplus /nolog<<EOS
    connect / as sysdba
    shutdown immediate
EOS
    emctl stop dbconsole
EOO
    ;;

    *)
    echo "Usage: $0 {start|stop}"
    ;;
esac
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between Oracle Server and Oracle Database ganninu Programming 3 02-27-2007 01:06 AM
xhost + as user oracle not working, need to see oracle install GUI enzo250gto Linux - Software 2 02-11-2007 11:27 AM
Changing Oracle user password will affect oracle db? sathyguy Linux - Newbie 1 02-11-2006 06:34 PM
Oracle 9i client with Oracle 8i server ganninu Programming 1 02-19-2004 04:35 PM
Oracle 9i Start/Stop scripts vous Linux - Software 0 01-16-2004 01:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration