Automating 18c Oracle Database Startup and Shutdown on Oracle Linux 7

PURPOSE

Oracle recommends to configure the system to automatically start Oracle Database when Operating System starts, and to automatically shut it down when the Operating System down.

Environment:
Operating System:     Oracle Linux 7
Oracle Database:        Oracle 18c

SOLUTION

  • Check and configure  /etc/oratab appropriately.
    ...
    ..
    .
    OEMREP:/opt/oracle/product/18c/dbhome_1:Y
    ...
    ..
    .
  • Change directory to /etc/init.d, and create a file “dbora” with below contents.
#! /bin/sh
# 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 ORACLE_HOME.

ORA_HOME=<Type your ORACLE_HOME in full path here>
ORA_OWNER=<Type your Oracle account name here>

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 "$ORA_HOME/bin/dbstart $ORA_HOME" &
    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 "$ORA_HOME/bin/dbshut $ORA_HOME" &
    rm -f /var/lock/subsys/dbora
    ;;
esac
  • Change file “dbaora” with right group name and permission.
# chgrp dba dbora
# chmod 750 dbora
  •  Create symbolic links to the dbora script in the appropriate run-level script directories:
  1. Platform Symbolic Links Commands
    Oracle Solaris
    # ln -s /etc/init.d/dbora /etc/rc0.d/K01dbora
    # ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora
    Linux
    # ln -s /etc/init.d/dbora /etc/rc.d/rc0.d/K01dbora
    # ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S99dbora
    # ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S99dbora
    IBM AIX on POWER Systems (64-Bit)
    # ln -s /etc/dbora /etc/rc.d/rc2.d/S99dbora
    # ln -s /etc/dbora /etc/rc.d/rc0.d/K01dbora

CHECK THE LOGS

  • /var/log/messages
  • $ORACLE_HOME/network/log/listener.log
  • $ORACLE_HOME/rdbms/log/shutdown.log
  • $ORACLE_HOME/rdbms/log/startup.log

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: