2

I am running CentOS 6 and I am trying to get my Oracle database to run at startup. I have been following these steps:

http://www.oracle-base.com/articles/linux/automating-database-startup-and-shutdown-on-linux.php (Oracle 11gR2 portion at bottom)

I have created this script and it is saved as /etc/init.d/dbora:

#!/bin/bash
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
# 
# Set ORA_OWNER to the user id of the owner of the
# Oracle database software.

ORA_OWNER=oracle

case "$1" in
    'start')
    # Start the Oracle databases:
    # The following command assumes that the oracle login
    # will not prompt the user for any values
    # Remove "&" if you don't want startup as a background process.
    su $ORA_OWNER -c "/home/oracle/scripts/startup.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1" &

    touch /var/lock/subsys/dbora
    ;;
'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 "/home/oracle/scripts/shutdown.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1"
    rm -f /var/lock/subsys/dbora
    ;;
esac

Next, I ran:

chmod 750 /etc/init.d/dbora

As per the instructions.

Finally, I added the script using chkconfig.

chkconfig --add dbora

I also added the scripts that the dbora file calls.

I am able to start the database using:

/etc/init.d/dbora start

However,

service dbora start

does not work.

Any ideas?

4

The main difference between runnning /etc/init.d/foo start and service foo start, is that service runs the init script in a clean environment. If you have a case where running the init script directly works, but does not with service, the an environment variable is being used in the startup that you have not manually initialized inside of the script. Since your init script is really simple, the environment variable usage is likely in the /home/oracle/scripts/startup.sh script.

Also note that if it does not run with service, it will not properly start on boot.

  • 1
    Thanks a lot! My startup.sh script referenced a environment variable. This is great to know for the future. – user1472409 Mar 19 '14 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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