Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I successfully installed Oracle 11g on a Fedora 15 system using this guide. Unfortunately, unlike when I'm using Windows, it seems I need to restart the database every single time I reboot my machine (it's a development machine, not a server).

I'm not sure this is the intended behavior or if I messed up something while installing the database.

Anyway, every single I reboot the machine I need to:

  • Use su to change the current user to the oracle user.
  • Use sqplus to startup the database.

Like this:

(oracle@machine)$ sqplus / as sysdba
SQL> startup
SQL> (Ctrl+D)
  • Then I need to start the listener using lsnrctl.

Once more:

(oracle@machine)$ lsnrctl start 
  • And now the Enterprise Manager should also be started.

At least:

(oracle@machine)$ emctl start dbconsole

I've taken those instructions from here.

I'm sorry if this quite noobish, I usually have a DBA or a sysadmin to setup an environment for me but I'm doing this at home, where I have no help (maybe I'm becoming quite spoiled as a developer :)).

I wonder if it's possible to automate this on Fedora 15 using a shell script. After automating, I'd like to hook this on the init system, so it's performed every time I start the machine.

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

I've found an answer on this guide on how to install Oracle 11g on CentOS 5.3. I did some minor tweaking on the init script. For the sake of completeness, I'll add steps here:

  • Edit /etc/oratab and change the last N on the configuration file to an Y.

Like this:

orcl:/u01/app/oracle/product/11.2.0/dbhome_1:N

To this:

orcl:/u01/app/oracle/product/11.2.0/dbhome_1:Y
  • Create the script /etc/init.d/dbora.

It should have this contents:

#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.

ORA_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
ORA_OWNER=oracle

if [ ! -f $ORA_HOME/bin/dbstart ]
then
        echo "Oracle startup: cannot start"
        exit
fi

case "$1" in

'start')

# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values

su - $ORA_OWNER -c "$ORA_HOME/bin/emctl start dbconsole"
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME"
;;

'stop')

# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values

su - $ORA_OWNER -c "$ORA_HOME/bin/emctl stop dbconsole"
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME"
;;

esac
  • Then change the script permission.

Like this:

chmod 750 /etc/init.d/dbora
  • Add it to chkconfig

Like this:

chkconfig --level 345 dbora on

Test it with /etc/init.d/dbora start and /etc/init.d/dbora stop. Be sure to have the correct path on the dbora script.

share|improve this answer
add comment

I think lsnrctl start is already included in the dbstart script.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.