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:
CHECK THE LOGS
- /var/log/messages
- $ORACLE_HOME/network/log/listener.log
- $ORACLE_HOME/rdbms/log/shutdown.log
- $ORACLE_HOME/rdbms/log/startup.log