Automate Oracle database startup and shutdown in Microsoft Azure

The Oracle database by default doesn't automatically start when you restart the server. To set up the Oracle database to start automatically, first sign in as root.

2 min read

The Oracle database by default doesn't automatically start when you restart the server. To set up the Oracle database to start automatically, first sign in as root. Then, create and update some system files.



  1. Sign on as root
sudo su -

2.  Using your favorite editor, edit the file /etc/oratab and change the default N to Y:

cdb1:/u01/app/oracle/product/12.1.0/dbhome_1:Y
How to edit the /etc/oratab file in Azure VM for Oracle database
In this tutorial we will learn how to edit /etc/oratab file to automate the startup/shutdown of an Oracle database.
Learn more about editing etc/oratab

3.  Create a file named /etc/init.d/dbora and paste the following contents:

#!/bin/sh
# chkconfig: 345 99 10
# Description: Oracle auto start-stop script.
#
# Set ORA_HOME to be equivalent to $ORACLE_HOME.
ORA_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
ORA_OWNER=oracle

case "$1" in
'start')
    # Start the Oracle databases:
    # The following command assumes that the Oracle sign-in
    # 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 sign-in
    # 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
How to create /etc/init.d/dbora file in Azure VM for Oracle database
In this tutorial we will learn how to create and edit /etc/init.d/dbora file to automate the startup/shutdown of an Oracle database.
Learn more about creating /etc/init.d/dbora


4.  Change permissions on files with chmod as follows:

chgrp dba /etc/init.d/dbora
chmod 750 /etc/init.d/dbora

5.  Create symbolic links for startup and shutdown as follows:

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

6.  To test your changes, restart the VM:

reboot


Featured Oracle

Connect Oracle Database to Datagrip IDE

In this tutorial, we will connect the Oracle database to the DataGrip IDE.

2 min read
Featured Oracle

How to install Oracle database in Microsoft Azure VM

In this tutorial, we will learn how to set up an Oracle database on a remote server and access it by using our browser.

7 min read